Bearbeiten

AppSourceCop Error AS0148

An interface method was made required without first being marked [RequiredPending].

Description

When transitioning an optional (default) interface method to required, the method must first be marked with [RequiredPending] in a prior version. This gives consumers advance notice before the breaking change takes effect.

Remarks

This error is raised when a default (optional) interface method in the baseline version has been changed to a required method (body removed) without first being marked with [RequiredPending].

Making an optional method required is a breaking change for dependent extensions; the dependent extension must implement the method or it won't compile. The [RequiredPending] attribute provides a warning period so implementors can add their implementation before it becomes mandatory.

This rule enforces the two-phase lifecycle for interface methods:

  1. Phase 1: Add [RequiredPending] to the default method. Implementors receive a compiler warning (AL0924) but their code continues to compile.
  2. Phase 2: In a later major version, remove the body to make the method required.

When both AS0148 and AS0149 fires on the same interface, AS0149 is suppressed because this error is more actionable.

How to fix this diagnostic?

Restore the method's body (making it a default method again) and add the [RequiredPending] attribute:

interface IMyInterface
{
    [RequiredPending('This method will become required. Add your implementation now.', '26.0')]
    procedure MyMethod(): Text
    begin
        exit('default');
    end;
}

In a subsequent major version, you can remove the body and the attribute to make the method required.

Learn more about the recommended lifecycle in Interface method lifecycle.

Getting started with AL
Developing extensions
RequiredPending attribute
Analyzer rule AS0149
Analyzer rule AS0066
Interface method lifecycle
AppSourceCop analyzer