Skip to content

Commit bbe3328

Browse files
authored
Merge pull request #1352 from microsoft/dev/lifengl/invalidOperationDuringLoadingSolution
Fix an invalid operation exception when enumerating RarelyRemoveItemSet.
2 parents 71812ef + d102825 commit bbe3328

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Microsoft.VisualStudio.Threading/RarelyRemoveItemSet`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public bool MoveNext()
205205

206206
case IndexBeforeFirstArrayElement:
207207
this.currentIndex = 0;
208-
return true;
208+
return this.count > 0;
209209
}
210210
}
211211

test/Microsoft.VisualStudio.Threading.Tests/RarelyRemoveItemSetTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,26 @@ public void RemoveFromTwoFIFO()
127127
Assert.Empty(this.list.ToArray());
128128
}
129129

130+
[Fact]
131+
public void RemoveFromTwoEnumeration()
132+
{
133+
var value1 = new GenericParameterHelper(1);
134+
var value2 = new GenericParameterHelper(2);
135+
this.list.Add(value1);
136+
this.list.Add(value2);
137+
138+
this.list.Remove(value1);
139+
this.list.Remove(value2);
140+
141+
int count = 0;
142+
foreach (GenericParameterHelper item in this.list.EnumerateAndClear())
143+
{
144+
count++;
145+
}
146+
147+
Assert.Equal(0, count);
148+
}
149+
130150
[Fact]
131151
public void RemoveFromMultiple()
132152
{

0 commit comments

Comments
 (0)