From cc2392ed49a9cb9c2e60ff8da83152491d72ba2f Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Wed, 28 Mar 2018 21:23:39 +0100 Subject: [PATCH] Fix Dictionary CopyTo regression --- .../System/Collections/Generic/Dictionary.cs | 14 +++++++------- .../shared/System/Collections/Generic/List.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs index 827cc24ac247..f0e892859ed1 100644 --- a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs @@ -315,7 +315,7 @@ private void CopyTo(KeyValuePair[] array, int index) { if (entries[i].hashCode >= 0) { - array[index + i] = new KeyValuePair(entries[i].key, entries[i].value); + array[index++] = new KeyValuePair(entries[i].key, entries[i].value); } } } @@ -822,7 +822,7 @@ void ICollection.CopyTo(Array array, int index) { if (entries[i].hashCode >= 0) { - dictEntryArray[index + i] = new DictionaryEntry(entries[i].key, entries[i].value); + dictEntryArray[index++] = new DictionaryEntry(entries[i].key, entries[i].value); } } } @@ -842,7 +842,7 @@ void ICollection.CopyTo(Array array, int index) { if (entries[i].hashCode >= 0) { - objects[index + i] = new KeyValuePair(entries[i].key, entries[i].value); + objects[index++] = new KeyValuePair(entries[i].key, entries[i].value); } } } @@ -1210,7 +1210,7 @@ public void CopyTo(TKey[] array, int index) Entry[] entries = _dictionary._entries; for (int i = 0; i < count; i++) { - if (entries[i].hashCode >= 0) array[index + i] = entries[i].key; + if (entries[i].hashCode >= 0) array[index++] = entries[i].key; } } @@ -1270,7 +1270,7 @@ void ICollection.CopyTo(Array array, int index) { for (int i = 0; i < count; i++) { - if (entries[i].hashCode >= 0) objects[index + i] = entries[i].key; + if (entries[i].hashCode >= 0) objects[index++] = entries[i].key; } } catch (ArrayTypeMismatchException) @@ -1393,7 +1393,7 @@ public void CopyTo(TValue[] array, int index) Entry[] entries = _dictionary._entries; for (int i = 0; i < count; i++) { - if (entries[i].hashCode >= 0) array[index + i] = entries[i].value; + if (entries[i].hashCode >= 0) array[index++] = entries[i].value; } } @@ -1453,7 +1453,7 @@ void ICollection.CopyTo(Array array, int index) { for (int i = 0; i < count; i++) { - if (entries[i].hashCode >= 0) objects[index + i] = entries[i].value; + if (entries[i].hashCode >= 0) objects[index++] = entries[i].value; } } catch (ArrayTypeMismatchException) diff --git a/src/mscorlib/shared/System/Collections/Generic/List.cs b/src/mscorlib/shared/System/Collections/Generic/List.cs index a5cbf12a658b..6b9f9b45b35c 100644 --- a/src/mscorlib/shared/System/Collections/Generic/List.cs +++ b/src/mscorlib/shared/System/Collections/Generic/List.cs @@ -163,12 +163,12 @@ public T this[int index] set { - _version++; if ((uint)index >= (uint)_size) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } _items[index] = value; + _version++; } }