microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

Analyzer 'Microsoft.Dynamics.Nav.UICop.Rule003RepeaterWithPartsCannotBeDisplayed' threw an exception of type 'System.InvalidCastException' #5149

Closed kine closed 5 years ago

kine commented 5 years ago

When compiling one of our app, I am getting this warning:

##[warning] Analyzer 'Microsoft.Dynamics.Nav.UICop.Rule003RepeaterWithPartsCannotBeDisplayed' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceReportTypeSymbol' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IPageTypeSymbol'. |  
-- | --
  | at Microsoft.Dynamics.Nav.UICop.Rule003RepeaterWithPartsCannotBeDisplayed.AnalyzeRepeater(SymbolAnalysisContext ctx) in F:\a\91\s\source\Prod\Microsoft.Dynamics.Nav.UICop\Rules\Rule003RepeaterWithPartsCannotBeDisplayed.cs:line 49 |  
  | at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass49_2.<ExecuteSymbolActionsCore>b__0() in F:\a\91\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 658 |  
  | at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in F:\a\91\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1082'

Because I do not know if it is related to AL code compiled or the codecop itself, I can reproduce it just by opening the VSCode with the wrokspace with my project. The warning is automatically displayed in the "Problems" tab and is "connected" to app.json file. But when I open different project, all is ok.

Screenshot from VSCode: image

Same error in CI pipeline: image

Versions:

Docker image platform: 14.0.34195.0

kine commented 5 years ago

Ok, we have found the problem and I can write the reproduce steps for you:

The analyzer fails when you add Repeater to Report Request Page: image

Repro steps: 1) Create new app, enable UICop 2) Add report 3) Set source table for the request page 4) Add repeater to the request page

atoader commented 5 years ago

Thank you for the repro, @kine !