AL icon indicating copy to clipboard operation
AL copied to clipboard

Analyzer AD0001 'Microsoft.Dynamics.Nav.CodeCop.Localizability.Rule218TooltipMustBeFilledOnPageForFieldsAndActions'

Open MS-net opened this issue 5 years ago • 14 comments

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.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, Nullable1 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:

  1. Open existing project while AL Language 6.1.x is installed
  2. activate codeanalyzers
  3. 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

MS-net avatar Dec 08 '20 07:12 MS-net

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.

SHermann73 avatar Dec 10 '20 15:12 SHermann73

Could we get an update on the current state of the error or plans for solving it?

MS-net avatar Jan 06 '21 08:01 MS-net

@PaulIvan can you follow up?

atoader avatar Jan 20 '21 19:01 atoader

@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.

SHermann73 avatar Jan 20 '21 21:01 SHermann73

@atoader @PaulIvan Hi all. Any news regarding this? An updated would still be highly appreciated.

SHermann73 avatar Feb 05 '21 07:02 SHermann73

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 avatar Apr 27 '21 13:04 LNitzsche

@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

atoader avatar Apr 29 '21 14:04 atoader

@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 avatar Apr 30 '21 09:04 PaulIvan

@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.

SHermann73 avatar May 04 '21 21:05 SHermann73

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

SHermann73 avatar Mar 10 '22 22:03 SHermann73

Hi @kalberes Maybe you can give some more insights on this?

Thanks in advance

SHermann73 avatar Mar 17 '22 10:03 SHermann73

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.

mazhelez avatar Jun 24 '22 10:06 mazhelez

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 avatar Jun 24 '22 11:06 SHermann73

@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.

mazhelez avatar Jun 26 '22 20:06 mazhelez