Επεξεργασία

Κοινή χρήση μέσω


AppSourceCop Hidden AS0076

Obsolete Tag format.

Description

Obsolete Tag must have a specific format.

Remarks

The ObsoleteTag property and attribute parameter values are not validated by the AL compiler. However it is possible to setup the AppSourceCop to verify them using a Regex expression.

Setting up AppSourceCop to validate the Obsolete Tag

Enabling the rule using a ruleset

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

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

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

Note

In order to fully validate obsolete properties and attributes, we recommend enabling the rules AS0072, AS0073, AS0074, AS0075, and AS0076.

Setting up the AppSourceCop.json

By default, the rule will validate that the specified obsolete tags are following the pattern (\\d+)\\.(\\d+).

However, it is possible to specify a custom pattern as a regular expression using the obsoleteTagPattern property in the AppSourceCop.json. The property obsoleteTagPatternDescription can be used in order to provide a human readable version of the expected pattern. The pattern description is used when reporting diagnostics.

{
    "obsoleteTagPattern": "^[A-Z]{3}$",
    "obsoleteTagPatternDescription": "Three upper case letters"
}

How to fix this diagnostic?

In order to fix this diagnostic, make sure that your obsolete tags are matching the expected obsoleteTagPattern.

For instance, when using the default obsolete tag pattern, two diagnostics will be reported by rule AS0076 because the obsolete tag property and the obsolete tag attribute parameter values do not respect the format Major.Minor.

codeunit 50100 MyCodeunit
{
    ObsoleteState = Pending;
    ObsoleteReason = 'Use codeunit X instead.';
    ObsoleteTag = 'Next major';

    [Obsolete('Use function Y instead', 'Next spring')]
    procedure MyProcedure()
    begin
    end;
}

The code should be fixed a follows:

codeunit 50100 MyCodeunit
{
    ObsoleteState = Pending;
    ObsoleteReason = 'Use codeunit X instead.';
    ObsoleteTag = '17.0';

    [Obsolete('Use function Y instead', '17.0')]
    procedure MyProcedure()
    begin
    end;
}

Note

The version to specify when using the default obsolete tag pattern is validated by the rules AS0072 and AS0074.

AppSourceCop Analyzer
Get Started with AL
Developing Extensions