My Little Coding Standards Adventure Begins…
I have been invited for a couple of weeks to do some coding standards work in a rather large IT department.
Basically the job is to evaluate their coding standards document and make sure it is enforced. Since coding standards documents are usually dropped on your table by your manager in your first day of work and they usually remain untouched, we have to come up with a solution that will actually force people to comply to these standards.
So I did some reading on FxCop and found this great video by Guy Smith-Ferrier that really brought me up to speed on writing custom FxCop rules in an hour. Writing these rules is a real pain and I’ll have to do my best to use existing rules and avoid creating new ones.
The only problem with using FxCop in order to apply these standards is that it will analyze entire assemblies and will produce a lot of warnings, as this IT department has dozens of large existing & legacy projects.
My challenge will be to make FxCop run without shouting too much on legacy code. I will continue to update as things progress.
You might want to look into the book Debugging Microsoft .NET 2.0 Applications by John Robbins from Wintellect. He has some nice FX cop rules about enforcing good coding practices.
1.) Each method needs to have an XML doc
2.)Each exception thrown by the method must be documented.
You can download his MSI from wintellect and look into his FXcop rules.
Cheers Adam
Ps keep up the good work with regionerate.
At a Microsoft presentation, one of the MS people talked about static code analysis (the Team VS version of FxCop). One comment he made was that future simplification of custom rules may break existing implementations. In other words, backwards compatibility is not guaranteed for custom rules. There is already a beta out of the new FxCop; you may want to test your rules with that.