microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

ALC.exe does not accept analyzer while AL Extension and devops pipeline do #6783

Closed PeterBizz closed 2 years ago

PeterBizz commented 3 years ago

I try to specify "MyAnalyzer" as analyzer in a call to alc.exe like this: $Cop = [MyAnalyzer].dll

alc.exe /analyzer:$Cop ........

This results in an warning: "The assembly C:\Program Files\GAC Business Solutions\Gac.Analyzers.AlCop\[MyAnalyzer].dll does not contain any analyzers"

while in vstudio code al workspace settings: "settings": { "al.enableCodeAnalysis": true, "al.codeAnalyzers": [ "[MyAnalyzer].dll" ],

work flawelessly

nndobrev commented 3 years ago

Hi @PeterBizz, I will try to investigate the issue due to the inconsistency in the behaviour of the VSC extension and the CLI compiler, but just to let you know that we don't have public documentation for supporting third party analyzers and hence we don't provide support about them. However, this doesn't mean we are not happy that the community is able to use our products in the best way to serve their needs. :)

MODUSCarstenScholling commented 3 years ago

Could it be an issue with the class declaration? It works for me with the current AL Language:

> .\alc.exe /project:C:\Dev\AL\ALCodeAnalysisTest /packagecachepath:C:\Dev\AL\ALCodeAnalysisTest\.alpackages /out:C:\Temp\codeanalysis.out.app /analyzer:C:\Dev\Csharp\MC.Dynamics.Bc.Al.LanguageServer\bin\Debug\netstandard2.0\MC.Dynamics.Bc.Al.CodeAnalysis.dll /analyzer:.\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll
Microsoft (R) AL Compiler version 8.1.8.999
Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'MODUS M365 ModusCop Test' containing '16' files at '11:24:44.597'.
[...]
C:\Dev\AL\ALCodeAnalysisTest\src\codeunit\CodeStyleTest.Codeunit.al(4,21): info MCP0016: Event Subscriber procedure name C6620_OnAfterCheckFromPurchaseCrMemoHeader does not follow the pattern On<EventSource><EventName><ElementName>. Suggested Identifier 'OnCopyDocumentMgtOnAfterCheckFromPurchaseCrMemoHeader'.
C:\Dev\AL\ALCodeAnalysisTest\src\codeunit\CommandTest.Codeunit.al(9,16): warning MCP0012: The Keyword 'confirm' must use proper casing 'Confirm'.
[...]

Compilation ended at '11:24:48.665'.

My declaration is this:

using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;

    [DiagnosticAnalyzer]
    public class Analyzer : DiagnosticAnalyzer
    {
[...]
    }
thloke commented 2 years ago

Closing as this is not a supported scenario and is out of scope for this repo.