What’s new in .NET 6?

What’s new in .NET 6?

Author

CEO and Co-Founder of Bits Orchestra

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

Table of contents

    Share

    Author

    Author

    Roman Hutnyk

    CEO and Co-Founder of Bits Orchestra

    email link linkedin link

    12 years of software development experience helped me to grow up a deep feeling of business needs and processes, the value we could introduce to business, quality standards, and trends in business as well as software development.

    As the CEO of Bits Orchestra software development company, I spearhead the mission to drive business innovation and growth, by building cutting-edge web & mobile applications, as well as specializing in Kentico development.

    Check other articles

    5 Top .NET CMS for Businesses in 2024

    5 Top .NET CMS for Businesses in 2024

    Blog | .NET Core vs .NET Framework: An In-depth Comparison

    .NET Core vs .NET Framework: An In-depth Comparison

    Blog | The .Net Core Framework Improves Software Development and Benefits Businesses

    The .Net Core Framework Improves Software Development and Benefits Businesses

    Contact us

    Before we proceed, please help us understand your needs better. We will review your application and schedule a free estimate call

    Roman Hutnyk

    CEO & Co-founder

    ceo