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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube