AppSourceCop Analyzer Rules

AppSourceCop is an analyzer that enforces rules that must be respected by extensions meant to be published to Microsoft AppSource.

Rules

Id Title Description MessageFormat Category Default Severity IsEnabledbyDefault
AS0001 Tables cannot be deleted. Tables cannot be deleted. Table '{0}' has been deleted. Upgrade Error true
AS0002 Fields cannot be deleted. Fields cannot be deleted. Field '{0}' has been deleted from table '{1}'. Upgrade Error true
AS0003 The previous version was not found. The previous version was not found. The previous version was not found. Name='{0}', Publisher='{1}', Version'{2}'. Upgrade Warning true
AS0004 Fields cannot change type. Fields cannot change type. Field '{0}' has changed type from '{1}' to '{2}'. Type changes are not allowed. Upgrade Error true
AS0005 Fields cannot change name. Fields cannot change name. Field '{0}' has changed name to '{1}'. Name changes are not allowed. Upgrade Error true
AS0006 Tables cannot change name. Tables cannot change name. Table '{0}' has changed name to '{1}'. Name changes are not allowed. Upgrade Error true
AS0007 Properties cannot change value. Properties cannot change value. The property '{0}' has changed value. Value change is not allowed for this property. Upgrade Error true
AS0008 Keys cannot change name. Keys cannot change name. Key '{0}' has changed name to '{1}'. Name changes are not allowed. Upgrade Error true
AS0009 Key fields cannot be changed. Key fields cannot be changed. Key '{0}' has changed the key fields. Changes to the field list are not allowed. Upgrade Error true
AS0010 Keys cannot be deleted. Keys cannot be deleted. Key '{0}' has been deleted. Key deletions is not allowed. Upgrade Error true
AS0011 A prefix is required. A prefix is required. The identifier '{0}' must have the prefix '{1}'. Extensibility Error true
AS0012 A suffix is required. A suffix is required. The identifier '{0}' must have the suffix '{1}'. Extensibility Error true
AS0013 The field identifier must be within the allowed range. The field identifier must be within the allowed range. The field identifier '{0}' is not valid. It must be within the allowed range '{1}' - '{2}'. Extensibility Error true
AS0014 The project manifest must contain the allocated identifier range. The project manifest must contain the allocated identifier range. The project manifest must contain the allocated identifier range. Extensibility Error true
AS0015 Please enable the TranslationFile feature in the app.json file for your project. Please enable the TranslationFile feature in the app.json file for your project. Please enable the TranslationFile feature in the app.json file for your project. Extensibility Error true
AS0016 Fields of field class 'Normal' must use the DataClassification property and its value should be different from ToBeClassified. Fields of field class 'Normal' must use the DataClassification property and its value must be different from ToBeClassified. FlowFields and FlowFilter fields are automatically set to the SystemMetadata data classification. Field with name '{0}' must use the DataClassification property and its value should be different from ToBeClassified. Extensibility Error true

Note

Several rules enforced by the AppSourceCop analyzer are incompatible with rules enforced by the PerTenantExtensionCop. Make sure to enable only one of these at a time.

Configuration

The AppSourceCop analyzer can be further configured by adding a file named AppSourceCop.json in the project's root folder. The AL Language extension will offer intellisense for this file.

The following table describes the settings in the AppSourceCop.json file:

Setting Mandatory Value
name No The name of a previous version of this package with which you want to compare the current package for breaking changes.
publisher No The publisher of a previous version of this package with which you want to compare the current package for breaking changes.
version Yes The version of a previous version of this package with which you want to compare the current package for breaking changes.
mandatoryPrefix No Prefix that must be prepended to the name of all new application objects, extension objects, and fields
mandatorySuffix No Suffix that must be appended to the name of all new application objects, extension objects, and fields.

The name, publisher, version properties are used for specifying a previous version of the current package. AppSourceCop will use this information to download the specified package from the server and compare the current package with it. AppSourceCop will report any breaking changes introduced by the current package.

The mandatoryPrefix and mandatorySuffix properties specify strings that must be prepended/appended to the names of all new objects, extension objects and fields. By using these affixes, you can prevent clashes between objects added by your extension and objects added by other extensions.

Example

In the following example, we will configure AppSourceCop to validate that all new elements have a name that starts with a specified prefix.

NOTE Make sure code analysis is enabled and ${AppSourceCop} is in the list of enabled code analyzers.

We start by creating the default "Hello world" extension.

pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    begin
        begin
            Message('App published: Hello world');
        end;
    end;
}

We continue by adding the configuration file AppSourceCop.json in the project's root folder and setting its content to the following.

{
    "mandatoryPrefix": "Pre"
}

You are immediately greeted by the following error message:

AS0011: The identifier 'CustomerListExt' must have the prefix 'Pre'.

Prepending Pre to the name of the page extension object will fix this error and prevent clashes between this page extension and page extensions added by other developers.

See Also

Using the Code Analysis Tool
Ruleset for the Code Analysis Tool
Using the Code Analysis Tools with the Ruleset