Object reference not set to an instance of an object
I've created and installed an extension. Specified the new extension as dependency in app.json. Declared a variable to point to one of the codeunits in the published extension and when trying to use intellisense to get it's functions I'm getting the following error below:
Microsoft (R) AL Compiler version 0.7.12087 Copyright (C) Microsoft Corporation. All rights reserved
Success: The package is created.
[Error - 3:56:16 PM] Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible.
Processing of message 'textDocument/completion' failed with error: 'Object reference not set to an instance of an object.'
StackTrace:
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.TypeSymbolExtensions.IsArray(ITypeSymbol type) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\KindsAndExtensions\TypeSymbolExtensions.cs:line 79
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitParameter(ParameterSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 213
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.AddParametersIfRequired(MethodSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 344
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitMethod(MethodSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 335
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplay.ToDisplayParts(ISymbol symbol, SemanticModel semanticModelOpt, Int32 positionOpt, SymbolDisplayFormat format, Boolean minimal) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplay.cs:line 106
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbol.ToDisplayParts(SymbolDisplayFormat format) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Symbol.cs:line 473
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.SymbolCompletionItem.Create(String displayText, TextSpan span, IReadOnlyList1 symbols, Int32 contextPosition, Int32 descriptionPosition, String sortText, String insertionText, Nullable1 glyph, String filterText, Boolean preselect, SupportedPlatformData supportedPlatforms, Boolean isArgumentName, ImmutableDictionary2 properties, ImmutableArray1 tags, CompletionItemRules rules) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\SymbolCompletionItem.cs:line 63
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List1 symbols, AbstractSyntaxContext context, TextSpan span, Boolean preselect, SupportedPlatformData supportedPlatformData) in C:\Agent\_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 111
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List1 symbols, AbstractSyntaxContext context, TextSpan span, Dictionary2 invalidProjectMap, List1 totalProjects, Boolean preselect) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 106
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.<>c__DisplayClass5_0.2 g) in C:\Agent\_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 47
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItems(Int32 position, IEnumerable1 symbols, TextSpan span, AbstractSyntaxContext context, Dictionary2 invalidProjectMap, List1 totalProjects, Boolean preselect) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 44
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.
Hi! I will try to repro this issue. It would be great if you could provide a small sample that reproduces the crash as you did for issue #492.
I could not reproduce the crash on the latest internal build following your instructions.
I was using latest publicly available build. Do you still want me to provide a small sample or is it not needed anymore?
If you can provide a sample that repros, I would appreciate it greatly. Maybe the bug is somewhere else and this is just a symptom.
Here are the files to generate the error. All files except AA_TEST.al and app.json.2.txt are used to create first extension. AA_TEST.AL and app.json.2.txt are used to create a second one that has dependencies. Now if you would try to use variable LibrarySales in file AA_TEST.al to see the functions in the codeunit the error would be shown in OUTPUT window.
AA_TEST.al.txt AndriusAndrulevicius_AutomatedTesting_1.0.0.0.navx.txt app.json.2.txt app.json.txt COD70130440_LibraryRandom.al.txt COD70130509_LibrarySales.al.txt COD70131000_LibraryUtility.al.txt COD70131300_LibraryERM.al.txt SampleTest.al.txt
Thanks! I found the issue. It is caused by how we generate reference symbols and it only happens when you have a parameter to a procedure that is a complex type.