AL icon indicating copy to clipboard operation
AL copied to clipboard

generateCrossReferences not working - System.AggregateException due to System.NullReferenceException

Open DavidFeldhoff opened this issue 7 months ago • 0 comments

Please include the following with each issue:

1. Describe the bug I want to compile my AL Project using the /generateCrossReferences switch to get the cross references from the compiler. The compilation as such succeeds, but then there's an Exception when generating the cross references:

System.AggregateException: Failure while creating cross reference graph (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.CrossReferenceExtensions.NodeId(ISymbol symbol) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\CrossReferenceExtensions.cs:line 32
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.Node.get_Id() in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\Node.cs:line 32
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.RelationshipGraph.NodeComparer.GetHashCode(Node obj) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\RelationshipGraph.cs:line 130
   at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value, Int32& location)
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.RelationshipGraph.InitializeNodes(Compilation compilation) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\RelationshipGraph.cs:line 56
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.RelationshipGraph..ctor(Compilation compilation) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\RelationshipGraph.cs:line 24
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.CrossReferenceAnalyzer.GenerateCrossReferenceInfo(Boolean saveToDGMLFile, Boolean saveToJsonFile) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\CrossReferenceAnalyzer.cs:line 82
   --- End of inner exception stack trace ---
   at Microsoft.Dynamics.Nav.CodeAnalysis.CrossReference.CrossReferenceAnalyzer.GenerateCrossReferenceInfo(Boolean saveToDGMLFile, Boolean saveToJsonFile) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CrossReference\CrossReferenceAnalyzer.cs:line 87
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.GenerateCrossReferenceAnalysis(Compilation compilation, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 622
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCoreImpl(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, Compilation compilation, AnalyzerDriver analyzerDriver, IEnumerable`1 analyzerExceptionDiagnostics, IEnumerable`1 additionalTextFiles, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 598
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, ITelemetryService telemetryService, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 495
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.Run(CompilerTextWriter consoleOutput, ITelemetryService telemetryService, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 345
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.Alc.<>c__DisplayClass1_0.<Run>b__0(CompilerTextWriter textWriterOut, CompilerTextWriter _) in X:\Prod\alc\Alc.cs:line 37
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.ConsoleUtil.RunWithOutput[T](Boolean useUtf8Encoding, Func`3 func) in X:\Prod\alc\ConsoleUtil.cs:line 25
   at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.Alc.Run(String clientDirectory, String baseDirectory, String[] args, IAnalyzerAssemblyLoader analyzerLoader) in X:\Prod\alc\Alc.cs:line 37

see here the log (a bit redacted)

log.txt

2. To Reproduce Steps to reproduce the behavior:

  1. Open a bigger project and compile it with /generateCrossReferences switch activated. Note that smaller projects work for me. I don't know exactly when or what causes the generation of the cross references to fail. I hope it becomes clear when seeing the callstack.

3. Expected behavior I expect to have the cross references afterwards.

4. Actual behavior Errors out.

5. Versions:

  • AL Language: v15.0.1433841
  • Visual Studio Code:
    • Version: 1.95.3 (user setup) Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813 Date: 2024-11-13T14:50:04.152Z Electron: 32.2.1 ElectronBuildId: 10427718 Chromium: 128.0.6613.186 Node.js: 20.18.0 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.26100
  • Operating System:
    • [x] Windows
    • [ ] Linux
    • [ ] MacOS

Final Checklist

Please remember to do the following:

  • [x] Search the issue repository to ensure you are reporting a new issue

  • [x] Reproduce the issue after disabling all extensions except the AL Language extension

  • [ ] Simplify your code around the issue to better isolate the problem

    • As it is about all bigger projects, I'd rather ask you to look into the callstack and hope that it's an easy fix. I'm happy to try a preview vsix then to see if it is fixed instead of shrinking my project step by step to narrow it down as that might be quite some effort. Internal work item: AB#579124

DavidFeldhoff avatar May 21 '25 09:05 DavidFeldhoff