microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
748 stars 245 forks source link

Cannot publish app when it uses an interface and enum from another extension #5776

Closed narongschmidt closed 4 years ago

narongschmidt commented 4 years ago

Describe the bug It's not possible to publish an app that uses an interface and enum that is defined in another extension.

Publishing results in error code 422 and message: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceEnumTypeSymbol' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceEnumTypeSymbol'.

To Reproduce Steps and to reproduce the behavior:

  1. Create new app A and define an interface with a corresponding enum.
  2. Create new app B and add a page action with this trigger code to any page (it doesn't matter):
    // Code in app B
    trigger OnAction()
    var
    RecordWithEnumFieldFromAppA: Record SomeRecord;
    InterfaceFromAppA: Interface SomeInterface;
    begin
    InterfaceFromAppA:= RecordWithEnumFieldFromAppA.EnumField;
    end;

Expected behavior The app is successfully published to the instance.

Screenshots If applicable, add screenshots to help explain your problem.

5. Versions:

kalberes commented 4 years ago

@PooyaKharamesh is this the case?

Weichwolf commented 4 years ago

@PooyaKharamesh I can confirm this bug.

You can not publish an app if it initializes an interface with a enum value defined in a referenced application.


procedure TestSquareValues()
var
    MathInterface_l: Interface MathInterface;           // defined in referenced application
    MathEnum_l: Enum MathEnum;                          // defined in referenced application
    MathSquare_l: Codeunit MathSquare;
begin
    MathInterface_l := MathSquare_l;                    // works correctly
    MathInterface_l := MathEnum_l::"Square Values";     // can not be published
    LibraryAssert_g.AreEqual(4, MathInterface_l.Calculate(2), '');
    LibraryAssert_g.AreEqual(36, MathInterface_l.Calculate(2, 3), '');
end;

Version: CH Business Central 16.0 (Platform 16.0.11233.12163 + Application 16.0.11240.12188)

nicolassaleron commented 4 years ago

I can confirm the bug too. It breaks my test pipelines: I am unable to publish my test apps if I use interfaces.

nicolassaleron commented 4 years ago

I have noticed that publishing from VSCode works but it fails when using the Powershell commands.

kalberes commented 4 years ago

@Weichwolf , @narongschmidt Have you create a workspace with proper dependencies (project references) and are you trying to publish from VsCode, or powershell? Since this should be working with project references in a workspace as mentioned above

Weichwolf commented 4 years ago

@kalberes A workspace with project references was created and I publish from VS Code.

https://github.com/Weichwolf/EnumInterfaceTest

preetgor commented 4 years ago

I do face the similar issue in Business central 16.0.

thpeder commented 4 years ago

Thanks for reporting the issue and providing reproduction steps, it helps a lot. I verified with the code from @Weichwolf repository and the issue has been fixed but please give it a try when the next update comes.

Weichwolf commented 4 years ago

It's still not working in 16.1.12629.12805

atoader commented 4 years ago

Are you able to test this on the preview version of the product by any chance?

jwikman commented 4 years ago

@thpeder Why is this closed? I still get this in platform 16.0.12630.12758

jwikman commented 4 years ago

I can confirm that it is solved in preview of 16.0 CU2 (Platform 16.0.13347.0). So @thpeder forget my question about why it is closed, it should be closed. :)