Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »


C# Plugins Ecosystem


Alexandre Victoor (Twitter), Fabrice Bellingard (SonarSource)


Latest Version

Not released yet

Requires Sonar

2.9 or higher





Not released yet

The C# plugins ecosystem is a set of Sonar plugins used to monitor the quality of .NET software written in the C# language.

The goal is to make C# a first-class citizen in Sonar - like Java can be. For that purpose, the ecosystem consists of the following plugins:

  • C# Core : the core plugin that defines API used by every other plugin in the ecosystem
  • C# Squid : the plugin that parses C# code source, computes metrics and detects copy-paste (distributed by SonarSource as a freeware)
  • C# FxCop : the plugin launches FxCop analyses to detect violations relating to potential bugs, tight coupling, globalization, ...
  • C# StyleCop : the plugin launches StyleCop analyses to detect violations primarily relating to coding style (formatting, comments, ...)
  • C# Gendarme : the plugin launches Gendarme analyses to detect violations primarily relating to coding bad practices, smell detection, performance, ...
  • C# Gallio : the plugin launches Gallio to run tests and gets execution report as well as coverage report (using PartCover or NCover)

Below are the links to download and install the analysis tools used by the plugins:

You can check the Maven .Net build plugin page to know which versions of every external tool are supported. Just for information, the plugins have been developed and tested using the following versions of those tools: FxCop 10.0, StyleCop 4.4 and Gendarme 2.10.

Installation & global settings

You need to install at least the C# Core plugin to be able to use the other plugins. You may proceed either by downloading the JARs and copying them into the "/extensions/plugins" folder of Sonar, or more simply by using the Update Center in Sonar admin console.

After installing the JARs, and depending on which plugins you selected, you will have to log into Sonar "System Settings" web page and set up the following properties for each plugin:

  • C# Core: ".NET SDK Directory"
  • C# FxCop: "FxCop executable"
  • C# StyleCop: "StyleCop install directory"
  • C# Gendarme: "Gendarme executable"


Project configuration file

Note for Sonar newbies


In order to allow Sonar to analyse your C# code base, you need to write a configuration file that gives Sonar information about your project. This configuration file may be of different type, depending on which runner you will use to launch the analysis.

Here are 2 examples of project configuration files with minimal settings (we assume here that Sonar is run in its standalone mode):

"" file for the simple Java runner

"pom.xml" file for Maven

With such configuration files, you will be able to analyse a C# project that has a SLN file located in the same directory (the file will be automatically discovered).


If the SLN file is elsewhere, then you can add the "sonar.dotnet.visualstudio.solution.file" properties to specify its relative path.


For each plugin, various other properties can be set on the configuration file. You can find them in Sonar "System Settings" web page. (they will be described here as soon as possible)

Launch a Sonar analysis

Once you wrote a configuration file for your project, then you can launch a Sonar analysis by running the following command in the configuration file folder:

Once the process is over, you will be able to browse the results in Sonar Web UI.


Warning: some tools (like FxCop) require that the C# code has been compiled first.

  • No labels