Dynamics 365 Business Central 2023 wave 1 (BC22) is generally available last week. More details: Dynamics 365 Business Central 2023 release wave 1 (BC22)
I will continue to test and share some new features that I hope will be helpful.
Business Central comes with a set of code analyzer rules, such as for PTEs and AppSource, and even enforces many for the latter when submitting apps. See Code analyzers for more.
Until now, each project or workspace would have to define their own rule sets in the ruleset file, making it hard to share, maintain (for example, when new rules are introduced), and prescribe a common rule set across apps. However, we are now adding the support to use URLs in the ruleset file, allowing maintenance of rule sets in a single, shared location.https://learn.microsoft.com/en-us/dynamics365/release-plan/2023wave1/smb/dynamics365-business-central/urls-includerulesets
As you might know, we can use static code analysis tool on an AL project from within Visual Studio Code.
To enable the code analysis, set the
al.enableCodeAnalysis in the settings file to
al.codeanalyzers setting, use Ctrl+Space to pick from the available code analyzers. Separate the list of code analyzers with commas.
PS: Business Central 2023 wave 1 (BC22) new features: Improved compiler resource handling and faster code analyzers
The AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code contains four analyzers:
- CodeCop is an analyzer that enforces the official AL Coding Guidelines. For more information about the CodeCop rules, see CodeCop Analyzer Rules.
- PerTenantExtensionCop is an analyzer that enforces rules that must be respected by extensions meant to be installed for individual tenants. For more information about the PerTenantExtensionCop rules, see PerTenantExtensionCop Analyzer Rules.
- AppSourceCop is an analyzer that enforces rules that must be respected by extensions meant to be published to Microsoft AppSource. For more information about the AppSourceCop rules, see AppSourceCop Analyzer Rules.
- UICop is an analyzer that enforces rules that must be respected by extensions that are meant to customize the web client. For more information about the UserInterfaceCop rules, see UICop Analyzer Rules.
In an AL project, you can use a custom ruleset file to specify how code analysis will report the issues it encounters. Different settings can affect how rules are applied and each ruleset file name must follow the pattern
<name>.ruleset.json to benefit from IntelliSense in Visual Studio Code. More details: Ruleset for the Code Analysis Tool
With this release, take advantage of new support for URLs in CodeCop rule sets to easily share, maintain, and enforce common rules. There are two ways to add rules via URLs.
1. Add URL to rules in settings.json
The settings file now contains two new properties to handle external ruleset files. You can point to an external location by using the
al.ruleSetPath property, and you can control whether the path is used through the new
Allows the use of urls as the location of project rulesets or included rulesets.
Sets the path to the file containing the customized rules to use when running code analysis. The path can be a filesystem path or a fully qualified remote url.
For example, I created a simple ruleset.json file on Github.
2. Add URL to rules in the ruleset file
You can also refer to external rule sets from the ruleset file, by adding the URL locations to the path property in the includedRuleSets, which until now only supported files.
List of external rule set files to include in the current rule set.
It is very convenient, only one file needs to be maintained in the future, and it can be shared quickly. Give it a try!!!😁
1. This feature can be used from the alc.exe command line tool as well by including the -enableexternalrulesets argument.
2. If you put the file on Github, please note that only raw data can be read.
An error occurred while loading the included rule set file Stream loaded ruleSet – Unexpected character encountered while parsing value: <. Path ”, line 0, position 0.
3. It seems that the file in Sharepoint or Onedrive cannot be read, even anyone with the link can edit.
An error occurred while loading the included rule set file ‘https://crmbc572567-my.sharepoint.com/personal/admin_crmbc572567_onmicrosoft_com/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fadmin%5Fcrmbc572567%5Fonmicrosoft%5Fcom%2FDocuments%2Fyzhums%2Eruleset%2Ejson&parent=%2Fpersonal%2Fadmin%5Fcrmbc572567%5Fonmicrosoft%5Fcom%2FDocuments&ga=1‘ – Response status code does not indicate success: 403 (Forbidden).
Hope this will help.
Thanks for reading.