Skip to content

Commit

Permalink
Fix an invalid operation exception when enumerating RarelyRemoveItemSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
lifengl committed Sep 19, 2024
1 parent 71812ef commit d102825
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit d102825

Please sign in to comment.