Repository navigation
Fix HashSet enumerator-invalidation test flags - #137165
Merged
eiriktsarpalis merged 1 commit intoNov 9, 2026
Merged
Conversation
ModifyEnumeratorThrows was derived from base.ModifyEnumeratorAllowed (None), so None & ~(...) left the modify-during-enumeration tests with nothing to check. Derive it from base.ModifyEnumeratorThrows instead, mark the empty-set singleton enumerator as not throwing, exclude Clear in the non-generic suite (HashSet.Clear does not invalidate), and give that suite an Add operation so its throw tests are not vacuous. Removing _version++ from HashSet.AddIfNotPresent previously passed all System.Collections tests; with this change 60 tests fail.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-collections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both HashSet test suites set
ModifyEnumeratorThrowsfrombase.ModifyEnumeratorAllowed, which isNone.None & ~(...)is alwaysNone, so the modify-during-enumeration tests have had nothing to check for HashSet since #37180. You can delete_version++fromHashSet<T>.AddIfNotPresentand System.Collections.Tests still passes.This switches both suites to
base.ModifyEnumeratorThrows. Two more changes were needed once the tests actually ran:Enumerator_Empty_ModifiedDuringEnumeration_ThrowsInvalidOperationExceptionis now false, same as in the LinkedList and OrderedDictionary tests.With this change System.Collections.Tests passes on osx-arm64, and removing that
_version++fails 60 tests.Overwriteends up in both the throws and allowed sets of the generic suite. It has no effect, since nothing generates an Overwrite operation for sets, but I can exclude it.