anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

File Wizard does not implement interfaces completely #560

Open NKarolak opened 5 months ago

NKarolak commented 5 months ago

Create a new interface:

interface MyInterface
{
    procedure MyProcedure() NewItemNo: Code[20]
}

Use the New AL File Wizard to create a codeunit that implements MyInterface. This will result in a codeunit in which the return value name is missing for MyProcedure:

codeunit 50000 MyCodeunit implements MyInterface
{
    procedure MyProcedure() : Code[20]
    begin

    end;
}

Expected:

codeunit 50000 MyCodeunit implements MyInterface
{
    procedure MyProcedure() NewItemNo : Code[20]
    begin

    end;
}

(By the way, the AL compiler does not care about the difference.)

anzwdev commented 4 months ago

Yes, AL compiler does not care about the difference, because "NewItemNo" is a local variable and is not part of the symbols reference in the compiled app.

If you compile this code:

interface MyInterface
{

    procedure P0();
    procedure P1(): Integer;
    procedure P2() MyVariable: Integer;
}

and then check SymbolReference.json inside the app file, there won't be any difference between P1 and P2 methods:

{
  "Methods": [
    {
      "MethodKind": 5,
      "Id": 296408841,
      "Name": "P0"
    },
    {
      "ReturnTypeDefinition": {
        "Name": "Integer"
      },
      "MethodKind": 5,
      "Id": 736563102,
      "Name": "P1"
    },
    {
      "ReturnTypeDefinition": {
        "Name": "Integer"
      },
      "MethodKind": 5,
      "Id": -554670559,
      "Name": "P2"
    }
  ],

So your request can only be implemented for interfaces and codeunits defined in the same app.