.NET 9
Introduction
.NET 9 saw its release during .NET Conf 2024 which is the most productive, modern, secure, intelligent and performant version of .NET yet, you can visit dotnetconf.net for details of all the announcements about .NET 9 and other sessions on .NET.
.NET 9 is more modern and secure including simplified Blazor authentication, improved integration with cloud native services and OpenTelemetry, enhance user interface controls across Blazor, .NET MAUI, WinUI 3 used in Windows AppSDK, Windows Presentation Foundation and Windows Forms along with dotnet restore auditing for known security vulnerabilities.
.NET 9 is where Microsoft are committed to infusing tools and applications with AI using intelligent features such as Microsoft.Extensions.AI for AI building blocks, AI tokenizers, Tensor and TensorPrimitives along with .NET SDKs for vector databases and server-sent event parser.
.NET 9 has seen investment in performance from Microsoft including adaptive garbage collection, up to 25% faster Blazor startup, optimised static web assets, with ref struct improvements, more Native AOT and trimming optimisations along with new NuGet restore resolver for large projects in .NET 9, plus there are over a thousand performance related pull-requests across nearly all aspects of .NET.
.NET 9 is the biggest .NET release which includes thousands of contributions from the community and Microsoft are making sure developers have the tools necessary to build modern apps that they want and the platforms they need such as web, desktop, cloud and with AI with fundamentals such as performance and accessibility. .NET allows developers to focus on what they do best, which is creating cool applications with .NET.
.NET Aspire
.NET Aspire provides the building blocks to create more delightful experiences for your customers. .NET Aspire is a collection of tools, opinionated templates and curated packages for .NET developers and simplifies managing projects, resources, containers, microservices and more at development time and gives you insights while you are developing your application with a streamlined inner-loop. Microsoft have worked with popular cloud library and service authors to create integrations for .NET Aspire that help simplify managing resources to develop applications at scale and have worked with teams in Azure and AWS to get your applications deployed with .NET Aspire.
.NET Aspire helps you though every step of the development journey where you can get started with open-source templates, build with service discovery, developer dashboard along with logs, metrics and distributed traces. NET Aspire features a single command to run your application where application topology can be defined using C# and deploy to the cloud. You can take advantage of built-in open telemetry support and can get up and running in the cloud easily or just use it locally to develop applications more easily. .NET Aspire has an app host which you can develop using a familiar looking API without having to worry about hosts, ports etc as you just need to give the resources names and define which services depend on each other and all the settings and connection details will be injected into the applications automatically by .NET Aspire.
.NET Aspire will wait for resources that are depended on by other services and can also have persistent containers that are kept running between deployments, so you don't have to wait for these to start up again. You can also enable structured logs and tracing that can be viewed in the developer dashboard and can see the real data behind logs and trace view can show the complicated interaction between operations throughout your application and can also integrate with other services that use Open Telemetry. .NET Aspire also supports service defaults such as resiliency and health checks that can be included in your application on day one or added later if the needs of your service changed. Integrations make it easy to integrate hosting integrations such as cloud services, Redis and RabbitMQ and client integrations are ones used by the actual applications themselves so can integrate things such as an event bus easily and use features such as dependency injection and can use companion services that make developer lives easier.
.NET Aspire also has a useful functionality that can be easily discovered and used with the .NET Aspire Community Toolkit and there is preview support for Azure Functions in .NET Aspire. .NET Aspire has helped the Xbox team tighten their inner development loop and helped with logging and metrics and the Microsoft Copilot team rebuilt the complete backend from scratch of Microsoft Copilot using .NET Aspire in just four months with a small team to be scalable and is three times faster with a third of the code but with feature parity of the previous version, they also took advantage of integrated Docker support to trace requests across services and reached five nines reliability with Microsoft Copilot and to build highly scalable and reliable services they highly recommend using .NET Aspire.
AI
AI integration with .NET is something Microsoft have been dedicated over the past couple of years to make it easier and simpler to integrate. Intelligent applications built on .NET include not only Microsoft Copilot and GitHub Copilot but other top-tier AI experiences such as KPMG Clara where .NET allowed them to deploy onto Azure with industry leading features to allow them to build an AI solution that empowers their audit professionals to improve audit quality and focus on higher risk areas with their .NET stack supporting rapid development of those AI features with the language and tools that their developers know and love with .NET.
AI ecosystem is rapidly evolving, and Microsoft are streamlining their AI integration with their unified APIs with Microsoft.Extensions.AI which supports common AI abstractions with standard middleware for interoperability and extensibility which will ease AI adoption into solutions to provide a straightforward and quicker way to integrate AI functionality into their applications and Microsoft.Extensions.AI is available in preview now for .NET 9. Developers using Microsoft.Extensions.AI to accelerate their AI development include Pieces which is an AI productivity toolchain for developers, and they were able to integrate Microsoft.Extensions.AI into their own SDK in just a few hours to provide their SDK users a simpler way to integrate the long-term memory of Pieces into their .NET applications.
ASP.NET Core & Blazor
ASP.NET Core is the full-stack platform for web apps and scalable web services for .NET. ASP.NET Core gives you everything you need to develop to provide access to back-end data with minimal APIs or web applications with Blazor. In .NET 9 there has been a focus on quality and fundamentals in ASP.NET Core to provide the best developer experience possible such as built-in OpenAPI support and expanded support for AoT compilation. .NET 9 includes the fastest ASP.NET Core yet with up to 15% more throughput, 93% reduction in memory usage on high core-count machines and a 25% reduction in startup time for Blazor WebAssembly along with WebSocket message compression for Blazor Server plus precompression and improved caching for static web assets which also includes fingerprinting to make sure the latest resources are loaded and can be aggressively cached.
C# 13
C# 13 includes minor improvements and enhancements to the language to make it easier to use, including features from C# 1.0 with params but to add support for generics which was originally added in C# 2.0 to include IEnumerable of a generic type for params in C# 13 which takes advantage of collection expressions from C# 12 to allow params on collection types or anything you can create with collection expressions so that arguments can be passed in as collections which can include Span or ReadOnlySpan and there will be work in C# 14 to make them even better and make spans first class citizens. You can also add an OverloadResolutionPriority attribute when using different members of the same type if needed to fine tune any APIs if you're having any issues with rules but want to keep existing code compatible but add new overloads to take advantage of new types such as span then only those with the highest priority will be the one used and if not will then go to the next lowest priority if needed for those libraries written in C# 13
C# has had partial methods for some time but recently they have been used mostly in source generators which can be a hook where a source generator will provide an implementation for. Before C# 13 you could only have partial methods but now in C# 13 you can now have partial properties where you can use same auto property syntax but only to create the definition of the property as a developer you still need to provide this so partial auto properties aren't supported. In C# any object can be locked and used with monitor classes and there are so many locks to choose from in .NET but there is only one that is used with lock keyword but with the new System.Threading.Lock in C# 13 that works with the lock keyword and it is for similar scenarios but it is more slim and lightweight than the previous monitor based lock so when used with the same lock keyword it will use the more efficient type but there are guardrails to warn about the wrong lock type being used.
C# has a feature that is in only in preview in .NET 9 and not part of the language proper where within an auto property you can access the backing field with the new field keyword and don't need to implement both property accessors as with an auto property you have a backing field generated for you than you can access which is the same type as the property generated. This is a breaking change as there are backing values called field in existing code bases, but inside accessors it is a keyword, but this is the best design but needs more of a breaking change so then have a new approach to how to do these, but there would only be one per release if any. The experience would be to use this.field or @field if there is a backing field called field already but will be ready to go for C# 14 but are looking for feedback so that the tooling experience is correct and this breaking change can be dealt with, with confidence.
C# 13 for ref structs are used by spans which have to live on the stack but you can enable the ability to implement and interface such as IDisposable with a Dispose method but it can't be converted to an IDisposable as it cannot be boxed but to allow this with a generic you can add an allows ref struct as an anti-constraint for a generic and then update the code to implicitly allow these in a method, before this a ref struct couldn't take part of any abstraction but it is now a first class thing that is being enabled for ref structs which will come in future versions of .NET.
Summary
.NET 9 includes updates to .NET Aspire making it easier than ever to build observable, reliable, scalable and manageable applications and partnering with industry leaders in AI to infuse applications with AI with Microsoft.Extensions.AI along with improvements and functionality for ASP.NET Core and optimised web asset handling in Blazor along with adaptive garbage collection for improved memory management, C# 13 plus a whole host of other features and functionality. Visit dot.net to get started, learn more and to download the latest runtime or SDK for .NET 9 or you can listen about .NET 9 on the RoguePlanetoid Podcast.