提交 e4e5e0d8 编写于 作者: M Matt Warren

Appease Jason

上级 aa2ec337
......@@ -603,18 +603,22 @@ public void TestLargeTextWriterDoesNotResuseSmallChunks()
[WorkItem(10452, "https://github.com/dotnet/roslyn/issues/10452")]
public void TestEmptyChangeAfterChange()
{
SourceText.From("Hello World")
.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)) // prepare a ChangedText instance
.WithChanges(); // this should not cause exception
var original = SourceText.From("Hello World");
var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance
var change2 = change1.WithChanges(); // this should not cause exception
Assert.Same(change1, change2); // this was a no-op and returned the same instance
}
[Fact]
[WorkItem(10452, "https://github.com/dotnet/roslyn/issues/10452")]
public void TestEmptyChangeAfterChange2()
{
SourceText.From("Hello World")
.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)) // prepare a ChangedText instance
.WithChanges(new TextChange(new TextSpan(2, 0), string.Empty)); // this should not cause exception
var original = SourceText.From("Hello World");
var change1 = original.WithChanges(new TextChange(new TextSpan(5, 6), string.Empty)); // prepare a ChangedText instance
var change2 = change1.WithChanges(new TextChange(new TextSpan(2, 0), string.Empty)); // this should not cause exception
Assert.Same(change1, change2); // this was a no-op and returned the same instance
}
}
}
\ No newline at end of file
......@@ -83,7 +83,7 @@ public override void CopyTo(int sourceIndex, char[] destination, int destination
public override SourceText WithChanges(IEnumerable<TextChange> changes)
{
// compute changes against newText to avoid capturing strong references to this ChangedText instance.
// note: _newText is never a ChangeText, so if WithChanges is a no-op the result will not be a ChangedText
// note: _newText is never a ChangedText, so if WithChanges is a no-op the result will not be a ChangedText
var changed = _newText.WithChanges(changes) as ChangedText;
if (changed != null)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册