Unveiling .NET 8 : Exploring its Cutting-Edge Features

Microsoft released .NET 8, the latest iteration of this powerful framework, on November 14th, 2023. This version, marked as the newest Long-Term Support (LTS) release, emphasizes enhanced security, performance, and stability, reshaping the landscape of intelligent, cloud-native applications and high-traffic services.

As we know, .NET offers many pre-written code collections(libraries), essential in building applications. Combining these codes with developer-friendly tools and reliable execution platforms, secure and scalable software applications can be created.

It is imperative to keep up with the dynamic field of software development and explore the potential it holds in transforming the methods of creating applications. Wide-ranging language models, like OpenAI’s GPT, can easily be integrated into .NET 8.

Let’s look at the newest features of .NET 8

• .NET runtime

The latest update in .NET 8 runtime shows improved speed in garbage collection, performance, and globalization for mobile applications through faster code processing, and lowering the load, in turn reducing the overall time taken at the time of execution. This facilitates faster application performance.

The new hybrid globalization mode on iOS, tvOS, and MacCatalyst platforms uses a smaller size ICU bundle with the icdut_hybrid.dat file being up to 34% smaller than the default icdut.dat file. This can be done by setting the HybridGlobalization MSBuild property to true.

• .NET SDK and Tooling

In .NET 7, third-party tools were needed to identify issues and monitor the health of applications, but in .NET 8, these concerns are taken care of with the help of new features like .NET SDK, Native AOT, code analysis, and diagnostics, which do the job within itself.

• C# 12

The updated features in C# 12 are collection expressions, primary constructors, experimental attributes, and default lambda expressions.

Collection expressions introduce a new syntax in creating common collection values and the spread operator () can be used to inline other collections into these values.

The following example expresses the use of spread operator(..) in collection expressions:

The experimental attribute is available to mark a type, method, or assembly as an experimental feature. The compiler then issues a warning if a method is used that has been annotated with the Experimental attribute.

• .NET Aspire

.NET Aspire is a cloud-ready stack for building applications that are observable, distributed, and production-ready. It is delivered through a collection of NuGet packages that handle specific cloud-native concerns and has features for running and connecting multi-project applications and their dependencies. It also comes with project templates for Visual Studio that help to create and interact with .NET Aspire applications.

• ASP.NET Core

The updates in ASP.NET Core are related to Blazor, SignalR, Minimal APIs, Native AOT, authentication, and authorization.

.NET 8 Blazor comes with a full-stack web UI framework. It handles both, the client and server simultaneously, thereby reducing the time taken to load pages.

MapIdentityAPI adds two new API endpoints, /register and /login that make it easier for developers to perform authentication in Javascript single-page apps.

Swagger UI endpoints can now be secured in Production using MapSwagger.RequireAuthorization()

Apps published using .NET native ahead of time (AOT) show better performance due to smaller app sizes, less memory usage, and faster startup time. The new ASP.NET Core Web API (Native AOT) project template has been created with AOT publish enabled.

However, some libraries use dynamic features that have compatibility issues when used with native AOT, such as the use of reflection to inspect and discover types, conditionally loading libraries at runtime, and generating codes to implement the functionality. In such cases, updates are essential and can be done using tools like Roslyn source generators.

SignalR – There is a new approach to set the ServerTimeout and KeepAliveInterval values.

Prior approach:

New approach:

• .NET MAUI

While the focus of .NET MAUI is quality, it now includes new functions for controls, gesture recognizers, Windows apps, navigation, and platform integration, along with some behaviour changes and many performance enhancements.

• Windows Presentation Foundation

Windows Presentation Foundation (WPF) changes include hardware acceleration and a new control for browsing and selecting folders. It offers an extensive collection of tools and libraries for developing engaging and aesthetically pleasing user interfaces. WPF allows for the separation of design and logic in application development by using XAML (Extensible Application Markup Language) to define user interface elements.

• EF Core

Entity Framework Core improvements include changes made to complex type objects primitive collections, JSON column mapping enhancements, raw SQL queries, lazy loading, tracked-entity access, model building, math translations, and other features. It also includes a new HierarchyId type.

EF8 requires .NET 8 SDK to build and requires the .NET 8 runtime to run. It won’t run on earlier .NET versions or on the .NET Framework.

• Windows Forms

Upgrades are made to data binding, button commands, Visual Studio DPI, and High DPI- to name a few. The data binding engine was in preview in .NET 7.0 and is now enabled.

Similarly, button commands were in Preview in .NET 7 and are now fully enabled.

Previously the Windows designer tab in Visual Studio ran at the DPI of Visual Studio. Now you can ensure it runs at the same DPI as that of the application. This setting is read when the project is loaded and not when it’s changed. After changing the setting, unload and reload the project.

Final Impressions

With its blend of cross-platform features, diagnostics, and performance improvements, .NET 8 opens the door to wider expansion and innovation in the software development field. Although .NET 7 showed efficiency, .NET 8 seems to be a more compelling option for developers across the world as it lays a solid base for the development of modern software applications, which is the future of application development. With its designation as the latest Long-Term Support (LTS) version, .NET 8 reaffirms its position as a reliable and futuristic platform for building intelligent and cloud-native applications.

WE WOULD LOVE TO HEAR FROM YOU