How To Write Custom FxCop Rules

I love FxCop. What I like about it most is that you can write your own FxCop rules. That means that when you define a coding rule in your development standard you can write a custom FxCop rule for it and get FxCop to enforce the rule. Certainly this speeds up code reviews but it also relieves us all from the dull drudgery of wading through code for the silly little things and allows us to spend our time using our brains instead.

I've been writing custom FxCop rules for a number of years and although I'm a big fan the part where I get to writing the rules has traditionally been a lot of pain. The reason is that there wasn't any documentation for the SDK - you had to work it out yourself. I wrote Chapter 13 of .NET Internationalization explaining how to write custom rules but this was focused more on what it meant to the world of internationalization than all of the details of how to write rules. Well now the pain can go away for everyone. Everyone put their hands together for Jason Kresowaty. Jason took it upon himself to write the documentation for the FxCop SDK! Microsoft didn't ask him to do it, he just did it anyway. And it's very good (you can download it here). What's even better is he wrote Introspector (available for download at the same location). Introspector does for introspection of assemblies what Reflector does for reflection of assemblies. FxCop is based on Microsoft's introspection engine (FxCop hasn't used reflection for some years now) so an Introspection tool is a godsend (or a Jason-send in this case).

Thanks, Jason, this is a big deal.

(Alternatively, if you don't want to read the docs I gave a presentation on this at a VBUG Conference and you can download a video of this presentation here and the slides here).


Technorati Tags: FxCop, Jason Kresowaty, Introspector, Introspection

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: GuySmithFerrier
Posted on: Thursday, July 10, 2008 at 9:50 PM
Categories: Internationalization | Miscellaneous - Technical
Actions: E-mail | Kick it! | DZone it! |
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Related posts