Bug 3735 - Attempting to JIT compile method: using Linq's "Any" fails on the device
Summary: Attempting to JIT compile method: using Linq's "Any" fails on the device
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime (show other bugs)
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-03-02 17:42 UTC by René Ruppert
Modified: 2012-03-05 10:22 UTC (History)
3 users (show)

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


Description René Ruppert 2012-03-02 17:42:41 UTC
Monotouch 5.2.6.

Getting JIT exception using "Any". Exception and code below.

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-managed) BLAPI3WrapperClassicWSServiceRef.DownloadType[]:System.Collections.Generic.IEnumerable`1.GetEnumerator ()' while running with --aot-only.

Code snippet:

List<DOWNLOAD_TYPE> aDownloadTypes = new List<DOWNLOAD_TYPE>();
			if ( aTypes != null )
				if ( aTypes.Any( eType => eType == DownloadType.BrainmarkImage || eType == DownloadType.BrainmarkPDF || eType == DownloadType.BrainmarkPDFRMS ) )
					aDownloadTypes.Add( DOWNLOAD_TYPE.Brainmark );
Comment 1 Sebastien Pouliot 2012-03-02 19:10:55 UTC
Hello René. We need the type definitions to duplicate the issue (since it will, internally, make a huge difference in the code generation and AOT compilation).

E.g. what do DOWNLOAD_TYPE and DownloadType look likes ? enums ?
Comment 2 René Ruppert 2012-03-03 07:20:54 UTC
Yes, they are enums. Integer, no flags attribute.
Can you think of a work around that allows keeping the "Any"?
Comment 3 Sebastien Pouliot 2012-03-03 12:50:21 UTC
I still need the exact details (you can mark them private if you need). E.g. this works for me:

			List<Environment.SpecialFolder> list = new List<Environment.SpecialFolder> () {
			Assert.True (list.Any (folder => folder == Environment.SpecialFolder.ApplicationData));
Comment 5 Sebastien Pouliot 2012-03-05 09:52:53 UTC
So it worked for me because I used the following for `aTypes` (same for my original test case):

List<DownloadType> aTypes = new List<DownloadType>() { DownloadType.BrainmarkPDF };

but I get the exception if use:

DownloadType [] aTypes = new DownloadType [] { DownloadType.BrainmarkPDF };

(which I assume is what you have) so the workaround is to use:

var lTypes = new List<DownloadType> (aTypes);

over your existing array. That will make it clear that the AOT compiler needs to bring the related enumerator type/methods in your final application.
Comment 6 René Ruppert 2012-03-05 10:03:29 UTC
But is there a real fix for one of the next MT releases the will work without the workaround?
Comment 7 Sebastien Pouliot 2012-03-05 10:22:16 UTC
Nothing immediate, as this is part of the generic limitations [1], but the workaround will still work if/when this gets fixed.

This issue, like others, are being tracked - i.e. both the failing case and the workaround are included in our test suite. So it's a constant reminder...

[1] http://docs.xamarin.com/ios/about/limitations#Limited_Generics_Support

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.