Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

.NET 7 was released in November 2022, and .NET 8 is already in sight. It’s about eight months until .NET 8, the next long-term support (LTS) release of .NET.

In this article, I’m going to tell you everything we already know about .NET 8, and at the end of the video, I will mention something new that you can already use today.

Hint: The video and this article were created when only the .NET 8 Preview 1 was released.

The Goals of .NET 8

Let’s start with the goals of .NET 8. The following statement is from the official blog post announcing .NET 8 Preview 1.

“.NET developers should be able to get their apps to the cloud quickly, scale their apps without compromising performance, and evolve their apps based on actionable data and feedback about your apps in production.”

The focus of .NET 8 will be on cloud-native development, .NET MAUI, and Blazor. It will also be the next target framework for developers and teams still on .NET 6 because they want to exclusively target long-term support releases.

Let’s see what we already know will be inside .NET 8.

Frozen Collections

Let’s start with something almost every developer will benefit from using in .NET 8. Frozen collections introduce immutable collections optimized for read operations. Once created, you cannot change the content of the collection.

The FrozenDictionary and FrozenSet types are a bit more expensive to create, but once created allow for much quicker read access. 

It will provide much better performance in scenarios where you populate a collection once and use it in a long-running service, such as a singleton in an ASP.NET Core WebAPI project.

Changes to the .NET SDK

The community has been asking for a long time why the dotnet publish, and dotnet pack commands haven’t produced a release build by default. 

That will be changed, and starting with .NET 8, those commands will create a release build as expected by most developers.

The PublishRelease and PackRelease properties controlling this behavior are already there for .NET 7. However, you must set them manually to true to get the same behavior as in .NET 8.

Native AOT

Ahead-of-Time (AOT) compilation is a feature in .NET that can significantly impact the performance of .NET applications. 

AOT apps contain the application code and a .NET runtime within a single executable file. The three most important benefits of AOT-compiled apps are:

  • Reduced memory footprint
  • Improved Startup time
  • Improved battery life

With .NET 8 Preview 1 comes macOS support, and the package size of AOT-compiled apps currently shrinks to about 1.8 MB with .NET 8. 

It’s about 50% less on Linux and about a third less on Windows compared to .NET 7.

Working with Randomness

.NET 8 offers two new methods when working with randomness. The System.Random and the System.Security.Cryptography.RandomNumberGenerator classes get two new utility methods.

The Shuffle method randomizes the order of elements in a span. And the GetItems method helps to select a number of random elements from a collection. 

Small performance improvements

There are already thousands of small code generation and other performance improvements in preview 1 of .NET 8. Until the final release of .NET 8, there will be many more performance improvements included.

It will be noticeable when migrating from .NET 7 and an even bigger performance boost when migrating your applications from .NET 6 or older.

Being a .NET developer today gives us so many improvements affecting the performance of the applications we build only by migrating to a newer target framework. It’s my biggest motivator to stay as current as possible with the projects I control.

The .NET Upgrade Assistant

The .NET Upgrade Assistant is a tool that helps you migrate your existing .NET projects to the latest .NET version.

For example, besides other project types, it helps you migrate an existing WPF or WinForms application from .NET Framework 4.7 to the current .NET version.

The .NET Upgrade Assistant has been around for a few years. However, you had to know about its existence, for example, by watching my channel or following others on the Internet. 

Since February 2023, it is now available as a Visual Studio extension. It has become easier than ever to check and migrate your legacy applications using the .NET Upgrade Assistant.

While the .NET Upgrade Assistant isn’t tied to .NET 7 or .NET 8, it can be used independently to help migrate existing .NET applications.

Testing .NET 8

If you are curious about the new features or want to see how your application behaves when using the .NET 8 Preview 1 release, there are only two steps to make it work. 

First, download and install the .NET 8 SDK from the .NET website. Next, you have to change the target framework of your project files to net8.0.

If you happen to test .NET 8, let me know about your experience. Otherwise, write in the comments what feature from .NET 8 excites you the most.

If you haven’t already, subscribe to the channel so you won’t miss future videos about .NET development.

 

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.