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
718 stars 242 forks source link

Application area issue, analyzer warning AD0001 - Rule189ApplicationAreaHasInvalidValue #7772

Open linasostreika opened 2 weeks ago

linasostreika commented 2 weeks ago

Hi,

We found ourselfves in situation where we receive a warning from analyzer with ID AD0001, which shouldnt be considered as warning.

We have a field obsoleted on Application Area Setup extension:

tableextension 17031631 "S4LA Appl. Area Setup Ext." extends "Application Area Setup" { fields { field(17021801; "S4LA Leasing"; Boolean) { DataClassification = CustomerContent; Caption = '(Obsolete) S4Leasing'; Description = 'S4Leasing new Application area'; ObsoleteState = Removed; ObsoleteReason = 'SL63 replaced by another field S4LALeasing'; ObsoleteTag = '63.0.0.0'; } field(17021802; S4LALeasing; Boolean) { Caption = 'S4LA Leasing'; DataClassification = CustomerContent; } } }

Analyzer shows warning:

warning AD0001: Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule189ApplicationAreaHasInvalidValue' threw an exception of type 'System.ArgumentException' with message 'System.ArgumentException: An item with the same key has already been added. Key: S4LALeasing at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at Microsoft.Dynamics.Nav.CodeCop.Design.Rule189ApplicationAreaHasInvalidValue.ExtractAppAreaFromFields(PooledList1 fields, PooledNameObjectDictionary1 appAreas, StringBuilder stringBuilder) in X:\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule189ApplicationAreaHasInvalidValue.cs:line 162 at Microsoft.Dynamics.Nav.CodeCop.Design.Rule189ApplicationAreaHasInvalidValue.GetApplicationAreas(CompilationStartAnalysisContext ctx, String& validAppAreasOrder) in X:\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule189ApplicationAreaHasInvalidValue.cs:line 138 at Microsoft.Dynamics.Nav.CodeCop.Design.Rule189ApplicationAreaHasInvalidValue.b__3_0(CompilationStartAnalysisContext compilationStartAnalysisContext) in X:\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule189ApplicationAreaHasInvalidValue.cs:line 35 at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1088'

BazookaMusic commented 1 week ago

The error shows the analyser is crashing. It shouldn't crash, thus marking for triage