Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News How VS2015 Update 2 Improves .NET Native Code

How VS2015 Update 2 Improves .NET Native Code

Microsoft continues to put forth new features and capabilities into Visual Studio 2015.  The latest changes, designated Update 2, is no exception as it has been packed with several updates to the .NET Native compiler.  As you may recall, when .NET native is used as a compilation target, Windows apps (defined here as UWP apps targeting Windows 10) are compiled directly to native code rather than the default Intermediate Language (IL). There are several advantages to doing so, principally developers can continue to write apps in C# or Visual Basic while users benefit from faster execution times, shorter startup times, and less memory usage as compared to a traditional IL-based app.

As can be expected, compiling .NET to native code does have some drawbacks.  Microsoft has prepared a lengthy list for what they deem to be “behavioral changes” between .NET Native and regular Windows apps.  Detailing all of these differences is beyond the scope of this article, but the salient point is that one of these changes concerns reflections on generic types.  As Microsoft’s Stacey Haffner and Matthew Whilden of the .NET team write, “Dynamism is a challenge when compiling to native code, since all of the code must be known and compiled at compile-time.” 

Because using static analysis to determine all of the generic instantiations is fairly complicated, the team is introducing Universal Shared Generics (UGS).  Now optimized code is generated where it is feasible to be represented by type specific code, and UGS is used when it is not.

Another big change that will benefit all developers targeting .NET Native is a switch in compiler backends used by the .NET Native project.  The new 1.3.1 release of the .NET Native tools now uses the “same whole program inlining engine” used by the Microsoft C++ compiler.  As time progresses the .NET team plans to utilize more of the optimizations the C++ compiler provides within the .NET Native project. 

To utilize these new compiler features, you will need to download the latest UWP App Development Tools (version 1.3.1 for Windows 10 SDK 10.0.10586) and the latest .NET Core UWP packages from NuGet.  Both of these should be installed on an instance of Visual Studio 2015 with Update 2 applied.

Rate this Article