pages

Thursday, 5 July 2018

.NET Standard: What it is and how to use


What really is dot net standard?  

Let me try to put it in simple words. We used to use different BCL's for different frameworks and remembering it is a tough job. So Microsoft once again has come up with a solution to help developers to put a little less load on on the brain to remember the API's. They have replaced all the BCL's with a common one which they are calling as .net Standard. 

.Net Standard 2.0 has around 32,000 API's. You can download the list from here or you can check it here at GitHub.

.Net Standard replaces Portable Class Libraries (PCLs) as the tool for building .NET libraries that work everywhere 


How to use it? 

If you have .net core installed on your machine you can start working on .net Standard just by creating a Class Library. Yes, the old Class library is now Class Library for .net standard. 






For those who understand pictures better or would like to read less. 


Above pictures are taken from a slide of Immo Landwerth. 

The table below can be used as the reference for writing a class library using the standard.

If you are choosing a version for writing .net standard, you should consider a trade-off which is the 
higher the version of .net standard more apis are available. Lower the version, more platforms have already implemented it.

You can follow .net standard on GitHub 

Below are the list of API's added newly in .net standard 2.0

Namespace
#APIs
Microsoft.Win32.SafeHandles 22
System 1,366
System.CodeDom.Compiler 46
System.Collections 335
System.Collections.Generic 23
System.Collections.ObjectModel 1
System.Collections.Specialized 281
System.ComponentModel 1,843
System.ComponentModel.Design 565
System.ComponentModel.Design.Serialization 155
System.Configuration.Assemblies 13
System.Data 1,587
System.Data.Common 907
System.Data.SqlTypes 971
System.Diagnostics 826
System.Diagnostics.CodeAnalysis 2
System.Diagnostics.Contracts 89
System.Diagnostics.SymbolStore 146
System.Diagnostics.Tracing 2
System.Drawing 520
System.Dynamic 226
System.Globalization 217
System.IO 309
System.IO.Compression 8
System.IO.IsolatedStorage 134
System.IO.MemoryMappedFiles 66
System.IO.Pipes 125
System.Linq 366
System.Linq.Expressions 50
System.Net 1,360
System.Net.Cache 52
System.Net.Http.Headers 20
System.Net.Mail 289
System.Net.Mime 75
System.Net.NetworkInformation 696
System.Net.Security 194
System.Net.Sockets 168
System.Net.WebSockets 188
System.Numerics 1
System.Reflection 403
System.Reflection.Emit 3
System.Resources 91
System.Runtime 12
System.Runtime.CompilerServices 190
System.Runtime.ConstrainedExecution 22
System.Runtime.ExceptionServices 6
System.Runtime.InteropServices 106
System.Runtime.InteropServices.ComTypes 15
System.Runtime.Serialization 486
System.Runtime.Serialization.Formatters 13
System.Runtime.Serialization.Formatters.Binary 23
System.Runtime.Serialization.Json 80
System.Runtime.Versioning 33
System.Security 124
System.Security.Authentication 11
System.Security.Authentication.ExtendedProtection 36
System.Security.Claims 206
System.Security.Cryptography 575
System.Security.Cryptography.X509Certificates 76
System.Security.Permissions 88
System.Security.Principal 41
System.Text 83
System.Text.RegularExpressions 31
System.Threading 330
System.Threading.Tasks 66
System.Timers 39
System.Transactions 223
System.Web 32
System.Xml 1,362
System.Xml.Linq 7
System.Xml.Resolvers 25
System.Xml.Schema 967
System.Xml.Serialization 943
System.Xml.XPath 261
System.Xml.Xsl 140