Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an invalid operation exception when enumerating RarelyRemoveItemSet. #1352

Merged
merged 1 commit into from
Sep 19, 2024
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 @@ -205,7 +205,7 @@ public bool MoveNext()

case IndexBeforeFirstArrayElement:
this.currentIndex = 0;
return true;
return this.count > 0;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ public void RemoveFromTwoFIFO()
Assert.Empty(this.list.ToArray());
}

[Fact]
public void RemoveFromTwoEnumeration()
{
var value1 = new GenericParameterHelper(1);
var value2 = new GenericParameterHelper(2);
this.list.Add(value1);
this.list.Add(value2);

this.list.Remove(value1);
this.list.Remove(value2);

int count = 0;
foreach (GenericParameterHelper item in this.list.EnumerateAndClear())
{
count++;
}

Assert.Equal(0, count);
}

[Fact]
public void RemoveFromMultiple()
{
Expand Down