Editorials

Why Upgrade Dev Tools?

One of the cool things about the separation of the Dot Net CLR and the Dot Net Compiler is that newer syntax implementations may be made in the compiler that are backward compatible with the Dot Net libraries that the CLR supports.

If that confuses you, just hang on and I’ll lay out some examples that should make it more clear.

Today I came across come code written in C# that takes advantage of newer property initialization capabilities. With C#6 and later, you can define an implicit property without using a backing field, and actually create a default value at the same time. The project was sent to me using the Dot Net 4.5 library for all of the projects. So, I opened it up in Visual Studio 2013, and the project would not compile. It didn’t like something like the following:

private List { get; set; } = new List();

In C# 6.0, this is legitimate code. When I tried to compile the solution, I received an error for each time this initialization of the properties inline was used. So, I closed the solution, and opened it again in Visual Studio 2015. Now it compiles just fine. The projects are still using older libraries (which I updated to Dot Net 4.6.1 because some of the older libraries are no longer supported).

Why does this work? The reason is that the syntax is all that has changed, which is implemented by the compiler into the Dot Net 4 CLR. If you are a user of IIS, you can go look at your app pools and easily find that the last version of the CLR supported is some version of 4.0???. Since the Visual Studio 2015 compiler (Roslyn) compiles to the Dot Net 4 CLR, new syntax capabilities are available that don’t require deploying a new instance of the CLR to all services using the CLR.

If you think about it this really make sense. The fact that you can write Dot Net code using different languages is much the same thing. The only difference is that you are looking at a change from one version to another of the same language. As long as it compiles down to acceptable byte code for the CLR, then all is well.

So, if you are looking for a reason to upgrade your development tool suite to a later version, the compiler and intelisense make a couple of arguments. They may not be compelling arguments in your situation. Perhaps if these are added to other issues you are facing it can make a difference.

Cheers,

Ben