Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with LinterCop Analyzers (v15.0.1177813 and v14.1.1180850) -- Rule0051, Rule0059 #822

Open
Daniel-Waleczek opened this issue Dec 5, 2024 · 3 comments
Assignees
Labels
bug Something isn't working part of upcoming release

Comments

@Daniel-Waleczek
Copy link

When using LinterCop for AL with the following versions:

  • v15.0.1177813 (pre-release)
  • v14.1.1180850 (release)

I encounter the following errors:

  1. Error in Rule0051SetFilterPossibleOverflow:

    Analyzer 'BusinessCentral.LinterCop.Design.Rule0051SetFilterPossibleOverflow' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.BoundCall' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IConversionExpression'.
    at BusinessCentral.LinterCop.Design.Rule0051SetFilterPossibleOverflow.AnalyzeInvocation(OperationAnalysisContext ctx)
    at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass54_1.<ExecuteOperationAction>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'AL(AD0001)
    
  2. Error in Rule0059SingleQuoteEscaping:

    Analyzer 'BusinessCentral.LinterCop.Design.Rule0059SingleQuoteEscaping' threw an exception of type 'System.NullReferenceException' with message 'System.NullReferenceException: Object reference not set to an instance of an object.
    at BusinessCentral.LinterCop.Design.Rule0059SingleQuoteEscaping.AnalyzeCalcFormula(SymbolAnalysisContext ctx)
    at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass50_2.<ExecuteSymbolActionsCore>b__0() in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 665
    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'AL(AD0001)
    

Steps to Reproduce:

  1. Use correct LinterCop with AL in either of the versions:
    • v15.0.1177813 (pre-release)
    • v14.1.1180850 (release)
  2. Open app.json.
    image

Expected Result:

The analyzers should execute without throwing exceptions.

Actual Result:

The analyzers throw exceptions:

  • System.InvalidCastException for Rule0051SetFilterPossibleOverflow.
  • System.NullReferenceException for Rule0059SingleQuoteEscaping.

Additional Information:

  • Reinstalling LinterCop and AL does not resolve the issue.

Environment:

  • LinterCop version: v0.31.3, v0.31.2
  • AL version: v15.0.1177813, v14.1.1180850
@Arthurvdv Arthurvdv added the bug Something isn't working label Dec 5, 2024
@Arthurvdv
Copy link
Collaborator

Thank you for reporting these exceptions!

I've created an updated version v0.31.3 of the LinterCop) to investigate what's causing this.

Normally closing (all) VS Code windows and opening again an AL project should be enough to automatically retrieve this updated version. Please make sure you have the "pre-release" option on the LinterCop extensions itself activated.

You should now have a LC0000 diagnostic instead of these exceptions. Would be great if you could share a small code example which causes one or both of these exceptions.

@Arthurvdv Arthurvdv self-assigned this Dec 5, 2024
@Daniel-Waleczek
Copy link
Author

For some reason, the .dll file is not updating automatically, even when using the Download Linter Cop action. I had to manually delete the existing file, and only then was it successfully downloaded.

Regarding Rule0059SingleQuoteEscaping, the issue disappeared as soon as I tried to open it. The error initially appeared for this field:
image

As for Rule0051SetFilterPossibleOverflow, the error is triggered by the following code:
Image

@Arthurvdv
Copy link
Collaborator

Thank you for share these code examples, this was quite helpful to resolve this errors.

I've created an updated version v0.31.3 of the LinterCop) which now will handle these scenrio's and no longer will throw an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working part of upcoming release
Projects
None yet
Development

No branches or pull requests

2 participants