What’s new in .NET 6?

SHARE

It is our pleasure to announce that the NET 6 framework has already been implemented with all the features like debugging, testing, and optimization on their way. Perhaps expecting something radically new in RC versions is no longer worthwhile. Instead, let's take a closer look at .NET 6 and try to understand why this version is better than the previous one.


Each time a new version of .NET is released, there is a lot of talk about how much better it will be than the previous version.

It is common for writers of press releases about the release of the new version to exaggerate its benefits, while keeping silent about its shortcomings. After reading all seven press releases and reviewing a large number of GitHub tickets, we were able to understand the true benefits. To better understand my point, let's look at the benefits of .NET 6.

Microsoft has completed its .NET unification initiative, which began with .NET 5 and will continue with .NET 6. The following features are available in the .NET 6 ecosystem:

  • It is easy to get started: the development process is simplified.
  • Also .NET 6 is the fastest full stack web framework in the cloud, which reduces computing costs.
  • You can achieve ultimate productivity with .NET 6 and Visual Studio 2022, which offer hot reload, git tooling, automated code analysis, and robust diagnostics.

As part of the long-term support program (LTS), .NET 6 will have long-term support for a period of three years.
By default, preview features are disabled. Also, if they are not suitable for production use, they may be removed in a future version.

Performance and Productivity

FileStream
Windows users will benefit from a new version of the System.IO.FileStream type written specifically for .NET 6.

Profile-guided optimization
Optimizing code based on the type and code path most frequently used by the user is called profile-guided optimization (PGO).

Crossgen2
The successor to Crossgen has been introduced with .NET 6, Crossgen2.

Arm64 support
.NET 6 also supports macOS Arm64 (or "Apple Silicon") and Windows Arm64 operating systems, both natively and via x64 emulation.

Hot reload
The hot reload feature allows you to modify your app's source code and apply the changes instantly to your application. With this feature, you won't need to restart the app between editing.

.NET MAUI
A release candidate of .NET Multi-platform App UI (.NET MAUI) will be available in the first quarter of 2022, followed by general availability (GA) in the second quarter.

C# 10 and templates
Among the innovations in C# 10 are global using directives, file-scoped namespace declarations, and record structs.

Additional info on Performance

Performance has always been a priority for .NET developers. On the one hand, the language and framework are constantly improving and adding new features - ref structs, stackalloc, System.Span *T>, and so on. With each new release of .NET, new optimizations are added, such as tiered compilation, compilation to native code, and, of course, advanced JIT compiler optimizations. When these tools are used as intended, they produce the desired results, which can be seen clearly in the graphs of key performance indicators in real combat situations.
NET 6 introduces three new tools that promise even greater efficiency gains. The new tools will benefit both developers and apps running in production. During debugging, we refer to pumped pre-compilation (using Crossgen2) and profiling-based optimization (PGO), as well as hot reloading of applications. 

Please keep in mind that some of the tools presented here are radical reworks of existing tools. Even though this revision has opened up new and exciting possibilities.

F# and Visual Basic

A number of improvements have been added to F# 6 as well as to F# Interactive. If you want to find out more, you can find out what has changed in F# 6.

The Visual Basic experience in Visual Studio and the startup of Windows Forms projects have been improved compared to previous versions.

SDK Workloads

Several components have been moved into new, optional SDK workloads to reduce the size of the .NET SDK. If you're using Visual Studio for the first time, it will take care of installing any SDK workloads you need.

System.Text.Json APIs

System.Text.Json has been significantly improved in .NET 6, so that it is now an "industrial strength" serialization solution.

  • Source generator

In .NET 6, System.Text.Json has a new source generator. JsonSerializer has a variety of configuration options. You can trim assemblies, increase performance, and reduce memory usage.

  • Writeable DOM

There is now a writable document object model (DOM) in addition to the existing read-only document object model (DOM). In situations where POCO types cannot be used, the new API provides a lightweight serialization alternative. Moreover, it simplifies navigation to a subsection of a large JSON tree and allows reading of arrays from that subsection or deserializing of POCOs. There are four types supporting the writeable DOM:

HTTP/3

A new version of HTTP, HTTP/3, is supported in preview in .NET 6. In addition to resolving a few existing performance and functional challenges, QUIC is a new underlying connection protocol for HTTP/3. QUIC enables roaming between cellular and Wi-Fi networks, establishing connections more quickly and independently of IP addresses.

ASP.NET Core

A number of new features will come with ASP.NET
This time, Blazor components can now be rendered in JavaScript and integrated with existing JavaScript applications.

OpenTelemetry

In .NET 6, OpenTelemetry support has been enhanced, which is a collection of tools, APIs, and SDKs for analyzing the performance and behavior of your software. This namespace contains the APIs supporting the OpenTelemetry Metrics API specification.

Security

.NET 6 adds the Control-Flow Enforcement Technology (CET) and Write Exclusive Execution (W*X) security mitigations.

IL trimming

Only unused assemblies were trimmed in .NET 5. .NET 6 trims unused types and members as well.

Code analysis

A number of new code analyzers are included in the .NET 6 SDK that deal with API compatibility, platform compatibility, trimming safety, etc.

Windows Forms

With .NET 6, you can use Application i known that templates for C# Windows Forms applications have been updated.

Source build

.NET SDK build now includes the source tarball, which contains all the .NET SDK source code. Using this source tarball, organizations like Red Hat can build their own version of the SDK.

Target framework monikers

There are now additional OS-specific target frameworks (TFMs) for .NET 6, such as net6.0-android, net6.0-ios, and net6.0-macos.

Generic math

Various operators are represented by these interfaces, for example, IAdditionOperators represents the + operator. NuGet package System.Runtime.Experimental contains the interfaces.

NuGet package validation

NuGet library developers can validate well-formed and consistent packages using new package-validation tooling.

Reflection APIs

Nullability information is provided by the following new APIs in .NET 6:

Date, time, and time zone improvements

In .NET 6, two new structs were added: System.DateOnly and System.TimeOnly. The date part and the time part of a DateTime are represented here, respectively. TimeOnly is useful for daily alarms and weekly business hours, whereas DateOnly is useful for birthdays and anniversaries.

Pre-compilation

As you know, the benefits of JIT compilation come at a cost. In particular, the increased time to "warm up" the application at startup, since the JIT compiler needs to grind too much IL-code at once. They have already tried to solve this problem by compiling applications directly into native code, such a technology already exists and is called Ready To Run. But in the new version of the framework, it has been significantly redesigned.
The old pre-compilation technology was too primitive and could only generate native code for platforms where the crossgen utility was running. In managed code, it was completely rewritten from scratch and named Crossgen2. In addition to optimizations, it offers new opportunities for using different compilation strategies across different platforms (Windows/Linux/macOS/x64/Arm). All of this is possible because the utility is now designed differently.

Basically, Crossgen2 parses the IL code into an application graph. In this case, he launches a JIT compiler for the required platform inside himself. This compiler analyzes the compiled graph and creates native code, applying various optimizations if necessary. As a result, the Crossgen2 utility can be run on both x64 and Arm64 platforms while generating native and even optimized code. However, it also works the other way around.
Currently, the .NET SDK is compiled with Crossgen2, and the old crossgen utility has been retired.

Profiling based optimization

A new feature in .NET 6 is Profile-Guided Optimization (PGO). Everyone knows that most applications cannot be executed by all written code. Some code is called more often than others, some is called very seldom, and some is never called at all. The compiler usually doesn't know about this, but it would be better if it did. The compiler uses PGO optimization to learn this. In this way, the application is simply run on a variety of standard cases, while at the same time it is profiled.

The compiler analyzes the results of profiling, and it begins to identify the most frequently used places in the code and optimizes them more carefully.

Sources: What’s new.Dot NET 6.

https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-6

Author

Check other articles

Bitsorchestra
5 5

What our clients say

Bits Orchestra team are outstanding developers​. They listen carefully to our business needs and easily turns our business objectives into a well thought out and executed development effort. Roman is very bright and definitely the most capable developer that has worked on our site. He is not only a Kentico expert but has successfully tackled other complicated development assignments demonstrating expertise in both front and backend development. Roman takes initiative to suggest enhancements that make site maintenance easier while improving the customer experience. The team is very responsive to our work requests and has great follow up. They have also worked very business partners and this has reflected positively on our company. Roman is a true partner for us and a tremendous asset to our organization. We will continue to work with them and would highly recommend Roman and his team for your development needs. He and his team will exceed your expectations!
 Alan Lehmann
Alan Lehmann
President at In energy sector

What our clients say

The Bits Orchestra team does excellent work. They are always available and I appreciate our frequent calls and screen-shares together. Their dedication to the projects and knowledge of Kentico is outstanding. They truly care about the quality of their work, and became a part of our team easily!
Shena Lowe
Shena Lowe
Managing Partner at Consensus Interactive

What our clients say

We hired Roman for a Kentico analysis project and have been very satisfied. He is very skilled and professional. We are looking to hire him and his team again on future projects.
Sylvain Audet
Sylvain Audet
CEO at MyDevPartner.com

What our clients say

Roman and team have taken over an existing Kentico EMS site for a large US Oil Company. So far, they have handled every single request that we have thrown at them and these were diverse, challenging, often bespoke, usually urgent and almost daily, over the last 11 months. Their work is of an extremely high quality, they are capable, quick and we have great confidence in the support that we are getting.
Jon Hollis
Jon Hollis
Head of Web Development at confidential

What our clients say

Bits Orchestra team was very helpful, they had a good understanding of the brief and deep knowledge of the system. They were always keen to provide advice and recommendations that benefit the project substantially.
Ramon Lapenta
Ramon Lapenta
Senior Front End Developer at Cyber-Duck Ltd