2

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?

johnc
  • 39,385
  • 37
  • 101
  • 139

3 Answers3

5

C# 4 will require the .NET 4.0 CLR.

Shannon Cornish
  • 961
  • 5
  • 11
  • 1
    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 Dec 03 '08 at 08:16
  • 1
    The compiler in VS RC1 compiles "dynamic" and named/optional arguments when I target 3.5. – Dan Apr 02 '10 at 19:01
4

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
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • I agree, I can see why dynamic may need a clr update, but code contracts not so much – johnc Dec 03 '08 at 05:19
  • 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 Dec 03 '08 at 05:30
  • Although there's a version of code contracts running against .NET 3.5, of course... – Jon Skeet Dec 03 '08 at 06:50
2

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.

Edwin Jarvis
  • 5,980
  • 6
  • 36
  • 41