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
744 stars 245 forks source link

AL(AA0210) The table Item Journal Line does not contain the key with the field Operation No. #5276

Closed BartPermentier closed 4 years ago

BartPermentier commented 5 years ago

Describe the bug You get this warning when you filter on a field that does not have a key in the table. This is a good warning that I would like to see to improve my solution. However it is not very logical that you get this warning on Standard Tables with their standard fields because you can only create keys for fields that you have created.

To Reproduce

    var
        ItemJnlLine: record "Item Journal Line";
    begin
        ItemJnlLine.setrange("Operation No.", 'test');
        ItemJnlline.findfirst();
    end;

Expected behavior Only show the warning for New Tables or for Extension Fields. OR give us the ability to add a key to standard fields. ( < we all prefer this solution)

Screenshots image

Versions:

salgiza commented 5 years ago

I was going to open a new ticket, but I think it is actually related to this one: we are also getting this error with keys that only include extension fields and for which there is a key in the table extension.

jwikman commented 5 years ago

This is also on Yammer here: https://www.yammer.com/dynamicsnavdev/threads/343040592707584

I'm adding my comments here for visiblity:

Right now it:

  1. complains about BaseApp tables and fields that we cannot do anything about
  2. complains about Virtual System tables that we definitely cannot modify (like the Date table)
  3. has above issues
  4. throws errors in app.json:
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceParameterSymbol' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IVariableSymbol'.

   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex.AnalyzeInvocations(SyntaxNodeAnalysisContext syntaxNodeAnalysisContex, ImmutableDictionary`2 processInvocations) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule210SuboptimalIndex.cs:line 86

   at Microsoft.Dynamics.Nav.CodeCop.Design.Rule210SuboptimalIndex.<>c.<Analyze>b__5_0(SyntaxNodeAnalysisContext syntaxNodeAnalysisContex) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule210SuboptimalIndex.cs:line 66

   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass52_1.<ExecuteSyntaxNodeAction>b__1() in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 742

   at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in F:\a\360\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1079'

I understand why this rule has been created, but having a rule with a lot of "false positives" does not help. Right now I've disabled this rule in our ruleset.json file.

But I would love a way to suppress individual problems, like the Diagnostics.CodeAnalysis.SuppressMessageAttribute attribute in PowerShell.

BartPermentier commented 4 years ago

So that's it? We are stuck with these warnings? The code cop should not give a warning for things that are out of our hand.