Web Development
Published: Nov 11, 2024

.NET 9 Release: Understanding the Updates and New Features

Verified
Verified Expert in Engineering
Jitendra Prasad is a dynamic Technical Innovator with a decade of experience under his belt. He has a proven record of delivering exceptional customer experiences.
Latest .NET 9 Features and Updates

Quick Summary: Developers are excited as there is a big update from the .NET team. It’s the release of .NET 9 that has set the ground for discussions about new features and updates. It offers many new updates including performance improvements and new functionalities. Explore more about .NET 9 in this blog to learn what’s new in it.

There is again a moment of excitement for .NET developers as a new iteration of this platform has been released. With the release of .NET 9 RC2 in October 2024, the latest version is now out for this platform. What makes this new release so special and what’s in store for developers in it? These are the questions we are going to discuss in this blog.

We will take a look at .NET 9 in detail and discuss the key changes or updates across the platform including SDK, libraries, Runtime, and more. There are many improvements, new features, and updates that the new .NET release brings to the table.

Let’s explore what’s new in .NET 9 without further ado!

Get the Advantages of the Latest Features by Switching to .NET 9 Frictionlessly

Hire .NET Experts
On This Page
  1. An Overview of .NET 9
  2. New Features and Updates in .NET 9
  3. Upgrade to .NET 9

A Quick Overview of .NET 9

Today, .NET is one of the leading open-source developer platforms to create a wide range of applications. It is widely used to develop high-performance, secure, scalable, and cross-platform applications for desktops, mobiles, the web, and the cloud.

Over the years, Microsoft has released newer versions of this platform to make it more developer-friendly and offer enhanced features to build robust applications. There has been a significant leap forward in this platform since the first launch.

Currently, .NET 9 is the latest release of this platform that has brought new changes and upgrades to it. The company released seven previews of .NET 9 before it released two release candidates (RCs). Now .NET 9 RC2 is the latest release.

It has been released with Standard-Term Support, which means it has a support period of 18 months. However, .NET 8 is LTS (Long Term Support) with a support period of 3 years. Older versions like .NET 7, .NET 5, .NET 3.1, and below are now outdated and no longer supported.

But the .NET 6 release is LTS and support for it is still available. Why so? Well, if you don’t know, Microsoft offers two types of releases: one comes with STS and the other with LTS. Even-numbered .NET releases come with Long-Term Support and odd-numbered releases come with Standard Term Support.

So, this is the reason that .NET 9 has been released with STS.

What are the Updates in .NET 9?

There are many notable new improvements in .NET 9 like a fresh attribute model for feature switches, default support for DATAS, experimental SVE support for ARM64 processors, and more. These features and improvements will enhance developer experience and help in creating robust applications. Let’s take a look at the key improvements and updates.

1. New Attribute Model for Feature Switches

There are many new upgrades in .NET 9 that generously improve coding. It introduces a new attribute model for feature switches that also supports runtime’s built-in trimming. Feature switches are a functionality in .NET that allows developers to enable or disable some features in an application based on “if” conditions.

With .NET 9, two new attributes have been added to the runtime that allow developers to define feature switches. This is a very useful upgrade for experimentation and testing out different versions of an application without rewriting code as they can write once and turn off respective code for different versions.

Apart from experimentation, the capability to define feature switches will also help in developing lightweight applications as the size of the build will be reduced when the extra code is removed. The two new attributes introduced in .NET 9 include FeatureSwitchDefinitionAttribute and FeatureGuardAttribute.

When the FeatureSwicthDefinitionAttribute is used, the feature switch property is considered to be constant during trimming.

public class Feature
{
[FeatureSwitchDefinition("Feature.IsSupported")]
internal static bool IsSupported => AppContext.TryGetSwitch("Feature.IsSupported", out bool isEnabled) ? isEnabled : true;
internal static void Implementation()
{
// Feature-specific implementation
}
}
if (Feature.IsSupported)
Feature.Implementation();

In the code above, a feature switch is used to toggle the implementation of the Feature class on/off based on the true or false condition of whether the feature is supported or not. So, when “Feature.IsSupported” is false, the implementation code in Feature.Implementation() is removed.

The second attribute ensures that some code runs only when the runtime environment supports it. This attribute requires another attribute RequiresDynamicCodeAttribute.

2. Default DATAS in Garbage Collection

The .NET team has taken a step towards the stability, performance, and scalability of applications by enabling DATAS (Dynamic Adaptation to Application Sizes) as default in Garbage Collection (GC) which was first introduced in .NET 8 as an opt-in feature.

DATAS GC is used by default instead of Server GC. It can adjust to an application’s memory requirements. So, the heap size for an application is adjusted to the long-lived data size. The heap size is adjusted when the workload becomes heavier or lighter.

Server GC isn't that flexible because it adjusts heap size not based on application size, but the throughput. The heap size grows aggressively when the workload moves to a machine with more memory and cores. Plus, Server GC doesn’t necessarily adjust the heap size if the workload gets lighter.

3. Experimental ARM SVE Support

Another important upgrade in .NET 9 is the integration of ARM SVE/SVE2 support. It helps in vectorization which is crucial for high-performance computing applications. Developers can leverage SVE .NET APIs for the power of flexible vector processing. It empowers developers to create more efficient code that can leverage modern hardware architectures.

However, it is the initial step from the .NET team in fully supporting and implementing this feature. So, it marks the beginning of integrating SVE into the .NET ecosystem. Currently, Vector<T> is going to be used to represent SVE2’s “flexible vector length” functionality.

4. CET Enabled by Default

CET (Control-flow Enforcement Technology) is enabled by default in .NET 9. It is enabled for apps on Windows to protect against return-oriented programming exploits (ROP). So, it’s a good step towards enhancing the security of the .NET runtime.

CET implements hardware-enforced stack protection against ROP. It puts some limitations on CET-enabled processes. It is also possible to opt out of this feature.

5. Generic Parameters for UnsafeAccessorAttribute

The UnsafeAccessorAttribute was introduced in .NET 8 that allowed unsafe access to type members that the caller couldn’t access. However, it wasn’t implemented with generic support. But now .NET provides support for generic parameters with this feature for native AOT and CoreCLR scenarios.

The following image shows the example usage of UnsafeAccessorAttribute.

UnsafeAccessorAttribute Generic Parameters

6. Performance Improvements

The .NET team has made many performance improvements that not only enhance developer experience but improve application performance. The following are the key performance improvements that the team has made:

  • Loop Optimizations: There are many improvements in loop optimization like induction-variable widening and post-indexed addressing that help optimize memory access with loop-index variables. Other compiler optimizations include strength reduction and loop counter variable direction.
  • AVX10v1: .NET 9 provides support for Advanced Vector Extensions (AVX10v1), a new SIMD instruction set provided by Intel.
  • New Constant Folding: The .NET 9 release comes with new constant-folding features for SIMD and floating-point numbers.
  • Reduced Address Exposure: The JIT compiler in .NET 9 helps avoid unnecessary address exposure by tracking the usage of local variables.
  • Better Exception Handing: A new approach to exceptional handling is added to CoreCRL that enhances the performance of exception handling.
  • Improved PGO Implementation: It helps profile more code patterns.

7. Improvements in .NET SDK

The workload sets feature is added to the .NET 9 SDK that denotes a group of workloads in the SDK with a specific version number. This version number can be used in workload-set update mode with update, install, or restore commands.

Integration of MSBuild with unit testing improved that offers parallel testing. There is also an improvement in NuGet security audit that now runs transitive and direct package references by default. MSBuild Script Analyzers are updated.

8. Improvements in .NET Libraries

Two new methods “AggregateBy” and “CountBy” are added in LINQ that help in aggregating state by key. With these methods, developers aren’t required to allocate intermediate groupings that are done using the “GroupBy” method.

There is also an improvement in collections as a new Remove(TElement, TElement, TPriority, IEqualityComparer<TElement>) method is added to the System.Collections.Generic.PriorityQueue<TElement,TPriority> type.

The release of .NET 9 also brings improvement in cryptography with the addition of a new one-shot hash method. Also, new classes are added that will utilize the KMAC algorithm for encryption.

Stay Up to Date with the Evolving .NET Technologies to Develop Cutting-Edge Applications

Let’s Build

Upgrade to .NET 9 For the Latest FeaturesThe .NET platform is continuously evolving to provide new features, performance enhancements, and security updates. Upgrading to the latest version provides the benefits of these improvements and updates. In 2024, the release of .NET 9 offers many kinds of improvements that boost performance and security. Plus, it also provides new features to improve the development experience.Using the latest technologies and tools is the core focus of our .NET development services as we help our clients get state-of-the-art solutions. By leveraging the latest technologies, we make sure that our clients get the best features, benefits, and top-notch security for their applications. We are ready to help you upgrade your existing applications to .NET 9.We ensure a smooth and hassle-free upgrade with zero downtime. Our team is there for you to resolve any challenges that come during migration and complete the whole process without breaking your existing functionality. Get in touch for a consultation on migration with our experts.

Don't Forget to share this post!

Jitendra Prasad

Jitendra Prasad

Verified
Verified Expert in Engineering
View All Posts

About the Author

Jitendra Prasad is a tech-savvy individual and works as a Technical Innovator at Radixweb. His expertise spans across various next-gen technologies, such as Angular, MVC, .NET/C#, .Net Core, Testcase, and Entity Framework. At Radixweb, he is known for his informed decision-making, practical solutions, and excellent problem-solving capabilities. His thorough understanding of software development and meticulous approach to testing helps us deliver unmatchable client experiences.