Code Contracts for .NET

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.

(53) Review
Visual Studio
2013, 2012, 2010
Download (125,153)
1/6/2015
1.7.11202.10
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Reviews (53)
Sign in to write a review
Sort by:

by Valo | Fri 11:11 PM

Code Contracts is an excellent design and programming device but, as many already said, it is very frustrating that there are no signs for updating the tool for Visual Studio 2015. Can someone please break the silence and let us know what the plans are. We have existing projects relying on it - shall we rewrite our code? Please, someone say something.

by Adrian Moș | May 05 2015

This is a really good thing to have, and I was a fan of the entire idea of static analysis and especially the extreme advantages of having Code Contracts that you could actually manage constructively (such as keeping all the heaviest checks on a test version, while keeping only public surface ones for a stable environment, etc.)

However, the actual implementation has seriously lagged behind the actual tools. With the really cool features of the newest framework versions and also newest Visual Studios, the Code Contracts implementation just does not arrive fast enough for it to be a useable tool.

This coupled with strange issues and abysmal performance in some cases, makes it unusable in another context than just academic musing.

Also, one has to wonder whether this could not have actually been better done directly in the framework rather than through ccrewrite.

by Jeffrey Cutting | May 01 2015

My team recently adopted code contracts. It's a fantastic tool that's already helped to catch some validation we would have missed otherwise. There's a learning curve for some devs who can't easily adapt to the contract way of thinking, but it's absolutely worth the curve and the time to bring people up to speed.

There are some places I wish the contracts and rewriter worked a little differently, but overall I think it's fantastic.

I will add to the requests for a MUCH needed update for VS2015. I installed the RC yesterday hoping to move my team to it next week, but we're on hold because of the ccrefgen errors related to ReadCustomMetadata.

by José Joye | April 27 2015

Me too. This actually prevent us moving to VS2015....

by darkmaku | April 10 2015

good tool!!! but i wish code contracts for VS 2015 xd

by Roy Mayfield | March 29 2015

Guys, these extensions are appreciated more than you'll ever know. YOU are unsung heroes. This pattern will no doubt grow across all aspects in computing. You have allowed us to prevent* bugs at code-time, *before* unit testing...

EDIT: I think the underlying neat synergy here is that as developers code Contract statements, it makes them *think about states, contexts, and very likely discover possible but unhandled states*. That, by itself, is fantastic ;)

There is no silver bullet, but this, combined with TFS check-in rules... = ? I don't know man... ;)

I bet a nickle at least one office conflict will be prevented (rather than resolved) as a result of this. And that is almost as good as saving a life ;) Kudos guys.

Roy Mayfield
Enterprise Architect
roy.mayfield@modelingscientific.com

by Borchin | March 14 2015

by Yatajga | February 20 2015

by michael_volz | February 06 2015

Please, please, please make a version for Visual Studio 2015!

Not having Code Contracts when using Visual Studio 2015 is really awful!

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

by Ash-Ash | February 04 2015

Great tool. Please let us know when to expect a V2015 version.

by Matt Hickford | January 05 2015

Great but please update this for Visual Studio 2015 as soon you can.

by Igorbek | December 06 2014

There's a NuGet package of standalone version of CodeContracts for MSBuild (could be used for CI such as Azure Kudu) - http://www.nuget.org/packages/CodeContracts.MSBuild

by IT-Marky | November 15 2014

This is a great project but I'm affected by the installer issues, too - after all four or five installations since the first time I installed CodeContracts I had to clean up the

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\CodeContracts

directory. Uninstalled the old version first, then installed the new; like now there are two folders 1.7.10908.11 and 1.7.11106.10 of which I have to delete the former older one. Maybe you should explicitly delete the folder from within the MSI uninstall sequence. The files that get left behind and might not be authored for proper removal are:

codecontracts_project.png
codecontracts_SM.png
extension.vsixmanifest
license.rtf

It's a bit unnerving :-)

by Francesco Logozzo | November 15 2014

hmmm I saw the problems with installation on one of my machine too. Updating to VS2013 v4 solved the issue.

Not sure what it is causing it, on other machines everything went very well.


You can try the suggestion from Miha Markic below otherwise.

f

by Myauz | November 07 2014

Installer frequently breaks between versions. You'd think "Research in Software Engineering" could figure out how to build a working installer. It doesn't build a lot of confidence, really. Its benefits aren't worth my struggles in updating it or dealing with how it occasionally breaks VS.

by Charlie Holland | October 23 2014

Full of great promise. Unfortunately it doesn't deliver. Static code analysis does absolutely nothing in VS2013 and the documentation is so inconsistent with the UI that it's impossible to work out where the problem may lie.

by Rene Damm | October 03 2014

Same problem. VS2013 is completely unusable even after uninstalling Code Contracts again. All kinds of stock VS functionality (like the Solution Explorer) doesn't load anymore.

by Fabien Launay | September 24 2014

My VS2013 don't start after update with V 1.7.10908.11 and devenv /resetsettings don't works also.

by lostmsu | September 23 2014

Please, add support for VS 14

by NLundberg1 | September 22 2014

The upgrade problems from version 1.5 to 1.6 seam to exist when upgrading from 1.6.60617.15 to 1.7.10908.11 as well.

1 - 20 of 53 Items