編輯

AppSourceCop Hidden AS0073

Attribute tag must be set.

Description

Attribute tag must be set.

Remarks

This rule validates that a tag is specified when using the Obsolete or RequiredPending attribute, or when setting the Obsolete State property. The tag provides tracking information such as the timeline of the deprecation or transition.

For Obsolete, the tag appears in the diagnostics AL0432 and AL0433 reported by the AL compiler. For RequiredPending, it appears in the AL0924 warning.

The format of the tag is not validated by the AL compiler. However, you can specify an expected format to be validated by the AppSourceCop. Learn more in AS0076.

Setting up AppSourceCop to validate the Obsolete Tag

The diagnostics for rule AS0073 are hidden by default, so you first have to use a ruleset to surface them.

For example, the following ruleset turns the diagnostic for rule AS0073 into an error.

{
    "name": "My custom ruleset",
    "rules": [
        {
            "id": "AS0073",
            "action": "Error",
            "justification": "Validating that obsolete tags are specified is important"
        }
    ]
}
{
    "al.ruleSetPath": "custom.ruleset.json"
}

Note

To fully validate obsolete properties and attributes, it is recommended to enable the rules AS0072, AS0073, AS0074, AS0075, and AS0076.

How to fix this diagnostic?

When the property Obsolete State is used to mark an object as Obsolete Pending or Obsolete Removed, you need to also specify the property Obsolete Tag.

When the attribute Obsolete is used, you need to specify the obsolete tag attribute parameter.

When the attribute RequiredPending is used, you need to specify the Tag parameter.

Code examples triggering the rule

Example 1 - Table marked as Obsolete Pending

table 50100 MyTable
{
    ObsoleteState = Pending;
    ObsoleteReason = 'This table has been deprecated for reason X. Use table Y instead.';

    fields
    {
        field(50100; MyField; Integer) { }
    }
}

Example 2 - Procedure marked as Obsolete

codeunit 50100 MyCodeunit
{
    [Obsolete('This procedure is being deprecated for reason X. Use procedure Y instead.')]
    procedure MyProcedure()
    begin
        // Business logic.
    end;
}

Example 3 - Default interface method marked as RequiredPending without tag

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

Code examples not triggering the rule

Example 1 - Table marked as Obsolete Pending

table 50100 MyTable
{
    ObsoleteState = Pending;
    ObsoleteReason = 'This table is being deprecated for reason X. Use table Y instead.';
    ObsoleteTag = 'This table is being deprecated with the newest build of the product.';

    fields
    {
        field(50100; MyField; Integer) { }
    }
}

Example 2 - Procedure marked as Obsolete

codeunit 50100 MyCodeunit
{
    [Obsolete('This procedure is being deprecated for reason X. Use procedure Y instead.', 'This table is being deprecated with the newest build of the product.')]
    procedure MyProcedure()
    begin
        // Business logic.
    end;
}

Example 3 - Default interface method marked as RequiredPending with tag

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

AppSourceCop Analyzer
Get Started with AL
Developing Extensions