Hello, I wrote a custom code analyzer and it runs on my solution code, but it also runs on generated code.
For example when AssemblyInfo.cs files get generated, my analyzer also analyzes these files and throws warnings inside of them. How can I tell my custom analyzer to not analyze generated code?
I know I could add something like this into my .editorconfig:
[*.{AssemblyAttributes.cs,AssemblyInfo.cs}]
generated_code = true
dotnet_diagnostic.***.severity = none
...
But is there a better way to do it?
You can do that using ConfigureGeneratedCodeAnalysis on the AnalysisContext (that is the parameter of the Initialize method):
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
Thank you, this is exactly what I needed!
Most helpful comment
You can do that using
ConfigureGeneratedCodeAnalysison theAnalysisContext(that is the parameter of theInitializemethod):