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
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-02 17:42 UTC by René Ruppert
Modified: 2012-03-05 10:22 UTC (History)
3 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 FIXED

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> () {
				Environment.SpecialFolder.ApplicationData,
				Environment.SpecialFolder.CommonApplicationData
			};
			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