StefanMaron / BusinessCentral.LinterCop

Community driven code linter for AL (MS Dynamics 365 Business Central)
https://stefanmaron.com
MIT License
72 stars 30 forks source link

LC0044 : Unhandled Exception #565

Open jamesmayr opened 5 months ago

jamesmayr commented 5 months ago

Used Version: 0.30.14 I get an exception when I want validate the following Source Code with the Business Central Linter:

Subtype = Upgrade;
    Access = Internal;

    trigger OnUpgradePerCompany()
    begin
        MigrateSetup();
        MigrateMapsMarkers();
    end;

    local procedure MigrateSetup()
    var
        _TargetMapsSetupMPIDAG: Record MapsSetupMPIDAG;
        _SourceMapsSetup11IDAG: Record MapsSetup11IDAG;
    begin
        if (_SourceMapsSetup11IDAG.FindSet()) then
            repeat
                if (not _TargetMapsSetupMPIDAG.Get(_SourceMapsSetup11IDAG.PrimaryKey)) then begin
                    _TargetMapsSetupMPIDAG.Init();
                    _TargetMapsSetupMPIDAG.SystemId := _SourceMapsSetup11IDAG.SystemId;
                    _TargetMapsSetupMPIDAG.Insert(false, true);
                end;
                _TargetMapsSetupMPIDAG.TransferFields(_SourceMapsSetup11IDAG, false);
                _TargetMapsSetupMPIDAG.Modify(false);
            until _SourceMapsSetup11IDAG.Next() = 0;
    end;

I don't know if its important, but MapsSetupMPIDAG and MapsSetup11IDAG are Tables from Extensions that are not part of the workspace.

Exception:

Unhandled exception. Unhandled exception. System.ArgumentException: Reported diagnostic 'LC0044' has a source location in file 'xxxxx/MapsSetup.Table.al', which is not part of the compilation being analyzed. (Parameter 'location')
   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyDiagnosticLocationInCompilation(String id, Location location, Compilation compilation) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs:line 98
   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyDiagnosticLocationsInCompilation(Diagnostic diagnostic, Compilation compilation) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs:line 81
   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyArguments(Diagnostic diagnostic, Compilation compilationOpt, Func`2 isSupportedDiagnostic) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs:line 65
   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.OperationAnalysisContext.ReportDiagnostic(Diagnostic diagnostic) in D:\a\_work\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalysisContext.cs:line 985
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.ReportFieldDiagnostics(OperationAnalysisContext ctx, Table table, List`1 fieldGroups)
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.AnalyzeTransferFields(OperationAnalysisContext ctx)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

When LC0044 is supressed, everything works fine.