Bug 33324 - Casting List to IList causes argument exception on device build in Add method.
Summary: Casting List to IList causes argument exception on device build in Add method.
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 8.10
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
Depends on:
Reported: 2015-08-24 08:08 UTC by INs
Modified: 2015-08-27 16:35 UTC (History)
3 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 INs 2015-08-24 08:08:24 UTC
Code like following:

var list = new List<double?> ();
 var l = (IList)list;
 l.Add (1.0);
 l.Add (null);

Raises the exception when running on device, but under simulator works fine. Found that issue when tried to deserialize a list of nullable doubles using Json.NET.

Actual Results:

Argument exception is raised.

Expected Results:

Should work without exceptions.

How often does this happen? 

Additional Information:

System.ArgumentNullException: Argument cannot be null.\nParameter name: item\n  at System.ThrowHelper.ThrowArgumentNullException (ExceptionArgument argument) [0x00000] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/external/referencesource/mscorlib/system/throwhelper.cs:82 \n  at System.ThrowHelper.IfNullAndNullsAreIllegalThenThrow[Nullable1] (System.Object value, ExceptionArgument argName) [0x00019] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/external/referencesource/mscorlib/system/throwhelper.cs:121 \n at (wrapper unknown) object:gsharedvt_in ()\n at (wrapper unknown) object:gsharedvt_out ()\n at System.Collections.Generic.List1[System.Nullable1[System.Double]].System.Collections.IList.Add (System.Object item) [0x00000] in /Users/builder/data/lanes/1977/2c66d2fe/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:256 \n`
Comment 1 Zoltan Varga 2015-08-27 16:34:22 UTC
Fixed by mono master d60aec02dca1e3ee15f21672675c2c275199b67a. The fix will be in an upcoming xamarin.ios release.
Comment 2 Zoltan Varga 2015-08-27 16:35:42 UTC
maccore master 3f2249d3d7ca48ab2131fda856d6f691b3c0ca4d is the mono bump which contains the fix.