Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
object Foo (object arr)
return arr ;
Actually, demoting to IList is fine IMO.
The issue I had was that it tried to demote to *object*, which would break the code.
However, I can no longer reproduce that issue.
Ah, IList<T> is okay. IList is not. So your fix is still good :)
Hm, or maybe not. Technically IList is okay here too.
it makes no real sense to 'forbid' arrays - I don't think that we should advise using ILists instead.
Well, the point of demoting the parameter to IList is so that consumers can pass in other IList implementations, e.g. an ArrayList. As long as it's valid, i.e. everything you do to the parameter can be done on an IList, this demotion is a reasonable suggestion IMO, as it makes the API more flexible for consumers.
It's not about API flexibility in this case. When I use arrays then I've a reason to do it - from my POV I use arrays when I want speed.
Now when changing them to ILists I loose some optimizations that can be done with arrays. Arrays are not really ILists - even if they implement that interface.
Ok I changed it back to IList (or IList<T> for non objects).
We generally suggest API flexibility & readable code in other cases - for consistency reasons I'll make it here too.
If performance is a problem the user should just ignore this rule.