building great libraries with net standard
play

Building Great Libraries with .NET Standard C h a d G r e e n C o - PowerPoint PPT Presentation

Building Great Libraries with .NET Standard C h a d G r e e n C o d e P a L O U s a 2 0 1 9 A u g u s t 2 3 , 2 0 1 9 @chadgreen Who is Chad Green Director of Software Development at ScholarRx Microsoft MVP (Developer Technology)


  1. Building Great Libraries with .NET Standard C h a d G r e e n C o d e P a L O U s a 2 0 1 9 A u g u s t 2 3 , 2 0 1 9 @chadgreen

  2. Who is Chad Green • Director of Software Development at ScholarRx • Microsoft MVP (Developer Technology) � chadgreen@chadgreen.com  chadgreen.com � ChadGreen � ChadwickEGreen @chadgreen

  3. Agenda B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d Quick History Choosing the 1 1 2 2 Lesson Right Version Referencing When to Use 3 3 4 4 .NET Framework .NET Standard Libraries Platform Specific Guidelines for 6 5 5 Code Great Libraries @chadgreen

  4. Quick History Lesson B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  5. Microsoft Development Tools Up to .NET • MicroSoft Basic @chadgreen

  6. Microsoft Development Tools Up to .NET • MicroSoft Basic • QuickBASIC @chadgreen

  7. Microsoft Development Tools Up to .NET • MicroSoft Basic • QuickBASIC • Visual Basic @chadgreen

  8. Introduction of Microsoft .NET • Java • Managed Runtime • Runtime of many names • COM+ • Compound Object Runtime (COR) • Universal RunTime (URT) • Next-Gen Windows Service (NGWS) • .NET @chadgreen

  9. Introduction of Microsoft .NET • Microsoft actually wanted industry support • Took specifications to ECMA • ECMA 334 – C# Language Specification • ECMA 335 – Common Language Infrastructure (CLI) • Microsoft, HP, Intel were core sponsors @chadgreen

  10. Microsoft .NET • Introduction of CLR • Support for object-oriented Web application development • Use of DLL class libraries @chadgreen

  11. So why something different? • .NET – a set of verticals @chadgreen

  12. So why something different? • .NET – a set of verticals • Birth of portable class libraries @chadgreen

  13. It’s a Whole New World B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  14. @chadgreen

  15. It’s a whole new world .NET Framework .NET Core Xamarin Windows Only Windows, Linux, iOS, Android Mac OS @chadgreen

  16. It’s a whole new world .NET Framework .NET Core Xamarin .NET Standard @chadgreen

  17. What is .NET Standard? Defines a set of APIs that all Not another A Specification .NET platforms .NET platform have to implement @chadgreen

  18. What is .NET Standard? .NET Core .NET .NET Standard Xamarin Framework @chadgreen

  19. What is .NET Standard? .NET Core Portal Portal Library Library .NET Xamarin Framework Portal Library @chadgreen

  20. What is .NET Standard? Portable Class Libraries .NET Standard • • Intersection profile are computed Set of APIs that are selected by humans • Depend on the targeted platform • Independent from any .NET • No systematic versioning approach Platform • Versioned linearly and backward compatible @chadgreen

  21. What is .NET Standard? @chadgreen

  22. OK, so which framework am I supposed to use? .NET Framework .NET Core .NET Standard Windows Only Windows, Linux, Cross .NET Mac OS Platform @chadgreen

  23. Demo B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  24. Choosing the Right Version B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  25. Choosing the Right Version 2.1 2.0 • A .NET Standard version contains all APIs 1.6 from the previous versions 1.5 1.4 1.3 • A .NET platform implements a specific 1.2 .NET Standard version 1.1 1.0 • Every .NET Standard version is immutable @chadgreen

  26. Choosing the Right Version A higher version A lower version Target the means more means less APIs, lowest possible APIs, but less but more version platforms platforms @chadgreen

  27. Choosing the Right Version @chadgreen

  28. Choosing the Right Version @chadgreen

  29. Choosing the Right Version @chadgreen

  30. Choosing the Right Version @chadgreen

  31. Choosing the Right Version @chadgreen

  32. Choosing the Right Version @chadgreen

  33. Choosing the Right Version @chadgreen

  34. Choosing the Right Version @chadgreen

  35. Choosing the Right Version https://dotnet.microsoft.com/platform/dotnet-standard @chadgreen

  36. Choosing the Right Version A higher version A lower version Target the means more means less APIs, lowest possible APIs, but less but more version platforms platforms @chadgreen

  37. Choosing the Right Version .NET Standard 2.1 • Span<T> @chadgreen

  38. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans @chadgreen

  39. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans • Reflection emit @chadgreen

  40. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans • Reflection emit • SIMD (Single Instruction, Multiple Data) • ValueTask and ValueTask<T> @chadgreen

  41. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans • Reflection emit • SIMD (Single Instruction, Multiple Data) • ValueTask and ValueTask<T> @chadgreen

  42. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans • Reflection emit • SIMD (Single Instruction, Multiple Data) • ValueTask and ValueTask<T> • DBProviderFactories @chadgreen

  43. Choosing the Right Version .NET Standard 2.1 • Span<T> • Foundational APIs working with spans • Reflection emit • SIMD (Single Instruction, Multiple Data) • ValueTask and ValueTask<T> • DBProviderFactories • General Goodness @chadgreen

  44. Referencing .NET Framework Libraries B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  45. Referencing .NET Framework Libraries .NET .NET Standard .NET Core Framework Class Library Console App Console App .NET Framework .NET Portability .NET Compatibility Shim Analyzer Framework Class Library @chadgreen

  46. When to Use .NET Standard B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  47. When to Use .NET Standard – New @chadgreen

  48. When to Use .NET Standard – Migration Already Library is .NET Need to use it reference it in a Standard on different .NET Standard Compatible .NET Platforms class library @chadgreen

  49. Platform Specific Code B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  50. Windows Compatibility Pack • Microsoft.Windows.Compatibility (NuGet package) • Can be referenced from .NET Core as well as .NET Standard • Has ~21k APIs (Windows-only as well as cross- platform) • Contents Ports Drawing ACLs Registry EventLog Code Pages Runtime Caching MEF v1 Code Dom WCF ODBC Configuration Windows Services Perf Counters Crypto Permissions DirectoryServices @chadgreen

  51. Multi-Targeting Best Practices • DO start with the .NET Standard 2.0 • Most general purpose libraries will not need APIs outside this set • CONSIDER targeting multiple frameworks • If you need to call platform-specific APIs outside of .NET Standard • DO NOT drop support for .NET Standard • Instead, throw from the implementation and offer capability APIs. This way, your library can be used anywhere and supports runtime light-up. • DO share your component using a NuGet package • It shields consumers from having to pick the appropriate implementation @chadgreen

  52. Guidelines for Great Libraries B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d @chadgreen

  53. Versioning Kind When to increment Comment Package Version Every change The ID of the NuGet package. Assembly Version As you see fit The version number of the assembly. Used by the loader to resolve assemblies. File Version Every change Generic concept, used by installers to determine which file is newer. Informational As you see fit Display string, does not need Version to be a version. @chadgreen

  54. Best Practices • DO follow the API Design Guidelines • Do target .NET Standard 2.0 • CONSIDER using multi-targeting to allow for platform- specific code • CONSIDER dual-targeting for .NET Framework 4.6.1 • DO use NuGet for packaging multi-targeted libraries • DO throw PlatformNotSupportedExecption for unsupported APIs • DO strong name your libraries • AVOID if your library cannot be used on .NET Framework @chadgreen

  55. Questions B u i l d i n g G r e a t L i b r a r i e s w i t h . N E T S t a n d a r d � chadgreen@chadgreen.com  chadgreen.com � ChadGreen � ChadwickEGreen Slides will be available on my site @chadgreen

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend