Bug 3028 - ArgumentException with enumerable.AsQueryable() expressions
Summary: ArgumentException with enumerable.AsQueryable() expressions
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: Highest critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2012-01-24 10:23 UTC by Eric Maupin
Modified: 2015-02-03 07:26 UTC (History)
4 users (show)

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

Sample project producing the error (6.20 KB, application/zip)
2012-01-24 10:23 UTC, Eric Maupin

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 Eric Maupin 2012-01-24 10:23:08 UTC
Created attachment 1260 [details]
Sample project producing the error

When using IEnumerable<T>.AsQueryable(), any LINQ expression used produces an ArgumentException for no reason.

This only occurs on the device, not the simulator. Tested with an iPhone 4 running 5.0.1 (9A405)

Example code:
string[] foos = new string[] { "hi", "bye" };
string f = foos.AsQueryable().First ();
Comment 1 Sebastien Pouliot 2012-01-25 10:53:24 UTC
confirmed, test case added in unit tests
Comment 2 Sebastien Pouliot 2012-01-26 08:46:16 UTC
> This only occurs on the device, not the simulator.

Nope, I get it under the simulator too, same as device (but it runs fine with Mono 2.10). 

note: Please always paste your exceptions/errors inside the bug reports so we can ensure we're hitting the exact same issue.

	[FAIL] AsQueryable_3028 : System.ArgumentException : arguments
		  at System.Linq.Expressions.Expression.CheckMethodArguments (System.Reflection.MethodBase method, IEnumerable`1 args) [0x00076] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq.Expressions/Expression.cs:1950 
		  at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, IEnumerable`1 arguments) [0x00075] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq.Expressions/Expression.cs:1033 
		  at System.Linq.Expressions.ExpressionTransformer.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) [0x00032] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq.Expressions/ExpressionTransformer.cs:201 
		  at System.Linq.QueryableTransformer.VisitMethodCall (System.Linq.Expressions.MethodCallExpression methodCall) [0x00018] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/QueryableTransformer.cs:48 
		  at System.Linq.Expressions.ExpressionTransformer.Visit (System.Linq.Expressions.Expression exp) [0x0012d] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq.Expressions/ExpressionTransformer.cs:95 
		  at System.Linq.Expressions.ExpressionTransformer.Transform (System.Linq.Expressions.Expression expression) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq.Expressions/ExpressionTransformer.cs:41 
		  at System.Linq.QueryableEnumerable`1[System.String].TransformQueryable (System.Linq.Expressions.Expression expression) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/QueryableEnumerable.cs:103 
		  at System.Linq.QueryableEnumerable`1[System.String].Execute[String] (System.Linq.Expressions.Expression expression) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/QueryableEnumerable.cs:113 
		  at System.Linq.Queryable.First[String] (IQueryable`1 source) [0x00006] in /Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Queryable.cs:575 
		  at MonoTouchFixtures.LinkSdkRegressionTest.AsQueryable_3028 () [0x00017] in /Developer/MonoTouch/Source/monotouch/tests/linksdk/LinkSdkRegressionTest.cs:340 
		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
		  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000c0] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:234 

One of the (default) difference between simulator and device (beside the AOT compiler) is that linking is disabled on simulator and enabled on devices (but you can change that whenever in doubt). Since I added the test to the "linksdk" unit test it *did* fail on the simulator. Turning linking off on device builds also worked (confirming it's related to linking).

IOW the linker is not preserving something it requires to allow this code to work properly.
Comment 3 Sebastien Pouliot 2012-01-26 10:41:13 UTC
fixed in 27ac6a871fba0128c3f7151a3b52f16835c25b14