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?
-
8Code Contracts is an excellent design and programming device but, as many already said, it is very frustrating that there are no signs for updating the tool for Visual Studio 2015. Can someone please break the silence and let us know what the plans are. We have existing projects relying on it - shall we rewrite our code? Please, someone say something. – Valo May 22 '15 at 23:14
-
1Sadly the project seems to be suffering from little activity by its developers https://github.com/Microsoft/CodeContracts/issues/409 – Daniël Tulp Jul 18 '16 at 06:37
3 Answers
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

- 5,312
- 7
- 36
- 63
"The contract editor extensions now have a single VSIX package for all of the Visual Studio versions includign VS2015!"
https://visualstudiogallery.msdn.microsoft.com/1ec7db13-3363-46c9-851f-1ce455f66970

- 753
- 1
- 5
- 12
I have installed CodeContracts v.1.10.10126.2-rc1 and it is working (and stable) with Visual Studio 2015.
This version of CodeContracts is the first major community-driven release of the DotNet CodeContracts. This release addresses a lot of pending issues with installer, new IL patterns introduced by Roslyn Csc compiler, etc..
NuGet package is located here: https://www.nuget.org/packages/DotNet.Contracts/1.10.10126.4
Prior to this version of CodeContracts, I had to turn contract checking off so I could get my applications to run in VS2015.

- 3,223
- 3
- 28
- 40
-
What edition of Visual Studio are you using? I have just installed under Community and cannot see the CodeContracts tab to enable the feature. – Pieter Geerkens Apr 28 '16 at 09:27
-
1Figured it out; I had to install the Visual Studio Extension as well as the NuGet package. – Pieter Geerkens Apr 28 '16 at 12:20