From 92d8f19e11e01948fdbdd3c87867b019a4250006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaya=20Da=CC=81vid?= Date: Fri, 13 Jul 2018 23:29:23 +0200 Subject: [PATCH] Version increment for TrimExcess and EnsureCapacity (#31007) --- src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs b/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs index ece6f44f33b9..a045cf39e0e4 100644 --- a/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs +++ b/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs @@ -972,6 +972,7 @@ public int EnsureCapacity(int capacity) int currentCapacity = _entries == null ? 0 : _entries.Length; if (currentCapacity >= capacity) return currentCapacity; + _version++; if (_buckets == null) return Initialize(capacity); int newSize = HashHelpers.GetPrime(capacity); @@ -1011,6 +1012,7 @@ public void TrimExcess(int capacity) return; int oldCount = _count; + _version++; Initialize(newSize); Entry[] entries = _entries; int[] buckets = _buckets;