SlideShare una empresa de Scribd logo
1 de 19
C# code sharing across the platforms
Andrei Marukovich
LunarFrog.com
twitter: @amarukovich
.NET ecosystem
.NET Framework .NET Core Xamarin
WPF
ASP.NET
WinForms UWP
ASP.NET Core
iOS
macOS
Android
Code sharing strategies
• Source file links
• Shared projects
• Portable class libraries (PCLs)
• .NET Standard
Shared projects
• Better version of the source file links
UWP project Xamarin project
File1.cs
File2.cs
SharedLib
File1.cs
File2.cs
SharedLib
File1.cs
File2.cs
SharedLibUI
App layer
UI
App layer
Shared projects
Shared projects
• Benefits
• Simple model
• May include platform-specific code
• Disadvantages
• Source-level sharing, no assembly
• Compiler directives
• Usability
Portable class libraries
• Sharing code in binary form, without recompiling
UWP project Xamarin project
File1.cs
File2.cs
PortableLib
UI
App layer
UI
App layer
How it works?
• PCLs are based on profiles
• Profile defines an API surface supported by the library
• Profile is identified by combination of supported platforms
• http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY
• C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable
UWP
Profile API surface
Xamarin
Android
.NET
Framework
PCLs
Portable class libraries
• Benefits
• PCLs allow binary distribution
• API enforcement
• No context switching, simple refactoring
• Disadvantages
• PCL’s require upfront decision on the supported platforms
• Lowest common denominator for the selected platforms
• Cannot use compiler directives
• Long term maintainability
.NET Standard
• An evolution of PCLs
• .NET Standard defines a set of APIs to be implemented by .NET
platforms (specification)
• .NET Standard is versioned (API level)
• Library developers may choose target .NET Standard version
• Version defines API surface, not supported frameworks
• The higher the version, the more APIs you have
• The lower the version, the more .NET platforms implement it
• Analogy: https://gist.github.com/davidfowl/8939f305567e1755412d6dc0b8baf1b7
.NET Standard
.NET platform support
.NET Standard 2.0
Big picture
.NET Standard
• Current state
• Tooling is in preview
• Currently PCLs support a wider range of platforms
• At the moment, PCL adoption (# of libraries) is higher than .NET Standard
• Future
• PCL replacement
• Standard 2.0 will have significantly larger API surface
• Standard 2.0 will be interoperable with .NET Framework
More information
• github.com/dotnet/standard
Thank you!
Andrei Marukovich
contact@lunarfrog.com
twitter: @amarukovich

Más contenido relacionado

La actualidad más candente

Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladoresQue hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
Rodolfo Finochietti
 

La actualidad más candente (20)

.NET Standard - Under the Hood
.NET Standard - Under the Hood.NET Standard - Under the Hood
.NET Standard - Under the Hood
 
DotNext 2017 in Moscow - Challenges of Managing CoreFX repo -- Karel Zikmund
DotNext 2017 in Moscow - Challenges of Managing CoreFX repo -- Karel ZikmundDotNext 2017 in Moscow - Challenges of Managing CoreFX repo -- Karel Zikmund
DotNext 2017 in Moscow - Challenges of Managing CoreFX repo -- Karel Zikmund
 
.NET MeetUp Brno - Challenges of Managing CoreFX repo -- Karel Zikmund
.NET MeetUp Brno - Challenges of Managing CoreFX repo -- Karel Zikmund.NET MeetUp Brno - Challenges of Managing CoreFX repo -- Karel Zikmund
.NET MeetUp Brno - Challenges of Managing CoreFX repo -- Karel Zikmund
 
Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)Building apps with common code for windows 8 and windows phone 8 (WP8)
Building apps with common code for windows 8 and windows phone 8 (WP8)
 
Microsoft .Net Framework
Microsoft .Net FrameworkMicrosoft .Net Framework
Microsoft .Net Framework
 
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHEREECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
 
Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladoresQue hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
Que hay de nuevo en 2013 en la plataforma Microsoft para desarrolladores
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
Five Real-World Strategies for Perforce Streams
Five Real-World Strategies for Perforce StreamsFive Real-World Strategies for Perforce Streams
Five Real-World Strategies for Perforce Streams
 
Manas
ManasManas
Manas
 
Presentation1
Presentation1Presentation1
Presentation1
 
.Net framework
.Net framework.Net framework
.Net framework
 
Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference ...
Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference ...Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference ...
Maximizing code reuse between Windows Phone 8 and Windows 8 (That Conference ...
 
Accelerating time to delivery modern tools for cobol development
Accelerating time to delivery modern tools for cobol developmentAccelerating time to delivery modern tools for cobol development
Accelerating time to delivery modern tools for cobol development
 
Recipy presentation #collabw15
Recipy presentation #collabw15Recipy presentation #collabw15
Recipy presentation #collabw15
 
.NET - The Current Spectrum
.NET -  The Current Spectrum.NET -  The Current Spectrum
.NET - The Current Spectrum
 
Product Camp Silicon Valley 2018 - PM Technical Skills
Product Camp Silicon Valley 2018 - PM Technical SkillsProduct Camp Silicon Valley 2018 - PM Technical Skills
Product Camp Silicon Valley 2018 - PM Technical Skills
 
The Python in the Apple
The Python in the AppleThe Python in the Apple
The Python in the Apple
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 

Destacado

Atmik_Soni_Resume
Atmik_Soni_ResumeAtmik_Soni_Resume
Atmik_Soni_Resume
Atmik Soni
 
Atoosa Samiei-Resume
Atoosa Samiei-ResumeAtoosa Samiei-Resume
Atoosa Samiei-Resume
Atoosa Samiei
 
ATIK SHEIKH(Resume) (1)
ATIK SHEIKH(Resume) (1)ATIK SHEIKH(Resume) (1)
ATIK SHEIKH(Resume) (1)
Atik Sheikh
 
Biomedical waste management ppt final1
Biomedical waste management ppt final1Biomedical waste management ppt final1
Biomedical waste management ppt final1
rashmi123vaish
 
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
Gulfam Raza
 

Destacado (14)

[3] silabus pai sma xi
[3] silabus pai sma xi[3] silabus pai sma xi
[3] silabus pai sma xi
 
Atul's Resume
Atul's ResumeAtul's Resume
Atul's Resume
 
Atmik_Soni_Resume
Atmik_Soni_ResumeAtmik_Soni_Resume
Atmik_Soni_Resume
 
Atoosa Samiei-Resume
Atoosa Samiei-ResumeAtoosa Samiei-Resume
Atoosa Samiei-Resume
 
ATIK SHEIKH(Resume) (1)
ATIK SHEIKH(Resume) (1)ATIK SHEIKH(Resume) (1)
ATIK SHEIKH(Resume) (1)
 
Business models
Business modelsBusiness models
Business models
 
Biomedical Waste Management
Biomedical Waste ManagementBiomedical Waste Management
Biomedical Waste Management
 
Makalah Sambiloto
Makalah Sambiloto Makalah Sambiloto
Makalah Sambiloto
 
Efusi pleura
Efusi pleuraEfusi pleura
Efusi pleura
 
Alzheimer's disease: Genetic Aspects
Alzheimer's disease: Genetic AspectsAlzheimer's disease: Genetic Aspects
Alzheimer's disease: Genetic Aspects
 
Environmental complexity
Environmental complexityEnvironmental complexity
Environmental complexity
 
Biomedical waste management ppt final1
Biomedical waste management ppt final1Biomedical waste management ppt final1
Biomedical waste management ppt final1
 
Safety health and environment aspects in thermal power plants
Safety health and environment aspects in thermal power plantsSafety health and environment aspects in thermal power plants
Safety health and environment aspects in thermal power plants
 
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
Principle & Applications of Transmission Electron Microscopy (TEM) & High Res...
 

Similar a C# code sharing across the platforms

Similar a C# code sharing across the platforms (20)

Whats new in .net for 2019
Whats new in .net for 2019Whats new in .net for 2019
Whats new in .net for 2019
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
 
Native App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual StudioNative App Development for iOS, Android, and Windows with Visual Studio
Native App Development for iOS, Android, and Windows with Visual Studio
 
C#: Past, Present and Future
C#: Past, Present and FutureC#: Past, Present and Future
C#: Past, Present and Future
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
 
Introduction to dot net
Introduction to dot netIntroduction to dot net
Introduction to dot net
 
ASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimaginedASP.NET 5 - Microsoft's Web development platform reimagined
ASP.NET 5 - Microsoft's Web development platform reimagined
 
Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016
 
Dotnet.ppt
Dotnet.pptDotnet.ppt
Dotnet.ppt
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
 
Best DotNet Training in Delhi
Best   DotNet Training  in DelhiBest   DotNet Training  in Delhi
Best DotNet Training in Delhi
 
Unboxing ASP.NET Core
Unboxing ASP.NET CoreUnboxing ASP.NET Core
Unboxing ASP.NET Core
 
.Net Core Fall update
.Net Core Fall update.Net Core Fall update
.Net Core Fall update
 
.NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016).NET Core Blimey! (dotnetsheff Jan 2016)
.NET Core Blimey! (dotnetsheff Jan 2016)
 
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...Lessons learned from building Eclipse-based add-ons for commercial modeling t...
Lessons learned from building Eclipse-based add-ons for commercial modeling t...
 
.Net Core 3.0. What’s inside? Павло Голубович
.Net Core 3.0. What’s inside? Павло Голубович.Net Core 3.0. What’s inside? Павло Голубович
.Net Core 3.0. What’s inside? Павло Голубович
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
 
Mini .net conf 2020
Mini .net conf 2020Mini .net conf 2020
Mini .net conf 2020
 
.NET (r)evolution
.NET (r)evolution.NET (r)evolution
.NET (r)evolution
 
Porting Projects to .NET 5
Porting Projects to .NET 5Porting Projects to .NET 5
Porting Projects to .NET 5
 

Más de Andrei Marukovich

Reactive Extensions for .NET
Reactive Extensions for .NETReactive Extensions for .NET
Reactive Extensions for .NET
Andrei Marukovich
 

Más de Andrei Marukovich (7)

Using NuGet libraries in your application
Using NuGet libraries in your applicationUsing NuGet libraries in your application
Using NuGet libraries in your application
 
Open Source Libraries for.NET developers
Open Source Libraries for.NET developersOpen Source Libraries for.NET developers
Open Source Libraries for.NET developers
 
Reactive Extensions for .NET
Reactive Extensions for .NETReactive Extensions for .NET
Reactive Extensions for .NET
 
Deceptive simplicity of async and await
Deceptive simplicity of async and awaitDeceptive simplicity of async and await
Deceptive simplicity of async and await
 
All about data persistence in Windows 8
All about data persistence in Windows 8All about data persistence in Windows 8
All about data persistence in Windows 8
 
ATDD in practice
ATDD in practiceATDD in practice
ATDD in practice
 
A Developer's View of Windows 8
A Developer's View of Windows 8A Developer's View of Windows 8
A Developer's View of Windows 8
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

C# code sharing across the platforms

  • 1. C# code sharing across the platforms Andrei Marukovich LunarFrog.com twitter: @amarukovich
  • 2. .NET ecosystem .NET Framework .NET Core Xamarin WPF ASP.NET WinForms UWP ASP.NET Core iOS macOS Android
  • 3. Code sharing strategies • Source file links • Shared projects • Portable class libraries (PCLs) • .NET Standard
  • 4. Shared projects • Better version of the source file links UWP project Xamarin project File1.cs File2.cs SharedLib File1.cs File2.cs SharedLib File1.cs File2.cs SharedLibUI App layer UI App layer
  • 6. Shared projects • Benefits • Simple model • May include platform-specific code • Disadvantages • Source-level sharing, no assembly • Compiler directives • Usability
  • 7. Portable class libraries • Sharing code in binary form, without recompiling UWP project Xamarin project File1.cs File2.cs PortableLib UI App layer UI App layer
  • 8. How it works? • PCLs are based on profiles • Profile defines an API surface supported by the library • Profile is identified by combination of supported platforms • http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY • C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETPortable
  • 10. PCLs
  • 11. Portable class libraries • Benefits • PCLs allow binary distribution • API enforcement • No context switching, simple refactoring • Disadvantages • PCL’s require upfront decision on the supported platforms • Lowest common denominator for the selected platforms • Cannot use compiler directives • Long term maintainability
  • 12. .NET Standard • An evolution of PCLs • .NET Standard defines a set of APIs to be implemented by .NET platforms (specification) • .NET Standard is versioned (API level) • Library developers may choose target .NET Standard version • Version defines API surface, not supported frameworks • The higher the version, the more APIs you have • The lower the version, the more .NET platforms implement it • Analogy: https://gist.github.com/davidfowl/8939f305567e1755412d6dc0b8baf1b7
  • 17. .NET Standard • Current state • Tooling is in preview • Currently PCLs support a wider range of platforms • At the moment, PCL adoption (# of libraries) is higher than .NET Standard • Future • PCL replacement • Standard 2.0 will have significantly larger API surface • Standard 2.0 will be interoperable with .NET Framework