We Know .NET 7 Is Good, But What About .NET 8?

Ollie Spear
The Tech Collective
4 min readApr 7, 2023
Generated by Bing Image Creator https://www.bing.com/create

The .NET Framework has been around for just over 2 decades from it’s inception back in 2002, in which time it has undergone tremendous evolution through several releases, name changes (.NET Framework, .NET Core and now .NET 5 6 7 and soon to be 8) and of course new functionality offerings. .NET has become a popular and widely used platform for developing applications across the powerhouse triumvirate of operating systems: Windows, Linux and macOS.

Overview of .NET 7

.NET 7, the most recent version of the .NET platform, was released as a standard-term support (STS) version back in November 2022. This release included a plethora of both significant and minor feature enhancements and additions, including:

  • Entity Framework Core improvements
  • ASP.NET Core improvements
  • Support for C# 11
  • Many .NET library improvements including Regular expression matching and substantial extensibility of the System.Text.Json library
  • Further added support and functionality for cross platform development which I have covered in a separate article
  • Multiple Performance improvements made to code generation for Arm64, the Mono runtime and Native Ahead Of Time (AOT) deployment

Expected .NET 8 Features and Release Date

Following the .NET release cadence of major releases we can expect to see the first official release of .NET 8 in November 2023, with .NET 8.0.0 Preview 2 being the most recent release currently available for download. Given that .NET 8 is still in in pre-release stages, the final product may differ from anticipated and expected features, so for the purposes of this article we’ll stick to some of the anticipated features and improvements that could ship with .NET 8.

As previously mentioned, there have already been significant functionality improvements and additions to the System.Text.Json library (which for those who missed that memo is a performant standards-compliant JSON processing library including serialization and deserialization capabilities) but .NET 8 is planning to take it even further. By default, if you’re deserializing a JSON payload that contains properties that don’t exist in the deserialized object type they are currently ignored. From .NET 8 onwards you will be able to specify on a property level basis whether the deserialization should skip the missing property or fail and throw a JsonException. The following code snippet shows the Name property from the JSON payload is unable to be mapped to MyClass as it does not exist, causing a JSONException to be thrown.

//Annotation responsible for throwing when an unmapped property is found
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public class MyClass
{
public int Id { get; set; }
public string Superpower { get; set; }
}


JsonSerializer.Deserialize<MyClass>(""" { "Id" : 42, "Name" : "Terry" } """);
// JsonException : The JSON property 'Name' could not be mapped
// to any .NET member contained in type 'MyClass'.

Another feature that was introduced to .NET 7 was Native AOT deployment which grants users the ability to produce self-contained applications that have faster startup times, a smaller memory footprint and no longer needs a local runtime to run as everything is included in a single file. .NET 8 plans to improve this further by adding support for Native AOT deployment for both x64 and Arm64 architectures on macOS.

There have been other smaller changes made as part of the .NET 8 Preview 1 release including the following:

  • Changes to the dotnet publish and dotnet pack commands to produce release assets by default
  • Improvements to code generation, including Arm64 performance improvements and Just In Time (JIT) throughput improvements
  • Function pointers have been improved to return a System.Type object rather than an IntPtr Struct which now offers information about the function pointer like how it is called, what it returns and what parameters it takes.

Considerations for upgrading to .NET 8

Like every upgrade to a new version of .NET, switching to .NET 8 can offer numerous advantages. However, it’s crucial to understand any possible behavioural or breaking changes that could affect your project, and upgrading to .NET 8 is no exception. One notable breaking change is related to directory separators on Unix systems. Unlike previous versions, the native CoreCLR runtime in .NET 8 is set to no longer automatically convert backslashes to forward slashes. This means that in your applications you’ll need to use the Path.DirectorySeparatorChar value instead of hardcoding backslashes or forward slashes.

Other smaller changes include a return type change for function pointers from an IntPtr struct to a System.Type object, the removal of Legacy methods such as Console.ReadKey(), CLI console output encoding changes to use UTF-8 and configuration changes to the dotnet publish and dotnet pack commands to use Release configuration by default.

Conclusion

In conclusion, .NET 8 is set to be a major release packed full of exciting features, including support for Arm64 architectures for Native AOT deployments, many library enhancements and under the hood performance improvements with many more yet to come as more preview versions are released. As the latest Long Term Support (LTS) major release, it will also receive 3 years worth of patches, ensuring that developers have a stable and secure platform to build their applications on. With these enhancements, .NET 8 promises to offer even greater performance and flexibility for developers working on a wide range of projects. So get ready to unleash your creativity and take advantage of all that .NET 8 is set to offer!

I hope you enjoyed reading my article and found it interesting! Feel free to let me know if you have any improvements and/or corrections.

--

--

Ollie Spear
The Tech Collective

Software Engineer writing about software development and programming languages