Rediger

Del via


AppSourceCop Error AS0019

Event attributes cannot be removed

Description

Removing Event attributes such as IntegrationEvent or BusinessEvent is not allowed because it will break dependent extensions that have subscribed to this event.

Remarks

Removing the event attribute on Business and Integration type events is not allowed, because it will break dependent extensions which are subscribing to them. It is allowed to remove the InternalEvent attribute, as InternalEvents can only be subscribed to from within the same module.

Note

Internal events are also available for the modules specified in the internalsVisibleTo property in your app.json file.

Code examples triggering the rule

In the following examples, the version 1.0 of the extension defines a Business type event whose accessibility is not public. This means that this event cannot be raised from other extensions, but it can still be subscribed to from other extensions.

Version 1.0 of the extension:

codeunit 50100 MyCodeunit
{
    [BusinessEvent(false)]
    local procedure MyEvent(i: Integer)
    begin
    end;
}

Version 2.0 of the extension:

codeunit 50100 MyCodeunit
{
    local procedure MyEvent()
    begin
    end;
}

In version 2.0, the event attribute has been renamed. If a dependent extension subscribed to this event, this will lead to a compilation error similar to Object member 'MyEvent' is not an event. (AL0281).

For example, the following extension compiles when depending on version 1.0, but fails to compile with version 2.0:

codeunit 50120 AnotherCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyCodeunit, 'MyEvent', '', false, false)]
    local procedure MyProcedure(i: Integer)
    begin
        // Subscriber logic
    end;
}

AppSourceCop Analyzer
Get Started with AL
Developing Extensions