Bug 46372 - Documentation of TargetIdiom out of synch with reality for UWP
Summary: Documentation of TargetIdiom out of synch with reality for UWP
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Chris King
URL:
Depends on:
Blocks:
 
Reported: 2016-11-03 11:27 UTC by John Hardman
Modified: 2017-05-09 00:45 UTC (History)
6 users (show)

Tags: UWP TargetIdiom Documentation Comments ac
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 FIXED

Description John Hardman 2016-11-03 11:27:56 UTC
The comments for TargetIdiom are as follows:

        //
        // Summary:
        //     (Unused) Indicates that Forms is running on an unsupported device.
        Unsupported = 0,
        //
        // Summary:
        //     Indicates that the width of the iPhone, iPod Touch, Windows Phone, or Android
        //     device on which Forms is running is narrower than 600 dips.
        Phone = 1,
        //
        // Summary:
        //     Indicates that the width of the iPad, Windows 8.1, or Android device on which
        //     Forms is running is wider than 600 dips.
        Tablet = 2,
        //
        // Summary:
        //     Indicates that Forms is running on a UWP app on Windows 10.
        Desktop = 3

That suggests to me that UWP on any device will report Desktop, which is not the case in practice. The code and comments are out of synch. The comments need updating to match the reality for UWP.
Comment 1 John Hardman 2016-11-03 11:29:06 UTC
Sorry, I should have made that clearer. For UWP on a non-desktop Windows 10 device, TargetIdiom does not report Desktop. The comments suggest it will.
Comment 2 John Hardman 2016-11-03 11:43:35 UTC
Here's the code from Forms.cs that sets the Idiom for UWP. It seems that it will report Desktop, Phone and Tablet, so the comments show above on TargetIdiom do need to be updated to reflect this.

#if WINDOWS_UWP
			switch (DetectPlatform())
			{
				case Windows.Foundation.Metadata.Platform.Windows:
					Device.Idiom = TargetIdiom.Desktop;
					break;
				case Windows.Foundation.Metadata.Platform.WindowsPhone:
					Device.Idiom = TargetIdiom.Phone;
					break;
				default:
					Device.Idiom = TargetIdiom.Tablet;
					break;
			}
#endif
Comment 3 adrianknight89 2016-11-06 02:40:46 UTC
Also, when/if they add MacOS support, the comment for Desktop needs to be edited. 

I probably would have picked Computer instead of Desktop because we generally group Desktops and Laptops into the Computer category and laptops are not considered to be tablets.
Comment 4 Paul DiPietro [MSFT] 2017-03-09 21:24:17 UTC
The docs will need to be updated.
Comment 6 Samantha Houts [MSFT] 2017-05-09 00:45:02 UTC
Should be resolved in 2.3.6-pre1. Thank you!