Microsoft is looking to provide “one library to rule them all.” With .Net Standard, developers have to master only a single base library to reach multiple .Net platforms.
The company on Monday shed further light on its plans for .Net Standard to enable code-sharing between applications. .Net Standard features a set of APIs for .Net platforms to implement. It is positioned as a replacement for Microsoft’s Portable Class Libraries going forward and will serve as tooling for building multiplatform .Net libraries.
Currently there are three major “flavors” of .Net — .Net Framework, .Net Core, and Xamarin — which means developers must master three different class libraries to write code that works across all implementations.
“.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 and games, and cloud services,” said Microsoft’s Immo Landwerth, program manager on the .Net team.
Also in the works is .Net Standard 2.0, for implementation by the three .Net variants. Version 2.0 will have an API surface covering XML, serialization, networking, IO, threading, and core capabilities.
“We’ve created .Net Standard so that sharing and re-using code between multiple .Net platforms becomes much easier,” Landwerth said. “With .Net Standard 2.0, we’re focusing on compatibility. In order to support .Net Standard 2.0 in .Net Core and UWP (Universal Windows Platform), we’ll be extending these platforms to include many more of the existing APIs.” This will also include a compatibility shim for referencing binaries that were compiled against the .Net Framework.
Tooling for .Net Standard 2.0 will ship in the same time frame as the upcoming release of Visual Studio, now called Visual Studio 15, Landwerth said. The Dev 15 release currently is available in a preview form; Microsoft declined to state when it would be generally available. Developers will reference .Net Standard as a NuGet package. “It will have first-class support from Visual Studio, VS Code, as well as Xamarin Studio,” Landwerth said.
.Net Standard is needed because of forking that has occurred on the .Net platform, according to Microsoft. “On the one hand, this [forking] is actually a really good thing. It allowed tailoring .Net to fit the needs that a single platform wouldn’t have been able to,” said Landwerth. “But on the other hand, this forking poses a massive problem for developers writing code for multiple .Net platforms because there isn’t a unified class library to target.”
.Net Core, which provided cross-platform implementation of Microsoft’s .Net runtime, was intended to lay the foundation for a portable .Net platform to unify APIs. “Unfortunately, it didn’t result in a great tooling experience,” said Landwerth. “Since our goal was to represent any .Net platform, we had to break it up into smaller NuGet packages.”
Microsoft plans to ship updated versions of .Net Core, Xamarin, and UWP that will add APIs to support .Net Standard 2.0. .Net Framework 4.6.1 already implements APIs that are part of .Net Standard 2.0.