StefanMaron / BusinessCentral.LinterCop

Community driven code linter for AL (MS Dynamics 365 Business Central)
https://stefanmaron.com
MIT License
74 stars 31 forks source link

LC0039 Rule0039ArgumentDifferentTypeThenExpected #635

Closed SKeiler closed 3 months ago

SKeiler commented 4 months ago

Hi,

we try to implement the rules on our ISV. So I'm not sure if it's a "local" problem in our environment or a problem with the project. We use it currently for BC23.4. We installed the LinterCop-VSC Extension and get the following warning in our project.

Analyzer 'BusinessCentral.LinterCop.Design.Rule0039ArgumentDifferentTypeThenExpected' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SimpleNavTypeSymbol' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IRecordTypeSymbol'. at BusinessCentral.LinterCop.Design.Rule0039ArgumentDifferentTypeThenExpected.AnalyzeSetRecordArgument(OperationAnalysisContext ctx) at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass54_1.b__1() in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 773 at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1088'

We are a little bit unsure what's the reason of the warning. Can you please give us a hint as to what the cause is.

Arthurvdv commented 4 months ago

Thank you for creating an issue, there's probably something wrong.

image

Could you switch over to the pre-release version of the LinterCop and try again? After reloading VS Code you should find a LC0000 diagnostic pointing to the line of code causing this error. Would be great if you could share a small portion of the code (or recreate a small sample)

SKeiler commented 4 months ago

Hi,

seem's to be a SetTableView based on a Variant-Record. image

Arthurvdv commented 3 months ago

This should now be resolved in the release version of v0.30.25 of the LinterCop.