The new read-only interfaces in .NET 4.5 such as IReadOnlyCollection<T>
and IReadOnlyDictionary<TKey,TValue>
are very useful, especially since they have been implemented on common BCL types such as Collection<T>
, List<T>
and Dictionary<TKey,TValue>
.
However, HashSet<T>
and SortedSet<T>
haven't been upgraded to implement IReadOnlyCollection<T>
, and I can't see the logic behind this decision since those classes match the interface without any modification or breaking change. Was it just overlooked by the BCL team, or is there something I'm missing here?
(This is especially annoying since there are no built-in ways to wrap a set inside a IReadOnlyCollection<T>
. Indeed, ReadOnlyCollection<T>
wraps IList<T>
and not ICollection<T>
. I know writing my own wrapper is trivial.)