From 42a435f41a380c6c769e46466644be8bfcc4ebb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?D=C3=A1vid=20Kaya?= Date: Sat, 28 Jul 2018 06:14:32 +0200 Subject: [PATCH] Added version increment for TrimExcess and EnsureCapacity (dotnet/coreclr#19096) * 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 | 12 ++++++++++++ .../src/System/Collections/Generic/Dictionary.cs | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/coreclr/tests/CoreFX/CoreFX.issues.json b/src/coreclr/tests/CoreFX/CoreFX.issues.json index 54ba010..5b85243 100644 --- a/src/coreclr/tests/CoreFX/CoreFX.issues.json +++ b/src/coreclr/tests/CoreFX/CoreFX.issues.json @@ -407,6 +407,18 @@ { "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" } ] } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs index 8f7ad70..69363d6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs @@ -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; -- 2.7.4