Add read-only interfaces to some System/System.Core collection classes.
authorAlex Rønne Petersen <alexrp@xamarin.com>
Tue, 17 Feb 2015 09:48:58 +0000 (10:48 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:07:50 +0000 (00:07 +0200)
mcs/class/referencesource/System.Core/System/Collections/Generic/HashSet.cs
mcs/class/referencesource/System/compmod/system/collections/generic/linkedlist.cs
mcs/class/referencesource/System/compmod/system/collections/generic/sorteddictionary.cs

index 889b638df36e9f76c97d5ef9e55a9becd1effde4..a4b1123148f340d3498048447518b9f13850a0f5 100644 (file)
@@ -61,6 +61,9 @@ namespace System.Collections.Generic {
     [Serializable()]
     [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
     public class HashSet<T> : ICollection<T>, ISerializable, IDeserializationCallback, ISet<T>
+#if MONO
+        , IReadOnlyCollection<T>
+#endif
 #endif
     {
 
index 41efdc5dcd003d80e6c53a64c90324b2c3aeb1ec..b16c750680ff93b6ee63686273b6e11f0a70974e 100644 (file)
@@ -14,9 +14,13 @@ namespace System.Collections.Generic {
 #if SILVERLIGHT
     public class LinkedList<T>: ICollection<T>, System.Collections.ICollection
 #else
+
     [Serializable()]    
     public class LinkedList<T>: ICollection<T>, System.Collections.ICollection
            ,ISerializable, IDeserializationCallback 
+#if MONO
+           , IReadOnlyCollection<T>
+#endif
 #endif
     {
         // This LinkedList is a doubly-Linked circular list.
index 6277e4b6cdf27fc5cd17976a88e2adeb8f5aa8f2..71c55972818ed24e5ef12b7779193da17fb1503f 100644 (file)
@@ -9,7 +9,11 @@ namespace System.Collections.Generic {
 #endif
     [DebuggerTypeProxy(typeof(System_DictionaryDebugView<,>))]
     [DebuggerDisplay("Count = {Count}")]        
-    public class SortedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary {
+    public class SortedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
+#if MONO
+        , IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>
+#endif
+    {
 #if !FEATURE_NETCORE
         [NonSerialized]
 #endif
@@ -146,6 +150,20 @@ namespace System.Collections.Generic {
                 return Values;
             }
         }
+
+#if MONO
+        IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys {
+            get {                
+                return Keys;
+            }
+        }
+
+        IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values {
+            get {                
+                return Values;
+            }
+        }
+#endif
         
         public void Add(TKey key, TValue value) {
             if( key == null) {