.NET Standard is a formal set.NET API specification, expected to be available in all .NET implementations. The motivation behind the introduction of .NET Standard was to improve consistency in the .NET ecosystem. ECMA 335 continues to establish uniformity for .NET implementation behavior, but there is no similar specification for .NET Base Class Libraries (BCLs) for .NET library implementations.
.NET Standard enables the following key scenarios:
- Define a unified, workload-agnostic set of BCL APIs for all .NET implementations that you want to implement.
- Enables developers to build portable libraries that can be used in various .NET implementations through the same set of APIs.
- Reduces or even eliminates conditional compilation of shared source code for .NET API aspects (OS APIs only).
Various .NET implementations target a specific version of .NET Standard. Each .NET implementation announces the highest .NET Standard version it supports, a statement that means it also supports previous versions. For example, the .NET Framework 4.6 implements .NET Standard 1.3. That is, it exposes all APIs defined in .NET Standard versions 1.0 through 1.3. Similarly, .NET Framework 4.6.1 implements .NET Standard 1.4, while .NET Core 1.0 implements .NET Standard 1.6.
The relationship between .NET Standard and .NET implementations is the same as the relationship between HTML specifications and browsers. The latter is the realization of the former.
Therefore, .NET Framework, Xamarin, and .NET Core, each of the managed frameworks implements . NET Standard. As the computer industry continues to introduce new hardware and operating systems, new ones will appear in the future. .NET Hosting Framework. The standard lets application developers know that they can rely on a consistent set of APIs.
Each. .NET versions correspond to a .NET Standard version.
The API is consistent, and porting applications to different managed implementations and providing tools will be simpler.
.NET Standard is defined as a separate NuGet package, because all . .NET implementations must be supported
.NET Standard vs Portable Libraries
Doesn't the portable library do the same thing?
Portable classes use common APIs that are supported by multiple platforms. As a result, the more platforms supported, the fewer APIs available, and for a particular combination of platforms, it can be difficult to know exactly which APIs are supported. For a new platform, the existing PCL must be recompiled. PCL also requires Microsoft to create a new framework implementation fork for each platform. Due to. NET Standard identifies an API, not an implementation, so there is no need to recompile the application. Any newly released . .NET implementations implement the necessary libraries. Applications do not need to be recompiled to run on new hardware platforms or operating systems. Theoretically, a NotSupportedException exception might be caught when calling the API, but that should be rare.
.NET implementation support
The following table lists the minimum platform versions that support each .NET Standard release. This means that later versions of the listed platforms also support the corresponding .NET Standard versions. For example, .NET Core 2.2 supports .NET Standard 2.0 and earlier.
|