AL icon indicating copy to clipboard operation
AL copied to clipboard

Rule137DoNotDeclareVariablesThatAreUnused throws an exception casting IdentifierNameOrEmptySyntax to IdentifierNameSyntax

Open JuricaB opened this issue 7 years ago • 1 comments

Describe the bug AL extension for VS Code reports multiple errors in app.json, all with same text : Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.IdentifierNameOrEmptySyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.IdentifierNameSyntax'. at Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused.UnusedVariableAnalyzer.AnalyzeSyntaxNode(SyntaxNodeAnalysisContext context) in C:\a\810\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule137DoNotDeclareVariablesThatAreUnused.cs:line 171 at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass52_1.b__1() in C:\a\810\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 745 at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in C:\a\810\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1082'

To Reproduce Steps and/or AL code to reproduce the behavior: This appears to happen if there are any warnings on compilation, but persists even if those warnings are resolved.

Expected behavior Would expect not to get this error.

Screenshots If applicable, add screenshots to help explain your problem.

Versions:

  • AL Language: 2.1.91153
  • Business Central: NZ Dynamics NAV 14.0 (27970)/platform 14.0.27940.0

JuricaB avatar Feb 11 '19 02:02 JuricaB

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 28234 and VS Code Extension Version 2.1.95346.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/

ALGitHubBot avatar Feb 21 '19 12:02 ALGitHubBot