I am looking to validate method parameters in my code, in the most elegant fashion possible. Code Contracts don't seem to work in 2015. Does anyone use any alternatives?
NET 4.0. Code Contracts API includes classes for static and runtime checks of code and allows you to define preconditions, postconditions, and invariants within a method.
Code contracts provide a way to specify preconditions, postconditions, and object invariants in . NET Framework code. Preconditions are requirements that must be met when entering a method or property.
Code Contracts provide a language-agnostic way to express coding assumptions in . NET programs. The contracts take the form of preconditions, postconditions, and object invariants. Contracts act as checked documentation of your external and internal APIs.
Code contract classes let you specify preconditions, postconditions, and object invariants in your code. Preconditions are requirements that must be met when entering a method or property. Postconditions describe expectations at the time the method or property code exits.
They're working on it: https://github.com/Microsoft/CodeContracts/pull/36
If you cannot wait, there are a few things that you can do to fix this: https://github.com/Microsoft/CodeContracts/issues/18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With