.NET 9 will be released this November, featuring versatile performance and security upgrades, C# syntax enhancements, and new LINQ methods along with the .NET Aspite stack for cloud-native development, ML .NET for extended AI capabilities, and an array of other handy updates. However, while we are still one month away from the official .NET 9 launch, its Preview version is already here, giving developers an early look at the latest advancements. Keep reading to explore the upcoming improvements in detail.
Table of Contents
- Performance and Development Improvements
- Cloud-Native Development With .NET Aspire
- Extended AI Capabilities of ML.NET
- Security Updates
- Improved Tooling for Productivity
- ASP.NET Core and EF Core Enhancements
- New Features in C# 13
- New LINQ Methods
- .NET MAUI Improvements
- How to Download and Set Up .NET 9 Preview
- Conclusion
Performance and Development Improvements
.NET 9 Preview is going to get major performance improvements, eventually making your applications faster and more efficient. Also, .NET 9 Preview is already bringing us several steps closer to cross-platform development with a single codebase, which is a much-awaited leap for those working on mobile and desktop projects at the same time.
Let’s overview these changes in a nutshell.
Enhanced Performance
Microsoft has introduced several key improvements to runtime and memory management in .NET 9, ensuring that your applications are going to show optimal performance results even under the most demanding conditions. Within the newest version, you’ll find:
- Optimized Just-In-Time (JIT) Compilation
- Improved Garbage Collection (GC)
- Enhanced Exception Handling
- Faster LINQ Operations
- Better Support for Hardware Intrinsics
While this already sounds promising, the performance outcomes might impress you even more. For instance, according to a benchmark conducted by Code Corner, the .NET 9 Preview version has improved by 30% when handling exceptions compared to .NET 8. And this is only the surface of what we’ll be getting this November.
Unified Development Platform
With the upgrade, we are going to get advanced cross-platform development .NET 9 features, as the framework will support both Android and iOS. Moreover, the recent updates to MAUI will let you handle native app development from a single codebase, targeting several platforms with the same code.
Cloud-Native Development With .NET Aspire
Recently, the Microsoft team focused on creating powerful cloud-native fundamentals, paving the way for using popular managed databases and caching services. As a result, the .NET Aspire cloud-ready stack was introduced to help developers build cloud applications with less effort and set up a bridge between application development and deployment.
.NET Aspire in .NET 9 Preview version will receive an improved DATAS GC for ASP.NET Core apps. Also, you will be able to scale .NET 9 apps to multiple instances within their Kubernetes-based environment. Moreover, .NET 9 features will include Auth tokens, as well as anti-forgery measures in terms of data protection. Finally, we expect seamless integration with Azure and similar cloud services.
Extended AI Capabilities of ML.NET
Tokenization plays a key role in the preprocessing of natural language text for Generative AI models. Thus, the latest version of ML.NET (4.0) will provide additional tokenizer support to work with popular tokenizers, such as Tiktoken and CodeGen, and versatile LLMs (e.g., Llama, codegen-350-mono, and phi-2). Also, integration of custom ML into .NET apps will become easier with the refined API for existing functionality.
Security Updates
Security is prioritized in .NET 9. Naturally, there were major improvements in intercepting and eliminating emerging threats to your applications, such as new classes using the KMAC algorithm and the release of the new CryptographicOperations.HashData method.
Let’s overview them.
KMAC Enhancements
KMAC (KECCAK Message Authentication Code) algorithm can perform message authentication and pseudorandom generation. With it, you can accumulate data, as well as use one-shot hashing with the HashData method.
Here are some new KMAC classes that you will get in .NET 9:
- Kmac128, to generate 128-bit codes (MACs).
- Kmac256, to generate 256-bit MACs.
- KmacXof128, to generate expandable output up to 128 bits at a time.
- KmacXof256, to generate expandable output up to 256 bits at a time.
Hashing Upgrade
Hashes are essential for informational security, and one of the ways to use them is to calculate the hash for some data and compare it with an expected value. In .NET development, there is a traditional way to do it with the “one-shot” SHA256.HashData and HMACSHA256.HashData methods. However, if you need to get an API where the person using your code decides which hashing algorithm to use, the NET 9 cryptography update will come in handy.
With the latest CryptographicOperations.HashData method, you’ll be able to take the desired algorithms and use the .NET CryptographicOperations class to calculate the hash, and then call ProcessHash to handle it.
Improved Tooling for Productivity
Microsoft pays a lot of attention to the experience you get when working with .NET. Thus, there were several important updates designed to boost productivity and prepare your workflow for the latest release. Let’s check them.
Visual Studio Support
Cannot wait till the release, and would like to try some of .NET 9 features already? The good news is that the latest versions of Microsoft VS, starting with Visual Studio 2022 17.12, already support .NET 9, so make sure to update your IIDE to ensure you get the best experience when coding.
Terminal Logger Updates
In .NET 9 SDK, the terminal logger is now enabled by default for all the terminal “interactive” sessions, formatting the console output of the build differently into the console logger. Also, its usability has improved since we can now see the total number of failures at the end of the build.
ASP.NET Core and EF Core Enhancements
Both ASP.NET Core framework and EF Core ORM will get major improvements with the .NET 9 version release. Let’s explore them in detail to ensure we know what to expect.
ASP.NET Core Improvements
ASP.NET Core 9 provides many improvements to your experience with Blazor, SignalR, OpenAPI, and authentication and authorization methods, all aimed at helping you build modern, robust, and efficient web applications.
Let’s start with some major updates to facilitate your work with Blazor. Within ASP.NET Core 9, you’ll get:
- A new solution template to use shared UI when you create .NET MAUI native and Blazor web client apps.
- MapStaticAssets to optimize the delivery of static assets.
- A new API to facilitate querying component states at runtime.
- Improved server-side reconnection.
- New APIs for easier authentication of an existing Blazor Web App.
- An option to add static SSR pages to apps that adopt global interactivity.
- The support of constructor injection.
- Websocket compression for Interactive Server components.
- A new KeyboardEventArgs.IsComposing property.
- OverscanCount parameter in QuickGrid.
Now, let’s move on to the SignalR library. There are quite a few of them worth paying attention to:
- Polymorphic type support in SignalR Hubs.
- Trimming and native ahead-of-time compilation support for SignalR client and server scenarios.
The enhancements to Minimal APIs are also robust:
- The TypedResults class for returning strongly-typed HTTP status code-based responses.
- The ProducesProblem and ProducesValidationProblem extension methods.
OpenAPI standard specifications have also received some advanced updates:
- Built-in support for OpenAPI document generation.
- Autocompletion enhancements for OpenAPI package.
- The [Required] and [DefaultValue] attributes for parameters or properties.
- The support for schema transformers.
- Upgrade of transformer registration APIs in Microsoft.AspNetCore.OpenApi.
- Trimming and native AOT for Microsoft.AspNetCore.OpenApi.
- Updated ProducesProblem and ProducesValidationProblem extension methods for route groups.
- IEnumerable<KeyValuePair<string, object?>> values for Problem and ValidationProblem result types.
At last, let’s check the latest authentication and authorization approvements:
- The support for Pushed Authorization Requests in ASP.NET Core’s OpenIdConnectHandler.
- OIDC and OAuth parameter customization.
- HTTP.sys extended authentication flags configurations.
As you can see, ASP.NET Core 9 will bring you dozens of advantages, resolve previous issues, and provide you with more ways to optimize your applications and improve performance.
EF Core Updates
Entity Framework Core 9 is expected to get updates for Azure Cosmos DB, specifically for NoSQL. Moreover, there will be essential upgrades to ahead-of-time compilation and pre-compiled queries. Here are the most significant enhancements in the latest EF Core ORM version.
Azure Cosmos DB for NoSQL updates:
- Hierarchical partition keys support.
- Support of built-in role-based access control (RBAC) system.
- Blocking of synchronous access attempts.
- Enhanced primitive collections.
Upgraded AOT and pre-compiled queries:
- AOT compilation and related processing performed as part of app building and publishing.
- Change tracking and the update pipeline compatibility with AOT/trimming.
- Interceptors, to redirect the query to precompiled code.
- Generation of the compiled model during build.
New LINQ and SQL translation capabilities:
- Grouping by a complex type instance.
- Removal of unnecessary columns when calling OPENJSON WITH.
- Translations involving GREATEST/LEAST functions.
- Options to force or prevent query parameterization.
- Inlined uncorrelated subqueries.
- New ToHashSetAsync<T> methods.
- Optimization of the queries using Count != 0.
- Translation of TimeOnly.FromDateTime and TimeOnly.FromTimeSpan when using SQL Server or Azure SQL.
Note that .NET 9 also provides new LINQ methods, which we’ll describe later in this article.
Also, within the latest EF Core version, you’ll get ExecuteUpdate and ExecuteDelete API feature updates, improved migrations, advanced model-building features, and a new method for HierarchyID.
New Features in C# 13
Along with the new .NET 9 SDK, we’re going to get C# 13, which, by the way, is already available for testing purposes. This new version has several major changes and upgrades, as well as some new features (lock object and escape sequence).
Let’s explore the changes in C# 13 syntax further.
Enhanced Syntax
The latest C# version has some essential changes in syntax that will potentially bring numerous advantages for different development scenarios. Here are some of them.
Params collection
With the recent update, you’ll be able to use the params modifier with any collection type, including those that have an add method (e.g., System.Span<T>, or System.ReadOnlySpan<T>). Now, there’s no limitation to an array type.
Lock object
Now, the lock statement will use an updated API whenever it recognizes the lock object, which significantly improves thread safety.
Escape sequence
In previous C# versions, you probably have used \u001B or \x1B methods. Now, to prevent occasional typos, C# 13 has introduced \e as a character literal escape sequence for the ESCAPE character.
Method group natural type
Previously, when the compiler located a method group, it generated a list of methods for this group. When you needed a “natural type,” it was determined based on the entire set of candidate methods, which led to slowdowns when working with complex datasets.
Now, with the “natural type” method group, we can expect a significant boost in performance, as the compiler will automatically prune inapplicable methods and evaluate candidate methods scope-by-scope.
Implicit index access
In C# 13, we’ll be able to use the implicit “from the end” index operator in an object initializer expression to initialize an array from its end, achieving a countdown effect. Here’s a quick sneak peek of how this is going to work:
var countdown = new TimerRemaining()
{
buffer =
{
[^1] = 0,
[^2] = 1,
[^3] = 2,
[^4] = 3
}
};
These are only some of the syntax improvements in C# 13 you’ll be able to use with the latest .NET 9 version. Please make sure to check the official page where all the upcoming updates are listed.
The Benefits of C# 13
The new syntax features in C# 13 go beyond just improving the overall readability of your code. E can expect an essential performance boost, especially from the use of System.Span<T> and System.ReadOnlySpan<T>, which will assist in memory allocation reduction.
To try the latest C# 13 with .NET 9, feel free to install the latest Visual Studio 22, which supports the updated syntax, and will let you play around with it.
New LINQ Methods
Even though we have briefly covered the major updates in C# 13, the brand new LINQ methods are worth mentioning separately, as they will bring significant changes in the ways we were previously using to query data.
Let’s check them out.
CountBy
This new method helps you group the elements that meet the specific condition and tell how many of them you’ve got. E.g. your list has items with “10” and “5” values. The CountBy method will help you determine how many items you’ve got on the list with a “10” value.
AggregateBy
Though CountBy and AggregateBy methods look similar, the difference is that AggregateBy not just counts elements that meet some conditions but aggregates their values. E.g., if your list contains 3 items with the value “10,” and only one of them has value “5”, AggregateBy can sum up all the values that meet the “10” condition and provide you with information that the sum of them would be “30.”
Index
This method is similar to the Select method that you could use before in LINQ to return the item and the index of an item (its position in the list).
Note that in .NET 9, the order of index and item is now reversed.
.NET MAUI Improvements
.NET MAUI updates in the .NET 9 are aimed mainly at product quality improvements. Thus, we expect more .NET 9 features to facilitate test coverage, improve end-to-end scenario testing, and streamline bug fixing. Here are some of the key feature highlights you should pay attention to.
New controls released in .NET 9 MAUI:
- HybridWebView enables hosting HTML/JS/CSS content and streamlines communication between JavaScript and C#/.NET.
- TitleBar control lets you add a custom title bar to apps on Windows.
Control upgrades within the latest version:
- Binding mode for BackButtonBehavior in Shell apps is now BindingMode.OneWay.
- BlazorWebView on iOS and Mac Catalyst defaults to localhost.
- ProcessTerminated event in WebView now triggers when a process ends unexpectedly.
- New optional handlers improve CollectionView and CarouselView performance on iOS and Mac Catalyst.
- Password, Date, and Time fields now support soft keyboard input.
- TimeSelected event in TimePicker now triggers when the selected time changes.
Other updates feature new remote notification lifecycle methods on iOS and Mac Catalyst, a new HandlerProperties.DisconnectPolicy property for controlling when handlers are disconnected, multi-window support, native embedding, project templates, and Xcode sync.
Also, the updated .NET MAUI version comes with multiple NuGet packages, which can be added automatically to your project as you assign it to the specific version needed for your work. Thus, you’ll be able to test even unreleased and experimental builds.
How to Download and Set Up .NET 9 Preview
To start exploring .NET 9 Preview, you’ll need to download and set up the appropriate tools. Ensure you have the latest version of Visual Studio that supports .NET 9 Preview. You can find detailed setup instructions and guidance in this video.
Conclusion
.NET 9 is still on the way, but we already know that in will give us significant performance boosts, provide enhanced security and essential AI features, as well as get us new development tools, redefining how applications are built. In this article, we tried to cover the most significant upgrades, and hopefully, now you are fully prepared for the upcoming release.
The dotConnect team is excited to meet the updated version this November, so be certain that we’ll ensure .NET 9 will be supported by our connectivity products to provide you with even more advantages.
Visit the ADO.NET Data Providers page to learn how you can connect to various databases using dotConnect!