BusinessCentral.LinterCop
BusinessCentral.LinterCop copied to clipboard
Rule0032ClearCodeunitSingleInstance
I'm facing below error with BCLinterCop v0.1.6 / Prerelease
Analyzer 'BusinessCentral.LinterCop.Design.Rule0032ClearCodeunitSingleInstance' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Boolean'.\r\n at BusinessCentral.LinterCop.Design.Rule0032ClearCodeunitSingleInstance.IsSingleInstanceCodeunitWithGlobalVars(ICodeunitTypeSymbol codeunitTypeSymbol)\r\n at BusinessCentral.LinterCop.Design.Rule0032ClearCodeunitSingleInstance.HasSingleInstanceCodeunitWithGlobalVars(IEnumerable
1 variables, ISymbol& codeunit)\r\n at BusinessCentral.LinterCop.Design.Rule0032ClearCodeunitSingleInstance.ClearAllCodeunit(OperationAnalysisContext ctx)\r\n at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable1 info) in D:\\a\\_work\\1\\s\\source\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\DiagnosticAnalyzer\\AnalyzerExecutor.cs:line 1079
Can you easily create a repo or do I need to add a LC0000 here?
@fvet I've added an extra check, and now will raise the LC0000 diagnostic in the pre-release v0.30.14 version of the LinterCop.
Would be great if you could share a code snippet that causes this error.
Creating a repo is not possible, it's a 600+ objects project.
I tried again to open my project using the latest AL prerelease, but it's just full of random errors, so I switched back to the latest release instead some weeks ago.
...
Will keep an eye on it though and if I encounter similar errors, maybe the LC0000 diagnostic might provide better insights.
I tried again to open my project using the latest AL prerelease, but it's just full of random errors, so I switched back to the latest release instead some weeks ago.
I've added the LC0000 rule to the pre-release of the LinterCop. You can try with the normale (stable) release version of the AL Language (v12.6) combined with the pre-release version of the LinterCop?
@fvet Did you had a change to look a this?
This is an interesting case though. If I understand the error the LinterCop is reporting, it seems that you have a value set for the SingleInstance
property on a codeunit what isn't a boolean 🤔
@Arthurvdv I'll reopen this issue when the error occurs again.
I've added temporary Try/Catch for this issue, specific for this issue, where I would like to implement a permanent solution for this.
With the new release yesterday, the regular release version of the LinterCop should now also raise a LC0000 diagnostic on this. Would be great if you could prove a small sample of recreating this issue (not sure if you still have this issue on one of your projects). Or can I now completely remove this Try/Catch piece of code?
@fvet Just checking in to see if you had a moment to look into finding an LC0000 diagnostic on this.
@fvet, I'm a curious about this one/ Any chance you can provide a small code snippet to reproduce this error?
The version v0.30.28 of the LinterCop is now the latest release.