Skip to content

LinterCop analyzer crashes (AD0001 MissingMethodException) when AL Language extension DevTools are newer than bundled ALCops.Analyzers #10

Description

@fvet

Follow-up on #8


Description

When using alcops-mcp with the AL Language VS Code extension installed, the analyze tool returns AD0001 because the bundled LinterCop analyzer throws at runtime:

System.MissingMethodException: Method not found:
'System.String Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.StringExtensions.QuoteIdentifierIfNeeded(System.String)'
   at ALCops.LinterCop.Analyzers.InternalProcedureNotReferenced.MethodSymbolAnalyzer.ReportUnchangedReferencePassedParameters(...)
   at ALCops.LinterCop.Analyzers.InternalProcedureNotReferenced.CheckApplicationObjects(...)

This appears to be a BC Development Tools version mismatch: the MCP server resolves DevTools from the AL Language extension (step 2 in BC Development Tools Resolution), but the bundled ALCops.Analyzers were compiled against an older DevTools build.

Other LinterCop rules that depend on the same analyzer (for example unused internal procedures) are silently skipped when this crash occurs.


Steps to reproduce

  1. Install AL Language VS Code extension (recent v17 build).

  2. Install the MCP server: dotnet tool install -g ALCops.Mcp (tested with 0.1.0-alpha.7).

  3. Configure Cursor / Claude with:

    {
      "mcpServers": {
        "alcops": {
          "command": "alcops-mcp"
        }
      }
    }
  4. Open a small AL project with code analysis enabled and at least one unused internal procedure (optional, to show missing LinterCop diagnostics).

  5. Call the MCP analyze tool with minSeverity: "Warning".


Actual behavior

  • AD0001 warning: LinterCop analyzer InternalProcedureNotReferenced throws MissingMethodException.

  • Only non-LinterCop warnings are returned reliably (for example CodeCop AA0228).

  • On MCP startup (stderr), DevTools resolve to the AL extension:

    BC DevTools: C:\Users\<user>\.vscode\extensions\ms-dynamics-smb.al-17.0.2273547\bin\Analyzers
    

Example diagnostic payload:

{
  "id": "AD0001",
  "message": "Analyzer 'ALCops.LinterCop.Analyzers.InternalProcedureNotReferenced' threw an exception of type 'System.MissingMethodException' ... QuoteIdentifierIfNeeded ...",
  "severity": "Warning",
  "copName": "Unknown",
  "hasCodeFix": false
}

Expected behavior

  • LinterCop analyzers run without crashing.
  • DevTools version used at runtime matches the version ALCops.Analyzers was built against, or the MCP server selects a compatible pair automatically.
  • Rules such as unused internal procedures are reported when applicable.

Environment

Component Version
OS Windows 10 (10.0.26200)
MCP client Cursor
alcops-mcp (ALCops.Mcp) 0.1.0-alpha.7
Bundled ALCops.LinterCop.dll 0.5.0
Bundled target (from ALCops.Mcp.deps.json) Microsoft.Dynamics.Nav.CodeAnalysis 17.0.33.55542
AL Language VS Code extension ms-dynamics-smb.al 17.0.2273547
Resolved Microsoft.Dynamics.Nav.CodeAnalysis.dll (from extension bin\Analyzers) 17.0.34.45391
BCDEVELOPMENTTOOLSPATH (not set)
~/.alcops/cache/devtools/ (empty before manual download)

NuGet DevTools versions confirmed on nuget.org:

  • 17.0.33.55542 — matches bundled ALCops.Analyzers dependency
  • 17.0.34.45391 — matches current AL Language extension

Root cause analysis

Per MCP Server — BC Development Tools Resolution, when BCDEVELOPMENTTOOLSPATH is unset and the AL Language extension is installed, the server always prefers the extension’s DevTools over the local cache or NuGet auto-download.

In this setup:

  1. ALCops.Analyzers 0.5.0 (shipped inside alcops-mcp) targets DevTools 17.0.33.55542.
  2. The AL Language extension supplies DevTools 17.0.34.45391.
  3. A breaking API change between those patch releases (StringExtensions.QuoteIdentifierIfNeeded) causes LinterCop to fail at runtime.

This matches the general “version mismatch between detection and compilation” guidance in the ALCops troubleshooting docs, applied to the MCP server’s DevTools resolution order.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions