Mark some readonly fields readonly (dotnet/coreclr#19559)
authorBen Adams <thundercat@illyriad.co.uk>
Mon, 20 Aug 2018 16:30:37 +0000 (17:30 +0100)
committerJan Kotas <jkotas@microsoft.com>
Mon, 20 Aug 2018 16:30:37 +0000 (09:30 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/1f1d43abf34ba27e86ff4150d6970e7d1fda98d0

src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs

index 69363d6..bc30407 100644 (file)
@@ -1157,11 +1157,11 @@ namespace System.Collections.Generic
         public struct Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>,
             IDictionaryEnumerator
         {
-            private Dictionary<TKey, TValue> _dictionary;
-            private int _version;
+            private readonly Dictionary<TKey, TValue> _dictionary;
+            private readonly int _version;
             private int _index;
             private KeyValuePair<TKey, TValue> _current;
-            private int _getEnumeratorRetType;  // What should Enumerator.Current return?
+            private readonly int _getEnumeratorRetType;  // What should Enumerator.Current return?
 
             internal const int DictEntry = 1;
             internal const int KeyValuePair = 2;
@@ -1392,9 +1392,9 @@ namespace System.Collections.Generic
 
             public struct Enumerator : IEnumerator<TKey>, IEnumerator
             {
-                private Dictionary<TKey, TValue> _dictionary;
+                private readonly Dictionary<TKey, TValue> _dictionary;
                 private int _index;
-                private int _version;
+                private readonly int _version;
                 private TKey _currentKey;
 
                 internal Enumerator(Dictionary<TKey, TValue> dictionary)
@@ -1575,9 +1575,9 @@ namespace System.Collections.Generic
 
             public struct Enumerator : IEnumerator<TValue>, IEnumerator
             {
-                private Dictionary<TKey, TValue> _dictionary;
+                private readonly Dictionary<TKey, TValue> _dictionary;
                 private int _index;
-                private int _version;
+                private readonly int _version;
                 private TValue _currentValue;
 
                 internal Enumerator(Dictionary<TKey, TValue> dictionary)
index 8d6d25b..698abe9 100644 (file)
@@ -1116,9 +1116,9 @@ namespace System.Collections.Generic
 
         public struct Enumerator : IEnumerator<T>, IEnumerator
         {
-            private List<T> _list;
+            private readonly List<T> _list;
             private int _index;
-            private int _version;
+            private readonly int _version;
             private T _current;
 
             internal Enumerator(List<T> list)