DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

[Suggestion] Add code action 'Add OnBeforePublisher / IntegrationEvent' #118

Closed fvet closed 3 years ago

fvet commented 3 years ago

While making our code extensible, we often have to provide new integrationevents to skip normal function logic. We do this by providing OnBefore publishers in the function body.

Similar to how the CRS / waldo codeunit method pattern works (although we don't create method codeunits)

image

it would be good if we had a code action 'Add OnBeforePublisher' on 'Procedure' level to:

If the functions return value (AccessKey) would not be named, either add a message / alert to first assign a name (preferred). Either add a local variable, that is only used in the exit statement.

internal procedure GetAccessKey() AccessKey: Text
    var
        Handled: boolean;
        AccessKeyNotFoundErr: Label 'Access key not found';
    begin
        OnBeforeGetAccessKey(AccessKey, Handled);
        if Handled then
            exit;

        if IsNullGuid("Access Key") then
            exit('');

....

[IntegrationEvent(false, false)]
    local procedure OnBeforeGetAccessKey(var AccessKey: Text; var Handled: boolean)
    begin
    end;
DavidFeldhoff commented 3 years ago

Sounds good, I'll see what I can do for you.

DavidFeldhoff commented 3 years ago

The commits that are referenced are linked by mistake. I wanted to link #120 and #121 ^^. I'm still working on 118 and #119