Description / Features
The plugin enables analysis of C# projects with SonarQube. It offers coding rules provided directly by the plugin, as well as integration with FxCop.
Note that multi-language .NET solutions (C# + VB.NET) can be analyzed with the SonarQube platform.
- Install the plugin through the Update Center or download it into the SONARQUBE_HOME/extensions/plugins directory
- Restart the SonarQube server
Additional installation steps
FxCop must be installed on the analysis machine in order to use the FxCop rules embedded in the plugin.
You may also want to install the Analysis bootstrapper for Visual Studio projects, which eases the configuration burden by reading your .sln and proj files to automatically set module-level configurations for you.
Running an Analysis
To use SonarQube Runner, you must create a sonar-project.properties file in the project root. Typically, this is the same directory that holds your .sln file, but in the case of a Team Foundation Server Build, for instance, where the binaries are extracted to a completely separate directory than the sources, sonar-project.properties would go into the directory that held both the solutions and binaries subdirectories.
If you are using the Analysis bootstrapper for Visual Studio projects, most of the project configuration is handled for you, but a minimal sonar-project.properties file is required. Without the bootstrapper, each module of a project must be manually configured in sonar-project.properties.
To display code coverage data:
- Prior to the SonarQube analysis, execute your unit tests and generate the NCover3 or OpenCover reports.
- Import these reports while running the SonarQube analysis by setting the
sonar.cs.ncover3.reportsPathsproperty to the path to the NCover3 reports (separated by commas if there are several reports) or the
sonar.cs.opencover.reportsPathsproperty to the path to the OpenCover reports. The path may be absolute or relative to the project base directory.
Extending Coding Rules
- Rules from JetBrains ReSharper can be added by installing the ReSharper plugin.
- New coding rules can be added using XPath. See the related documentation. To navigate the AST, download the SSLR CSharp Toolkit.
Carefully read Upgrade from the .NET Ecosystem.