Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Remove version increment from Dictionary<K,V>.Remove overloads #18854

Merged
merged 5 commits into from
Jul 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ public bool Remove(TKey key)
}
_freeList = i;
_freeCount++;
_version++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth a comment indicating why we aren't incrementing version in these places - without context, it might look like a mistake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside I think we are inconsistent already. Looks like both TrimExcess() and EnsureCapacity() are missing version increments, even though they can invalidate an enumeration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like both TrimExcess() and EnsureCapacity() are missing version increments, even though they can invalidate an enumeration.

Bug that we should fix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both could silently change enumeration results in the worst case so i'd say bug and fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true;
}

Expand Down Expand Up @@ -865,7 +864,6 @@ public bool Remove(TKey key, out TValue value)
}
_freeList = i;
_freeCount++;
_version++;
return true;
}

Expand Down
109 changes: 108 additions & 1 deletion tests/CoreFX/TopN.CoreFX.x64.Unix.issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,112 @@
"classes": null,
"methods": []
}
},
{
"name": "System.Collections.Tests",
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
"methods": [
{
"name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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_string_string.IEnumerable_Generic_Enumerator_Reset_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_string_string.IEnumerable_Generic_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_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_Reset_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.IEnumerable_Generic_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_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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_int_int.IEnumerable_Generic_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_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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_int_int.IEnumerable_Generic_Enumerator_Reset_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_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"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"
}
]
}
}
]
]
118 changes: 113 additions & 5 deletions tests/CoreFX/TopN.CoreFX.x64.Windows.issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[
{
"name": "System.Console.Tests",
"enabled": true,
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
Expand All @@ -20,7 +20,7 @@
},
{
"name": "System.Drawing.Common.Tests",
"enabled": true,
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
Expand Down Expand Up @@ -70,7 +70,8 @@
},
{
"name": "System.Security.Cryptography.X509Certificates.Tests",
"enabled": true, "exclusions": {
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
"methods": [
Expand Down Expand Up @@ -110,7 +111,7 @@
},
{
"name": "System.Threading.Tests",
"enabled": true,
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
Expand All @@ -124,7 +125,7 @@
},
{
"name": "System.Xml.Xsl.XslTransformApi.Tests",
"enabled": true,
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
Expand All @@ -139,5 +140,112 @@
}
]
}
},
{
"name": "System.Collections.Tests",
"enabled": true,
"exclusions": {
"namespaces": null,
"classes": null,
"methods": [
{
"name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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_string_string.IEnumerable_Generic_Enumerator_Reset_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_string_string.IEnumerable_Generic_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_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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.IEnumerable_Generic_Enumerator_Reset_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.IEnumerable_Generic_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_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_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_int_int.IEnumerable_Generic_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_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_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_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_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_int_int.IEnumerable_Generic_Enumerator_Reset_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_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException",
"reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n"
},
{
"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"
}
]
}
}
]