How to use StyleCop
StyleCop is an open source static code analysis tool from microsoft which is used to maintain coding standards for the c# code
Step1:Download style cop from this url
http://stylecop.codeplex.com/releases/view/
Step2 Install it in MSBuild Mode as show below
sample project to test style cop
Follow the slides initiallyNow run the project it won’t show any warning ,we have run style cop manually .
We can integrate this process to MSBuild by adding tag in ‘.csproj ‘ file.
To do that we have unload project first then open “csproj” file to include those tags.Edit csproj file
Copy the path of the file styleCop.Targets
Include that stylecop.Targets path in import tag in csproj file
Now save changes and reload the project. Now buid /run solution , you find warnings on fly as shown below
To show those warnings as errors add following tag to csproject file as shown below in the rounded codeSave and reload project . Now run/build project . you will see following screen
No comments:
Post a Comment