tags:

views:

805

answers:

3

Are all the additions to C# for version 4 (dynamic, code contracts etc) expected to run on the current .NET CLR, or is there a planned .NET upgrade as well?

+5  A: 

C# 4 will require the .NET 4.0 CLR.

Shannon Cornish
I must admit, I'm not 100% convinced by such a sweeping statement... certainly .NET 4.0 will, but have you tried any of the non-dynamic C# 4.0 things on the VS2010 CTP? Unfortunately I don't have my CTP available at the moment...
Marc Gravell
The compiler in VS RC1 compiles "dynamic" and named/optional arguments when I target 3.5.
Dan Finch
+2  A: 

You don't have to wait for 4.0 to use Code Contracts as it runs on .NET 3.5, the download link for the academic preview release is here.

Augusto Radtke
For Academic licensed VS2008 only :(
johnc
Keep the license issues aside, it doesn't need 4.0 runtime to run, that's important and nice.
Augusto Radtke
Wow, that's awesome. I'm been dying to try it out, but I haven't had time to setup a VS 2010 box.
Jonathan Allen
+3  A: 

Well, .NET 4.0 will require CLR 4.0; however, it is a little harder to answer what parts of C# 4.0 will work on .NET 2.0/3.x. We can hope that VS2010 will still be multi-targeting(I don't have the CTP "on me" so to speak, so I can't check...). But some of the language features don't seem hugely tied to the runtime (named parameters, some of the COM changes such as "ref") - so I can't think of a good reason why they wouldn't be available when talking to .NET 2.0/3.x. I haven't checked, though.

However, as with C# 3.0, some of the features are tied to the runtime - in particular dynamic.

I need to dig out the CTP and have another play, methinks...

Marc Gravell
I agree, I can see why dynamic may need a clr update, but code contracts not so much
johnc
Well, code-contracts will require the attributes themselves... and if they are housed in .NET 4.0 (which I suspect they are), you will probably need to target CLR 4.0.
Marc Gravell
Although there's a version of code contracts running against .NET 3.5, of course...
Jon Skeet