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

LC0054 'BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide' threw an exception of type 'System.NullReferenceException' #671

Open pri-kise opened 3 months ago

pri-kise commented 3 months ago

Since today I receive the following error.

Analyzer 'BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide' 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.Rule0054FollowInterfaceObjectNameGuide.GetIndexAfterAffix(String typeSymbolName)
   at BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide.AnalyzeObjectName(SymbolAnalysisContext context)
   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 Language Extension: v14.0.1055126

tscottjendev commented 3 months ago

Me too.

Arthurvdv commented 3 months ago

I think I've found the reason for this Exception (I didn't test without an AppSourceCop.json file exists in the project).

@pri-kise and @tscottjendev , did this resolve the Exception?

pri-kise commented 2 months ago

I checked this project again and we have an AppSourceCop.json, but in this project we haven't specified the property mandatoryAffixes, but the property mandatoryPrefix.

Maybe this is the reason for the issue?

warning AD0001: Analyzer 'BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide' 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.Rule0054FollowInterfaceObjectNameGuide.GetAffixes(Compilation compilation)
   at BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide.PopulateListOfAffixes(CompilationStartAnalysisContext context)
   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'

Update: I switched to MandatoryAffixes and now the error is gone.