Skip to main content

Automation of Coding Standards for .Net using StyleCop

While writing c# code, it is very difficult to ensure that every developer is following coding standards guideline. Forget the advanced level of coding standards even we have experienced that basic level of coding standards are not followed properly in the project. And the major reason behind this is the manual process of forcing team members to follow the coding standards some time developer minds it and taking negatively. It is better idea to force developer by machine rather than human to follow coding standards in their code. For this there are couple of tools which are used to automate the coding standards process such as 
  1.  StyleCop 
  2.  FxCop 
  3.  Code Analysis etc. 
All these tools have some good and bad thing with own. Here this document is going to contain all about StyleCop. 

StyleCop is a tool from Microsoft (an open Source Tool btw.) to analyse the Source Code. It works on C# source files directly rather than .DLLs.
StyleCop defined a set of rules and on the basis of these rules every c# file is evaluated to ensure that the code written in the file must follow the coding standards.

Installation of StyleCop 
  1. Download ReSharper (ReSharperSetup.8.2.0.2160) and install it before installing StyleCop. 
  2. Download StyleCop (StyleCop-4.7.49.0) and install it.
How to execute StyleCop from Visual Studio after installing it: 
After installed StyleCop to your machine, you can see it inside tool menu of the visual studio or right click window of the project as shown below:
To run StyleCop, you have to click on Run StyleCop or Run StyleCop (Rescan All) button.
Alternatively you can run StyleCop by right clicking on the c# file and Run StyleCop button. 
For details understanding and sample please follow my Github link.

Comments