StefanMaron / BusinessCentral.LinterCop

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

AL Language Extension Version: v14.0.1002061 (pre-release) - Unhandled exception. System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.ParameterListSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VarSectionSyntax'. #606

Closed pri-kise closed 3 months ago

pri-kise commented 6 months ago

The latest version of the LinterCop Preview version seems to have problems with the preview version of the AL Language extension.

System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.ParameterListSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VarSectionSyntax'.
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.FindLocalVariables(SyntaxNode node)
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.AnalyzeTransferFields(OperationAnalysisContext ctx)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

AL Language Extension Version: v14.0.1002061 (pre-release)

pri-kise commented 6 months ago

I've downloaded the latest LinterCop DLLs.

I copied the DLL BusinessCentral.LinterCop.AL-14.0.1002061.dll to BusinessCentral.LinterCop.dll

I closed all VS Code sessions.

Is there anything I did wrong in the manual process to use the correct LinterCop Version?

Arthurvdv commented 6 months ago

You did everything right, unfortunately the rule indeed needs some rework for the new version of the AL Language.

Note: We're created a new release of the LinterCop and the VS Code extension, where you now no longer need to manually copy .dll files anymore, see https://github.com/StefanMaron/BusinessCentral.LinterCop/issues/592#issuecomment-2095977402 and https://github.com/StefanMaron/BusinessCentral.LinterCop/issues/580#issuecomment-2095975595.

Arthurvdv commented 5 months ago

I'm going to close this issue, where I believe it's resolved with the latest update of the LinterCop (combined with the VS Code extension) to handle this.

pri-kise commented 3 months ago

@Arthurvdv can you maybe reopen this issue. This issue is back for our NextMajor Pipelines:

VSIX: 14.0.1070882

pri-kise commented 3 months ago

@Arthurvdv I must have been blind. The error looks pretty similiar, but is a little bit different:

Unhandled exception. Unhandled exception. System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.VarSectionSyntax' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.GlobalVarSectionSyntax'.
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.FindGlobalVariables(SyntaxNode node)
   at BusinessCentral.LinterCop.Design.Rule0044AnalyzeTransferFields.AnalyzeTransferFields(OperationAnalysisContext ctx)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

The function FindGlobalVariables instead of the function FindLocalVariables is the problem this time.

Arthurvdv commented 3 months ago

@pri-kise , I see now I added an LC0000 for the FindLocalVariables the last time, where I was hoping for a small code sample to reproduce this error. In the pre-release version of the LinterCop I now also added this to the FindGlobalVariables.

Can you see if you have a LC0000 diagnostic on this? Would be great if you could share a small code sample on this.

pri-kise commented 3 months ago

@Arthurvdv thanks for your fast response. I tried to reproduce the error and now it's gone.

During my research I found out, that we are having problems with our Download Script. We currently only Download the normal BCLintercopp.dll and not the BCLinterCop.next.dll. Therefore the next DLL wasn't up to date. After manually replacing the next DLL the error was gone.

I will close this issue for now. Thanks for you help.

Arthurvdv commented 3 months ago

No problem! I'm going to remove these LC0000 diagnostic for now (to reduce the Try/Catch).

P.S. I'm thinking of obsoleting the BusinessCentral.LinterCop.next.dll artifact in the future, because this is the same as the BusinessCentral.LinterCop.AL-PreRelease.dll.

pri-kise commented 3 months ago

a good to know. I wasn't aware of that. Hopefully not in the next months during summer holdiay, because we're still relying on this artifact.

Arthurvdv commented 3 months ago

Absolutely not during the holiday season (juli/august), probably somewhere 2025 I guess.

I’ve posted an issue to be made this generally known.