Bug 54693 - Device.RuntimePlatform gives "Windows" on Windows Mobile
Summary: Device.RuntimePlatform gives "Windows" on Windows Mobile
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-07 07:41 UTC by Novak Savic
Modified: 2017-06-16 17:39 UTC (History)
4 users (show)

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

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 ANSWERED

Description Novak Savic 2017-04-07 07:41:16 UTC
Device.RuntimePlatform gives "Windows" on Windows Mobile, instead "WinPhone".
I'm not sure if this intentionally done, because of Win 10 and UWP. 

Test environment: 
Xamarin.Forms: 2.3.4 
Device: Microsoft RM-1104_15442
OS: WindowsMobile 10.0.14393.953
Comment 1 Jimmy [MSFT] 2017-04-07 14:57:18 UTC
Windows 10 and Windows 10 Mobile are both considered UWP so this is expected since Device.RuntimePlatform will just return the device's platform. 

"Windows" is used for Windows 8.1/Windows Phone 8.1 RT and UWP while "WinPhone" is used for the Windows Phone 8 Silverlight platform. Note that "Windows" will be split into "UWP" and "WinRT" in a future update[1].

If you want to determine what _type_ of device the app is being ran on, you can use TargetIdiom instead[2].

switch (Device.Idiom)
{
    case TargetIdiom.Phone:
        ...
    case TargetIdiom.Desktop:
        ...
}

[1] https://github.com/xamarin/Xamarin.Forms/pull/748
[2] https://developer.xamarin.com/api/type/Xamarin.Forms.TargetIdiom/
Comment 2 Novak Savic 2017-04-08 10:50:17 UTC
Hi Jimmy.

I would not mix UWP with actual OS platform, similar as I would not mix Unified API for iOS.

Anyhow, you are saying that Device.RuntimePlatform by design shall return "Windows" for:
- Windows 8.1 
- Windows Phone 8.1 RT
- Windows 10
- Windows 10 Mobile

And "WinPhone" only for:
- Windows Phone 8

This is not really consistent, and we should not mix RuntimePlatform and Idiom to get actual platform.

For me the right way would be that Device.RuntimePlatform returns "Windows" for:
- Windows 8.1
- Windows 10

And "WinPhone" for:
- Windows Phone 8.1 RT
- Windows 10 Mobile
- Windows Phone 8

Is there information in official documentation regarding returned values from Device.RuntimePlatform on different platforms?
If not, I guess its not bad idea to add this information in official documentation.
Comment 3 Cody Beyer (MSFT) 2017-06-16 17:39:40 UTC
Hey,

We cover the different options at the following documentation page: https://developer.xamarin.com/guides/xamarin-forms/platform-features/device/

Thanks!