News

.NET Standard 2.0 Is Finalized for Consistent API Usage

The open source .NET Standard 2.0 project was finalized today, providing a formal spec for .NET APIs that should be available to developers working with all .NET implementations.

With finalization, developers can now create .NET Standard 2.0 libraries and NuGet packages, Microsoft program manager Immo Landwerth announced in a GitHub issue.

The .NET Standard project for Visual Studio 2017, hosted on a GitHub site belonging to the .NET Foundation, was announced last September. Microsoft said .NET Standard will replace Portable Class Libraries (PCLs) as the de-facto tooling story used by developers for building multi-platform .NET libraries.

".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 services," Microsoft said in a huge blog post (with nearly 200 comments) explaining the standard in detail.

Apparently facing developer confusion about exactly what .NET Standard is for, Microsoft has devoted some guidance to explaining it, even pointing to an analogy written by David Fowler.

Furthermore, Microsoft explains the difference between the .NET Standard and .NET Core in a FAQ. "NET Standard is a specification that covers which APIs a .NET platform has to implement," it says. ".NET Core is a concrete .NET platform and implements the .NET Standard."

Other developers took a stab at describing it in a Hacker News post. "Conceptually, I think of it in terms of browsers and browser standards," said one commenter identifying as a Microsoft .NET team member. "The relationship between .NET Standard and the various .NET platforms (.NET Core, .NET Framework, Mono, Xamarin, UWP, etc.) is similar to HTML specifications (e.g. https://www.w3.org/TR/html5/) and individual browsers. Newer HTML features are available on newer browsers, and some browser feature implementation is contextualized (e.g. some web features don't make sense on a mobile phone browser)."

.NET Standard 2.0
[Click on image for larger view.] .NET Standard 2.0 (source: Microsoft).

The new version 2.0 standard introduces no breaking changes from the prior version 1.6, but Microsoft said it was given a major revision number because it's so different from the previous release. The number of differences is so great that the GitHub page created to detail those differences wouldn't display the list, saying the file was too big (the gigantic diff file can be viewed in raw format). The project FAQ said 2.0 more than doubled the API surface and added a compat shim that lets developers reference existing binaries, even if such binaries are not built against .NET Standard or PCLs.

In fact, Landwerth said in his post, the number of available APIs jumped from about 13,000 to 32,000. Regarding the .NET Framework compatibility mode, he said: "The vast majority of NuGet packages are currently still targeting .NET Framework. Many projects are currently blocked from moving to .NET Standard because not all their dependencies are targeting .NET Standard yet. That's why we added a compatibility mode that allows .NET Standard projects to depend on .NET Framework libraries as if they were compiled for .NET Standard.

"Of course, this may not work in all cases (for instance, if the .NET Framework binaries uses WPF), but we found that 70 percent of all NuGet packages on nuget.org are API compatible with .NET Standard 2.0, so in practice it unblocks many projects," he continued.

Visual Studio 2017 15.3 should be used to create .NET Standard 2.0 libraries.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube