Microsoft .NET 6 is the end result of the .NET unification that began with .NET 5. Cross-platform .NET 6 merges the .NET Core, .NET Framework, and Xamarin/Mono applied sciences right into a single .NET Framework, unifying the SDK and runtime for desktop, cellular, net, and cloud purposes.
Microsoft made .NET 6 usually accessible on November 9, 2021, alongside C# 10 and Visible Studio 2022. Along with an improved developer expertise total, .NET 6 brings vital efficiency boosts in comparison with its earlier counterparts. In actual fact, .NET 6 is the quickest .NET but. It’s additionally a Lengthy-Time period Assist (LTS) launch, which suggests Microsoft will assist .NET 6 for 3 years.
It goes with out saying that you should perceive the brand new options of .NET 6 earlier than you’ll be able to take full benefit of them. This text discusses what’s new in .NET 6 and what it means to go ahead as a C# 10 developer. You’ll be able to obtain a duplicate of .NET 6.0 for Home windows, Linux, and macOS.
Notice that .NET 6 is supported in each Visible Studio 2022 and Visible Studio 2022 for Mac. Nonetheless, .NET 6 isn’t suitable with Visible Studio 2019, Visible Studio for Mac 8, or MSBuild 16. You have to to improve to Visible Studio 2022 in the event you want to use .NET 6. You’ll be able to obtain Visible Studio 2022 right here.
A unified and prolonged .NET platform
.NET 6 offers a unified platform for desktop, cellular, net, cloud, and IoT purposes. The underlying platform helps purposes of varied varieties and makes it easy to re-use code throughout all purposes. New options and enhancements have been launched to make sure that code executing within the cloud, on a desktop, or on a cellular gadget all behaves the identical manner.
Some of the engaging enhancements is the .NET Multi-platform App UI (.NET MAUI). Now you can write code that gives a contemporary shopper app expertise throughout desktop and cellular working programs in a single undertaking. .NET MAUI turned usually accessible in Might.
Notice that neither .NET 5 nor .NET 6 is a substitute for the legacy .NET Framework. Microsoft has no plans to port Internet Types, Home windows Communication Basis (WCF), or Home windows Workflow Basis (WF) from .NET Framework to .NET 5 or .NET 6. Nonetheless, there are supported options for every of those applied sciences as proven beneath.
- Internet Types will be changed by ASP.NET Core Blazor or Razor Pages.
- Home windows Communication Basis (WCF) will be changed by gRPC.
- Home windows Workflow Basis (WF) will be changed by open supply CoreWF.
What’s new in .NET 6
Let’s now take a look at the brand new options and enhancements in .NET 6.
Improved efficiency
Efficiency is significantly improved, notably for file I/O, leading to diminished execution time, latency, and reminiscence use. The FileStream class has been re-written to enhance async file I/O efficiency. The implementation on Home windows now not makes use of blocking APIs, which makes it a number of instances sooner.
The Simply in Time (JIT) compiler has been up to date. There have been enhancements within the rubbish collector as properly. System varieties comparable to Guid and string have been improved significantly.
Profile-guided optimizing
Profile-guided optimizing (PGO) is a compiler optimization approach and a brand new characteristic launched in .NET 6 that enables the JIT compiler to generate optimized code in keeping with the categories and codes which can be most frequently used.
Unified platform assist
Microsoft’s work towards a unified platform for .NET purposes began with .NET 5. The concept was to offer a uniform platform for growing apps that may run on any gadget and any working system. Thus all .NET 6 purposes, throughout net browser, desktop, cloud, IoT, and cellular units, use the identical .NET libraries.
New APIs launched
New APIs have been added for HTTP/3, JSON, arithmetic, and extra.
Safety enhancements
There have been vital enhancements in safety, comparable to assist for the ChaCha20Poly1305 encryption scheme, OpenSSL, and “protection in depth” runtime mitigations.
C# 10 and F# 6 enhancements
The appreciable enhancements in C# 10 embody the introduction of latest lambda capabilities, report structs, and implicit utilizing. There have been enhancements to F# 6 as properly that embody pipeline debugging and Job-based async.
Enhancements in JSON APIs
Enhancements to JSON APIs deliver extra capabilities and enhanced efficiency. A brand new supply generator for System.Textual content.Json has been launched that eliminates the necessity for runtime reflection and code creation and permits for the manufacturing of acceptable serialization code at construct time.
Enhancements in cloud diagnostics
Cloud diagnostics have been enhanced with the addition of OpenTelemetry and dotnet-monitor, that are at present in manufacturing and accessible with Azure App Service.
Enhancements in code high quality
Supply mills and analyzers have been launched that will help you write higher, safer, and sooner code.
Scorching Reload
Scorching Reload is among the most placing new options added in .NET 6. You’ll be able to benefit from this characteristic to switch the person interface when your utility is in execution. You’ll be able to see the adjustments mirrored as quickly as you save them—you don’t have to restart the applying. This characteristic boosts developer productiveness significantly.
DateOnly and TimeOnly structs
It is a long-awaited characteristic in .NET. Now you can set values to an object that’s only a date or a time. Beneath are just a few examples that illustrate how you would use DateOnly and TimeOnly structs.
var dateNow = new DateOnly(2021, 11, 17);
var newDate = dateNow.AddDays(7);
var timeNow = new TimeOnly(12, 0, 0);
var newTimeNow = timeNow.AddHours(5);
Assist for async streaming
With .NET 6, you now have assist for async streaming, utilizing IAsyncEnumerable<T>, which lets you stream information from the server with none buffering.
Focusing on .NET 6
If you create a brand new .NET 6 utility in Visible Studio 2022, the TargetFramework node ought to check with .NET 6. A typical .csproj file created in .NET 6 will appear to be this:
<Venture Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>allow</ImplicitUsings>
<Nullable>allow</Nullable>
</PropertyGroup>
</Venture>
You can too specify a taste of .NET 6 in the event you’re concentrating on a selected working system:
- net6.0-android
- net6.0-ios
- net6.0-maccatalyst
- net6.0-tvos
- net6.0-windows
What’s lacking from .NET 6?
Notice that some applied sciences had been dropped in .NET 5. Therefore, they don’t seem to be part of .NET 6 as properly. These embody the next:
- ASP.NET Internet Types. The legacy ASP.NET Internet Types is now not supported. You may wish to use Blazor, Angular, or React as a substitute.
- Home windows Communication Basis (WCF). Microsoft had meant to deliver WCF again to the .NET ecosystem, however dropped the thought after figuring out it might take some three years to take action. Microsoft recommends utilizing gRPC, Google’s open supply RPC framework, as a substitute. (For a information, see my article right here.)
- Home windows Workflow Basis (WWF). WWF, a workflow framework that has been in use for a few years, has being dropped from .NET as properly.
The .NET launch schedule
After the discharge of .NET 5, Microsoft promised to ship a brand new model of .NET in November of yearly. The next desk lists the discharge schedule for .NET.
.NET Framework was deprecated after .NET 5 was launched. This implies you’ll be able to nonetheless use .NET Framework on variations of Home windows that assist it. Nonetheless, with Microsoft shortening the lifecycles of the working programs, you would simply find yourself utilizing a Home windows model whose end-of-life has already arrived.
Microsoft offers Lengthy-Time period Assist for .NET 6. It must be famous that LTS releases are normally supported for a interval of three years from the date of launch. Thus, Microsoft plans to assist .NET 6 till November 2024. The subsequent LTS launch, .NET 8, is due in November 2023.
A brand new period of .NET growth
From a greater, sooner, and unified runtime to an improved developer expertise, the sweeping advantages of .NET 6 make it essentially the most vital launch within the .NET ecosystem since .NET 4. .NET 6 is each the quickest .NET but, with a smaller footprint and diminished useful resource consumption, and essentially the most developer-friendly, with many language enhancements and options like Scorching Reload.
Most necessary, .NET 6 takes us an enormous step towards easing the event of cross-platform purposes. It’s a cross-platform framework that lets you create native cellular and desktop purposes for Android, iOS, macOS, and Home windows, with out having to keep up a number of codebases to assist all these completely different platforms.
Microsoft .NET 6 not solely establishes a brand new basis for all future .NET platforms. It marks a brand new period of growing performant, modern-day purposes for a number of working programs and architectures in .NET. With a unified platform, higher language maturity, and improved developer instruments, .NET 6 is properly set to be the default Microsoft growth platform for years to return.
Copyright © 2022 IDG Communications, Inc.