0

We are using the Microsoft.CodeAnalysis.NetAnalyzer and StyleCop.Analyzer roslyn Analyzers in our solutions to check code quality. We've been asked to provide evidence that we run these analyzers to some stakeholders. Unfortunately, we only get a list of warnings/errors when there are issues, but nothing when everything is fine. I.e. I would need a list that shows all the inspections performed and that they passed.

Any ideas on how I could come up with such a report?

(I found that there is a possibility to create a file with the warnings/errors found, using an <ErrorLog> tag in the csproj. But here it's the same problem - I don't get a list of the checks performed in the successful case, only if problems are found.)

Efrain
  • 3,248
  • 4
  • 34
  • 61

1 Answers1

1

You can use <ReportAnalyzer>true</ReportAnalyzer> and compile using the /bl option to generate a binlog. The binlog contains the list of rules (and the execution time for each rule). Note that it doesn't show the severity of each rules. So, you need to also check all .editorconfig files and the csproj to get these information (you can search for AnalyzerConfigFiles in the binlog).

https://www.meziantou.net/understanding-the-impact-of-roslyn-analyzers-on-the-build-time.htm

meziantou
  • 20,589
  • 7
  • 64
  • 83
  • thanks for the idea - it works and I get confirmation that the analyzers ran, but it's quite hard to get the information out still in a structured format. I think I will probably end up just creating a hand-crafted report from the code analysis ruleset. – Efrain Jun 22 '21 at 07:59