-
-
Save MKGAURAB/b0ce03030363930e1ba4aeafe6f6032e to your computer and use it in GitHub Desktop.
How .NET Standard relates to .NET Platforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace Analogy | |
| { | |
| // Each interface represents a target framework and methods represents groups of APIs available on that target framework. | |
| // The goal is to show the relationship between .NET Standard API surface and other .NET platforms | |
| // .NET Standard | |
| interface INetStandard10 | |
| { | |
| void Primitives(); | |
| void Reflection(); | |
| void Tasks(); | |
| void Xml(); | |
| void Collections(); | |
| void Linq(); | |
| } | |
| interface INetStandard11 : INetStandard10 | |
| { | |
| void ConcurrentCollections(); | |
| void LinqParallel(); | |
| void Compression(); | |
| void HttpClient(); | |
| } | |
| interface INetStandard12 : INetStandard11 | |
| { | |
| void ThreadingTimer(); | |
| } | |
| interface INetStandard13 : INetStandard12 | |
| { | |
| void FileSystem(); | |
| void Console(); | |
| void ThreadPool(); | |
| void Crypto(); | |
| void WebSockets(); | |
| void Process(); | |
| void Sockets(); | |
| void AsyncLocal(); | |
| } | |
| interface INetStandard14 : INetStandard13 | |
| { | |
| void IsolatedStorage(); | |
| } | |
| interface INetStandard15 : INetStandard14 | |
| { | |
| void AssemblyLoadContext(); | |
| } | |
| // .NET Framework | |
| interface INetFramework45 : INetStandard11 | |
| { | |
| void FileSystem(); | |
| void Console(); | |
| void ThreadPool(); | |
| void Crypto(); | |
| void WebSockets(); | |
| void Process(); | |
| void Drawing(); | |
| void SystemWeb(); | |
| void WPF(); | |
| void WindowsForms(); | |
| void WCF(); | |
| } | |
| interface INetFramework451 : INetFramework45, INetStandard12 | |
| { | |
| // TODO: .NET Framework 4.5.1 specific APIs | |
| } | |
| interface INetFramework452 : INetFramework451, INetStandard12 | |
| { | |
| // TODO: .NET Framework 4.5.2 specific APIs | |
| } | |
| interface INetFramework46 : INetFramework452, INetStandard13 | |
| { | |
| // TODO: .NET Framework 4.6 specific APIs | |
| } | |
| // Windows Universal Platform | |
| interface IWindowsUniversalPlatform : INetStandard13 | |
| { | |
| void GPS(); | |
| void Xaml(); | |
| } | |
| // Xamarin | |
| interface IXamarinIOS : INetStandard15 | |
| { | |
| void AppleAPIs(); | |
| } | |
| interface IXamarinAndroid : INetStandard15 | |
| { | |
| void GoogleAPIs(); | |
| } | |
| // .NET Core | |
| interface INetCore10 : INetStandard15 | |
| { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Analogy | |
| { | |
| class Example1 | |
| { | |
| public void Net45(INetFramework45 project) | |
| { | |
| // .NET Framework 4.5 has access to all APIs | |
| project.FileSystem(); | |
| // This fails because .NET Framework 4.5 does not implement .NET Standard 1.3 | |
| // Argument 1: cannot convert from 'Analogy.INetFramework45' to 'Analogy.INetStandard13' | |
| NetStandardLibrary13(project); | |
| } | |
| public void NetStandardLibrary11(INetStandard11 project) | |
| { | |
| project.HttpClient(); | |
| } | |
| public void NetStandardLibrary13(INetStandard13 project) | |
| { | |
| // Newer .NET Standard compatible libraries work with older ones | |
| NetStandardLibrary11(project); | |
| project.FileSystem(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment