提交 16faf273 编写于 作者: V VSadov

Merge pull request #9036 from VSadov/fixCr

Last  \r in source should not be represented as if there is another line in the source.
......@@ -83,5 +83,20 @@ public void TestBinary()
{
CSharpSyntaxTree.ParseText(new RandomizedSourceText());
}
[WorkItem(8200, "https://github.com/dotnet/roslyn/issues/8200")]
[Fact]
public void EolParsing()
{
var code = "\n\r"; // Note, it's not "\r\n"
var tree = CSharpSyntaxTree.ParseText(code);
var lines1 = tree.GetText().Lines.Count; // 3
var textSpan = Text.TextSpan.FromBounds(0, tree.Length);
var fileLinePositionSpan = tree.GetLineSpan(textSpan); // throws ArgumentOutOfRangeException
var endLinePosition = fileLinePositionSpan.EndLinePosition;
var line = endLinePosition.Line;
var lines2 = line + 1;
}
}
}
......@@ -801,7 +801,7 @@ private int[] ParseLineStarts()
var index = 0;
if (lastWasCR)
{
if (buffer.Length > 0 && buffer[0] == '\n')
if (length > 0 && buffer[0] == '\n')
{
index++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册