Closed pri-kise closed 4 years ago
If it helps: when the analyzer crashes it always says that the error is in the app.json file, instead of pointing to the real .al file that it was parsing when it crashed (unfortunately, I've been there a lot of times).
So, you seem to have found a bug in the analyzer (it should never crash), but it is probably unrelated to the app.json. You might want to remove *.al files from the app until the errors disappear, to try to find what in particular is causing these crashes.
Any progress on this issue. Currently when there is a "runtime" error in the CodeCop Analyzer referencing app.json the CodeCop stops working and we will not see the error before our build pipeline fails. At the moment we have a lot over overhead due to this issue.
@MarcHansenMicrosoft can you take a look?
CodeCop does run on app.json as well as code.
Could provide a sample repro solution, so we can investigate the issue?
@MarcHansenMicrosoft Regardless of whether this particular error is due to the app.json or not, could it be possible to catch error exceptions in CodeCop, so that when it crashes it tells you which file it was parsing? (instead of always pointing to the app.json)
@atoader that is more a question for you.
Hi, I don't know if this can help or if really related but I encountered same kind of error linked to App.json recently. I did not succeed reproducing in fresh new hello world project but can observe it in our own. In my case It came from declaring same type variables on single line. Once I rollback to one line by variable the error desapeared.
AL Language 5.0.254558, BC 16.0.11240.12474
Here is the error received when variables are declared on same Line:
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule205VariablesMustAlwaysBeInitialized' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VariableListDeclarationSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VariableDeclarationSyntax'.
at Microsoft.Dynamics.Nav.CodeCop.Design.Rule205VariablesMustAlwaysBeInitialized.InitializeGlobalVariablesAnalyzer(SyntaxNodeAnalysisContext syntaxNodeAnalysisContext) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule205VariablesMustAlwaysBeInitialized.cs:line 105
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass52_1.
I can provide an al project with the problem if you setup a private file transfer workspace and send this link to the workspace to krj@elbek-vejrup.dk
@MarcHansenMicrosoft the issue maybe here that the codeanalyzer in place does not read correctly the diagnostic source file location.
Thank your for reporting this issue. I am closing it as it looks like a duplicate of #5889. Feel free to contribute on the issue linked.
Describe the bug
To Reproduce I have no idea how this can be reproduced.
Expected behavior These Codecops shouldn't evaluate the
app.json
file.Screenshots
5. Versions: