[forms-devel] API: OnPlatform and Device.Platform extension to support Mac properly
Jason Smith
jason.smith at xamarin.com
Fri May 6 00:57:27 UTC 2016
Topic: OnPlatform and Device.OS
TargetIdiom and TargetDevice on their own are fine and easily extended,
however when combined with the OnPlatform API's we have no method of adding
new platforms to Xamarin.Forms without incurring an ABI break in the core
lib. This is due to some poor planning back in the day (hi there) and is
needing to be fixed as we now have community interest in making a Mac
backend.
The reason for the ABI limitation is due to the fact that Device.OnPlatform
takes optional parameters AND has a default parameter which means we cannot
simply add the new platforms to that API call without breaking old code.
Device.OnPlatform (iOSAction, androidAction, winPhoneAction, defaultAction);
would call to the wrong parameter if a hypothetical Mac action were added
in there.
In order to avoid an ABI break I am proposing the following:
1) Obsolete Device.OnPlatform
2) Extend TargetPlatform to include Mac
The OnPlatform class (different from the Device.OnPlatform) does not suffer
this limitation and can be kept. Users wishing to use OnPlatform semantics
in the future should simply do:
switch (Device.OS) {
case TargetPlatform.Mac:
break;
case TargetPlatform.iOS:
break;
default:
break;
}
At this time I do not believe there is a strong need to actually replace
the Device.OnPlatform call with something else as the language already
provides this feature (albeit slightly more verbose).
Jason
*What is this email?*
This email is intended to start a conversation with the forms developers
and the community about the above topic. This is the first step in the
Xamarin Evolution Process as described here:
https://github.com/xamarin/xamarin-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/forms-devel/attachments/20160505/e69df836/attachment.html>
More information about the forms-devel
mailing list