Description / Features
The plugin enables analysis of C# (all versions) with SonarQube. It offers coding rules provided directly by the plugin, as well as integration with FxCop / Code Analysis (version 10 at least).
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 / Code Analysis (version 10 at least) must be installed on the analysis machine in order to be able to enable its rules in the plugin.
Running an Analysis
The SonarQube Runner is recommended for analyzing .NET solutions.
To use SonarQube Runner, you must create a sonar-project.properties file in the folder containing the solution (*.sln) file.
To display code coverage data:
- Prior to the SonarQube analysis, generate the NCover3, OpenCover (at least version 4.5), dotCover (at least version 2.7) or Visual Studio (MSTest / VSTest) XML coverage reports.
- Import these reports while running the SonarQube analysis by setting the
sonar.cs.ncover3.reportsPathsproperty to the path of the NCover3 reports (separated by commas if there are several reports). Set the
sonar.cs.opencover.reportsPathsproperty for OpenCover reports,
sonar.cs.dotcover.reportsPathsfor dotCover HTML reports (JSON / XML not supported), and
sonar.cs.vscoveragexml.reportsPathsfor Visual Studio XML coverage reports. Paths may be absolute or relative to the solution directory.
Unit Test Results
To display unit test results data, set the
[test project name].sonar.cs.vstest.reportsPaths property to the path of the
*.trx Visual Studio Test Results reports (separated by commas if there are several reports).
Extending Coding Rules
- Rules from JetBrains ReSharper can be added by installing the ReSharper plugin.
- Custom FxCop rules are supported by the rule template "Template for custom FxCop rules" (CustomRuleTemplate).
- New coding rules can be added using XPath. See the related documentation. To navigate the AST, download the SSLR C# Toolkit.
Additional .NET plugins
Upgrading from version 2.1?
Carefully read Upgrade from the .NET ecosystem version 2.1.