Search code examples
.net-corecode-contracts

.NET Core: Code Contracts approach is closed for now?


Some years ago was many information about Code Contracts. I did not have time to learn it and found this time only now :)

But when I try to use it, I see, that Visual Studio 2017 does not support it, CC tool is updated last time more than 3 years ago...

So, Code Contracts is closed for now?


Solution

  • Sadly, Code Contracts is no longer supported.

    The good news is that C#8 is going to include a new nullable reference types feature that will handle a large portion of the invariants and pre- and post-conditions for which Code Contracts was used. This will assist with detecting and avoiding possible null-reference exceptions.

    The bad news is that there is no built-in support for other types of contracts, and nothing like it has been announced for the future.

    Correctness guarantees will have to come from third-party tools, or another language will have to be used (e.g., Ada Spark).