Bug 44510 - Cannot cast array to IList in PCL projects
Summary: Cannot cast array to IList in PCL projects
Status: RESOLVED DUPLICATE of bug 44402
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2016-09-20 01:08 UTC by Adam
Modified: 2016-09-20 10:20 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 GitHub or Developer Community 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 Adam 2016-09-20 01:08:53 UTC
I am using Xamarin Studio on a Mac, for iOS. My project contains a PCL (net45, profile78) project, and an iOS project.

In the iOS Project - this compiles:
IList list = (IList)new string[] { "DOES THIS CAST?" };

In the PCL project - this generates a compile error "cannot convert type 'string[]' to 'System.Collections.IList'" :
IList list = (IList)new string[] { "DOES THIS CAST?" };

Obviously, this code used to be perfectly fine.
I discovered this, because our application started crashing after updating Xamarin, because the following line:

// items is an array
var candidate = new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Add, items, candidate.NewStartingIndex);

used to resolve to this method declaration
public NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction action, IList changedItems, int startingIndex)

and NOW it's resolving to this one:
public NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction action, object changedItem, int index)

My "notify collection changed event" that is then fired, reports a collection of a collection! So my handlers puke...

This is a HUGE bug, HELP!!!!!
Comment 1 Marek Safar 2016-09-20 07:49:45 UTC

*** This bug has been marked as a duplicate of bug 44402 ***