0

I used Code Contracts mechanism in my C# projects written via Visual Studio 2015 and I like it. I learned about this mechanism through the C# 6.0 in a nutshell book. But already in C# 7.0 in a nutshell book this info disappeared. This puts me on my guard...

I saw the question Does Visual Studio 2017 work with Code Contracts and its content doesn't inspire me with optimism... . But now I use Visual Studio 2019.

If I try to use Code Contracts in .Net Framework 4.8 and .Net Core 3.1 then I get the runtime-error (when I started my exe manually):

Process terminated. Precondition failed. An assembly (probably "ConsoleApp_CodeContractsCore") must be rewritten using the code contracts binary rewriter (CCRewrite) because it is calling Contract.Requires and the CONTRACTS_FULL symbol is defined. Remove any explicit definitions of the CONTRACTS_FULL symbol from your project and rebuild. CCRewrite can be downloaded from http://go.microsoft.com/fwlink/?LinkID=169180. \r\nAfter the rewriter is installed, it can be enabled in Visual Studio from the project's Properties page on the Code Contracts pane. Ensure that "Perform Runtime Contract Checking" is enabled, which will define CONTRACTS_FULL.

But I see Code Contracts for .NET hasn't version for Visual Studio 2019... Its source code has not been updated for several years.

Is Code Contracts mechanism already dead and hasn't future?

Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
  • Did you try to reach their [GitHub](https://github.com/microsoft/CodeContracts)? – Pavel Anikhouski Aug 05 '20 at 08:37
  • "How to use code contracts in .Net Core" might be a better title. Asking if something is dead may sounds too opinion-based. – Sinatr Aug 05 '20 at 08:38
  • @PavelAnikhouski This will not help resolve the issue in the long run. If the mechanism is not planned to be maintained and developed, then it would be more expedient for me to refuse to use it. – Andrey Bushman Aug 05 '20 at 08:41
  • I see [Contract](https://learn.microsoft.com/en-US/dotnet/api/system.diagnostics.contracts.contract) class is supported in .Net Core 3.1 and .Net Framework 4.8. – Sinatr Aug 05 '20 at 08:42
  • @Sinatr I have the same problem not only for .NET Core, but for .NET Framework 4.8 also. – Andrey Bushman Aug 05 '20 at 08:43
  • @Sinatr the error appears when I manually start my created exe-file. – Andrey Bushman Aug 05 '20 at 08:44
  • Nothing stops rapidly. Even dead and depricated technologies are still used and often supported for years. Don't panic. Try looking for topics with exact error you get. If you still need a help, then please, ask concise question with [mcve] instead of futile discussion about future of technology. – Sinatr Aug 05 '20 at 08:54

0 Answers0