Tuesday, May 5, 2009

Style cop and helper utilities

One of the basic necessities when you are working on a project is that the style cop warnings in your code should be zero. If there is a single style cop warning in the code one can run into several issues like
1) I don't like it when there's a warning in the Visual Studio Compile log
2) I don't like it when my build log on the build server becomes several hundred kbs just because of style cop warnings and to find wh

For the records style cop is a visual studio plug in which ensures that the code is written in a consistent way i.e. tabs, indentation, regions etc. are defined very clearly in the code. It can even be integrated into msbuild so that the build points out the errors and warnings.It can be downloaded from msdn if you want it for your project.

Once you start working with Style Cop you'd find it difficult sometimes to take care of every warning on yourself. The trick is to do the hard work early on by fixing each and every warning manually and then slowly you'd become habitual of writing the style cop compliant code.

Here are a couple of utilities which can help in case the warnings are huge and there's a time constraint on delivering the code

1) NArrange :- Takes care of beautifying the code. It can be downloaded from here. Use it carefully for the existing files as it rearranges the whole file according to style cop rules and more. It clearly demarcates the regions for fields, methods etc. The catch is that if you already have a version of a file in your source control the tool will rearrange the code in such a way that diffing the file against the version in source control is not going to help much.

2) GhostDoc :- Its an intelligent documentation tool which generates the documentation for the methods based on parameters. It can be downloaded from here. Most of the time if you are using the proper naming conventions the documentation generated by this tool works pretty well. However some time you might want to review it. What's more it can even take your customizations done on a method in interface to the class automatically.

So use these cool utilities and write your code using style cop.
Happy coding....


No comments: