New Code Contracts Extension: See Contracts in Intellisense

This blog has moved, you should read this at my new place!

Code Contracts just got a whole lot better with a brand new extension for Visual Studio 2010!

This new extension brings a couple of cool new features that help you while developing with Code Contracts.

See contracts as you type

Just start typing a method with contracts, and they will be listed right beneath the description of the method.

The great thing about this is that it works for methods in the BCL as well as your own methods.

See inherited contracts

Contracts that are inherited show up above your methods. It’s a helpful visual reminder of the contracts that are defined on the interface or class you’re inheriting from.

This way you can easily add preconditions and postconditions without having to look back and forth to see which contracts are already defined.

And it doesn’t actually add text to your code file, it’s just an adornment which you can easily click away too.

See contracts for external assemblies

Another helpful addition is being able to see contracts of external assemblies. The contracts are visible in the metadata file you see when you ‘go to definition’ of a member of a class of which you don’t have the source.

This can also be disabled by a simple click of a button labeled “Hide all contracts” ( See, it’s all obvious ).


Before this extension, visibility of the contracts was one of my major concerns with Code Contracts. Not being able to see contracts as you type made you rely on the static checker to see what contracts were defined on your code. This extension is a great improvement and incentive to using Code Contracts. It’s only just released, but I’m loving it already!

Great! So how can you have a piece of this?

It’s easy!

  1. Install the latest version of Code Contracts
  2. Install the Code Contracts Editor Extension for Visual Studio 2010.
  3. Enable Code Contracts and choose ‘Build’ for ‘Contract Reference assembly’ in the Code Contracts properties pane.
  4. Build your code

And you’re ready to see your contracts showing up as you type! Have fun =)