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

Conversation

Wraith2
Copy link

@Wraith2 Wraith2 commented Jul 10, 2018

Removes the version increment from Remove operations

This addresses the coreclr side of the api change Add Dictionary<K,V>.Remove(predicate) with the intention of allowing removal of items from the dictionary while enumerating per direction from @jkotas . All collections tests and modified and new tests added in the related corefx PR.

@@ -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.

Copy link
Member

@danmoseley danmoseley left a comment

Choose a reason for hiding this comment

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

LGTM .. thanks!

@stephentoub
Copy link
Member

With the new test system @A-And implemented, ~50 tests are now failing as a result of this change and will need to be disabled in coreclr before it can be merged (they will then need to also be fixed in corefx).

@A-And
Copy link

A-And commented Jul 11, 2018

To disable a test you can add it to the exclusion list.

The expected format and a guide for testing can be found in the repo.

@Wraith2
Copy link
Author

Wraith2 commented Jul 12, 2018

@A-And thanks for the info. I've added the exclusions and the tests are re-running. I wasn't quite sure if I needed to add the parameters in the names but did so anyway.

@danmosemsft if I ever get this PR and tests merged I'll probably pick up the trim one as well since I'm familiar with the area.

@A-And
Copy link

A-And commented Jul 12, 2018

@Wraith2 - the parameter names are tripping up the testing framework - you'd probably want just the test names, i.e. System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException

@danmoseley
Copy link
Member

@A-And the test still is failing eg https://ci.dot.net/job/dotnet_coreclr/job/master/job/x64_checked_osx10.12_corefx_innerloop_prtest/164/ but seems excluded b49ee54#diff-2cb3a7742fa51cdfeb43b1cf4d901391R225

Can you please help us get this PR green?

@A-And
Copy link

A-And commented Jul 12, 2018

Alright, so there seems to be two thing here -

The OSX and Ubuntu exclusions need to be added to https://github.com/dotnet/coreclr/blob/master/tests/CoreFX/TopN.CoreFX.x64.Unix.issues.json (this just got merged yesterday). Currently they're excluded on Windows, but not on OSX or Ubuntu. That was my bad - I should have mentioned it.

See my comment for the Windows failing jobs.

"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(count: 1)",
"name": " System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException",
Copy link

Choose a reason for hiding this comment

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

This is being passed with an extra space in the beginning - the xunit runner parses it as a command arg and the test suite fails.
I.e. if you check https://ci.dot.net/job/dotnet_coreclr/job/master/job/x64_checked_windows_nt_corefx_innerloop_prtest/642/consoleFull you'll see:
error: unknown command line option: System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException

@danmoseley
Copy link
Member

We can merge now right? Still says WIP

@danmoseley
Copy link
Member

Could you please open a corefx issue to follow up and take advantage of this change in our corefx product code?

@Wraith2 Wraith2 changed the title [WIP] Remove version increment from Dictionary<K,V>.Remove overloads Remove version increment from Dictionary<K,V>.Remove overloads Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants