Bug 33287 - Device.OnPlatform returns the iOS value on Windows
Summary: Device.OnPlatform returns the iOS value on Windows
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-21 01:28 UTC by Christiaan Veeningen
Modified: 2016-04-13 18:16 UTC (History)
2 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Sample project (2.40 MB, application/x-zip-compressed)
2015-08-21 01:28 UTC, Christiaan Veeningen
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Christiaan Veeningen 2015-08-21 01:28:30 UTC
Created attachment 12595 [details]
Sample project

When using Device.OnPlatform in a Windows Phone 8.1 (runtime) project it returns the value given for iOS. 

Tested it both in Xamarin.Forms 1.4.4.6392 &&  1.5.0.6396-pre1.

In a WP 8.0 project it's returning the correct value. 

I also read the documentation that the Device.OnPlatform cannot make a difference between WP 8.1 or Windows 8.1, but returning the iOS value doesn't seem like the best option.

I have added an
Comment 1 Sander Schutten 2015-08-21 03:16:34 UTC
I witness the same behavior and have located the error.

The OnDevice method uses the following switch statement to return the value:

switch (Device.OS)
{
    case TargetPlatform.iOS:
    {
        return iOS;
    }
    case TargetPlatform.Android:
    {
        return Android;
    }
    case TargetPlatform.WinPhone:
    {
        return WinPhone;
    }
}
return iOS;

The Forms.Init function in the assembly Xamarin.Forms.Platform.WinRT.Phone.dll, used by the Windows Phone 8.1 (runtime) project, sets the Device.OS value to TargetPlatform.Windows. As there is no case that matches this value, the iOS value is returned instead.
Comment 2 Paul DiPietro [MSFT] 2016-04-13 18:16:11 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.


For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team