2

I have set up a local SonarQube 5.1.1 server. I have also installed the C# plugin (version 4.1), as well as the MSBuild runner (version 1.0). I then performed two separate runs on the .NET codebase for the project I am currently working on:

  1. Using sonar-runner and the C# plugin
  2. Using the MSBuild runner

Both runs were made through the CLI. However, the runs yielded very different results. Here is an example: In the first run SonarQube calculated the number of code lines to be roughly 956 000, while in the second run it was calculated to be "only" about 434 000. I then did some digging, and it seems like the latter skips some auto-generated files. These files/classes were generated by an old, internally developed ORM tool.

I thought that unless specified otherwise - by using include/exclude patterns - the MSBuild SonarQube runner would analyse every single .cs file in a given project, but apparently that is not the case.

Has anyone experienced the same "problem", and does anyone know what kind of auto-generated files that will be automatically excluded from an analysis?

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
nils1k
  • 467
  • 5
  • 20

1 Answers1

2

I have found some information in the Sonar .NET documentation, which states, among other things, states that:

"Certain types of project will automatically be excluded from analysis. For example, Microsoft Fakes generates additional projects during build. These auto-generated projects will not be analysed."

and

"Files that are generated by custom tools within Visual Studio are automatically excluded from analysis, such as the xxx.Designer.cs file generated from a .resx file:"

I assume that our internal ORM tool falls into the latter category. Thus, that explains why those files are being excluded from the analysis.

nils1k
  • 467
  • 5
  • 20
  • 1
    And by the way, the goal is to go even further by automatically excluding source code annotated with [GeneratedCode], [CompilerGenerated], ... attributes : https://github.com/SonarSource/sonarlint-vs/issues/164 – Freddy - SonarSource Team Aug 25 '15 at 06:34
  • Excellent! Thanks a lot for the information, @Freddy - SonarSource Team. – nils1k Aug 25 '15 at 06:37