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
732 stars 243 forks source link

Codecop-analyzer keeps crashing #5726

Closed navdotnetreqs closed 4 years ago

navdotnetreqs commented 4 years ago

{ "resource": "/c:/Users/app.json", "owner": "_generated_diagnostic_collectionname#1", "code": "AD0001", "severity": 4, "message": "Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions' threw an exception of type 'System.NullReferenceException' with message 'System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.ExtractCountOfOptionsFromGlobalVar(ISymbol symbol) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 287\r\n at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzeCaptions(SymbolAnalysisContext symbolAnalysisContext, SyntaxNode node, IdentifierNameSyntax identifierName, ISymbol symbol) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 265\r\n at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzeModifiedControlsAndActions(SymbolAnalysisContext symbolAnalysisContext, SyntaxNode node, ISymbol symbol) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 123\r\n at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzePageModifyFields(SymbolAnalysisContext symbolAnalysisContext, ImmutableArray1 changeSymbols) in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.CodeCop\\Localizability\\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 88\r\n at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzePage(SymbolAnalysisContext symbolAnalysisContext) in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.CodeCop\\Localizability\\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 61\r\n at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass49_2.<ExecuteSymbolActionsCore>b__0() in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\DiagnosticAnalyzer\\AnalyzerExecutor.cs:line 655\r\n at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable1 info) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1099'", "source": "AL", "startLineNumber": 1, "startColumn": 1, "endLineNumber": 1, "endColumn": 1 }

nicolassaleron commented 4 years ago

Same here, it seems to happen for me when rule "AA0218" is disabled.

MarcHansenMicrosoft commented 4 years ago

Hi

Could you provide some info on the repro that makes it crash?

/Marc

nicolassaleron commented 4 years ago

From my side it's complicate to reproduce. It occurs on all my apps. But when I create a new app with only one page without a tooltip, the error does not occur.

salgiza commented 4 years ago

The analyzer kept crashing with this error with one of our apps, and I've managed to reproduce it (it requires a Spanish version of BC16).

pageextension 50000 "Test Purchase Order" extends "Purchase Order"
{
    layout
    {
        modify("Special Scheme Code")
        {
            Visible = false;
        }
    }
}

For whatever reason (because I don't see anything particular about those fields) the analyzer crashes as soon as we try to modify one of the fields added by the Spanish localization for SII (reporting taxes to the Spanish tax agency).

Note: reproduced with v5.0.236243 of the AL extension.

miljance commented 4 years ago

Same here, it happens for me when rule "AA0218" is disabled.

MarcHansenMicrosoft commented 4 years ago

Thanks for the added info.

tinfister commented 4 years ago

It seems it's the problem with modifying Option fields. No analyzer problem with modifying Text field image Problem with modifying Option field image

AL Language extensiton 5.0.254558

atoader commented 4 years ago

@MarcHansenMicrosoft can you take a look?

Djordje-Arsic commented 4 years ago

Hello,

I had the same issue appearing like this, but the cause and the solution were different.

I'm playing with interfaces and enums, so I had an enum extension in my app, extending native Enum "Price Asset Type" that is implementing "Price Asset". In this case since it's interface, the strong contract demands that my value in enum extension also implements, and I was missing property Implementation. But instead of having compile error, I had this warning that is not very intuitive and it had nothing to do with tooltip missing.

waldo1001 commented 4 years ago

This issue is now failing my build pipeline: image

MarcHansenMicrosoft commented 4 years ago

We have just gotten the latest platform into Nav repo.

This would mean that if you get the latest development docker that will be coming. Then this issue should be fixed.