Added version increment for TrimExcess and EnsureCapacity (dotnet/coreclr#19096)
authorDávid Kaya <mail@davidkaya.sk>
Sat, 28 Jul 2018 04:14:32 +0000 (06:14 +0200)
committerDan Moseley <danmose@microsoft.com>
Sat, 28 Jul 2018 04:14:32 +0000 (21:14 -0700)
* Added version increment for TrimExcess and EnsureCapacity

* Added old unit test to exclusion list

* Excluded missing unit tests

Commit migrated from https://github.com/dotnet/coreclr/commit/5d31194880e800a9df8eef76e7a0a53646aa72d3

src/coreclr/tests/CoreFX/CoreFX.issues.json
src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs

index 54ba010..5b85243 100644 (file)
                 {
                     "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException",
                     "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
+                },
+                {
+                    "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration",
+                    "reason": "outdated"
+                },
+                {
+                    "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration",
+                    "reason": "outdated"
+                },
+                {
+                    "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration",
+                    "reason": "outdated"
                 }
             ]
         }
index 8f7ad70..69363d6 100644 (file)
@@ -970,6 +970,7 @@ namespace System.Collections.Generic
             int currentCapacity = _entries == null ? 0 : _entries.Length;
             if (currentCapacity >= capacity)
                 return currentCapacity;
+            _version++;
             if (_buckets == null)
                 return Initialize(capacity);
             int newSize = HashHelpers.GetPrime(capacity);
@@ -1009,6 +1010,7 @@ namespace System.Collections.Generic
                 return;
 
             int oldCount = _count;
+            _version++;
             Initialize(newSize);
             Entry[] entries = _entries;
             int[] buckets = _buckets;