- Since
ReadOnlyCollection<T> exposes indexer, its naming should be ReadOnlyList<T> to stuck with current approach.
- Implementing
ICollection<T>, IList<T>, IList is also debatable. Since .NET Core is brand new, one could have been observing more changes to collection designs:
• Saying that ReadOnlyCollection<T> is implementing these is as well designed as design IReadOnlyList<T> in manner where public indexer public T this[int index] { get; } will have setter part supposed to throwing NotImplementedException.
• Proper way is to redesign read-only interfaces in a way that they are providing non-altering methods like Contains(T), IndexOf(T) and remove these methods from their alter-also counterparts. So for instance ICollection<T>.Contains(T) should be sited to IReadOnlyCollection<T>. Alike IList<T>.IndexOf<T> should be in IReadOnlyList<T>. Then altering interface should implement read-only interface in natural logic way of inheritance design.
Then there can be ReadOnlyList<T> not implementing many methods that throws exception. 👍