Search code examples
c#stylecoproslyn-code-analysis

How to report StylecopAnalyzers to LogFileXML


I configured my csharp projects as below blog post to be enabled CodeAnalyzers and StylecopAnalyzers.

http://anthonygiretti.com/2018/01/24/code-quality-using-codeanalysis-fxcopanalyzers-and-stylecop-in-net-core-2-applications/

I ran msbuild on commandlines.(assumption of CI) Then I got its report as a xml file in output directory. In the file, I couldn't find any stylecop errors out, though could some codeanalysis's ones out.

How do I configure my projects to get stylecop errors in the report xml?


Solution

  • I found out the comment below described by sharwell who is one of developers of StyleCopAnalyzers. It says that it is their policy not to support report generation function.

    https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1178

    I'm planning to close this as outside the scope of this project. I don't believe this tool is as necessary for this project as it was for StyleCop classic for the following reasons:

    • Analyzers are directly integrated into MSBuild. You can't build the project and not have the warnings reported for enabled rules. StyleCop classic used a separate pass from compilation. The project build output already functions as the report.
    • Most of the diagnostics now have code fixes that support fixing all violations of style rules in one operation. It's much less likely for fixes to these rules to be delayed (and thus need a report) because the rules are almost trivial to follow in the first place.