Gendarme

Gendarme is a extensible rule-based tool to find problems in .NET applications and libraries. Gendarme inspects programs and libraries that contain code in ECMA CIL format (Mono and .NET) and looks for common problems with the code, problems that compiler do not typically check or have not historically checked.

Gendarme uses the Cecil library to introspect code.

Table of contents

Why ?

  1. Because we often repeat our mistakes. The biggest one being not to review things we know;
  2. Because it's a lot funnier (and safer) to write a rule than to review millions of source lines of code (SLOC) to ensure it's being followed.

History

Gendarme was originally created by Sebastien Pouliot to assist in the security auditing process in Mono. Aaron Tomb later integrated his .NET bug-finding code (supported by the 2005 Google Summer of Code, GSoC) into the same framework. Since then the number of contributors and rules has been growing.

Many Gendarme tasks have been realized in Google Summer Of Code (GSoC): three projects in 2007, one in 2008 - and in the Google Highly Open Participation (GHOP): 17 tasks providing 40 rules (2007/2008), renamed Google Code In (2010/2011) : 30 tasks providing 30 rules and a few tools/templates. If you are interested in such tasks please see the StudentProjects page.

Runners

Gendarme's rules are executed against user code by using a 'runner'. This is the application responsible to load the rules, user assemblies, analysis and finally reporting defects. Gendarme currently ships with two different runners.

Console

A console-based runner is available to use Gendarme, and the rules, on your own compiled assemblies. It is capable to output its results directly on the console, into XML files or into nice looking HTML reports.

This runner is the one that includes the most features. To see every options just type the following command in your terminal:

man gendarme

Wizard

A System.Windows.Forms-based GUI runner is also part of the Gendarme distribution. This is a step-by-step, wizard-based, runner that allows you to select assemblies, rules, options and report the analysis results just like the console runner does (i.e. text, xml or html reports). However it has fewer options (to remain simple) than the console runner.

CruiseControl.NET

Daniel Nauck (dna on IRC) contributed Gendarme support for CC.NET. You can find the documentation here. Note: The Gendarme task is available since CC.NET version 1.4.3.

NAnt

NĂ©stor Salceda, a long time Gendarme contributor, has released a first preview version of a NAnt task-based runner. A screencast showing it in action is available. The preview can be downloaded from Gendarme's Google Group files section.

Daniel Nauck (dna) also created a NAnt task for Gendarme. Unlike the previous one this is not a runner itself but calls the console runner, which reduce the build dependencies.

Rules

Gendarme is modular and load all of it's rules from assemblies, i.e. there are no hard-coded, static, rules.

For the console runner the list of assemblies to load rules from is defined in the rules.xml configuration file and can be adapted to different needs (e.g. project specific rules). The wizard runner will display all rules from every assemblies present in it's installation directory.

Current rules are divided into the following categories/assemblies:

Download

Linux

  • Gendarme is part of mono-tools and is available on most recent Linux distributions
  • Packages for many distributions and, from time to time, preview versions are also available from the openSUSE Build Service

Windows

  • Win32 installers (msi) are available on github web site. The .NET framework version 3.5 (or later) needs to be installed prior to running the setup.

Binaries only (multi-platform)

  • ZIP files that contains Gendarme's binaries and configuration files are also available on the github web site. They requires Mono 2.8 or the .NET framework 3.5 to be installed to execute properly.

Source Code

Other Cool Stuff

Resources

Getting Help

  • A list of frequently asked questions can be found in Gendarme.FAQ.
  • You can find some basic answers about developing rules, or hacking on Gendarme itself, in the FAQ.
  • You are welcome to participate in Gendarme's discussions on it's Google Group. This group is used for both users and developers of Gendarme.
  • Gendarme's fans are also present on IRC (#gendarme on GIMPnet).

Feedback

Please report any documentation errors, typos or suggestions to the Gendarme Google Group. Thanks!