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.

(34) Review
Visual Studio
2013, 2012, 2010
Download (81,728)
6/19/2014
1.6.60617.15
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Reviews (34)
Sign in to write a review
Sort by:

by Miha Markic | August 19 2014

As some others reported, great concept but I am stuck with 1.5 on VS2013 as well. Duh.
Update: as suggested before, deleting C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\CodeContracts and reinstallation did the trick.

by Doug Stichler | July 30 2014

Anywhere to get the older versions?

by Тridy | July 28 2014

I decided to give it another try after last used in VS2010.
I tried to create a small 4.5.1 solution in VS2013 with a library and a console project. With Code Contracts it takes at least 3 times longer time to build and analyze.

BTW, I believe it was supposed to be part of 4.0. Why is it still a separate downloadable tool?

by Christiaan Rakowski | July 22 2014

by John Crim - PD | July 18 2014

Love the idea, and the implementation works pretty well - we've standardized on code contracts and have used it for several years.

However the impact on build times is truly painful - and it isn't getting any better. .NET build times are delightful and very productive (compared to Java and C++), until you add Code Contracts to your projects.

by Winged Cat Software | July 10 2014

While it takes some serious investment in your code to get value from code contracts, once you do so you'll never want to go back!

by zyrconium | May 28 2014

Uninstalled 1.5 from Add/Remove Programs. Deleted Code Contracts folder from Visual Studio Extensions folder. But it still shows as installed in Visual Studio. Tried to search in registry. No luck. Where else can I look?

by Jiří Zídek | May 26 2014

Failed to upgrade from 1.5 to 1.6 - installation passes, but VS2013U2 RTM sees still V1.5 and notifies me about update, loop closes here. Unistalling 1.5 is always gray (running VS as admin or not)...
Generally without stable Editor Extensions usability is crippled.

Unfortunately cant get rid of 1.5.60911.10 in Tools/Extensions/Installed/All; in Add/Remove it does not exists and folder suggested is deleted. Still appears in VS and still wishes to upgrade in Notifications....

by Espen- | May 25 2014

Jiří Zídek:
Uninstall from Add/Remove programs
Delete folder "CodeContracts"
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\CodeContracts

Install again. Enjoy :)

by stupidservice | April 03 2014

Build performance degradation kills all the good things in this solution.

by Viacheslav - Ivanov | March 14 2014

Need a new releases!

by Francesco Logozzo | February 13 2014

Hi, CC should work with VS2013 without any problem.
Try to uninstall and reinstall?
Francesco

by FiLCoN | January 21 2014

Not working in VS 2013

by GardenMusic | December 12 2013

It's Dec. 12, 2013. I have VS 2008 with Framework 3.5.

I'd like to use Code Contracts so I'm trying to install the dll that is meant for 2010/4.0 that EVERWHERE I read it says it will work with VS 2008. BUT, the only download I can find is this .VSIX file and VS 2008 will not open it, nor can I find anything that will.

All links I find lead back to this page. So I'm about to give up on using Code Contracts with VS2008 and go back to Debug.Assert. I'd sure appreciate a way to avoid that!!!

Thanks,

dlk

by Aleksandr Vishnyakov | November 27 2013

Great tools! When will be released version with Visual Studio 2013 RTM full support?

by Lennox22 | November 22 2013

I previously used Code Contracts back in 2010 and 2011 (with Pex). Worked well. Good concept especially linked with Pex (aka Digger). After upgrading to VS2013, I tried to use Code Contracts on a new project, however after installing, it completely crashes VS2013 Premium - everything is broken, all docked windows are showing exception messages. Extensions are failing to load. Eventually VS "stops" according to Windows. The solution is to repair the VS2013 installation. I will not install this again - especially since PEX is not supported in VS2013.

by John Crim | November 04 2013

Great concept, decent implementation. It's good enough that I've chosen to standardize my dev team on it; and I haven't seen anything comparable in any other programming environment. The concept is definitely 5 stars, but the implementation is 3 stars IMO:

It does have a few bugs I've had to work around, it isn't open-sourced, and it significantly slows down build time (by 10x or more), even with static analysis disabled. The build time is a drag in productivity - C# normally builds so blazingly fast, that dev/test/fix cycles are fast and uninterrupted. But with CC enabled, builds are slow enough that you look for something else to do for a few seconds.

I've found the static analysis to not be worthwhile - it might be worthwhile for new projects starting from the ground up, but it takes a lot of extra work to satisfy in my experience.

But the ability to concisely specify a contract, and leverage it across libraries and documentation is definitely worthwhile.

by Markus.Hanke | October 22 2013

After a while, one is wondering, how one could write projects without this tool.

(pl. add a link to the release notes here, where the download is)

by Kevin_Schilling | September 08 2013

by Vrane | September 05 2013

Code Contracts doesn't work with Resharper :( Any plans for supporting R#?

1 - 20 of 34 Items