Closed BartPermentier closed 4 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.
This is also on Yammer here: https://www.yammer.com/dynamicsnavdev/threads/343040592707584
I'm adding my comments here for visiblity:
Right now it:
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.
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.
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
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
Versions: