A new .NET release will be here soon, with a new set of compilers that promises a cross-platform future.
The next release of the .NET platform is around the corner. The new annual cadence of releases makes .NET 6 the first long-term support release of the unified .NET. That makes it a more important event than most as itโs the first one that organizations can really trust to use as the foundation of their development strategy.
Microsoft recently published its first release candidate, one of two that will come with a โgo liveโ license that ensures Microsoft support for production applications. This is always a big step. At this point, what had been used for prototypes and other tests gets used at scale, revealing any bugs. Thatโs why Microsoft makes support available, so the .NET team is able to see the edge cases that it couldnโt reach in its own tests.
Should you begin to switch to .NET 6? Certainly, if youโre already using .NET 5 you should find migrating relatively easy, with the new release adding plenty of new features. Migrations from the .NET Framework remain harder, though .NET 6 adds more compatibility features. Still, thereโs enough of a difference between the two platforms that migrating code will be a significant project. Even so, itโs probably a good time to start any migrations, with support readily available with a long-term release as a target.
You can download the current runtime and installers from Microsoft now, with development tool support in the latest preview builds of Visual Studio 2022 (which should launch alongside .NET 6 at .NETconf in November). A version of Visual Studio 2022 for macOS with .NET 6 support is currently in private preview.
Taking off the covers of a new .NET compiler
For most of us, the languages we use are our main touchpoint for .NET, and like previous releases, .NET 6 brings new versions of its main tools. However, the most important parts of a new version are under the hood in the tools that take our code and run it on target hardware, from pocketable ARM devices to massive multicore cloud x64 systems.
A lot of the work in .NET 6 has been inย improving its compilers, working on optimizing code, using profile-guided optimization inside the project to produce optimized runtime libraries. Itโs perhaps best thought of as a teaser for .NET 7. You can get the benefit of static profile-guided optimizationย (PGO) in your code, but you canโt use it yourself yet. At the same time, thereโs an opt-in dynamic PGO tool built into the .NET JIT compiler. Itโs a good way of improving the performance of running code, but any optimizations will be lost between runs.
Dynamic PGO takes advantage of .NET 6โs support for tiered compilation. This uses a preliminary Tier 0 compilation pass to quickly build unoptimized code. Once you have this, you can see what methods are used the most, and these can then be optimized in a Tier 1 compiler pass, building on data from earlier runs. The resulting code will have a larger memory footprint, but itโll also be significantly faster. Microsoft documentation gives examples that are more than twice the speed of code that doesnโt use dynamic PGO.
These features are all part of the new Crossgen2 compiler. Itโs a significant, stand-alone tool that works with the .NET JIT to deliver code that can run anywhere thereโs a supported set of .NET. This allows your code to be built for one environment and then delivered to another. Crossgen2 produces ready-to-run code, compiling an entire assembly in advance of running them. Although thatโs inefficient, itโs a start for future compiler versions. Currently it supports older instruction sets, which will still run on newer hardware, though they have been superseded by newer instructions that will take advantage of modern cloud-scale hardware. Itโs perhaps best to think of Crossgen2 as the first pass at a new way of building and delivering code, one that mixes JIT and ready-to-run compilation, but one where we wonโt see the full benefit until .NET 7 ships in 2022.
Changing network stacks
One of the more important changes in .NETโs networking isย support for HTTP/3 and the QUIC protocol. This will improve support for secure HTTP connections, with built-in Transport Layer Security (TLS) and User Datagram Protocol (UDP) to avoid connection blocking. It makes it easier for connections to roam between wired, wireless, and cellular, as QUIC (Quick UDP Internet Connection) is independent of the underlying connection address. That makes roaming a lot easier, as long transactions like downloads can continue operating even if the underlying connection from device to internet changes.
Support for the underlying QUIC protocol is important for other reasons. The migration from the .NET Framework to .NET Core that began with .NET 5 has left some key .NET components by the wayside, including WCF, the Windows Communication Foundation. The WCF APIs were used to build service-oriented applications in .NET, a model thatโs increasingly important with the move to cloud-native applications. Microsoft recommends moving to gRPC as a way of implementing service endpoints, and itโs working on an implementation thatโs based on HTTP/3. This approach makes a lot of sense for mobile and edge applications where connections may well switch between Wi-Fi and cellular depending on position and conditions.
Itโs not a big step to move from HTTP/2 to HTTP/3 for gRPC, but there should be significant performance improvements, especially for mobile devices and Internet of Things and other edge implementations. You can experiment with it now if you enable HTTP/3 support in your code and then implement a gRPC interface. Client code should auto-negotiate an HTTP/3 connection if itโs supported in the host OS.
With Windows and Linux getting .NET 6โs HTTP/3 support, it wonโt be there on macOS, as Apple doesnโt provide any QUIC APIs. However, with QUIC becoming increasingly popular, itโs likely to gain support relatively quickly. In the meantime, any code that uses gRPC HTTP/3 should be written to respond to standard gRPC calls over HTTP/2 as well.
An open .NET
Another interesting development in .NET 6 is the ability to build a runtime thatโs provably open source. For most Linux distributions, tools need to be built using open source tools, which for .NET requires a two-stage process. To enable this, Microsoft is now able to deliver .NET source code in a source tarball like any other major Linux component. Whereas this used to be a manual process that often delayed distribution, itโs now an automated part of the .NET build process, ensuring that code from Linux distributions like Red Hat is in sync with Microsoftโs own builds.
Support for source tarballs is an important sign of Microsoftโs and the .NET Foundationโs commitment to an open .NET. Thereโs a lot of work in the latest version that comes from outside Microsoft, though Redmond is still by far the biggest contributor. But Microsoft is using its blogs to call out contributors to its libraries and to reference partnerships with companies like Red Hat. It makes sense for Microsoft to bet on open in .NET: It needs to target a huge number of platforms as the computing environment expands and new architectures, like ARMโs new instruction sets, arrive.


