Wintellect - Devscovery - Portable Class Library

Jeremy Likness
Jeremy LiknessSr. Cloud Developer Advocate at Microsoft
Portable Class Library: Tomorrow's Apps Today




                            Jeremy Likness (@JeremyLikness)
                            Principal Consultant
                            jlikness@wintellect.com
                                                                Copyright © 2012




consulting   training   design   debugging                    wintellect.com
what we do
    consulting     training    design     debugging

 who we are
   Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins –
   we pull out all the stops to help our customers achieve their goals through advanced
   software-based consulting and training solutions.

 how we do it                                           Training
                                                        •   On-site instructor-led training
   Consulting & Debugging                               •   Virtual instructor-led training
   •   Architecture, analysis, and design services      •   Devscovery conferences
   •   Full lifecycle custom software development
   •   Content creation                                 Design
   •   Project management                               •   User Experience Design
   •   Debugging & performance tuning                   •   Visual & Content Design
                                                        •   Video & Animation Production


consulting    training    design     debugging                                   wintellect.com
Building Windows 8 Apps with C#
                                   • http://bit.ly/win8design
                                   • Free source at:
                                      http://windows8applications.codeplex.com/
                                   • Everything you need to build and
                                     deploy Windows Store apps
                                     using C# and XAML
                                   • Includes the portable project you
                                     will see today




consulting   training   design   debugging                          wintellect.com
Agenda
 •   Introduction to the Portable Class Library
 •   Understanding Extension SDKs
 •   Portable profiles
 •   Chasing ICommand: PCL Under the Hood
 •   Porting existing code
 •   Strategies for building new applications
 •   Comprehensive Example: Wintellog
 •   PCL Futures




consulting   training   design   debugging        wintellect.com
Introducing PCL
 • Write and build managed assemblies that work (without
   recompiling) on more than one .NET Framework platform
 • Target frameworks include:
      –   .NET Framework 4 and later (including WPF)
      –   .NET for Windows Store apps (Windows 8)
      –   Silverlight 4 and later
      –   Windows Phone 7 and later
      –   Xbox 360
 • Eliminate sharing of source




consulting   training   design   debugging             wintellect.com
Supported Features
   Feature             .NET           Windows     Silverlight   Windows   Xbox 360
                       Framework      Store                     Phone
   Core                Yes            Yes         Yes           Yes       Yes
   XLINQ               4.0.3+         Yes         Yes           Yes       Yes
   LINQ                Yes            Yes         Yes           Yes
   Network             Yes            Yes         Yes           Yes
   Serialization       Yes            Yes         Yes           Yes
   WCF                 Yes            Yes         Yes           Yes
   IQueryable          Yes            Yes         Yes           7.5+
   MVVM                4.5            Yes         Yes           Yes
   MEF                 Yes            Yes         Yes
   Numerics            Yes            Yes         Yes
   Dynamic             4.5            Yes         Yes
   Annotations         4.0.3+         Yes         Yes


consulting      training     design   debugging                           wintellect.com
PCL in MSDN Documentation




consulting   training   design   debugging   wintellect.com
PCL in MSDN Documentation




consulting   training   design   debugging   wintellect.com
PCL and Model-View-ViewModel
 • .NET Framework 4.5, .NET for Windows Store apps,
   Silverlight, and Windows Phone
 • Observable collections (normal and read-only)
 • Notify property changed
 • Notify collection changed
 • Notify data error info
 • ICommand




consulting   training   design   debugging        wintellect.com
PCL + VS 2012 = Extension SDK
 • Software Development Kit (SDK) is a collection of files that Visual
   Studio will treat as a single item
      – Platform SDK – mandatory for a target platform, i.e. "Windows 8 SDK"
      – Extension SDK – optional components to extend a platform
 • Target Platform Moniker (TPM) = Identifier (TPI) and Version (TPV) ex:
   "Windows, version=8.0"
 • References (binaries, either .WinMD or
   assemblies), redistributables, and design-time components
 • Can drop any components to a path with a TPM and Visual Studio will
   substitute that path
 • Easy to see what the target profile is
 • Each combination of target platforms creates a unique profile



consulting   training   design   debugging                           wintellect.com
PCL Under the Covers
 •   Use ILDASM to inspect portable assemblies




 •   ICommand lives in System.Windows.dll for Silverlight, but System.dll in .NET
     4.5 and Windows.UI.Xaml.Input.dll in Windows Store apps ("retargetable")




consulting   training   design   debugging                              wintellect.com
PCL Under the Covers (cont.)
 •   Classic type forwarders route to the appropriate assembly




consulting   training   design   debugging                       wintellect.com
PCL Under the Covers (cont.)
 •   Windows Store apps forward to System.ObjectModel and language
     projections maps them to the WinRT framework




consulting   training   design   debugging                       wintellect.com
demo
   Basic MVVM with PCL




consulting   training   design   debugging   wintellect.com
Porting Existing Code
 • Always easier when implementing MVVM, but are your
   ViewModels tied to views (i.e. do you include XAML
   namespaces?)
 • Decoupled code is key
 • Identify key APIs that are platform-specific and implement
   façade
 • Common areas to refactor out include UI, networking, and
   storage
 • Convert an existing class library to a PCL assembly




consulting   training   design   debugging          wintellect.com
Porting Existing Code
 • You can convert an existing class library to a PCL
 • First, unload the project
 • Second, change the settings:
     <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets"
     /> to
     <Import
     Project="$(MSBuildExtensionsPath32)MicrosoftPortable$(Target
     FrameworkVersion)Microsoft.Portable.CSharp.targets" />
 • Next, add the following project GUIDs to the end of the first property
   group – this adds the library tab and dialog to change the targets:
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-
     6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-
     00C04F79EFBC}</ProjectTypeGuids>
 • Finally, reload the project and select the target frameworks


consulting   training   design   debugging                        wintellect.com
Strategies for Building New Apps
 •   Follow S.O.L.I.D. Principles – they do make it easier
      –   Single responsibility – a class should only do one thing and change for one reason
      –   Open/closed principle – open for extension, closed for modification
      –   Liskov substitution principle – no side effects/unexpected behaviors when cast to a base class
      –   Interface segregation – interfaces should be focused on specific, targeted functionality
      –   Dependency Injection – keep dependencies external from your class and inject them
 •   Use MVVM and keep view-specific code in the view, not the view model
 •   Target the smallest number of frameworks possible in your portable
     assemblies to ensure the widest surface area of APIs to choose from, i.e. don't
     include Xbox if you're not going to write for it
 •   Pick a target platform to run your unit tests and only write tests for PCL
     assemblies in that target
 •   Don't forget to write unit tests for the classes that are specific to target
     platforms




consulting     training      design      debugging                                         wintellect.com
demo
   Wintellog: Windows Store and WPF




consulting   training   design   debugging   wintellect.com
Recap
 • PCL is native to VS 2012 and uses Extension SDKs
 • PCL maps target frameworks to profiles that represent a
   "lowest common denominator" of API surface area
 • Under the hood, PCL takes advantage of type forwarders
   and Windows 8 advances to enable the portable assembly
 • Existing code can be ported to use the PCL
 • New applications should take advantage of the PCL for
   various core assemblies, with storage and UI abstracted
   away
 • PCL should be a solid investment as the team is actively
   working on updates to keep pace with the latest

consulting   training   design   debugging         wintellect.com
Questions?




                            Jeremy Likness (@JeremyLikness)
                            Principal Consultant
                            jlikness@wintellect.com



consulting   training   design   debugging                    wintellect.com
1 of 20

Recommended

Software Factory - Overview by
Software Factory - OverviewSoftware Factory - Overview
Software Factory - Overviewslides_teltools
3.6K views33 slides
A Tale of Two Toolkits by
A Tale of Two ToolkitsA Tale of Two Toolkits
A Tale of Two ToolkitsZend by Rogue Wave Software
493 views32 slides
Automated Testing for CA Plex and 2E by
Automated Testing for CA Plex and 2EAutomated Testing for CA Plex and 2E
Automated Testing for CA Plex and 2ECM First Group
3.8K views29 slides
A Software Factory Integrating Rational Team Concert and WebSphere tools by
A Software Factory Integrating Rational Team Concert and WebSphere toolsA Software Factory Integrating Rational Team Concert and WebSphere tools
A Software Factory Integrating Rational Team Concert and WebSphere toolsProlifics
1.6K views31 slides
Syncfusion Brochure 2010 Web by
Syncfusion Brochure 2010 WebSyncfusion Brochure 2010 Web
Syncfusion Brochure 2010 WebMarissa Keller Outten
689 views12 slides
Java vs .Net by
Java vs .NetJava vs .Net
Java vs .NetTejasvi Rastogi
32.6K views54 slides

More Related Content

What's hot

Introduction To NetBeans IDE by
Introduction To NetBeans IDEIntroduction To NetBeans IDE
Introduction To NetBeans IDEMuhammad Ghazali
4.3K views55 slides
Building software using Rich Clients Platforms Rikard Thulin by
Building software using Rich Clients Platforms Rikard ThulinBuilding software using Rich Clients Platforms Rikard Thulin
Building software using Rich Clients Platforms Rikard ThulinRikard Thulin
438 views51 slides
Silverlight difference faqs-1 by
Silverlight  difference faqs-1Silverlight  difference faqs-1
Silverlight difference faqs-1Umar Ali
598 views7 slides
A Lap Around Visual Studio 11 by
A Lap Around Visual Studio 11A Lap Around Visual Studio 11
A Lap Around Visual Studio 11Chad Green
1.1K views35 slides
Agile in Action - Act 3: Testing by
Agile in Action - Act 3: TestingAgile in Action - Act 3: Testing
Agile in Action - Act 3: TestingSpiffy
863 views30 slides
Mainframe DevOps Using Zowe Open Source by
Mainframe DevOps Using Zowe Open SourceMainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open SourceDevOps.com
870 views18 slides

What's hot(20)

Building software using Rich Clients Platforms Rikard Thulin by Rikard Thulin
Building software using Rich Clients Platforms Rikard ThulinBuilding software using Rich Clients Platforms Rikard Thulin
Building software using Rich Clients Platforms Rikard Thulin
Rikard Thulin438 views
Silverlight difference faqs-1 by Umar Ali
Silverlight  difference faqs-1Silverlight  difference faqs-1
Silverlight difference faqs-1
Umar Ali598 views
A Lap Around Visual Studio 11 by Chad Green
A Lap Around Visual Studio 11A Lap Around Visual Studio 11
A Lap Around Visual Studio 11
Chad Green1.1K views
Agile in Action - Act 3: Testing by Spiffy
Agile in Action - Act 3: TestingAgile in Action - Act 3: Testing
Agile in Action - Act 3: Testing
Spiffy863 views
Mainframe DevOps Using Zowe Open Source by DevOps.com
Mainframe DevOps Using Zowe Open SourceMainframe DevOps Using Zowe Open Source
Mainframe DevOps Using Zowe Open Source
DevOps.com870 views
Mobilize Your Business, Not Just an App by Teamstudio
Mobilize Your Business, Not Just an AppMobilize Your Business, Not Just an App
Mobilize Your Business, Not Just an App
Teamstudio1.2K views
Scaling Continuous Integration Practices to Teams with Parallel Development by IBM UrbanCode Products
Scaling Continuous Integration Practices to Teams with Parallel DevelopmentScaling Continuous Integration Practices to Teams with Parallel Development
Scaling Continuous Integration Practices to Teams with Parallel Development
Dart Past Your Competition by Getting Your Digital Experience into Market Fas... by Perficient, Inc.
Dart Past Your Competition by Getting Your Digital Experience into Market Fas...Dart Past Your Competition by Getting Your Digital Experience into Market Fas...
Dart Past Your Competition by Getting Your Digital Experience into Market Fas...
Perficient, Inc.542 views
Introduction to PHP H/MVC Frameworks by www.silicongulf.com by Christopher Cubos
Introduction to PHP H/MVC Frameworks by www.silicongulf.comIntroduction to PHP H/MVC Frameworks by www.silicongulf.com
Introduction to PHP H/MVC Frameworks by www.silicongulf.com
Christopher Cubos2.7K views
Show110 | Using the XPages Extension Library for the Real World by pdhannan
Show110 | Using the XPages Extension Library for the Real WorldShow110 | Using the XPages Extension Library for the Real World
Show110 | Using the XPages Extension Library for the Real World
pdhannan9.1K views
.NET Fundamentals and Business Application Development by 명신 김
.NET Fundamentals and Business Application Development.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development
명신 김73 views
Extension Library - Viagra for XPages by Ulrich Krause
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
Ulrich Krause5K views
Developing XPages Applications by Niklas Heidloff
Developing XPages ApplicationsDeveloping XPages Applications
Developing XPages Applications
Niklas Heidloff1.9K views

Similar to Wintellect - Devscovery - Portable Class Library

Wintellect - Windows 8 for the Silverlight and WPF Developer by
Wintellect   - Windows 8 for the Silverlight and WPF DeveloperWintellect   - Windows 8 for the Silverlight and WPF Developer
Wintellect - Windows 8 for the Silverlight and WPF DeveloperJeremy Likness
961 views28 slides
Introduction to the Managed Extensibility Framework in Silverlight by
Introduction to the Managed Extensibility Framework in SilverlightIntroduction to the Managed Extensibility Framework in Silverlight
Introduction to the Managed Extensibility Framework in SilverlightJeremy Likness
619 views24 slides
Introduction_to_NET.ppt by
Introduction_to_NET.pptIntroduction_to_NET.ppt
Introduction_to_NET.pptDarwin Terraza
2 views20 slides
Windows 8: A Tale of Two Stacks by
Windows 8: A Tale of Two StacksWindows 8: A Tale of Two Stacks
Windows 8: A Tale of Two StacksJeremy Likness
582 views45 slides
Staying connected: An Overview of Announcements from Microsoft’s Connect(); by
Staying connected: An Overview of Announcements from Microsoft’s Connect();Staying connected: An Overview of Announcements from Microsoft’s Connect();
Staying connected: An Overview of Announcements from Microsoft’s Connect();dotNet Miami
402 views39 slides
c#.Net Windows application by
c#.Net Windows application c#.Net Windows application
c#.Net Windows application veera
6.5K views13 slides

Similar to Wintellect - Devscovery - Portable Class Library(20)

Wintellect - Windows 8 for the Silverlight and WPF Developer by Jeremy Likness
Wintellect   - Windows 8 for the Silverlight and WPF DeveloperWintellect   - Windows 8 for the Silverlight and WPF Developer
Wintellect - Windows 8 for the Silverlight and WPF Developer
Jeremy Likness961 views
Introduction to the Managed Extensibility Framework in Silverlight by Jeremy Likness
Introduction to the Managed Extensibility Framework in SilverlightIntroduction to the Managed Extensibility Framework in Silverlight
Introduction to the Managed Extensibility Framework in Silverlight
Jeremy Likness619 views
Windows 8: A Tale of Two Stacks by Jeremy Likness
Windows 8: A Tale of Two StacksWindows 8: A Tale of Two Stacks
Windows 8: A Tale of Two Stacks
Jeremy Likness582 views
Staying connected: An Overview of Announcements from Microsoft’s Connect(); by dotNet Miami
Staying connected: An Overview of Announcements from Microsoft’s Connect();Staying connected: An Overview of Announcements from Microsoft’s Connect();
Staying connected: An Overview of Announcements from Microsoft’s Connect();
dotNet Miami402 views
c#.Net Windows application by veera
c#.Net Windows application c#.Net Windows application
c#.Net Windows application
veera 6.5K views
Nashua Cloud .NET User Group - Basic WP8 App Dev With XAML and C#, April 2013 by John Garland
Nashua Cloud .NET User Group - Basic WP8 App Dev With XAML and C#, April 2013Nashua Cloud .NET User Group - Basic WP8 App Dev With XAML and C#, April 2013
Nashua Cloud .NET User Group - Basic WP8 App Dev With XAML and C#, April 2013
John Garland1.6K views
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2 by Jeremy Likness
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Jeremy Likness639 views
Net Beans by marx wang
Net BeansNet Beans
Net Beans
marx wang493 views
Net Beans by marx wang
Net BeansNet Beans
Net Beans
marx wang302 views
New voice, new tone, new IA: Writing for the modern developer by Keith Boyd
New voice, new tone, new IA: Writing for the modern developerNew voice, new tone, new IA: Writing for the modern developer
New voice, new tone, new IA: Writing for the modern developer
Keith Boyd1K views
Rcs project Training Bangalore by Sunil Kumar
Rcs project Training BangaloreRcs project Training Bangalore
Rcs project Training Bangalore
Sunil Kumar92 views
Sitecore development approach evolution – destination helix by Peter Nazarov
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helix
Peter Nazarov406 views
AWS Summit Auckland - Moving MS .NET Applications One Container at a Time by Amazon Web Services
AWS Summit Auckland - Moving MS .NET Applications One Container at a TimeAWS Summit Auckland - Moving MS .NET Applications One Container at a Time
AWS Summit Auckland - Moving MS .NET Applications One Container at a Time
(WPF + WinForms) * .NET Core = Modern Desktop by Oren Novotny
(WPF + WinForms) * .NET Core = Modern Desktop(WPF + WinForms) * .NET Core = Modern Desktop
(WPF + WinForms) * .NET Core = Modern Desktop
Oren Novotny2.1K views
Cincom Smalltalk News by ESUG
Cincom Smalltalk NewsCincom Smalltalk News
Cincom Smalltalk News
ESUG459 views
Moving microsoft .net applications one container at a time by Amazon Web Services
 Moving microsoft .net applications one container at a time  Moving microsoft .net applications one container at a time
Moving microsoft .net applications one container at a time
Amazon Web Services1.7K views

Recently uploaded

20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
41 views73 slides
Attacking IoT Devices from a Web Perspective - Linux Day by
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day Simone Onofri
16 views68 slides
Evolving the Network Automation Journey from Python to Platforms by
Evolving the Network Automation Journey from Python to PlatformsEvolving the Network Automation Journey from Python to Platforms
Evolving the Network Automation Journey from Python to PlatformsNetwork Automation Forum
13 views21 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
30 views15 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
127 views24 slides
Vertical User Stories by
Vertical User StoriesVertical User Stories
Vertical User StoriesMoisés Armani Ramírez
14 views16 slides

Recently uploaded(20)

Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri16 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman33 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views

Wintellect - Devscovery - Portable Class Library

  • 1. Portable Class Library: Tomorrow's Apps Today Jeremy Likness (@JeremyLikness) Principal Consultant jlikness@wintellect.com Copyright © 2012 consulting training design debugging wintellect.com
  • 2. what we do consulting training design debugging who we are Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions. how we do it Training • On-site instructor-led training Consulting & Debugging • Virtual instructor-led training • Architecture, analysis, and design services • Devscovery conferences • Full lifecycle custom software development • Content creation Design • Project management • User Experience Design • Debugging & performance tuning • Visual & Content Design • Video & Animation Production consulting training design debugging wintellect.com
  • 3. Building Windows 8 Apps with C# • http://bit.ly/win8design • Free source at: http://windows8applications.codeplex.com/ • Everything you need to build and deploy Windows Store apps using C# and XAML • Includes the portable project you will see today consulting training design debugging wintellect.com
  • 4. Agenda • Introduction to the Portable Class Library • Understanding Extension SDKs • Portable profiles • Chasing ICommand: PCL Under the Hood • Porting existing code • Strategies for building new applications • Comprehensive Example: Wintellog • PCL Futures consulting training design debugging wintellect.com
  • 5. Introducing PCL • Write and build managed assemblies that work (without recompiling) on more than one .NET Framework platform • Target frameworks include: – .NET Framework 4 and later (including WPF) – .NET for Windows Store apps (Windows 8) – Silverlight 4 and later – Windows Phone 7 and later – Xbox 360 • Eliminate sharing of source consulting training design debugging wintellect.com
  • 6. Supported Features Feature .NET Windows Silverlight Windows Xbox 360 Framework Store Phone Core Yes Yes Yes Yes Yes XLINQ 4.0.3+ Yes Yes Yes Yes LINQ Yes Yes Yes Yes Network Yes Yes Yes Yes Serialization Yes Yes Yes Yes WCF Yes Yes Yes Yes IQueryable Yes Yes Yes 7.5+ MVVM 4.5 Yes Yes Yes MEF Yes Yes Yes Numerics Yes Yes Yes Dynamic 4.5 Yes Yes Annotations 4.0.3+ Yes Yes consulting training design debugging wintellect.com
  • 7. PCL in MSDN Documentation consulting training design debugging wintellect.com
  • 8. PCL in MSDN Documentation consulting training design debugging wintellect.com
  • 9. PCL and Model-View-ViewModel • .NET Framework 4.5, .NET for Windows Store apps, Silverlight, and Windows Phone • Observable collections (normal and read-only) • Notify property changed • Notify collection changed • Notify data error info • ICommand consulting training design debugging wintellect.com
  • 10. PCL + VS 2012 = Extension SDK • Software Development Kit (SDK) is a collection of files that Visual Studio will treat as a single item – Platform SDK – mandatory for a target platform, i.e. "Windows 8 SDK" – Extension SDK – optional components to extend a platform • Target Platform Moniker (TPM) = Identifier (TPI) and Version (TPV) ex: "Windows, version=8.0" • References (binaries, either .WinMD or assemblies), redistributables, and design-time components • Can drop any components to a path with a TPM and Visual Studio will substitute that path • Easy to see what the target profile is • Each combination of target platforms creates a unique profile consulting training design debugging wintellect.com
  • 11. PCL Under the Covers • Use ILDASM to inspect portable assemblies • ICommand lives in System.Windows.dll for Silverlight, but System.dll in .NET 4.5 and Windows.UI.Xaml.Input.dll in Windows Store apps ("retargetable") consulting training design debugging wintellect.com
  • 12. PCL Under the Covers (cont.) • Classic type forwarders route to the appropriate assembly consulting training design debugging wintellect.com
  • 13. PCL Under the Covers (cont.) • Windows Store apps forward to System.ObjectModel and language projections maps them to the WinRT framework consulting training design debugging wintellect.com
  • 14. demo Basic MVVM with PCL consulting training design debugging wintellect.com
  • 15. Porting Existing Code • Always easier when implementing MVVM, but are your ViewModels tied to views (i.e. do you include XAML namespaces?) • Decoupled code is key • Identify key APIs that are platform-specific and implement façade • Common areas to refactor out include UI, networking, and storage • Convert an existing class library to a PCL assembly consulting training design debugging wintellect.com
  • 16. Porting Existing Code • You can convert an existing class library to a PCL • First, unload the project • Second, change the settings: <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" /> to <Import Project="$(MSBuildExtensionsPath32)MicrosoftPortable$(Target FrameworkVersion)Microsoft.Portable.CSharp.targets" /> • Next, add the following project GUIDs to the end of the first property group – this adds the library tab and dialog to change the targets: <ProjectTypeGuids>{786C830F-07A1-408B-BD7F- 6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B- 00C04F79EFBC}</ProjectTypeGuids> • Finally, reload the project and select the target frameworks consulting training design debugging wintellect.com
  • 17. Strategies for Building New Apps • Follow S.O.L.I.D. Principles – they do make it easier – Single responsibility – a class should only do one thing and change for one reason – Open/closed principle – open for extension, closed for modification – Liskov substitution principle – no side effects/unexpected behaviors when cast to a base class – Interface segregation – interfaces should be focused on specific, targeted functionality – Dependency Injection – keep dependencies external from your class and inject them • Use MVVM and keep view-specific code in the view, not the view model • Target the smallest number of frameworks possible in your portable assemblies to ensure the widest surface area of APIs to choose from, i.e. don't include Xbox if you're not going to write for it • Pick a target platform to run your unit tests and only write tests for PCL assemblies in that target • Don't forget to write unit tests for the classes that are specific to target platforms consulting training design debugging wintellect.com
  • 18. demo Wintellog: Windows Store and WPF consulting training design debugging wintellect.com
  • 19. Recap • PCL is native to VS 2012 and uses Extension SDKs • PCL maps target frameworks to profiles that represent a "lowest common denominator" of API surface area • Under the hood, PCL takes advantage of type forwarders and Windows 8 advances to enable the portable assembly • Existing code can be ported to use the PCL • New applications should take advantage of the PCL for various core assemblies, with storage and UI abstracted away • PCL should be a solid investment as the team is actively working on updates to keep pace with the latest consulting training design debugging wintellect.com
  • 20. Questions? Jeremy Likness (@JeremyLikness) Principal Consultant jlikness@wintellect.com consulting training design debugging wintellect.com

Editor's Notes

  1. var one = 1;one;typeof one;var two = &apos;2&apos;,two;typeof two;var three = one + two;three;typeof three; var three = Number(one) + Number(two);typeof three;three;var one = [1,2,3];one;typeof one;var two = [&apos;1&apos;, &apos;2&apos;, &apos;3&apos;]two;typeof two;one[0] == two[0];one[0] === two[0];var three = one + two;typeof three;three;var three = one.concat(two);three;typeof three;
  2. var one = 1;one;typeof one;var two = &apos;2&apos;,two;typeof two;var three = one + two;three;typeof three; var three = Number(one) + Number(two);typeof three;three;var one = [1,2,3];one;typeof one;var two = [&apos;1&apos;, &apos;2&apos;, &apos;3&apos;]two;typeof two;one[0] == two[0];one[0] === two[0];var three = one + two;typeof three;three;var three = one.concat(two);three;typeof three;
  3. var one = 1;one;typeof one;var two = &apos;2&apos;,two;typeof two;var three = one + two;three;typeof three; var three = Number(one) + Number(two);typeof three;three;var one = [1,2,3];one;typeof one;var two = [&apos;1&apos;, &apos;2&apos;, &apos;3&apos;]two;typeof two;one[0] == two[0];one[0] === two[0];var three = one + two;typeof three;three;var three = one.concat(two);three;typeof three;
  4. var one = 1;one;typeof one;var two = &apos;2&apos;,two;typeof two;var three = one + two;three;typeof three; var three = Number(one) + Number(two);typeof three;three;var one = [1,2,3];one;typeof one;var two = [&apos;1&apos;, &apos;2&apos;, &apos;3&apos;]two;typeof two;one[0] == two[0];one[0] === two[0];var three = one + two;typeof three;three;var three = one.concat(two);three;typeof three;
  5. Show the original first. Run in IE8 and IE9, then show crash in IE7 – find out if students can even see where the crash is coming from.Run JSLint, note it stops after a short time and you have to keep making fixes to keep it moving. Note complaints about spaces. Show that the defect was addressed.Now configure JSHint and show that experience.
  6. Show the original first. Run in IE8 and IE9, then show crash in IE7 – find out if students can even see where the crash is coming from.Run JSLint, note it stops after a short time and you have to keep making fixes to keep it moving. Note complaints about spaces. Show that the defect was addressed.Now configure JSHint and show that experience.