Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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?

like image 825
Oleg Sh Avatar asked Mar 15 '19 01:03

Oleg Sh


People also ask

What is difference between .NET 5 and .NET 6?

NET 6.0 has more advantages than working with the . NET 5.0 as . NET 6.0 has more improvement on the performance which also includes some major advantage as it has intelligent code editing and also it is called the fastest full-stack web framework.

What are C# contracts?

Abstract: Code Contracts API includes classes for static and runtime checks of code and allows you to define preconditions, postconditions, and invariants within a method. The Contracts class is found in the System. Diagnostics namespace.


1 Answers

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).

like image 91
Jeffrey L Whitledge Avatar answered Oct 18 '22 21:10

Jeffrey L Whitledge