Skip to content
Alexander Fast edited this page Aug 30, 2016 · 11 revisions

StyleCop analyzes C# source code to enforce a set of style and consistency rules. It has many benefits.

  1. It can be checked automatically. With any other style, you have to be a "human style cop" every time you review a pull request. This is boring.
  2. With any other style, there is always a gray area that's discussed endlessly. This is boring. A line according to StyleCop is either good or bad, nothing else.
  3. Rules that we find are too rigid can be turned off, it's not an all or nothing deal.

To install:

Visual Studio

StyleCop appears to be included in Visual Studio 2015 Express by default. But in case you dont have it:

  1. In the menu bar click Tools and then Extensions and updates....
  2. Click Online.
  3. In the search box in the upper right type StyleCop.
  4. Select Visual StyleCop and click Download.

MonoDevelop

  1. In the menu bar click Tools (or MonoDevelop-Unity on MacOS) and then Add-in Manager.
  2. Click Gallery.
  3. In the search box in the upper right type StyleCop.
  4. Should be one hit, select it and click Install.

To Run

Visual Studio

  1. In the menu bar click Tools.
  2. Click Run StyleCop (Ctrl+Shift+Y).
  3. Errors are presented as compiler warnings.
  4. Run like this it scans the entire project.
  • You can also start it by right clicking a file in the solution explorer to run on just that file.

MonoDevelop

  1. In the menu bar click Tools.
  2. Click Run StyleCop.
  3. Errors are highlighted in your current file, if any.
  4. Errors are also presented as compiler warnings.
  5. Run like this it scans the entire project.
  • You can also start it by right clicking a file tab to run on just that file.