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 for Converge360.

comments powered by Disqus

Featured

  • See Prompts Microsoft Engineers Use for Bleeding-Edge Multimodal RAG AI Research

    Vision-centric queries show how front-line experts are prompting LLMs these days.

  • AI Explains Expressions in Update to Java on VS Code

    "The Spring Tools now show code lenses above these expressions that allow you to quickly let GitHub Copilot explain those statements for you."

  • Microsoft Eases Integration with Semantic Kernel AI SDK

    The basic idea is to provide unified API abstractions, especially for idiomatic C# code, to help platform developers and others work with any provider with standard implementations for caching, telemetry, tool calling and other common tasks.

  • Final .NET 9 Preview Ships with Go-Live License

    Visual Studio developers can now download the SDK for .NET 9 Release Candidate 2 with a go-live license, meaning devs get Microsoft support for production applications even before the framework reaches general availability next month.

Subscribe on YouTube