Strategy for debugging C# analyzer

Viewed 25

I've created my own code analyzer

    [DiagnosticAnalyzer(LanguageNames.CSharp)]
    public class PluginAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer { ... }

During unit test pattern / error / I'm looking for is reported as it should. However when I plugin in the analyzer to real project the analysis its not getting executed - or at lest the error is not getting reported (I'm using file from this project in unit test).

E.G.:

realproject.csproj

 <PackageReference Include="MyAnalyzer" Version="1.0.0">
   <PrivateAssets>all</PrivateAssets>
   <IncludeAssets>analyzers</IncludeAssets>
 </PackageReference>

I can see the analyzer is getting executed (csc.exe /analyzer:..MyAnalyzer.dll) yet the error is not getting reported. Is there a way to debug the analyzer / analyze if it is getting triggered or why it is getting ignored ?

0 Answers
Related