views:

129

answers:

1

I want to jump into coding by contract. I got VS2010 (with the C# 4.0 compiler) but I have to target the 3.5 framework.

What 3rd party code by contract library has classes and interface the most like the .NET 4.0 ones?

+7  A: 

From the user guide:

Starting with the CLR v4, the Contract class and related types reside in mscorlib.dll. Prior to CLR v4, these types appear in a separate assembly called Microsoft .Contracts. dll that is installed under %PROGRAMFILES%/Microsoft/Contracts/PublicAssemblies. You can need to add a reference to this assembly if you are compiling against a pre 4.0 CLR.

You may have some interesting issues if you want to use the same built assembly against both 3.5 and 4.0 (I don't know - it may just work) but if you're just using 3.5, that should be okay.

The extension installs into VS2008 as well as VS2010, I believe.

Jon Skeet
You can build the same assembly against multiple CLR versions? Actually... why would you want to?
R. Bemrose
@R. Bemrose: If you have some applications running against .NET 3.5 and some against .NET 4.0, you may well only want to build once... if it works.
Jon Skeet
@Jon: I believe the relevant classes are compiled into *your* assembly by the CC rewriter, so that there shouldn't be any versioning problems. (At least this is what I've gathered from Reflector!)
Porges
@Porges: That's definitely the case for a lot of the stuff, but I wasn't sure whether it was *all* classes...
Jon Skeet