From d783311d376853e88aecf461362708d798c76183 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 22 Dec 2020 20:55:00 -0800 Subject: [PATCH] Add regression test for markup splitting line end Closes #637 --- .../MarkupParserTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/MarkupParserTests.cs b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/MarkupParserTests.cs index 2b2d3fe54..e52b63dd0 100644 --- a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/MarkupParserTests.cs +++ b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/MarkupParserTests.cs @@ -375,5 +375,23 @@ public void CDataMarkup2() Assert.True(spans.TryGetValue(string.Empty, out var unnamed)); Assert.Equal(new[] { new TextSpan(0, 9), new TextSpan(13, 3) }, unnamed); } + + [Fact] + [WorkItem(637, "https://github.com/dotnet/roslyn-sdk/issues/637")] + public void MarkupSpanSplitsEndOfLine() + { + var markup = "class C { }\r{|b:\n|}"; + var expected = "class C { }\r\n"; + TestFileMarkupParser.GetPositionsAndSpans(markup, out var result, out var positions, out ImmutableDictionary> spans); + Assert.Equal(expected, result); + + Assert.Empty(positions); + Assert.Single(spans); + + Assert.True(spans.TryGetValue("b", out var named)); + Assert.Equal(new[] { new TextSpan(12, 1) }, named); + + Assert.False(spans.TryGetValue(string.Empty, out _)); + } } }