Reputation: 722
I use Code Contracts. I like Code Contracts. Code Contracts for C#, however, are far from perfect. Most of the issues related to them I have been able to maneuver around or soften with policies. Still... there are a few parts of it that make me cringe (for example, having to implement ContractClasses for abstractions).
The only real alternatives I found were an open source library that isn't any better than CC, and using regular guards (which may violate LSP).
Is there another better option that I have missed? I ask not out of desperation, but just for the sake of knowing all my options.
Upvotes: 4
Views: 1231
Reputation: 29213
I am not aware of any alternative options that you have at the moment.
However, there is a discussion on the Roslyn repository on GitHub about bringing language-level support for code contracts in C#. The issue has been deemed as being of some interest (though not strong interest) for inclusion in the feature set of C# 7.
Regarding the subject of LSP, there hasn't been any mention of it in that particular discussion. For example, there is no mention of the possibility of strengthening postconditions and weakening preconditions when specializing a virtual method.
Upvotes: 3