Code Contracts
Discuss and provide feedback on Code Contracts.
Announcements
Release 1.2.21023.14 is now available!
Mike BarnettMSFTSaturday, October 24, 2009 9:07 PMA new release of Code Contracts is now live. And we almost made our once-a-month release schedule! This is mostly a release that fixes a lot of problems reported on the forum. Check out the release notes for the details.
Please keep using the forum to let us know how you're using Code Contracts and what problems you're running into. Of course, we'd be thrilled to hear of any success stories too.
And we'll be at PDC 2009! We'll be having a session along with Pex and also a demo booth. If you're going to PDC (and of course you should), please come by and see us.Welcome to Code Contracts for .NET
Mike BarnettMSFTFriday, February 20, 2009 2:28 AMWe are so happy that you are interested in Code Contracts! You are at exactly the right place for learning how to use contracts from any .NET language to:
- Specify method preconditions for expressing conditions that a caller must meet in order to call a method.
- Specify method postconditions for expressing conditions that the implementation of a method must meet before returning. Conditions can be specified for both normal termination as well as exceptional termination.
- Specify object invariants that describe the healthy states for an instance of a class.
We currently provide three tools for making use of contracts:
- A binary rewriter that operates as a post-build step to inject the contracts into the appropriate places for them to be evaluated at runtime.
- A static checker that operates as a post-build step to analyze your code without even executing it for potential contract violations.
- A documentation generator that adds information about the contracts to the XML documentation files for your project.
The installer for these tools is available for either commercial or non-commercial use.
We welcome you to use the forum to ask questions about how to use contracts and the tools, to make suggestions for how we can improve, and --- if you really must --- to report bugs and problems.
You can also check out our home page at Microsoft Research.
Filtering and SortingUse these options to narrow down the question and discussion list.
- 2215

CodeContracts XML docs not getting generated
Manuel FahndrichMSFTThursday, November 05, 2009 9:55 PM - 10461

Release 1.2.21023.14 is now available!
Mike BarnettMSFTSaturday, October 24, 2009 9:10 PM - 13363

Get started using contracts!
Mike BarnettMSFTFriday, February 20, 2009 2:37 AM - 03111

Frequently Asked Questions
Manuel FahndrichMSFTWednesday, February 25, 2009 6:33 AM - 150

False Positive: CodeContracts: Suggested precondition: Contract.Requires(!string.IsNullOrEmpty(value));
Jonathan Allen Saturday, November 21, 2009 7:53 AM - 173

Missing Requires in indexer of ReadOnlyCollection<T>
Alexey R. Wednesday, November 18, 2009 6:43 PM - 191

Can this be used with the Compact Framework?
Reis Sunday, November 15, 2009 7:28 PM - 147

Suggestion: Contract.Requires(bool condition, Func<string> messageGenerator)
xor88 Saturday, November 21, 2009 1:21 AM - 144

Contract Request by Usage - This method's contracts should be verifiably correct
Strilanc Friday, November 20, 2009 6:11 PM - 2194

Static checker fails to identify obvious problems
fcharlon Friday, November 13, 2009 12:47 PM - 154

More trouble with mixed-mode projects
Jahn Otto Næsgaard Andersen Thursday, November 19, 2009 3:15 PM - 050

Contract Requests - Net.IPEndPoint, Net.IPAddress, and a new postcondition for String.IndexOf
Strilanc Friday, November 20, 2009 3:41 AM - 4136

Rewrite failed to produce verifiable assembly
David K Allen Tuesday, November 17, 2009 5:04 AM - 3111

Setting Runtime Checking in VS 2010 Beta 2 Team
Kathleen DollardMVPTuesday, November 17, 2009 4:00 PM - 057

One more variation of Assert/Assume
Alexey R. Thursday, November 19, 2009 11:09 AM - 3228

Adding ensures causes other contracts to fail
Porges Sunday, November 08, 2009 4:35 AM - 1137

ContractsRuntime recursion guard optimization
Alexey R. Sunday, November 15, 2009 12:20 PM - 077

Default Display Hides Abort/Retry/Ignore Buttons
Kathleen DollardMVPTuesday, November 17, 2009 5:13 PM - 3156

Can't create projects in VS2010 Beta 2 after installing devlabs package
Richard BlewettMVPThursday, November 12, 2009 7:52 AM - 194

Contracts and Constructor Overloading
BrendanForster Monday, November 16, 2009 6:00 AM


