StyleCop – How it can help Enterprise Software Development

This Article will describe what  StyleCop is and how it can be useful for enterprise development teams.

StyleCop is a style analysis tool that works at the source code level. It exists primarily to provide a single common style that managed projects can use to remain consistent within the larger world of managed software and help to avoid confusion about styling at code level for e.g. space after braces etc . There are custom rules for StyleCop which are not always practical in real world scenario ,so StyleCop provides SDK for developers to develop their own styles which suites their development environment and needs.

StyleCop support C# 4.0 syntax and also provides integration into VS 2010. StyleCop could also be used to investigate issues in non-compiled languages such  as JavaScript or Xml.

Installing StyleCop for MsBuild

Make sure MsBuild Integration is selected

StyleCop will be installed under C:\Program Files (x86)\MSBuild\StyleCop

Once StyleCop is installed , no desktop or other shortcut will be seen. To use StyleCop in Visual Studio – Developer need to open C# project  and open class file  and then right click  anwhere on code screen and they will see option  StyleCop which is marked in circle in the following screen and when option is clicked all the warnings will appear in the errorlist screen.

Other way to use StyleCop for  entire project is – right click project select run  StyleCop

How to Manage Settings of StyleCop

Right Click Project Name and click StyleCop Settings…

This brings up the Settings of StyleCop for that project

Make any necessary adjustments to the settings for a project,  then hit OK. This will produce a new file called Settings.SourceAnalysis,  located in the same folder on disk as the project file. This settings file  should be checked into your source control system so that it will be available  to all developers within your organization.

In next article I will discuss how to use StyleCop with MsBuild .