2

I am working on a large C# project which uses code contracts extensively and compiles against an older version of the .NET Framework (3.5). This project is a library, and I am also developing other applications which consume it as a dependency. I would like to use .NET Core 2.1 for these new projects. I believe my options are as follows:

  1. Upgrade the library from .NET Framework 3.5 to .NET Framework 4.6.1+, which I believe will make it compatible with .NET Standard 2.0 and thus usable by a .NET Core 2.1 project.
  2. Upgrade the library to build against .NET Standard 2.0 explicitly, using the new .NET Core toolchain.

I have the following questions:

  1. It looks like code contracts are dead and unsupported in .NET core; this means I will be unable to run the code contract analyzer if I go with Option (2), correct?
  2. If I go with Option (1), the analyzer can still run but I'll have to switch to Igor Beck's unofficial NuGet package per this answer to support .NET 4.6.1+, correct?

Ideally I'd like to keep the benefits of code contracts, although since they're unsupported I recognize this will continue to hold back the library version as time goes on.

ahelwer
  • 1,441
  • 13
  • 29
  • Assumption (option) #1 is wrong. .NET framework 4.6.1+ doesn't guarantee .NET Standard supportability. Question #1 is wrong. Code contracts are not "dead". They are just not available in .NET Core. Assumption #2 doesn't make sense since .NET Standard != .NET Core. Question #2 is moot since Assumption (option) #1 is wrong. – Sani Huttunen Aug 21 '18 at 22:42
  • Your only option is to change the target to .NET Core 2.1 and fix the issues that arrive. There is no middle ground or short cut. – Sani Huttunen Aug 21 '18 at 22:49
  • 1
    Oh yes, now I remember why I hate stackoverflow. Thank you for telling me assumption #1 is wrong! I am a bit confused as to how .NET Framework 4.6.1 and .NET Standard 2.0 are related with regard to what can import what. Code Contracts are unsupported by Microsoft, haven't seen an update to the core functionality in 2-3 years, and there is zero political will to add them to Core. They're dead. I know .NET Standard != .NET Core. Usually, when you compile with the .NET Core toolchain, you compile against .NET Standard. – ahelwer Aug 21 '18 at 22:49

0 Answers0