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
744 stars 245 forks source link

Publish failes with usage of `as` keyword #7800

Closed StefanMaron closed 2 months ago

StefanMaron commented 3 months ago

Please include the following with each issue:

1. Describe the bug

https://www.youtube.com/watch?v=-7jh-9h-3Nc&t=2462s

If you are targeting a cloud instance, supply these IDs if contacting Microsoft support.
[2024-07-18 13:17:51.38] The request for path /f0e918da2707dev/dev/apps?tenant=default&SchemaUpdateMode=synchronize&DependencyPublishingOption=default failed with code UnprocessableEntity. Reason: Publishing failed due to 'C# compilation has failed for the application object CodeUnit_50102.
The failing c# file name is 3CDE62AA3D2B7A3932BBF38A1368C3CD453FD7F0D597211EE31134ED86AB0AD6.cs. You can find this file with the associated AL file saved in the c:\DatabasesVol\ALAssemblies\apps\compilationerrors folder.
Detailed compilation error: c:\DatabasesVol\ALAssemblies\apps\metadata\3\3C\3CDE62AA3D2B7A3932BBF38A1368C3CD453FD7F0D597211EE31134ED86AB0AD6.cs(78,70): error CS1061: 'NavInterfaceHandle' does not contain a definition for 'InvokeInterfaceMethodAsync' and no accessible extension method 'InvokeInterfaceMethodAsync' accepting a first argument of type 'NavInterfaceHandle' could be found (are you missing a using directive or an assembly reference?)
'. The original extensions have been restored.

2. To Reproduce Steps to reproduce the behavior:

// Welcome to your new AL extension.
// Remember that object names and IDs should be unique across all extensions.
// AL snippets start with t*, like tpageext - give them a try and happy coding!

namespace DefaultPublisher.v25FeatureTest;

using Microsoft.Sales.Customer;

pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage()
    var
        Capacity: Codeunit "Capacity";
        ICapacity: Interface CapacityInterface;
    begin
        ICapacity := Capacity;

        DriveCar(ICapacity as CarInterface);
    end;

    local procedure DriveCar(ICar: Interface CarInterface)
    begin
        ICar.Drive();
        OnAfterDriveCar(ICar);
    end;

    [BusinessEvent(false)]
    local procedure OnAfterDriveCar(ICar: Interface CarInterface)
    begin
    end;
}

codeunit 50102 MyCodeunit
{
    [EventSubscriber(ObjectType::Page, Page::"Customer List", OnAfterDriveCar, '', false, false)]
    local procedure PrintLoadOnAfterDriveCar(ICar: Interface CarInterface)
    begin
        if ICar is CapacityInterface then
            (ICar as CapacityInterface).GetLoad(); // Error happens here
    end;
}

interface VehicleInterface
{
    procedure Move()
}
interface CarInterface extends VehicleInterface
{
    procedure Drive()
}
interface BoatInterface extends VehicleInterface
{
    procedure Sail()
}

interface CapacityInterface extends CarInterface, BoatInterface
{
    procedure GetLoad()
}

codeunit 50100 Car implements CarInterface
{
    procedure Drive()
    begin
        Message('Car drives');
    end;

    procedure Move()
    begin
        Drive();
    end;

}

codeunit 50101 Capacity implements CapacityInterface
{
    procedure GetLoad()
    begin
        Message('GetLoad');
    end;

    procedure Drive()
    begin
        Message('Drive');
    end;

    procedure Sail()
    begin
        Message('Sail');
    end;

    procedure Move()
    begin
        Drive();
        Sail();
    end;
}

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

3. Expected behavior A clear and concise description of what you expected to happen.

4. Actual behavior A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring

5. Versions:

Final Checklist

Please remember to do the following:

Internal work item: AB#542455

azure-boards[bot] commented 3 months ago

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