Bug 12811 - Enum list of string generic method AOT crash
Summary: Enum list of string generic method AOT crash
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.2.x
Hardware: Macintosh All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-06-21 07:43 UTC by Dylan
Modified: 2013-07-04 08:57 UTC (History)
2 users (show)

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:

Description Dylan 2013-06-21 07:43:45 UTC
I have a helper method which takes an Enum, and returns an IEnumerable of all the items in the enum type. However this causes an AOT crash when running on the device. 

The method:

        public static IEnumerable<string> GetStringList<T>() where T : struct, IConvertible
            return Enum.GetValues(typeof(T)).Cast<T>().Select(x=>x.ToString());

foreach(var e in EnumHelper.GetStringList<TestEnum>())

However if I replace the usage to something like this is works:
foreach(var e in Enum.GetValues(typeof(TestEnum)).Cast<TestEnum>().Select(x=>x.ToString()))
Comment 1 Sebastien Pouliot 2013-07-04 08:57:42 UTC
I added both tests case to our unit tests. Both variations works fine with 6.3.7 (beta)

The 6.3.x series has support for generics over value-types (including enums). It's still a beta but will soon become the next stable series for Xamarin.iOS.