Bug 59674 - Visual Studio 2017 crashes in design time when using ApplicationInfoFlags.System
Summary: Visual Studio 2017 crashes in design time when using ApplicationInfoFlags.System
Status: CONFIRMED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android (show other bugs)
Version: 4.6.0 (15.3)
Hardware: PC Windows
: High critical
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-22 02:03 UTC by Jorge Zafra
Modified: 2017-10-13 12:22 UTC (History)
7 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 for Bug 59674 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
CONFIRMED

Description Jorge Zafra 2017-09-22 02:03:43 UTC
I am using PackageManager to retrieve the installed applications in the Android device. Once I get the apps I loop through them to filter out the System applications and use only the user installed apps. To do that in my code I am using ApplicationInfoFlags enumerator to check if the application is a system app by using the flag value "System". This is an example of the code:

            var flag = PackageInfoFlags.MetaData;
            var apps = PackageManager.GetInstalledApplications(flag);
            //filter out system apps
            foreach (ApplicationInfo app in apps)
            {
                if ((app.Flags & ApplicationInfoFlags.System) != 0) <-- Highlight also causes the crash      
                {
                   
                }
            }

The above code will compile and the IDE will not crash if I do not hover over the enum values "System".

The issue is that in design time if I do a mouse hover over the word "System", VS 2017 immediately crashes, shutsdown and restarts. I am not debugging or running the app. Just hovering over the code.

I also tried doing the mouse hover over the single notation like this:

            var flag = PackageInfoFlags.MetaData;
            var apps = PackageManager.GetInstalledApplications(flag);
            ApplicationInfoFlags.System; <-- Just doing the mouse hover the word System will make VS 2017 crash. 



I am not sure if this is an actual bug in Visual Studio but since the enumerator is part of Xamarin.Android I decided to report it here.
Comment 1 Jon Douglas [MSFT] 2017-09-25 15:04:33 UTC
Can you please include your version information that this is occurring with? You can find this information in Help -> About Visual Studio and copy the text inside that dialog.

Secondly, do you have any additional extensions installed such as code helping tools like Resharper, Ozcode, or anything else? Make sure to disable those if you do have them enabled. I will be investigating when I know what version you are seeing this with!
Comment 2 Jorge Zafra 2017-09-28 23:39:30 UTC
I am using 

Microsoft Visual Studio Community 2017 Version 15.3.4
Microsoft .Net Framework 4.7.02046
MVVM Light version 5.2
Xamarin 4.6.3.4
Xamarin.Android SDK 7.4.3.1
Xamarin.IOS and XamarinMac SDK 10.12.3.3

As far as extension I do not have any. 

Thanks.
Comment 3 Ramachandran Iyer 2017-10-03 13:37:18 UTC
This happens with Visual Studio 2015 as well. You move the move over the "System" value of the "ApplicationInfoFlags" enum, and gone! You have a crash and VS restarts.
Comment 4 Ramachandran Iyer 2017-10-03 13:48:12 UTC
UPDATE: Same result when you try typing or hovering the mouse over UpdatedSystemApp too.. And moving the mouse even by mistake crashes the IDE. For now, I am using the numerical values of the constants like this:


// Note: 1 and 128 are values of System and UpdatedSystemApp respectively.
if (pInfo.ApplicationInfo.Flags != 128 && pInfo.ApplicationInfo.Flags != 1)
Comment 5 Jon Douglas [MSFT] 2017-10-03 15:24:34 UTC
Very interesting. When I had first tried this reproduce this issue, hovering over System was fine. However this second attempt, it is now crashing.

Reproduction Steps:

1. Create a new Xamarin.Android Blank Project

2. Add the following code somewhere in the MainActivity's OnCreate option

var flag = PackageInfoFlags.MetaData;
var apps = PackageManager.GetInstalledApplications(flag);
var q = ApplicationInfoFlags.System;

3. Hover over the "System" in ApplicationInfoFlags.System item.

4. Visual Studio will go unresponsive and crash.

Given the nature of this bug and that it's IDE specific. I am moving this bug to Visual Studio and setting the priority to HIGH - CRITICAL due to the nature of a crash.

I am also CONFIRMING this issue as I am able to reproduce on the current stable channel (15.3.5). I had attempted to reproduce on VSfM using 7.1 and 7.2, however it seems to work just fine.