Analyzer AD0001 'Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions'
Describe the bug When resolving the new codecop warnings in AL Language 6.1.x, this warning was displayed. Ignoring, resolving, or leaving warnings for rule 218 doesn't seem to make any difference.
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.MethodDeclarationSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VariableDeclarationBaseSyntax'.
at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.ExtractCountOfOptions(ISymbol symbol) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 318
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 298
at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzePageFields(SymbolAnalysisContext symbolAnalysisContext, ImmutableArray1 controlSymbols, PageTypeKind pageTypeKind) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 76
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 66
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass49_2.1 info) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1100'
To Reproduce Steps and to reproduce the behavior:
- Open existing project while AL Language 6.1.x is installed
- activate codeanalyzers
- warning appears
Expected behavior No warning or a warning which points to a solvable issue.
5. Versions:
- AL Language: 6.1.362735
- Business Central: 17.1.18256.19616-W1
Is there a way to get further debug information regarding exceptions in case the CodeCop crashes? If we could get the information which .al file or even better which line is causing the exception, we could try to find a way around it on our own. As this error seems to get trigger by a complete other code change, which is unsuspicious and has no connection to Tooltips, it's not directly the last change which is the real cause of the exception.
Could we get an update on the current state of the error or plans for solving it?
@PaulIvan can you follow up?
@atoader, @PaulIvan A follow up would be highly appreciated. :-) This bug is currently blocking us to commit a set of changes to our code because they make the codecop crash most of the time.
@atoader @PaulIvan Hi all. Any news regarding this? An updated would still be highly appreciated.
I also get from time to time an error like this. I am using AL Language Extension 7.1.441.584. Switching to 6.6.434101 reduces the number of errors, but it still remains faulty. The package can always be created, but I fear that the Codecop stops with this error and will not detect any real errors which should have been detected.
{
"resource": "/d:/Work/DevOps/VAPS-BCv18/MainApp/app.json",
"owner": "generated_diagnostic_collection_name#1",
"code": "AD0001",
"severity": 4,
"message": "Analyzer 'Microsoft.Dynamics.Nav.AppSourceCop.Upgrade.RulePublicAPIBreakingChangesNotAllowed' threw an exception of type 'System.ArgumentException' with message 'System.ArgumentException: An item with the same key has already been added. Key: 1507148336\r\n at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\r\n at Microsoft.Dynamics.Nav.AppSourceCop.Helper.ProcedureVerificationHelper.MatchFunctions(IEnumerable1 newMethods, IEnumerable1 oldMethods, PooledDictionary2 unmatchedNewMethods, PooledDictionary2 unmatchedOldMethods, PooledList1 matchedMethodPairs) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.AppSourceCop\Helper\ProcedureVerificationHelper.cs:line 66\r\n at Microsoft.Dynamics.Nav.AppSourceCop.Helper.ProcedureVerificationHelper.MatchFunctions(IEnumerable1 newMethods, IEnumerable1 oldMethods, PooledList1 unmatchedNewMethods, PooledList1 unmatchedOldMethods, PooledList1 matchedMethodPairs) in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.AppSourceCop\\Helper\\ProcedureVerificationHelper.cs:line 45\r\n at Microsoft.Dynamics.Nav.AppSourceCop.Upgrade.RulePublicAPIBreakingChangesNotAllowed.CompareApplicationObjects(SymbolAnalysisContext ctx, ITypeSymbol oldObject, ITypeSymbol newObject) in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.AppSourceCop\\Upgrade\\RulePublicAPIBreakingChangesNotAllowed.cs:line 86\r\n at Microsoft.Dynamics.Nav.AppSourceCop.Upgrade.RulePublicAPIBreakingChangesNotAllowed.AnalyzeModule(SymbolAnalysisContext ctx) in D:\\a\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.AppSourceCop\\Upgrade\\RulePublicAPIBreakingChangesNotAllowed.cs:line 55\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 656\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 1100'",
"source": "AL",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1
}
@LNitzsche please open another issue and provide a project that reproduces the issue. Your issue is triggered by a rule in AppSOurceCop not in CodeCop
@MS-net Please try again with the latest developer preview. Verify that it still triggers the error. If it does please attach a code example that triggers it and the error itself.
@PaulIvan Hi Paul Thanks for the feedback. Unfortunately it looks like the error still persist. Finally I could hunt this down to the following code example:
page 50100 "Rule218Error"
{
layout
{
area(Content)
{
field("Related Fields"; DoRelatedFieldsExist())
{
ToolTip = 'Related Fields Tooltip';
}
}
}
local procedure DoRelatedFieldsExist() FieldsExist: option "No Fields","Some Fields"
begin
exit(FieldsExist::"No Fields")
end;
}
Error Text:
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.MethodDeclarationSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VariableDeclarationBaseSyntax'.
at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.ExtractCountOfOptions(ISymbol symbol) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 317
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 292
at Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions.AnalyzePageFields(SymbolAnalysisContext symbolAnalysisContext, ImmutableArray`1 controlSymbols, PageTypeKind pageTypeKind) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Localizability\Rule218TooltipMustBeFilledOnPageForFieldsAndActions.cs:line 76
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 51
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 656
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1078'
AL Language: 8.0.454854
Hope this helps.
Hi @atoader, @PaulIvan I would like to kindly ask if this issue will someday going to be fixed? Currently it's still open and I still get the error. The above provided code can still be used to reproduce.
Tested now with AL Language v8.4.586670
Thanks in advance
Hi @kalberes Maybe you can give some more insights on this?
Thanks in advance
Thanks for reporting this issue. Sorry we haven’t completed it yet, but we’ve had to prioritize elsewhere. We’re planning to give the CodeCop engine and its rules an overhaul in a future major release. Thanks for your patience.
Hi @mazhelez Thanks for the update. I would prefer if you could keep this issue open and include it in your overhaul rather than just closing it. By closing it, it's just going to be forgotten.
@SHermann73 do not worry about that. I have created an internal work item to track the issue.
However, since CodeCop-related work is yet to be planned, we want to set the right expectations. Namely, as we are focusing elsewhere, so we cannot promise a fix soon.