Altabel Group's Blog

Introducing .NET Standard 2.0

Posted on: November 3, 2016

Recently Immo Landwerth post about .NET Standard 2.0 appeared in the web. Briefly, it is the unification of three major.NET Framework branches: .NET Framework, .NET Core and Xamarin. Simply saying, it is an API set which will be implemented by all platforms. This will join up the .NET platforms and stave off future fragmentation. This means that developers don’t need to master three different base class libraries to write code that runs across all of them. As long as industry is rapidly changing new .NET features will be designed by Microsoft or someone else.

A significant change is that .NET Standard will replace Portable Class Libraries (PCLs) in order to build multi-platform .NET libraries. Although the gist will be the same for developers, but implementation will be different.

The .NET Standard will include two types of APIs, the ones which are absolutely necessary to be implemented by all platforms, and optional APIs, which are not obligatory to be implemented. The last will be available as individual NuGet packages.

The APIs that can not be implemented on all platforms can be divided into two groups: specific APIs for each runtime and specific APIs for each OS. There are three ways to deal with unrealizable API. The first one is to make API unavailable. Secondly, you can make API available, but throw PlatformNotSupportedException on the platforms where there is no implementation. And also you can simulate API (as Mono does, partially simulating the registry as .ini files).

.NET Standard uses all of these variations and their combination, depending on the situation. Technologies that are available only on certain platforms will be implemented as NuGet packages. If it is unreal to make a stand-alone package, then there are options: throw an exception or simulate API.

There are many versions of .NET Standard, which are compatible with different platforms:
 

In this table the arrows are showing the platform ability to support a higher version of .NET Standard. For example, .NET Core 1.0 supports the .NET Standard version 1.6, which is the reason why arrows point to the right for the lower versions 1.0 – 1.5.

As you can see, the 4.6.1 framework version meets twice. With this version exactly .NET Standard 2.0 will be compatible, as well as future versions of Xamarin and .NET Core. There was a roll back of changes that were included in versions 1.5 and 1.6. This was done in order to support backward compatibility. Newer versions of .NET Standard should contain previous and new features. During the analysis of NuGet.org only 6 packages with .NET Standard 1.5/1.6 target platform were found, the author of which is not Microsoft, so it was decided to take 4.6.1 as a basis, and to offer the authors of these 6-packs to update them.

PCL is replaced by .NET Standard, but you are still able to work with it. You can make a reference from one .NET Standard library to another, or to PCL library.

Graphically, this looks as follows:

 

 

In addition, it is possible to make a reference to a conventional .NET library using the compatibility shim.

 

 

But it will only work in case all APIs in this .NET library are supported by .NET Standard. In this case it will be much easier to apply the references to existing libraries.

The following image shows the main APIs of .NET Standard 2.0

 

 
Opportunities which are likely to appear in .NET Core are quite predictable as long as this brunch has less possibilities than others.
As for Xamarin, many of these APIs have been included in the release of Cycle 8 / Mono 4.6.0

Source: .Net Blog.

What do you think about these new features? Please feel free to share your thoughts with us. Thank you in advance!

 

Darya Bertosh

Darya Bertosh

Business Development Manager

E-mail: darya.bertosh@altabel.com
Skype: darya.bertosh
LI Profile: Darya Bertosh

 

altabel

Altabel Group

Professional Software Development

E-mail: contact@altabel.com
www.altabel.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: