11

I am working on extending number of supported platforms for my app, it used to support .NET4/Windows Store/Windows Phone, but I hope to also cover Mono for Android and iOS. I've put all business logic, models and view models to portable class libraries (PCL) but it's a big dilemma what subset of platforms I should target. Each combination causes something to fail. Here are the results for 4 platforms that I might use:

Profile 78 (NET45+WP8+Store): no problem with TPL,await/async and support for CallerMemberName attribute (used in BindableBase view model base class). But the Mono.Android project that refers such library fails to build complaining about non-present System.Runtime.dll that should be referenced.

Profile 104 (NET45+SL4+WP75+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 147 (NET403+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 158 (NET45+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

So I am not really sure what to choose. Profiles 78, 104, 147 are limited, profile 78 is the only one that supports both await/async and CallerMemberName used BindableBase, but it fails on Android complaining about System.Runtime.dll. So if you have an experience with what PCL profile is the best match for PCL targeting Mono, please share your thoughts.

4
  • Be sure to use Microsoft.Bcl.Async (which depends on Microsoft.Bcl). These add async/await/CallerMemberName support to profiles 104/147/158. May 9, 2013 at 14:48
  • Microsoft.Bcl.Async can only be distributed on Windows platform (so far). No Mono. May 10, 2013 at 7:28
  • @VagifAbilov licensing has been changed on Microsoft.Bcl.Async hanselman.com/blog/…
    – Nate Cook
    Apr 10, 2014 at 1:34
  • @NateCook yes, that was a great move from Microsoft. Apr 10, 2014 at 4:46

1 Answer 1

11

Thinking about profile numbers is hard - I prefer to think in terms of the platforms.

Ideally I'd love my projects to support:

  • .Net 3.5 and higher
  • SL3 and higher
  • WP7.x phone and higher
  • MonoDroid 1.6 and higher
  • MonoTouch iOS6 and higher
  • (Mac desktop OSX Lion)

The main PCL project I support is MvvmCross - which requires Mvvm 'facilities' like ICommand. These facilities are only available in platforms for .Net 4.5 and higher... that's a hard limit - nothing I can do about it - so changes my needs to:

  • .Net 3.5 and higher .Net 4.5
  • SL3 and higher SL4 and higher
  • WP7.x phone and higher
  • MonoDroid 1.6 and higher
  • MonoTouch iOS6 and higher
  • (Mac desktop OSX Lion)

With this selection in place, then this leads me to a profile number - 104 (no idea how the platform decided this... gave up asking a long time ago!)

So I've targeted MvvmCross at profile 104 - and it will stay there while WP7.x support is still needed.

This selection does mean that MvvmCross cannot out-of-the-box support things like async/await and CallerMemberName - but this is a compromise we've decided to make - we have users who need WP7.


However, some people are asking about await/async...

To use these new features, there are some BCL.Async Nuget hacks to make them work in profile 104... or these users can target their apps at a newer profile (one that doesn't support WP7.x and SL4) - this leads them to build their apps in profile 78, but to add references to my profile 104 assemblies.

Neither of these sets of solutions works very well with the Xamarin twins at present - e.g. you hit issues like the missing System.Runtime.dll assembly. However, I anticipate that when Xamarin officially supports PCLs (and after some alpha/beta testing) then these problems will be resolved. This official support is due very soon now - which is why I don't bother expending too much of my time thinking about these problems...


I expect in the medium term that MvvmCross will drop support for WP7.x and SL4. When that happens, we may also move the core libraries to profile 78.


The only other large platform I know that has started PCL support is ReactiveUI. I believe this platform must use profile 78 because the PCL version of Reactive from Microsoft is targeting 78.

7
  • Thanks Stuart, great answer as always. I have to check how important is BindableBase for my app. I guess you planned some replacement for it in MvvmCross. May 10, 2013 at 7:29
  • Dunno - what's BindableBase? Is it just github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross/… with the CallerMemberName methods added?
    – Stuart
    May 10, 2013 at 7:33
  • 1
    The essential part of BindableBase is this: SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null) So it's more than MvxNotifyPropertyChanged. May 10, 2013 at 7:52
  • In my mind that's the same class/function - just making use of c# 5 features - when MvvmCross is able to move forwards to C#5 then we'll probably add that type of method to MvxNotifyPropertyChanged. Also my guess is that whatever framework you got BindableBase from originally had it before CallerMemberName and that it looked different back then :) Regardless, over and out on this question from me.
    – Stuart
    May 10, 2013 at 8:04
  • OK, I think I have a place where I am currently using BindableBase.SetProperty (on Windows Store). I'll try to rewrite it using only Mvx. May 10, 2013 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.