Chapter 15. Letting your code speak more clearly with Code Contracts

This chapter covers

  • The objectives of Code Contracts
  • Writing contracts in your code
  • Binary rewriting
  • Static checking
  • Contract documentation
  • Applying contracts

This book is about C#, the language. I haven’t attempted to cover the whole of the .NET framework or even just the Base Class Library (BCL). Apart from when we were looking at different LINQ providers in chapter 12, I’ve been rigidly focused on explaining the features introduced in each version of C#. This chapter is somewhat different. It’s not about a new ability of the language itself, but a combination of tools and types (collectively called Code Contracts) that can radically change your code’s appearance and ...

Get C# in Depth, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.