BusinessCentral.LinterCop icon indicating copy to clipboard operation
BusinessCentral.LinterCop copied to clipboard

Rule0005 Variable Casing Should Not Differ From Declaration Exception

Open Hilbekale opened this issue 10 months ago • 10 comments

Hi,

I get the following error in one repository (upgrade from NAV to BC 25:

Image

I can not identify which line is causing this issue.

Lintercop Version 0.1.10 AL Language extension: 14.2.1249978

Hilbekale avatar Jan 27 '25 09:01 Hilbekale

Could you verify if the right BusinessCentral.LinterCop.dll file has been downloaded?

You can always manual remove the BusinessCentral.LinterCop.dll file and close all Windows of VS Code. It wil then download again the right version.

Arthurvdv avatar Jan 27 '25 13:01 Arthurvdv

I actually removed it manually and started vs code and used the command Download Lintercop.,

Image

I think it should be the updated version.

Hilbekale avatar Jan 27 '25 13:01 Hilbekale

	"resource": "/c:/Users/Administrator/Desktop/git/Pfalzmarkt/BC_Pfalzmarkt_General-7/app/app.json",
	"owner": "_generated_diagnostic_collection_name_#2",
	"code": "AD0001",
	"severity": 4,
	"message": "Analyzer 'BusinessCentral.LinterCop.Design.Rule0005VariableCasingShouldNotDifferFromDeclaration' threw an exception of type 'System.NullReferenceException' with message 'System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.BinderFactory.BinderFactoryVisitor.VisitCore(SyntaxNode node) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Binder\\BinderFactory.cs:line 327\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxVisitor`1.VisitIfDirectiveTrivia(IfDirectiveTriviaSyntax node) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Generated\\SyntaxVisitor.Generated.cs:line 1617\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.IfDirectiveTriviaSyntax.Accept[TResult](SyntaxVisitor`1 visitor) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Generated\\SyntaxNodes.Generated.cs:line 30687\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxVisitor`1.VisitUnaryExpression(UnaryExpressionSyntax node) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Generated\\SyntaxVisitor.Generated.cs:line 1467\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.BinderFactory.GetBinder(SyntaxNode node, Int32 position) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Binder\\BinderFactory.cs:line 81\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.ReportDataItemSemanticModel.GetSymbolInfoWorker(SyntaxNode node, CancellationToken cancellationToken) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Compilation\\ReportDataItemSemanticModel.cs:line 96\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxTreeSemanticModel.GetSymbolInfoWorker(SyntaxNode node, CancellationToken cancellationToken) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Compilation\\SyntaxTreeSemanticModel.cs:line 95\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.SemanticModel.GetSymbolInfo(ExpressionSyntax expression, CancellationToken cancellationToken) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Compilation\\SemanticModel.cs:line 551\r\n   at Microsoft.Dynamics.Nav.CodeAnalysis.SemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken) in X:\\Prod\\Microsoft.Dynamics.Nav.CodeAnalysis\\Compilation\\SemanticModel.cs:line 409\r\n   at BusinessCentral.LinterCop.Design.Rule0005VariableCasingShouldNotDifferFromDeclaration.AnalyzeIdentifierName(SyntaxNodeAnalysisContext ctx)\r\n   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'",
	"source": "AL",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 1
}]

Hilbekale avatar Jan 27 '25 13:01 Hilbekale

Thanks for double checking that you've got the right version of the BusinessCentral.LinterCop.dll.

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

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 avatar Jan 27 '25 16:01 Arthurvdv

It is a report

Image

the properties are disabled with preprocessorSymbols in App.json for the migration. Looks like something goes wrong there.

Hilbekale avatar Jan 27 '25 17:01 Hilbekale

I'm getting the idea what is causing this, but unfortunately I'm not able to setup an repo on this.

Can you share a small code sample what is causing this error? Because with the example below I can't seem to reproduce the same exception.

report 50100 MyReport
{
    dataset
    {
        dataitem(SalesHeader; "Sales Header")
        {
#if not FLDEXT
            DataItemTableView = sorting("Document Type", "No.") where("Document Type" = const(Invoice));
            RequestFilterFields = "Posting Date";
#endif
            column(No; SalesHeader."No.") { }
        }
    }
}

Arthurvdv avatar Jan 27 '25 18:01 Arthurvdv

Unfortunately i can not reproduce it while i try to do it in a clean project. I even tried to copy the whole report and replace the dataitems with standard tables.

The issue must come from the symbols within the project. I will try to track it down if i touch the report but it may take some days until i can report more details to it.

Hilbekale avatar Jan 27 '25 22:01 Hilbekale

I think I have another idea; I've added the information that I need to the LC0000 diagnostic to the updated pre-release version.

Would be great if you could could share the LC0000 diagnostic message, where I'm interested in the Node and ParentNode values.

Image

Arthurvdv avatar Jan 28 '25 08:01 Arthurvdv

Image

It did not changed, also the whole repository only has one LC0000 and it had two LC0000 before (although the secondwarning was not displayed).

Hilbekale avatar Jan 30 '25 12:01 Hilbekale

@Hilbekale, thank you for sharing the details of de diagnostic.

I believe I've resolved this in the Pre-release v0.34.1 version of the LinterCop. Could you verify if everything now works as expected?

Arthurvdv avatar Jan 31 '25 13:01 Arthurvdv

The version v0.35.0 of LinterCop has been released as the latest, where this issue is now resolved.

Arthurvdv avatar Mar 19 '25 10:03 Arthurvdv