What Can We Already Expect From .NET 7?

Even though there is no official release date for .NET 7 yet, the development team has already announced .NET Preview 4 (with Preview 3 being released in April 2022). And by looking at the newly introduced features in all Preview versions, we can already get a good understanding of what .NET 7 will have under its hood. Without further ado, let’s quickly go through the history of .NET 7 Preview versions and focus on the most anticipated functionality.

What Can We Already Expect From .NET 7?

From Preview 1 to Preview 4

The first beta version of .NET 7 aka Preview 1 was announced in February 2022, right in the middle of celebrating the 20 years of the .NET history and in this way, marking its further development. Being based on the .NET 6, .NET 7 Preview 1 did not bring anything revolutionary to life but it promised a simpler and more enjoyable development experience. The main areas of focus in Preview 1 included easier work with containers, specialized tools for an easier upgrade of legacy projects, support for nullability, support for hot reload scenarios, and several new APIs.

A month later (March 2022, to be more specific), the .NET team released Preview 2. In addition to the already introduced features, the new beta version included enhancements to RegEx source generators and a vast number of improvements to the “dotnet new” CLI experience. As well, the .NET team started experimenting with NativeAOT – more on it below.

In April 2022 (yes, the releases have been pretty consistent), .NET Preview 3 was announced and it had several anticipated improvements. The major one was probably a confident shift of the Native AOT from its experimental status to the mainline development. As well, Preview 3 offered developers major enhancements to observability, startup time improvements, and enablement of GC regions by default. And now in May 2022, we have a new Preview 4 version rolled out – and once again, it has several new features to test and play around with. 

As you can see, the .NET team has been consistent about releasing new Preview versions and seems like the new .NET 7 will be packed with valuable and demanded features. Let’s look at the most interesting ones that both Preview 3 and Preview 4 have to offer.

Native AOT

Native ahead-of-time compilation was first mentioned in Preview 2 but at that time, it had just been moved to the mainline development out of the experimental status. With the release of Preview 3, developers now have an option to test Native AOT for .NET and enjoy what it has to offer.

Ahead-of-time compilation implies code generation at the app’s build time rather than at run-time. This approach usually provides faster startup time, lighter apps, faster rendering, and more efficient memory usage. Even though AOT is not new for .NET, native AOT is something freshly introduced. The main idea behind native AOT is that it produces native artifacts only. In this way, the underlying OS is fully responsible for handling the executable file format parsing. And while the use of native AOT is not obligatory, this approach is recommended for projects where startup time matters the most. 

The .NET team states that console apps and native libraries are the main targets for native AOT use. The main condition for apps to be compatible with the native AOT approach is that they should be trimmable. For that, Microsoft provides detailed documentation on how to prepare apps and libraries for trimming and therefore, make them suitable for native AOT.


.NET supports observability via OpenTelemetry so several enhancements were made to continue and improve this support. But first, a quick note on OpenTelemetry. It is a set of SDKs, APIs, tools, and integrations that help you create and manage telemetric data such as logs or metrics (in other words, observe them). .NET 7 is intended to bring more efficiency and transparency to the existing observability with the following improvements:

  • New Activity.Current change event for receiving notifications on span context changes;
  • Exposed methods for enumerating Activity properties;
  • Trace state is now mutable for samplers.

Startup time improvements

One of the main areas of focus of the new .NET 7 version is performance so it’s no surprise that the development team is working hard on that. In Preview 3, the .NET team announced that they managed to significantly improve the startup time by reimplementing the precode and call counting stubs. This was done with Write-Xor-Execute enabled which is also a newly introduced thing. 

It’s interesting that this approach also resulted in state performance improvements in a few ASPNet Benchmarks and microbenchmarks and their performance saw improvement even with the disabled Write-Xor-Execute. However, it’s important to mention that this change resulted in several regressions that are currently being worked on. These regressions happened on Intel processors only and impacted only Orchard and Fortunes benchmarks.

On Stack Replacement for better performance

Another great contribution to the startup time and overall performance is the implementation of On Stack Replacement (OSR) which was introduced in Preview 4. With enabled OSR, the code that’s executed by currently running methods can be changed mid-execution by the runtime. In this way, the runtime can quickly jit all methods at first and then shift to more optimized ones if needed (i.e. when the methods are called frequently). As a result, developers can enjoy a great performance boost from using OSR.

Microseconds and nanoseconds in date and time structures

A really interesting innovation added to the .NET Preview 4 is the introduction of milliseconds and microseconds to the date and time implementations. Before, developers had to perform computations on the “tick” value (100ns) to determine the values of microseconds and nanoseconds. Now, a new API surface area addresses the issue and makes date and time structures more manageable. 

Bonus: the updates in C# 11 Preview

Alongside the .NET Preview development, the Microsoft team also introduced several exciting updates to the C# 11 Preview. All of them are aimed at improving the productivity of developers and making the coding process more enjoyable and fun. Here is what C# 11 Preview can already offer for testing:

  • Raw string literals: allow to avoid escaping content inside strings, thus contributing to increased productivity and readability.
  • Pattern matching with spans: boosts productivity and allows to pattern match a Span<char> or a ReadonlySpan<char> with a string literal.
  • UTF-8 String Literals: developers can now convert string literals that contain UTF-8 characters only to their byte representation.
  • Auto-default structs: allow to initialize struct values in an easier manner.
  • Checked user-defined operators: user-defined operators now respect the current arithmetic overflow check status.
  • A cached delegate for method group conversion: the feature allows caching static method groups instead of creating fresh delegate instances which improves the runtime performance.

Summing up

As you can see, the .NET team is really dedicated to bringing a superior development experience with the new .NET 7 version. By now, all newly introduced features look really exciting and seems like the development team takes all feedback into consideration and delivers corresponding changes. And while waiting for the Preview 5, you can test the Preview 4 version and see yourself how the newly implemented changes look and feel.

Want to stay updated on the latest tech news?

Sign up for our monthly blog newsletter in the form below.

Softteco Logo Footer