Queries are read fine when debugging only My Code. However, when disabling the option in Visual Studio in 'Debug > Options > Enable Just My Code', antlr.MismatchedTokenException is thrown for almost every SQL query which is run through the parser.
Here's a simplified example, which throws:
antlr.MismatchedTokenException 'expecting "Dot", found 'AS''
Ignoring the exceptions, the select statement works fine and is passed to the app no problem. But the constant spam of .NET exceptions is puzzling. The literal interpretation of the exception doesn't seem to make sense for this SQL query.
I can't see anything wrong with this example query.
private static StatementList PrepareSql(string sql)
{
sql = "SELECT A.[ID] AS [Activities_Id] FROM [Activities] A";
var parser = new TSql140Parser(false, SqlEngineType.SqlAzure);
return parser.ParseStatementList(new StringReader(sql), out var errors1);
}
--
Update: We believe the exception occurs not in the immediate library referenced by the portal, but in ANTLR. We still cannot find the reason for the exception. Currently we've added a workaround to cache the SQL query so that the exception is only thrown once per query - but that's still one too many.