Code Contracts
Discuss and provide feedback on Code Contracts.
Announcements
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.Okay, Release 1.2.30118.5 is now ready for download.
Mike BarnettMSFTWednesday, January 13, 2010 11:42 PMA new release of Code Contracts is now live. So much for our once-a-month release schedule... We know it has been a long time, but we hope that this release will help make it up to you! Check out the release notes for the details. Besides the usual bucket o' bug fixes, we've added Silverlight 4 support.
Please keep using the forum for communicating with us. If you have any examples of bugs that you've found using Code Contracts or feel that it has saved you time, then we'd really love to hear about it.
Filtering and SortingUse these options to narrow down the question and discussion list.
- 0245

Release 1.2.30118.5 now ready for download
Manuel FahndrichMSFTWednesday, January 20, 2010 4:07 AM - 1656

Francesco Logozzo speaks about the Static Checker
PeliMSFTFriday, December 25, 2009 1:03 AM - 027

How to add ensures to a struct containing reference-type fields
Eric Zeitler - ebnf 13 hours 39 minutes ago - 032

Statich checker problem on object properties
Sgro 14 hours 15 minutes ago - 3138

missing contracts on System.Diagnostics.StackFrame.GetMethod in mscorlib
David K Allen Saturday, February 06, 2010 6:56 AM - 3117

Access Code Contracts through CCI
Martin W. Angler Thursday, February 04, 2010 11:01 AM - 2549

Static checker randomly checks multiple projects
Sgro Tuesday, July 21, 2009 12:07 PM - 294

Latest Contracts download causes VS2010 Beta 2 to fail loading projects
darrellp Friday, February 05, 2010 7:54 AM - 2348

Is the contract for stream.read incorrect?
John Melville Monday, November 23, 2009 5:14 AM - 163

Will 1.2.30118.5 work with the VS 2010 RC?
Mickey WilliamsMVPTuesday, February 09, 2010 4:25 AM - 7961

Invariants on interface properties?
Matthias Jauernig Monday, March 09, 2009 1:02 PM - 056

Precondition fail, should throw exception.
Tiago Veloso Monday, February 08, 2010 9:21 PM - 170

Link on Code Contracts site points to older documentation
David K Allen Saturday, February 06, 2010 8:21 PM - 197

Access programmatically a method's conditions?
Martin W. Angler Wednesday, February 03, 2010 9:32 AM - 042

Generic Type Argument Equality
Dave Sexton Monday, February 08, 2010 5:46 AM - 4141

Suppress Ensures warnings?
RobertMcCarter Friday, February 05, 2010 3:45 AM - 051

ContractPublicPropertyNameAttribute Accessibility Is Too Strict
Dave Sexton Monday, February 08, 2010 12:53 AM - 077

MSDN Documentation
Dave Sexton Sunday, February 07, 2010 1:55 PM - 091

Have any of you read the recent article "A Few Billion Lines of Code Later, Using Static Analysis to Find Bugs in the Real World"?
David K Allen Saturday, February 06, 2010 11:37 PM - 1292

Missing contracts on system types
Dluk Monday, December 28, 2009 12:02 PM

