- We have released the sources on GitHub: http://github.com/CodeContractsDotNet/CodeContracts
- Francesco's blog on CodeContracts has some answers to FAQs, tricks, documentation, news, etc., primarily for the static checker. The blog ishttp://blogs.msdn.com/b/francesco.
- The contract editor extensions now have a single VSIX package for all of the Visual Studio versions includign VS2015! See contracts as you write code in intellisense and when you look at framework method definitions.
There is no discusson page here on the Gallery.
- Read the blog (http://blogs.msdn.com/b/francesco) for answers to the most common questions on the Code Contracts static checker.
- Please use the Issues page at GitHub for all questions, bug reports, and especially compliments!
- Much more information, including videos and papers can be found on our website.
- Or you can just go directly to our user manual.
Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs.
The contracts take the form of pre-conditions, post-conditions, and object invariants. Contracts act as checked documentation of your external and internal APIs. The contracts are used to improve testing via runtime checking, enable static contract verification, and documentation generation. Code Contracts bring the advantages of design-by-contract programming to all .NET programming languages. We currently provide three tools:
- Runtime Checking. Our binary rewriter modifies a program by injecting the contracts, which are checked as part of program execution. Rewritten programs improve testability: each contract acts as an oracle, giving a test run a pass/fail indication. Automatic testing tools, such as Pex, take advantage of contracts to generate more meaningful unit tests by filtering out meaningless test arguments that don't satisfy the pre-conditions.
- Static Checking. Our static checker can decide if there are any contract violations without even running the program! It checks for implicit contracts, such as null dereferences and array bounds, as well as the explicit contracts.
- Documentation Generation. Our documentation generator augments existing XML doc files with contract information. There are also new style sheets that can be used withSandcastle so that the generated documentation pages have contract sections.
You must download and run the Code Contracts .msi file. It installs in any edition of Visual Studio other than the Express edition. It includes the static checker and the binary rewriter (for runtime checking). It also contains a stand-alone contract library (for use with .NET projects that target a runtime earlier than version 4), the contract assembly generator, a set of contract assemblies for the .NET Framework, and user documentation.