Open
Description
There are many places in the Linq / Collection code that leverage detecting if an IEnumerable<T>
is an ICollection<T>
to perform optimizations (e.g. presizing a new array, etc.)
Because ICollection<T>
implements IReadonlyCollection<T>
, IReadonlyCollection<T>
should be exclusively used in these scenarios to support custom IReadonlyCollection<T>
implementations that don't necessary want to expose Add(T item)
Currently, collection authors have to implement ICollection to take advantage of the performance gains and leave Add throwing NotImplementedException
to convey proper usage.