There is a freely available chapter about code contracts in the upcoming book C# in Depth, second edition. By some guy named Jon Skeet, some of you may be familiar with him :)
As for practical usage. You can use them anywhere in your code, but especially if you're developing framework / API type libraries that lots of people will be using, I expect them to come in quite handy. Static verification of your code saves a lot of time compared to finding out at runtime that you didn't handle some edge case.
You may document your method usage all you like, but will people actually read that documentation? Is it allowed to have string parameter x in method y be null, or not? Code contracts can provide that information, to take the guesswork out of the equation.
Here's an example of just such a case:
static int CountWhitespace(string text)
{
Contract.Requires<ArgumentNullException>(text != null, "text");
return text.Count(char.IsWhiteSpace);
}
The verification will complain if anyone tried to pass a string to CountWhitespace
that might be null. In addition, it will throw an ArgumentNullException at runtime.
I've only recently converted my private class library to .NET 4.0, but I plan to add code contracts to it real soon.