AL icon indicating copy to clipboard operation
AL copied to clipboard

'textDocument/inlayHint' failed with error: 'Object reference not set to an instance of an object.'

Open JavierFuentes opened this issue 1 year ago • 5 comments
trafficstars

1. Describe the bug the setting "editor.inlayHints.enabled": "on" throws error:

2. To Reproduce activate this setting "editor.inlayHints.enabled": "on" in VSCode for a BC extension:

3. Expected behavior no errors

4. Actual behavior

[Error - 10:08:49] Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible.
Processing of message 'textDocument/inlayHint' failed with error: 'Object reference not set to an instance of an object.'
Details:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.GetRecordStructure(Symbol symbol) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 1485
   at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitParameter(ParameterSymbol symbol) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 273
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.InlayHintRequestHandler.CreateContent(ISymbol symbol, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\InlayHintRequestHandler.cs:line 115
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.InlayHintRequestHandler.GetInlayHints(Document document, Nullable`1 range, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\InlayHintRequestHandler.cs:line 81
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.InlayHintRequestHandler.HandleAsync(InlayHintRequest request, Int32 requestId, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\InlayHintRequestHandler.cs:line 46
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase`1.HandleAsync(JToken requestContents, Int32 requestId, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\MessageProtocol\RequestHandlerBase.cs:line 84
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.Process(Message message) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 84

5. Versions:

  • AL Language: Version 13.1
  • Visual Studio Code: Versi??n: 1.91.1 (user setup) Confirmar: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Fecha: 2024-07-09T22:06:49.809Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 SO: Windows_NT x64 10.0.22631
  • Business Central: ES Business Central 24.3 (Plataforma 24.0.21667.0 + Aplicaci??n 24.3.21374.21517)
  • List of Visual Studio Code extensions that you have installed: None

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

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

Internal work item: AB#542456

JavierFuentes avatar Jul 15 '24 08:07 JavierFuentes

✅ Successfully linked to Azure Boards work item(s):

azure-boards[bot] avatar Jul 21 '24 10:07 azure-boards[bot]

IT would be quite helpful for a fix a small repro.

kalberes avatar Jul 21 '24 10:07 kalberes

I dont have an example, but I have noticed a place where the error occurs.

We have an app A which exposes this function:

procedure GetWorkTypeRelationByResourceNo(ResourceNo: Code[20]; WorkType: Code[20]; var WorkTypeRealtion: Record "Work Type Relation3_LON")
begin
end;

When this function is called in our customers extension B, the inline hits are missing and the error is produced. To create a lot of these errors I can simply press Ctrl+Alt (Normal to show Inline Hits). If I comment out the line with Functionpublisher, the error isn't produced. Maybe it's because we have a number in our tablename?

local procedure CreatePayrollJnlEntry(ResLedgerEntry: Record "Res. Ledger Entry") Result: Integer
var
    Employee: Record Employee_LON;
    WorkTypeRelation: Record "Work Type Relation3_LON";
    Functionpublisher: Codeunit Functionpublisher_LON;
begin
    Employee.SetRange("Resource No.", ResLedgerEntry."Resource No.");
    if not Employee.FindFirst() then
        exit;
    Functionpublisher.GetWorkTypeRelationByResourceNo(ResLedgerEntry."Resource No.", ResLedgerEntry."Work Type Code", WorkTypeRelation);
    if CreateAbsenceJnlLine(ResLedgerEntry, WorkTypeRelation, Employee) then
        Result += 1;
    if CreatePayrollJnlLine(ResLedgerEntry, WorkTypeRelation, Employee) then
        Result += 1;
end;

I have tried to downgrade to 13.0.1027618, but the problem persists (Currently I'm using 13.1.1065068)

joandrsn avatar Aug 12 '24 11:08 joandrsn

I encounter the same error as described above. (13.1.1065068)

When switching to the file in vscode the error is thrown once. Every time i add a new line and wait for the inline hint it throws the error again.

Example:

namespace DefaultPublisher.RepScenario;
using Microsoft.Inventory.Tracking;

codeunit 50100 "Rep. Scenario"
{
    trigger OnRun()
    var
        TrackingSpecification: Record "Tracking Specification";
        ReservMgt: Codeunit "Reservation Management";
    begin
        ReservMgt.CreateReservation('', WorkDate(), 1, 1, TrackingSpecification);
        // Add new line below and wait.
    end;
}

SKnoppers avatar Aug 21 '24 15:08 SKnoppers

I am getting the same error too. (14.2.1249978)

The error is thrown when I have one AL code line that calls a function from another app. The AL object has otherwise many other lines of code.

That other AL app is available as an *.app file in the ".alpackages" folder.

That app file can be opened as a zip file. The app file does not contain any source code, but only 4 files:

  • DocComments.xml
  • NavxManifest.xml
  • SymbolReference.json (16+Mb -> too big?)
  • [Content_Types].xml

I can see the symbols of that other app in VS Code, but not the source code (as expected).

yurim108 avatar Jan 14 '25 12:01 yurim108