How about using lambdas, anonymous types, type inference, automatic properties and lazy initialization in your .NET Framework 2.0 application? Using the multi targeting feature in Visual Studio 2008 will help you do that. With Multi-Targeting in VS 2008 can build application for .NET Framework 2.0 -> 3.5 by just setting a project property to inform VS what version to target.
Selecting the target framework will compile the application to run on the specified version. This makes it quite easy to upgrade from VS2005 to VS2008 since you don't have to move your codebase into V3.5.
Note: While the application will run on .NET Framework 2.0 the project files will be specifically for VS2008, so if the developers in your team is upgrading, makes sure all of them can before letting anyone convert the project files.
This is a really nice feature in VS2008. But what does that has to do with the title of this post?
When investigating how visual studio does the multi targeting one of the first thing you will notice is that Visual Studio is using the CSC compiler from v3.5 of the framework:
There is no special flag sent to CSC to tell it to compile for V2 it just compiles. This works since the real difference between V2 and V3.5 lies in the class libraries and not in the CLR / CLI specifications. Both versions of the framework shares V2.0.50727 (3.5 just adds a service pack to it) and when building apps for V3.5 we event get the base class library mainly from V2 so mscorlib and it's siblings is not upgraded to V3.5.
The effect of this is that you for the projects you upgrade from VS2005 or applications you build that will target V2; will be able to use C# 3.0 features since they are all compiler tricks. Well almost all of them, extension methods require a reference to System.Core.dll which isn't available when targeting V2 of the framework. I've tried and confirmed that lambdas, anonymous types, type inference, automatic properties and lazy initialization will work fine for your V2 applications using Visual Studio 2008.
So if the CLR and the compiler is indifferent, what does differ from V2 and V3.5? It's really about what class libraries are shipped with the different version, targeting V2 Visual Studio will filter out the assembles that won't be available on a V2 installation.
So upgrading to VS2008 will have more benefits then just nice new colors and some new analyzing tools if your building applications for V2 of the Framework, you will also get some of those nice productivity enhancement that C# 3.0 brings to the table.
Now are there any reason not to upgrade at this point?
|