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
728 stars 241 forks source link

System.ArgumentNullException: Value cannot be null. (Parameter 'key') #7593

Closed Arthurvdv closed 5 months ago

Arthurvdv commented 9 months ago

1. Describe the bug I've encountered an error on the CodeCop while working in AL. The error occurs when leaving out the ; at the end of line 7.

image

Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule228DoNotDeclareUnusedLocalMethods' threw an exception of type 'System.ArgumentNullException' with message 'System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule228DoNotDeclareUnusedLocalMethods.MethodSymbolAnalyzer.AnalyzeObjectSyntax(SyntaxNodeAnalysisContext syntaxNodeAnalysisContext) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule228DoNotDeclareUnusedLocalMethods.cs:line 112
   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule228DoNotDeclareUnusedLocalMethods.CheckApplicationObjects(SyntaxNodeAnalysisContext syntaxNodeAnalysisContext) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule228DoNotDeclareUnusedLocalMethods.cs:line 54
   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass52_1.<ExecuteSyntaxNodeAction>b__1() in D:\a\_work\1\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 D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1102'

A clear and concise description of what the bug is.

2. To Reproduce Create an empty project an create the AL code below, without the ; at the ending of the IF-statement line.

codeunit 50100 MyCodeunit
{
    local procedure MyProcedure()
    var
        Rec: Record "Warehouse Entry";
    begin
        if Rec."Reference Document" >= Rec."Reference Document"::"Posted P. Inv." then
    end;
}

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

5. Versions: