Code Contracts for .NET

Microsoft DevLabs Free

Code Contracts are static library methods used from any .NET program to specify the code’s behavior. Runtime checking and static checking tools are both provided for taking advantage of contracts.

(11) Review
Visual Studio
2012, 2010
Download (17,205)
5/2/2013
1.5.60502.11
E-mail Twitter del.icio.us Digg Facebook
Add To Favorites
Description
Reviews (11)
Sign in to Write a Review
Sort By:

by Kevin_Schilling | May 30 2013

by carbon twelve | April 14 2013

Absolutely excellent. I use code contracts extensively and they have added value in discovering bugs (by being "debug.assert" on steroids, and useful for static analysis), preventing bugs (by making it painless to provide brilliant documentation for you methods and types, so other devs easily know what a method/type supports and what it doesn't), and accelerating the resolution of bugs (with the rewriter turning contracts into assertions, you catch issues usually much closer to where the bug actually occurs, than where it actually starts causing damage -- like where an exception is thrown; also, so often we will know "okay, this bug is because this method doesn't handle the case where p=5 correctly. But we know must read around the code a bit because we've got no idea if this is a bug in the method and it /should/ handle p=5, or it's a bug in the caller which shouldn't ever /pass/ p=5 -- we never ask these questions with methods documented with code contracts).

by _Flynn_ | April 12 2013

Excellent tool! I wish more people would know about it.

by Sohnee | April 05 2013

I love this project. The fact that I can create contracts against an interface saves me code in multiple implementations as well as keeping changes to rules in a single place. This is the best kept secret of the .NET world - more people should use this.

by Xperiandri | March 30 2013

by Ioan Crisan | March 27 2013

I absolutely love it and warmly recommend it.

by RohitArora | February 28 2013

Nearly two years back I used it and then I think it was not in the list of extensions. That time I found it quite handy.

by Vaccanoll | February 22 2013

It would be nice to see a code example or a link to more information.

I don't really see how it works from the short writeup on the description page...

RiSE (Research in Software Engineering) February 22 2013
| Edit |
Delete

Sorry, we were in a hurry when we created this page. I've added a link to our website where you can find much more information. Let us know if you want to know more!

by Eyal Shilony | February 20 2013

Love it! :)

by Alexander Taeschner | February 20 2013

Very helpful tool chain.

by Dave Sexton | February 20 2013