Microsoft's Adam Tuliper on the .NET Standard and Porting Your .NET Code
Microsoft Principal Software Engineer Adam Tuliper explains the .NET Standard, a formal specification of .NET APIs that are intended to be available on all .NET implementations in order to establish greater uniformity in the .NET ecosystem.
Creating .NET code that runs across the various .NET platforms is challenging on many levels, complicated by the need to accommodate many different runtimes and versions. For example, how do developers move code between Unity, Xamarin, .NET Core, .NET Framework, UWP or other .NET platforms? To answer those questions and more, Adam Tuliper, a principal software engineer at Microsoft, will present a session at the upcoming Visual Studio Live! Boston conference titled "Getting to the Core of the .NET Standard." Here, he offers more information on how .NET Standard makes targeting multiple platforms much easier than ever before.
Why was the .NET Standard created?
Creating portable code was difficult at times. With profile-based Portable Class Libraries (PCLs), you had to know the platforms ahead of time. The .NET Standard makes it easier for developers to create reusable code.
What is important for developers to understand about how the .NET standard is built and how it is versioned?
In order to understand how the .NET standard works, it is important to know how it is versioned. For example, the .NET Standard, for all intents, tries to be completely forward-compatible to ensure old code continues to work. It is also important to understand what new APIs are supported. We have several ways of looking this up, through the API Browser but also directly in the .NET Standard definition.
"Microsoft goes through great lengths to ensure the APIs supported are worthwhile. Creating an API is easy. Creating an API that is relevant years from now takes a lot more thought."
Adam Tuliper, Principal Software Engineer, Microsoft
Microsoft goes through great lengths to ensure the APIs supported are worthwhile. Creating an API is easy. Creating an API that is relevant years from now takes a lot more thought.
What are the top 3 benefits that developers can expect to get out of transitioning to using the .NET Standard?
The top three benefits are:
- Blissful ignorance of the future platforms your code may run on -- you don't necessarily need to care now.
- Immediate code sharing across your .NET platforms (.NET Framework, .NET Core projects, Unity, UWP, Xamarin and more!)
- Simplified development experience in creating a class library compared to profile-based PCLs. Simply create a project and target a .NET Standard version; there's no need worry about choosing platforms or installing targets.
What are the most important steps that developers need to take to make their code portable under the .NET Standard?
The process is pretty easy. If it's new code, simply developing with a .NET Standard Library project type will keep you within constraints. If you are unfamiliar with what APIs are supported, they can be viewed in the .NET Standard specification. For existing code, you can run the API Portability Analyzer.
What's another interesting feature about the .NET Standard?
The type forwarding that happens behind the scenes is a fascinating process. It enables, for example, a DataSet to exist in difference assemblies (like System.Data in .NET Framework and System.Data.Common in .NET Core) and be able to resolve to the correct location at run time.
What else should developers know about this topic?
The .NET Standard is a fairly simple concept, don't overcomplicate it. It's essentially a contract that the compiler enforces for a set of APIs to deem your library a .NET Standard library. There's a bit more to the process, but in a nutshell that's the idea.
Becky Nagel is the vice president of Web & Digital Strategy for 1105's Converge360 Group, where she oversees the front-end Web team and deals with all aspects of digital projects at the company, including launching and running the group's popular virtual summit and Coffee talk series . She an experienced tech journalist (20 years), and before her current position, was the editorial director of the group's sites. A few years ago she gave a talk at a leading technical publishers conference about how changes in Web browser technology would impact online advertising for publishers. Follow her on twitter @beckynagel.