4

In the .net framework there were Code Contracts which allowed me to specify pre/post conditons in my code. Are they supported in .net core/.net 5?

  • 1
    yes, if you click on `System.Diagnostics.Contracts` it is version net 5 https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts – daremachine Nov 24 '20 at 11:27
  • 1
    Great, thanks. If you can format this as an answer I will accept it – Andrew Malachov Nov 24 '20 at 11:35
  • 1
    hm, namespace is available but I found this interesting thread https://github.com/dotnet/runtime/issues/23869 – daremachine Nov 24 '20 at 11:45
  • Well that's a pity. So they keep the namespace but are missing a rewriter. And it is unclear if they will support it in the future. Thanks for the link! – Andrew Malachov Nov 24 '20 at 11:49

1 Answers1

4

Namespace System.Diagnostics.Contracts is available but project is abandoned.

Alternative VS2019
https://softwarerecs.stackexchange.com/questions/47108/the-best-code-contracts-alternative-for-vs-2017-2019-and-net-core-projects

Discussion about .Net Core

https://github.com/dotnet/runtime/issues/23869

Is Code Contracts still the recommended way to go in 2020

https://github.com/dotnet/docs/issues/17640

WeNeedAnswers
  • 4,620
  • 2
  • 32
  • 47
daremachine
  • 2,678
  • 2
  • 23
  • 34
  • 1
    It seems this link from the comment to stack exchange question is the most informative: https://github.com/dotnet/runtime/issues/23869#issuecomment-415670905 Seems like the project lead switched to Facebook and the project was abandoned. – Andrew Malachov Nov 24 '20 at 12:17