Study guide
15.4 AL Analyzers: CodeCop, AppSourceCop, UICop & PTECop
Microsoft Dynamics 365 Business Central Developer MB-820
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Business Central Architecture & Platform Foundation
1.1 Business Central Architecture & Extensions Model 1.2 Customization Lifecycle: Cloud (SaaS) vs. On-Premises 1.3 Base Application, System Application & AppSource
2 Chapter 2: Development Environment & Configuration
2.1: Development Environment Setup: VS Code, AL: Go! Projects & Sandboxes 2.2: AL Configuration Files: app.json & launch.json Parameters 2.3: Multi-Root Workspaces & Project Dependencies
3 Chapter 3: Extension Lifecycle: Debugging, Deployment, Multilanguage & Maintenance
3.1 Debugging & Snapshot Debugging in Visual Studio Code 3.2 Extension Deployment & Schema Synchronization Modes 3.3 Multilanguage Development with XLIFF & Translation Files 3.4 Extension Maintenance, Deprecation & Breaking Changes
4 Chapter 4: Tables, Table Extensions & Data Modeling
4.1: Building Tables, Fields, Keys & Data Types 4.2: Table Extensions & Table Modifications 4.3: FlowFields, FlowFilters & Table Relations 4.4: Enums, Enum Extensions & Extensible Types
5 Chapter 5: Pages, Page Extensions & Role Centers
5.1: Page Types, Anatomy & Control Structure 5.2: Building Card, List & Document Pages 5.3: Page Extensions & Page Customizations 5.4: Role Centers, Headlines & Cue Data Modeling
6 Chapter 6: Reports & Document Generation
6.1 Report Architecture, DataItems & Dataset Design 6.2 Report Layouts: RDLC, Word, Excel & Multilanguage 6.3 Document Reports & Request Page Programming 6.4 Processing-Only Reports & Report Substitutions
7 Chapter 7: XMLports & Data Exchange
7.1 XMLport Architecture, Formats & Properties 7.2 XMLport Node Hierarchy, Triggers & Stream Manipulation
8 Chapter 8: Codeunits, Events, Triggers & Interfaces
8.1 Codeunit Types, Execution & SingleInstance Codeunits 8.2 Events, Publishers, Subscribers & Event Isolation 8.3 Interfaces, Polymorphism & Dynamic Codeunit Invocation 8.4 Installation & Upgrade Codeunits, Data Transfer & Archive
9 Chapter 9: Entitlements, Permissions & Queries
9.1 Permission Sets & Permission Set Extensions 9.2 Inherent Permissions, Inherent Entitlements & Security Scoping 9.3 Query Objects: Joins, Aggregation & Query as Report Data Source
10 Chapter 10: UI Customization, User Assistance & Onboarding
10.1 Profile Objects & Custom Page Views in AL 10.2 User Assistance: ToolTips, Teaching Tips & In-App Tours 10.3 Assisted Setup, Guided Experience & Onboarding Checklists
11 Chapter 11: Business Central Design Patterns & Data Process Model
11.1 Functional Table Types: Master Data, Supplemental & Setup Patterns 11.2 Document Standards: Header, Line, History & Journal Architectures 11.3 Data Process Model & Posting Routine Architecture
12 Chapter 12: AL Language Fundamentals, Data Types & Variables
12.1 AL Syntax, Variable Scope, Primitive & Complex Data Types 12.2 Expressions, Control Flow Statements & Built-in Functions 12.3 Access Modifiers (Public, Internal, Local) & Code Scoping
13 Chapter 13: Data Manipulation, Streams & Error Handling
13.1 Record Operations: Get, FindSet, ModifyAll & Filter Functions 13.2 Streams, File Management & TempBlob 13.3 Error Handling: ErrorInfo, TryFunctions & Collectible Errors
14 Chapter 14: Testing, Test Toolkit & Automation
14.1 Testing Architecture & the Test Toolkit 14.2 Authoring Test Codeunits & UI Handler Functions
15 Chapter 15: Telemetry, Performance Optimization & Analyzers
15.1 Telemetry Configuration & Azure Application Insights 15.2 Custom Telemetry Signals with Session.LogMessage & KQL 15.3 Performance Profiler, SetLoadFields & Query Optimization 15.4 AL Analyzers: CodeCop, AppSourceCop, UICop & PTECop
16 Chapter 16: REST Web Services & JSON in AL
16.1 HttpClient, HttpRequestMessage & REST API Consumption 16.2 JSON Processing: JsonObject, JsonArray, JsonValue & JsonToken
17 Chapter 17: API Pages, OData, Read Scale-Out & OAuth
17.1 API Pages (PageType=API), OData Web Services & REST Endpoints 17.2 Bound and Unbound OData Actions with [ServiceEnabled] 17.3 Read Scale-Out Architecture & DataAccessIntent Configuration 17.4 Microsoft Entra ID App Registrations & OAuth 2.0 Integration
15.4 AL Analyzers: CodeCop, AppSourceCop, UICop & PTECop
Key Takeaways Explain This Topic AI
Business Central provides 4 official Roslyn-based static code analyzers: CodeCop (code quality), AppSourceCop (AppSource certification & breaking changes), UICop (Web Client UI standards), and PerTenantExtensionCop (tenant extension rules).
AppSourceCop enforces mandatory 3-to-4 character prefix/suffix rules (AS0011) and compares current code against a baseline package to prevent breaking schema changes (AS0001, AS0002).
UICop validates Web Client behaviour, including searchable pages and reports via UsageCategory and ApplicationArea (AW0006).
Analyzers are enabled in VS Code settings.json via al.enableCodeAnalysis and al.codeAnalyzers.
Developers manage and customize analyzer diagnostics using ruleset.json files, which can suppress specific warnings, elevate warnings to errors, or adjust rule severities.
Last updated: August 2026
15.4 AL Analyzers: CodeCop, AppSourceCop, UICop & PTECop
Static code analysis is an essential phase of the Business Central software development lifecycle. Built upon the .NET Roslyn compiler framework, AL static code analyzers continuously evaluate source code to enforce coding best practices, verify UI design guidelines, detect breaking schema changes, and ensure compliance with Microsoft AppSource marketplace certification requirements.
1. The Four Official AL Static Code Analyzers
Microsoft provides four specialized code analyzers bundled directly inside the AL Language extension for Visual Studio Code and the AL compiler ( alc.exe ). +-----------------------------------------------------------------------+
- | AL SOURCE CODE COMPILATION |
- | (.al Object Files) |
- +-----------------------------------┬-----------------------------------+
- │ (Roslyn Static Analysis Pipeline)
- ▼
- +-----------------------------------------------------------------------+
- | THE 4 OFFICIAL AL CODE ANALYZERS |
- | |
- | 1. CodeCop (${CodeCop}) |
- | - General AL code quality, syntax formatting, unused variables. |
- | |
- | 2. AppSourceCop (${AppSourceCop}) |
- | - AppSource certification, prefix/suffix, breaking changes. |
- | |
- | 3. UICop (${UICop}) |
- | - Web Client UI standards, mandatory ToolTips, Promoted Actions. |
- | |
- | 4. PerTenantExtensionCop (${PerTenantExtensionCop}) |
- | - Per-tenant safety, target on-prem blocks, schema validation. |
- +-----------------------------------┬-----------------------------------+
- │ (Filtered by ruleset.json)
- ▼
- +-----------------------------------------------------------------------+
- | COMPILER DIAGNOSTICS & BUILD GATES |
- | - VS Code Problems Panel (Real-Time Squiggles & Tooltips) |
- | - CI/CD Azure DevOps / GitHub Actions Automated Build Pipeline |
- | - Microsoft Partner Center AppSource Technical Ingestion Gate |
- +-----------------------------------------------------------------------+
- 1. CodeCop ( ${CodeCop} )
Primary Purpose: General AL code quality, styling conventions, and language best practices.
Key Diagnostics:
AA0005 : Only use BEGIN..END to enclose compound statements.
AA0008 : Flags function calls that omit required parentheses (e.g., Customer.FindSet instead of Customer.FindSet() ).
AA0137 : Flags declared local or global variables that are never used in code.
AA0205 : Variables must be initialized before usage.
- AA0207 : The EventSubscriber method must be local. (Variable shadowing is covered by AA0198 .)
- 2. AppSourceCop ( ${AppSourceCop} )
Primary Purpose: Enforces technical rules required for publishing solutions to Microsoft AppSource, maintaining public API stability, and preventing breaking schema changes.
Key Diagnostics:
AS0011 : An affix is required — enforces the registered 3-to-4 character prefix or suffix on object names, table fields, page actions, and enum values. ( AS0079 extends this to procedures on extension objects; AS0013 is a different rule — The field identifier must be within the allowed range .)
AS0001 : Tables and table extensions that have been published must not be deleted. (Pages are covered by AS0029 , table renames by AS0006 .)
AS0002 : Fields must not be deleted. (Length reductions are AS0080 ; length increases are AS0086 .)
AS0004 : Fields must not change type, since dependent extensions may break. (Primary-key field changes are AS0009 .)
AS0018 : A procedure belonging to the public API cannot be removed. (Signature changes are AS0024 ; return-type changes are AS0023 .)
3. UICop ( ${UICop} )
Primary Purpose: Validates user experience and user interface standards for the modern Business Central Web Client.
Key Diagnostics:
AW0005 : Actions should use the Image property. (Missing ToolTips are a CodeCop concern — AA0218 / AA0220 .)
AW0006 : Pages and reports should use the UsageCategory and ApplicationArea properties to be searchable.
AW0013 : Groups containing promoted actions should not be hidden. ( AW0014 does the same for groups containing actionref targets.)
AW0010 : A Repeater control used on a List page must be defined at the beginning of the area(Content) section.
4. PerTenantExtensionCop ( ${PerTenantExtensionCop} )
Primary Purpose: Validates extensions intended exclusively for deployment as Per-Tenant Extensions (PTE) in a specific customer tenant.
Key Diagnostics:
PTE0001 : Object ID must be in free range. (The "target": "OnPrem" restriction for SaaS is PTE0005 .)
PTE0002 : Field ID must be in free range.
PTE0004 : Table definitions must have a matching permission set.
Loading diagram... AL Static Code Analysis, Rule Enforcement & CI/CD Pipeline
2. Comprehensive Analyzer Comparison Matrix
Analyzer Name VS Code Identifier Primary Scope Mandatory For Key Enforced Rules
CodeCop ${CodeCop} Universal AL code health All AL Projects Unused variables ( AA0137 ), parentheses on parameterless calls ( AA0008 ), uninitialized variables ( AA0205 ).
AppSourceCop ${AppSourceCop} Marketplace certification & backward compatibility AppSource ISV Apps Registered prefix/suffix ( AS0011 ), breaking schema change prevention ( AS0001 , AS0002 ).
UICop ${UICop} Web client user experience AppSource Apps & High-Quality PTEs Action images ( AW0005 ), searchable pages/reports ( AW0006 ), hidden promoted-action groups ( AW0013 ).
PerTenantExtensionCop ${PerTenantExtensionCop} Single-tenant cloud safety Per-Tenant Extensions (PTE) Free-range object and field IDs ( PTE0001 , PTE0002 ), prohibits the OnPrem target ( PTE0005 ).
3. Enabling Analyzers in Visual Studio Code
Analyzers are enabled and configured in the project's .vscode/settings.json file. Developers can activate individual analyzers or run all four concurrently: {
- "al.enableCodeAnalysis": true,
- "al.codeAnalyzers": [
- "${CodeCop}",
- "${AppSourceCop}",
- "${UICop}",
- "${PerTenantExtensionCop}"
- ],
- "al.backgroundCodeAnalysis": "Project",
- "al.ruleSetPath": "./ruleset.json",
- "al.enableCodeActions": true
- }
- Baseline Package Configuration for AppSourceCop
To detect breaking changes between versions, AppSourceCop must compare the active workspace code against the previously published .app baseline package. This is configured in settings.json : {
- "al.assemblyProbingPaths": [
- "./.netpackages"
- ],
- "AppSourceCop.baselinePackage": "./baselines/Contoso.Logistics_23.0.0.0.app"
- }
4. Managing Rules with ruleset.json
Projects can customize analyzer diagnostic behaviors using a ruleset.json file. A ruleset allows teams to elevate specific warnings to fatal compilation errors, downgrade errors to informational notices, or suppress false positives. {
- "name": "Contoso Enterprise Ruleset",
- "description": "Enforces strict AppSource compliance while suppressing local casing warnings.",
- "includedRuleSets": [
- {
- "action": "Default",
- "path": "./company.ruleset.json"
- }
- ],
- "rules": [
- {
- "id": "AA0137",
- "action": "Error",
- "justification": "Unused variables must be treated as fatal compilation errors to maintain clean code."
- },
- {
- "id": "AA0218",
- "action": "Error",
- "justification": "All page fields and actions must have ToolTips for user onboarding."
- },
- {
- "id": "AA0072",
- "action": "Hidden",
- "justification": "Type-suffix naming is suppressed during the initial migration phase."
- },
- {
- "id": "AS0011",
- "action": "Error",
- "justification": "Strict enforcement of registered publisher prefix 'CONT_'."
- }
- ]
- }
- Supported Rule Actions
Error : Elevates the diagnostic to a fatal compilation error, blocking the .app build.
Warning : Emits a warning diagnostic in the VS Code Problems panel and build logs.
Info : Displays an informational tip in the IDE without failing strict warning-free builds.
Hidden : Diagnostic is calculated internally by the language server but hidden from the user interface.
None : Completely disables the analyzer rule calculation.