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 ?
It is actually pretty straightforward:
c:\Users\[your user name]\.nuget\packages\[your package name]\[your package version]\analyzers\dotnet\cs\public override void Initialize(AnalysisContext context) {
if (!Debugger.IsAttached) {
Debugger.Launch();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With