Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
JavierFuentes opened this issue Jul 15, 2024 · 4 comments
Labels

Comments

@JavierFuentes
Copy link

JavierFuentes commented Jul 15, 2024

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:

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

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

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

Internal work item: AB#542456

Copy link

azure-boards bot commented Jul 21, 2024

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

@kalberes
Copy link
Contributor

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

@joandrsn
Copy link
Contributor

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)

@SKnoppers
Copy link

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants