Question

Altough I've known Code Contracts for some time, as I've used it a bit in Java, I would like to start using them in C#, now that they are part of C# 4.0.

I am looking on learning material, books or vids. Altough tutorials are also welcome, I'd like to have something comprehensive to read, not the typical "here's how you use Requires and here's how you use Ensures". I am looking for something that really stands out in this area.

Thanks

Was it helpful?

Solution

Jon Skeet has an entire chapter dedicated to them in the 2nd edition of C# in Depth. It's roughly 40 pages based on the last MEAP update. This isn't final since, as Joel mentioned, it's not out yet, but you could buy it and get access to the MEAP releases: http://www.manning.com/skeet2/

C# 4.0 in a Nutshell covers it in Ch. 13, "Diagnostics and Code Contracts." Based on the chapter headings in the table of contents I estimate ~17 pages on the topic.

I imagine Andrew Troelsen's Pro C# 2010 and the .NET 4 Platform book will cover it, but I wasn't able to find a TOC for it.

OTHER TIPS

I've heard Jon Skeet's covering them in the next C# in Depth, but it's not out yet.

Though not really a book, the official documentation downloadable with the Code Contracts software is pretty good.

For specific questions, you can use the official Code Contracts forum. The developers seem to be pretty responsive.

By the way: My understanding is that Code Contracts are not part of C# 4.0. Rather, they are part of the .NET 4.0 BCL and available as a separate assembly for .NET 3.5. Both .NET 4.0 and 3.5 requiere you to install additional software to use the contracts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top