Sunday, September 06, 2009

.Net Code Contracts + XML Comments = (as good as) peanut butter and chocolate?

Peli's Farm - Pex, Stubs, QuickGraph, MbUnit, Reflector Addins - Code Contracts.Net to Xml Comments!

“The new release of Code Contracts is out and brings a very cool feature: Xml comment generation. This means that you do not have to worry about keeping the comments in sync with the code, the compiler takes care of this.

Contracts to Xml Comments in action

Unless you invest a lot of work in them, Xml comments are most often worthless. …

However, the body of the constructor contains Contracts that state the pre-conditions and post-conditions of the constructor: source and target should not be null, etc… With the new xml comment generation, these contracts will be added to the xml documentation and ultimately will show up in the compiled documentation.

Finally, we run the documentation file through Sandcastle*** to get the final result..

image_18

…”

Now that’s pretty cool and very logical. It seems a prefect way to extend and enhance our generated doc’s.

.Net Code Contracts is something I’ve been lightly following on a low priority background thread, waiting for it to bake a little more. Seeing this, I think I’m going to have to increase the priority on that thread. (Yeah it’s a little thing, but little things add up to some pretty big things… ;)

No comments: