Microsoft has updated the .NET Standard after almost one year. Since .NET Standard 2.0 was released, the company introduced new updates to .NET Core 2.1 and is working its way towards .NET Core 2.2. This week, .NET Standard 2.1 is being announced to include new updates and concepts implemented over the last year as well as small improvements designed to make implementations of .NET easier.
“.NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud service,” Microsoft wrote in its GitHub repository. The standard is a set of APIs for .NET platforms to implement.
The goals of the .NET Standard 2.1 was to include Span<T> for representing managed and unmanaged memory in a uniformed way, core APIs working with spans, and general features across the base class libraries, the team explained. The update to the standard features about 3000 APIs, including brand new APIs and updates to existing APIs.
The team reached its goal with the addition of Span<T>. “It’s at the heart of most performance-related improvements in .NET Core 2.1. Since it allows managing buffers in a more efficient way, it can help in reducing allocations and copying. We consider Span<T> to be a very fundamental type as it requires runtime and compiler support in order to be fully leveraged,” Immo Landwerth, program manager on .NET at Microsoft, wrote in a post. Span<T> is available as a .NET Standard compatible NuGet package. The team also added foundational APIs or companion APIs for working with Span<T> to expanded its availability.
To improve productivity, the team announced reflection and reflection emit. “Emit is often used as a tool to optimize performance as well as a way to generate types on the fly for proxying interfaces. As a result, many of you asked for reflection emit to be included in the .NET Standard,” Landwerth wrote.
For “general goodness” base class libraries like System.HashCode and System.String have been updated.
According to the team, .NET Standard 2.1 is still a work in progress. For now, .NET Framework 4.8 will remain on .NET Standard 2.1. .NET Core 3.0, Xamarin, Mono, and Unity will be updated to .NET Standard 2.1. “Library authors who need to support .NET Framework customers should stay on .NET Standard 2.0. In fact, most libraries should be able to stay on .NET Standard 2.0, as the API additions are largely for advanced scenarios,” Landwerth wrote.