diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
index 59dd15d9e23..1f5570155f3 100644
--- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/CSharpBlockTest.cs
@@ -1082,6 +1082,136 @@ public void SwitchExpression_WithMarkupInside_WithLessThan()
""");
}
+ [Fact]
+ public void GitConflictMarker_InMarkup()
+ {
+ ParseDocumentTest("""
+
+ <<<<<<< HEAD
+
Current changes
+ =======
+
Incoming changes
+ >>>>>>> feature-branch
+
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_InCodeBlock()
+ {
+ ParseDocumentTest("""
+ @{
+ <<<<<<< HEAD
+ var x = 1;
+ =======
+ var x = 2;
+ >>>>>>> feature-branch
+ }
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_InExpression()
+ {
+ ParseDocumentTest("""
+ @(
+ <<<<<<< HEAD
+ someValue
+ =======
+ otherValue
+ >>>>>>> feature-branch
+ )
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_MixedWithRazor()
+ {
+ ParseDocumentTest("""
+ @if (true)
+ {
+ <<<<<<< HEAD
+ @currentValue
+ =======
+ @incomingValue
+ >>>>>>> feature-branch
+ }
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_StartMarkerOnly()
+ {
+ ParseDocumentTest("""
+
+ <<<<<<< HEAD
+
Unresolved conflict
+
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_WithDividerOnly()
+ {
+ ParseDocumentTest("""
+
+ <<<<<<< HEAD
+
Current changes
+ =======
+
Missing end marker
+
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_AtDocumentStart()
+ {
+ ParseDocumentTest("""
+ <<<<<<< HEAD
+ Current
+ =======
+ Incoming
+ >>>>>>> main
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_InImplicitExpression()
+ {
+ ParseDocumentTest("""
+ @<<<<<<< HEAD
+ """);
+ }
+
+
+ [Fact]
+ public void GitConflictMarker_Malformed_Trailing()
+ {
+ ParseDocumentTest("""
+ @{
+ <<<<<<< HEAD var x = 0;
+ var x = 1;
+ ======= var x = 3;
+ var x = 2;
+ >>>>>>> feature-branch var x = 4;
+ }
+ """);
+ }
+
+ [Fact]
+ public void GitConflictMarker_Malformed_Leading()
+ {
+ ParseDocumentTest("""
+ @{
+ var x = 0; <<<<<<< HEAD
+ var x = 1;
+ var x = 3; =======
+ var x = 2;
+ var x = 4; >>>>>>> feature-branch
+ }
+ """);
+ }
+
private void RunRazorCommentBetweenClausesTest(string preComment, string postComment, AcceptedCharactersInternal acceptedCharacters = AcceptedCharactersInternal.Any)
{
ParseDocumentTest(preComment + "@* Foo *@ @* Bar *@" + postComment);
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.cspans.txt
new file mode 100644
index 00000000000..538ba88714f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.cspans.txt
@@ -0,0 +1,17 @@
+Markup span at (0:0,0 [1] ) - Parent: Tag block at (0:0,0 [1] )
+Markup span at (1:0,1 [1] ) - Parent: Tag block at (1:0,1 [1] )
+Markup span at (2:0,2 [1] ) - Parent: Tag block at (2:0,2 [1] )
+Markup span at (3:0,3 [1] ) - Parent: Tag block at (3:0,3 [1] )
+Markup span at (4:0,4 [1] ) - Parent: Tag block at (4:0,4 [1] )
+Markup span at (5:0,5 [1] ) - Parent: Tag block at (5:0,5 [1] )
+Markup span at (6:0,6 [1] ) - Parent: Tag block at (6:0,6 [8] )
+Markup span at (7:0,7 [5] ) - Parent: Markup block at (7:0,7 [5] )
+Markup span at (12:0,12 [2] ) - Parent: Tag block at (6:0,6 [8] )
+Markup span at (14:1,0 [3] ) - Parent: Tag block at (14:1,0 [3] )
+Markup span at (17:1,3 [7] ) - Parent: Markup block at (0:0,0 [68] )
+Markup span at (24:1,10 [4] ) - Parent: Tag block at (24:1,10 [4] )
+Markup span at (28:1,14 [11] ) - Parent: Markup block at (0:0,0 [68] )
+Markup span at (39:3,0 [3] ) - Parent: Tag block at (39:3,0 [3] )
+Markup span at (42:3,3 [8] ) - Parent: Markup block at (0:0,0 [68] )
+Markup span at (50:3,11 [4] ) - Parent: Tag block at (50:3,11 [4] )
+Markup span at (54:3,15 [14] ) - Parent: Markup block at (0:0,0 [68] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.stree.txt
new file mode 100644
index 00000000000..97c0c5d7496
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_AtDocumentStart.stree.txt
@@ -0,0 +1,91 @@
+RazorDocument - [0..68)::68 - [<<<<<<< HEADLFCurrent
LF=======LFIncoming
LF>>>>>>> main]
+ MarkupBlock - [0..68)::68
+ MarkupElement - [0..1)::1
+ MarkupStartTag - [0..1)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [1..2)::1
+ MarkupStartTag - [1..2)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [2..3)::1
+ MarkupStartTag - [2..3)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [3..4)::1
+ MarkupStartTag - [3..4)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [4..5)::1
+ MarkupStartTag - [4..5)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [5..6)::1
+ MarkupStartTag - [5..6)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [6..14)::8
+ MarkupStartTag - [6..14)::8 - [< HEADLF] - Gen
+ OpenAngle;[<];
+ Text;[];
+ MarkupMinimizedAttributeBlock - [7..12)::5 - [ HEAD]
+ MarkupTextLiteral - [7..8)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [8..12)::4 - [HEAD] - Gen
+ Text;[HEAD];
+ MarkupMiscAttributeContent - [12..14)::2
+ MarkupTextLiteral - [12..14)::2 - [LF] - Gen
+ NewLine;[LF];
+ CloseAngle;[];
+ MarkupElement - [14..28)::14
+ MarkupStartTag - [14..17)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [17..24)::7 - [Current] - Gen
+ Text;[Current];
+ MarkupEndTag - [24..28)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [28..39)::11 - [LF=======LF] - Gen
+ NewLine;[LF];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ NewLine;[LF];
+ MarkupElement - [39..54)::15
+ MarkupStartTag - [39..42)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [42..50)::8 - [Incoming] - Gen
+ Text;[Incoming];
+ MarkupEndTag - [50..54)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [54..68)::14 - [LF>>>>>>> main] - Gen
+ NewLine;[LF];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ Whitespace;[ ];
+ Text;[main];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.cspans.txt
new file mode 100644
index 00000000000..8452417f893
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.cspans.txt
@@ -0,0 +1,6 @@
+Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [84] )
+Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [84] )
+MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [84] )
+Code span at (2:0,2 [81] ) - Parent: Statement block at (0:0,0 [84] )
+MetaCode span at (83:6,0 [1] ) - Parent: Statement block at (0:0,0 [84] )
+Markup span at (84:6,1 [0] ) - Parent: Markup block at (0:0,0 [84] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.stree.txt
new file mode 100644
index 00000000000..a9c1ced571d
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InCodeBlock.stree.txt
@@ -0,0 +1,36 @@
+RazorDocument - [0..84)::84 - [@{LF<<<<<<< HEADLF var x = 1;LF=======LF var x = 2;LF>>>>>>> feature-branchLF}]
+ MarkupBlock - [0..84)::84
+ MarkupTextLiteral - [0..0)::0 - [] - Gen
+ Marker;[];
+ CSharpCodeBlock - [0..84)::84
+ CSharpStatement - [0..84)::84
+ CSharpTransition - [0..1)::1 - Gen
+ Transition;[@];
+ CSharpStatementBody - [1..84)::83
+ RazorMetaCode - [1..2)::1 - Gen
+ LeftBrace;[{];
+ CSharpCodeBlock - [2..83)::81
+ CSharpStatementLiteral - [2..83)::81 - [LF<<<<<<< HEADLF var x = 1;LF=======LF var x = 2;LF>>>>>>> feature-branchLF] - Gen
+ NewLine;[LF];
+ ConflictMarkerTrivia;[<<<<<<< HEAD];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[1];
+ Semicolon;[;];
+ NewLine;[LF];
+ ConflictMarkerTrivia;[=======];
+ NewLine;[LF];
+ CSharpDisabledText;[ var x = 2;LF];
+ ConflictMarkerTrivia;[>>>>>>> feature-branch];
+ NewLine;[LF];
+ RazorMetaCode - [83..84)::1 - Gen
+ RightBrace;[}];
+ MarkupTextLiteral - [84..84)::0 - [] - Gen
+ Marker;[];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.cspans.txt
new file mode 100644
index 00000000000..ce2657b53e2
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.cspans.txt
@@ -0,0 +1,6 @@
+Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [75] )
+Transition span at (0:0,0 [1] ) - Parent: Expression block at (0:0,0 [75] )
+MetaCode span at (1:0,1 [1] ) - Parent: Expression block at (0:0,0 [75] )
+Code span at (2:0,2 [72] ) - Parent: Expression block at (0:0,0 [75] )
+MetaCode span at (74:6,0 [1] ) - Parent: Expression block at (0:0,0 [75] )
+Markup span at (75:6,1 [0] ) - Parent: Markup block at (0:0,0 [75] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.stree.txt
new file mode 100644
index 00000000000..ef91dd93443
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InExpression.stree.txt
@@ -0,0 +1,28 @@
+RazorDocument - [0..75)::75 - [@(LF<<<<<<< HEADLFsomeValueLF=======LFotherValueLF>>>>>>> feature-branchLF)]
+ MarkupBlock - [0..75)::75
+ MarkupTextLiteral - [0..0)::0 - [] - Gen
+ Marker;[];
+ CSharpCodeBlock - [0..75)::75
+ CSharpExplicitExpression - [0..75)::75
+ CSharpTransition - [0..1)::1 - Gen
+ Transition;[@];
+ CSharpExplicitExpressionBody - [1..75)::74
+ RazorMetaCode - [1..2)::1 - Gen
+ LeftParenthesis;[(];
+ CSharpCodeBlock - [2..74)::72
+ CSharpExpressionLiteral - [2..74)::72 - [LF<<<<<<< HEADLFsomeValueLF=======LFotherValueLF>>>>>>> feature-branchLF] - Gen
+ NewLine;[LF];
+ ConflictMarkerTrivia;[<<<<<<< HEAD];
+ NewLine;[LF];
+ Identifier;[someValue];
+ NewLine;[LF];
+ ConflictMarkerTrivia;[=======];
+ NewLine;[LF];
+ CSharpDisabledText;[otherValueLF];
+ ConflictMarkerTrivia;[>>>>>>> feature-branch];
+ NewLine;[LF];
+ RazorMetaCode - [74..75)::1 - Gen
+ RightParenthesis;[)];
+ MarkupTextLiteral - [75..75)::0 - [] - Gen
+ Marker;[];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.cspans.txt
new file mode 100644
index 00000000000..5c480248afc
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.cspans.txt
@@ -0,0 +1,12 @@
+Markup span at (0:0,0 [3] ) - Parent: Tag block at (0:0,0 [3] )
+Transition span at (3:0,3 [1] ) - Parent: Expression block at (3:0,3 [1] )
+Code span at (4:0,4 [0] ) - Parent: Expression block at (3:0,3 [1] )
+Markup span at (4:0,4 [1] ) - Parent: Tag block at (4:0,4 [1] )
+Markup span at (5:0,5 [1] ) - Parent: Tag block at (5:0,5 [1] )
+Markup span at (6:0,6 [1] ) - Parent: Tag block at (6:0,6 [1] )
+Markup span at (7:0,7 [1] ) - Parent: Tag block at (7:0,7 [1] )
+Markup span at (8:0,8 [1] ) - Parent: Tag block at (8:0,8 [1] )
+Markup span at (9:0,9 [1] ) - Parent: Tag block at (9:0,9 [1] )
+Markup span at (10:0,10 [1] ) - Parent: Tag block at (10:0,10 [6] )
+Markup span at (11:0,11 [5] ) - Parent: Markup block at (11:0,11 [5] )
+Markup span at (16:0,16 [4] ) - Parent: Tag block at (16:0,16 [4] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.diag.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.diag.txt
new file mode 100644
index 00000000000..97923201b49
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.diag.txt
@@ -0,0 +1 @@
+(1,5): Error RZ1005: "<<" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.stree.txt
new file mode 100644
index 00000000000..6c3d754905f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InImplicitExpression.stree.txt
@@ -0,0 +1,61 @@
+RazorDocument - [0..20)::20 - [@<<<<<<< HEAD
]
+ MarkupBlock - [0..20)::20
+ MarkupElement - [0..20)::20
+ MarkupStartTag - [0..3)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ CSharpCodeBlock - [3..4)::1
+ CSharpImplicitExpression - [3..4)::1
+ CSharpTransition - [3..4)::1 - Gen
+ Transition;[@];
+ CSharpImplicitExpressionBody - [4..4)::0
+ CSharpCodeBlock - [4..4)::0
+ CSharpExpressionLiteral - [4..4)::0 - [] - Gen
+ Marker;[];
+ MarkupElement - [4..5)::1
+ MarkupStartTag - [4..5)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [5..6)::1
+ MarkupStartTag - [5..6)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [6..7)::1
+ MarkupStartTag - [6..7)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [7..8)::1
+ MarkupStartTag - [7..8)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [8..9)::1
+ MarkupStartTag - [8..9)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [9..10)::1
+ MarkupStartTag - [9..10)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [10..16)::6
+ MarkupStartTag - [10..16)::6 - [< HEAD] - Gen
+ OpenAngle;[<];
+ Text;[];
+ MarkupMinimizedAttributeBlock - [11..16)::5 - [ HEAD]
+ MarkupTextLiteral - [11..12)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [12..16)::4 - [HEAD] - Gen
+ Text;[HEAD];
+ CloseAngle;[];
+ MarkupEndTag - [16..20)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.cspans.txt
new file mode 100644
index 00000000000..70e05121515
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.cspans.txt
@@ -0,0 +1,20 @@
+Markup span at (0:0,0 [5] ) - Parent: Tag block at (0:0,0 [5] )
+Markup span at (5:0,5 [2] ) - Parent: Markup block at (0:0,0 [109] )
+Markup span at (7:1,0 [1] ) - Parent: Tag block at (7:1,0 [1] )
+Markup span at (8:1,1 [1] ) - Parent: Tag block at (8:1,1 [1] )
+Markup span at (9:1,2 [1] ) - Parent: Tag block at (9:1,2 [1] )
+Markup span at (10:1,3 [1] ) - Parent: Tag block at (10:1,3 [1] )
+Markup span at (11:1,4 [1] ) - Parent: Tag block at (11:1,4 [1] )
+Markup span at (12:1,5 [1] ) - Parent: Tag block at (12:1,5 [1] )
+Markup span at (13:1,6 [1] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (14:1,7 [5] ) - Parent: Markup block at (14:1,7 [5] )
+Markup span at (19:1,12 [2] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (21:2,0 [3] ) - Parent: Tag block at (21:2,0 [3] )
+Markup span at (24:2,3 [15] ) - Parent: Markup block at (0:0,0 [109] )
+Markup span at (39:2,18 [4] ) - Parent: Tag block at (39:2,18 [4] )
+Markup span at (43:2,22 [11] ) - Parent: Markup block at (0:0,0 [109] )
+Markup span at (54:4,0 [3] ) - Parent: Tag block at (54:4,0 [3] )
+Markup span at (57:4,3 [16] ) - Parent: Markup block at (0:0,0 [109] )
+Markup span at (73:4,19 [4] ) - Parent: Tag block at (73:4,19 [4] )
+Markup span at (77:4,23 [26] ) - Parent: Markup block at (0:0,0 [109] )
+Markup span at (103:6,0 [6] ) - Parent: Tag block at (103:6,0 [6] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.stree.txt
new file mode 100644
index 00000000000..db1555ab415
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_InMarkup.stree.txt
@@ -0,0 +1,108 @@
+RazorDocument - [0..109)::109 - [LF<<<<<<< HEADLF
Current changes
LF=======LF
Incoming changes
LF>>>>>>> feature-branchLF
]
+ MarkupBlock - [0..109)::109
+ MarkupElement - [0..109)::109
+ MarkupStartTag - [0..5)::5 - [] - Gen
+ OpenAngle;[<];
+ Text;[div];
+ CloseAngle;[>];
+ MarkupTextLiteral - [5..7)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupElement - [7..8)::1
+ MarkupStartTag - [7..8)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [8..9)::1
+ MarkupStartTag - [8..9)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [9..10)::1
+ MarkupStartTag - [9..10)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [10..11)::1
+ MarkupStartTag - [10..11)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [11..12)::1
+ MarkupStartTag - [11..12)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [12..13)::1
+ MarkupStartTag - [12..13)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [13..21)::8
+ MarkupStartTag - [13..21)::8 - [< HEADLF] - Gen
+ OpenAngle;[<];
+ Text;[];
+ MarkupMinimizedAttributeBlock - [14..19)::5 - [ HEAD]
+ MarkupTextLiteral - [14..15)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [15..19)::4 - [HEAD] - Gen
+ Text;[HEAD];
+ MarkupMiscAttributeContent - [19..21)::2
+ MarkupTextLiteral - [19..21)::2 - [LF] - Gen
+ NewLine;[LF];
+ CloseAngle;[];
+ MarkupElement - [21..43)::22
+ MarkupStartTag - [21..24)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [24..39)::15 - [Current changes] - Gen
+ Text;[Current];
+ Whitespace;[ ];
+ Text;[changes];
+ MarkupEndTag - [39..43)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [43..54)::11 - [LF=======LF] - Gen
+ NewLine;[LF];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ NewLine;[LF];
+ MarkupElement - [54..77)::23
+ MarkupStartTag - [54..57)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [57..73)::16 - [Incoming changes] - Gen
+ Text;[Incoming];
+ Whitespace;[ ];
+ Text;[changes];
+ MarkupEndTag - [73..77)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [77..103)::26 - [LF>>>>>>> feature-branchLF] - Gen
+ NewLine;[LF];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ CloseAngle;[>];
+ Whitespace;[ ];
+ Text;[feature-branch];
+ NewLine;[LF];
+ MarkupEndTag - [103..109)::6 - [ ] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[div];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.cspans.txt
new file mode 100644
index 00000000000..51a24f6a55b
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.cspans.txt
@@ -0,0 +1,6 @@
+Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [120] )
+Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [120] )
+MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [120] )
+Code span at (2:0,2 [117] ) - Parent: Statement block at (0:0,0 [120] )
+MetaCode span at (119:6,0 [1] ) - Parent: Statement block at (0:0,0 [120] )
+Markup span at (120:6,1 [0] ) - Parent: Markup block at (0:0,0 [120] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.stree.txt
new file mode 100644
index 00000000000..9a036399e86
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Leading.stree.txt
@@ -0,0 +1,93 @@
+RazorDocument - [0..120)::120 - [@{LFvar x = 0; <<<<<<< HEAD LF var x = 1;LFvar x = 3; ======= LF var x = 2;LFvar x = 4; >>>>>>> feature-branch LF}]
+ MarkupBlock - [0..120)::120
+ MarkupTextLiteral - [0..0)::0 - [] - Gen
+ Marker;[];
+ CSharpCodeBlock - [0..120)::120
+ CSharpStatement - [0..120)::120
+ CSharpTransition - [0..1)::1 - Gen
+ Transition;[@];
+ CSharpStatementBody - [1..120)::119
+ RazorMetaCode - [1..2)::1 - Gen
+ LeftBrace;[{];
+ CSharpCodeBlock - [2..119)::117
+ CSharpStatementLiteral - [2..119)::117 - [LFvar x = 0; <<<<<<< HEAD LF var x = 1;LFvar x = 3; ======= LF var x = 2;LFvar x = 4; >>>>>>> feature-branch LF] - Gen
+ NewLine;[LF];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[0];
+ Semicolon;[;];
+ Whitespace;[ ];
+ CSharpOperator;[<<];
+ CSharpOperator;[<<];
+ CSharpOperator;[<<];
+ LessThan;[<];
+ Whitespace;[ ];
+ Identifier;[HEAD];
+ Whitespace;[ ];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[1];
+ Semicolon;[;];
+ NewLine;[LF];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[3];
+ Semicolon;[;];
+ Whitespace;[ ];
+ CSharpOperator;[==];
+ CSharpOperator;[==];
+ CSharpOperator;[==];
+ Assign;[=];
+ Whitespace;[ ];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[2];
+ Semicolon;[;];
+ NewLine;[LF];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[4];
+ Semicolon;[;];
+ Whitespace;[ ];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ GreaterThan;[>];
+ Whitespace;[ ];
+ Identifier;[feature];
+ CSharpOperator;[-];
+ Identifier;[branch];
+ Whitespace;[ ];
+ NewLine;[LF];
+ RazorMetaCode - [119..120)::1 - Gen
+ RightBrace;[}];
+ MarkupTextLiteral - [120..120)::0 - [] - Gen
+ Marker;[];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.cspans.txt
new file mode 100644
index 00000000000..17fdf7a74ff
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.cspans.txt
@@ -0,0 +1,6 @@
+Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [117] )
+Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [117] )
+MetaCode span at (1:0,1 [1] ) - Parent: Statement block at (0:0,0 [117] )
+Code span at (2:0,2 [114] ) - Parent: Statement block at (0:0,0 [117] )
+MetaCode span at (116:6,0 [1] ) - Parent: Statement block at (0:0,0 [117] )
+Markup span at (117:6,1 [0] ) - Parent: Markup block at (0:0,0 [117] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.stree.txt
new file mode 100644
index 00000000000..31e97863b1c
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_Malformed_Trailing.stree.txt
@@ -0,0 +1,36 @@
+RazorDocument - [0..117)::117 - [@{LF<<<<<<< HEAD var x = 0;LF var x = 1;LF======= var x = 3;LF var x = 2;LF>>>>>>> feature-branch var x = 4;LF}]
+ MarkupBlock - [0..117)::117
+ MarkupTextLiteral - [0..0)::0 - [] - Gen
+ Marker;[];
+ CSharpCodeBlock - [0..117)::117
+ CSharpStatement - [0..117)::117
+ CSharpTransition - [0..1)::1 - Gen
+ Transition;[@];
+ CSharpStatementBody - [1..117)::116
+ RazorMetaCode - [1..2)::1 - Gen
+ LeftBrace;[{];
+ CSharpCodeBlock - [2..116)::114
+ CSharpStatementLiteral - [2..116)::114 - [LF<<<<<<< HEAD var x = 0;LF var x = 1;LF======= var x = 3;LF var x = 2;LF>>>>>>> feature-branch var x = 4;LF] - Gen
+ NewLine;[LF];
+ ConflictMarkerTrivia;[<<<<<<< HEAD var x = 0;];
+ NewLine;[LF];
+ Whitespace;[ ];
+ Keyword;[var];
+ Whitespace;[ ];
+ Identifier;[x];
+ Whitespace;[ ];
+ Assign;[=];
+ Whitespace;[ ];
+ NumericLiteral;[1];
+ Semicolon;[;];
+ NewLine;[LF];
+ ConflictMarkerTrivia;[======= var x = 3;];
+ NewLine;[LF];
+ CSharpDisabledText;[ var x = 2;LF];
+ ConflictMarkerTrivia;[>>>>>>> feature-branch var x = 4;];
+ NewLine;[LF];
+ RazorMetaCode - [116..117)::1 - Gen
+ RightBrace;[}];
+ MarkupTextLiteral - [117..117)::0 - [] - Gen
+ Marker;[];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.cspans.txt
new file mode 100644
index 00000000000..e762e40661f
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.cspans.txt
@@ -0,0 +1,3 @@
+Markup span at (0:0,0 [0] ) - Parent: Markup block at (0:0,0 [116] )
+Transition span at (0:0,0 [1] ) - Parent: Statement block at (0:0,0 [116] )
+Code span at (1:0,1 [115] ) - Parent: Statement block at (0:0,0 [116] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.stree.txt
new file mode 100644
index 00000000000..36226ef55af
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_MixedWithRazor.stree.txt
@@ -0,0 +1,35 @@
+RazorDocument - [0..116)::116 - [@if (true)LF{LF<<<<<<< HEADLF @currentValue
LF=======LF @incomingValue
LF>>>>>>> feature-branchLF}]
+ MarkupBlock - [0..116)::116
+ MarkupTextLiteral - [0..0)::0 - [] - Gen
+ Marker;[];
+ CSharpCodeBlock - [0..116)::116
+ CSharpTransition - [0..1)::1 - Gen
+ Transition;[@];
+ CSharpStatementLiteral - [1..116)::115 - [if (true)LF{LF<<<<<<< HEADLF @currentValue
LF=======LF @incomingValue
LF>>>>>>> feature-branchLF}] - Gen
+ Keyword;[if];
+ Whitespace;[ ];
+ LeftParenthesis;[(];
+ Keyword;[true];
+ RightParenthesis;[)];
+ NewLine;[LF];
+ LeftBrace;[{];
+ NewLine;[LF];
+ ConflictMarkerTrivia;[<<<<<<< HEAD];
+ NewLine;[LF];
+ Whitespace;[ ];
+ LessThan;[<];
+ Identifier;[p];
+ GreaterThan;[>];
+ Identifier;[@currentValue];
+ LessThan;[<];
+ CSharpOperator;[/];
+ Identifier;[p];
+ GreaterThan;[>];
+ NewLine;[LF];
+ ConflictMarkerTrivia;[=======];
+ NewLine;[LF];
+ CSharpDisabledText;[ @incomingValue
LF];
+ ConflictMarkerTrivia;[>>>>>>> feature-branch];
+ NewLine;[LF];
+ RightBrace;[}];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.cspans.txt
new file mode 100644
index 00000000000..6af60ee76d5
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.cspans.txt
@@ -0,0 +1,16 @@
+Markup span at (0:0,0 [5] ) - Parent: Tag block at (0:0,0 [5] )
+Markup span at (5:0,5 [2] ) - Parent: Markup block at (0:0,0 [55] )
+Markup span at (7:1,0 [1] ) - Parent: Tag block at (7:1,0 [1] )
+Markup span at (8:1,1 [1] ) - Parent: Tag block at (8:1,1 [1] )
+Markup span at (9:1,2 [1] ) - Parent: Tag block at (9:1,2 [1] )
+Markup span at (10:1,3 [1] ) - Parent: Tag block at (10:1,3 [1] )
+Markup span at (11:1,4 [1] ) - Parent: Tag block at (11:1,4 [1] )
+Markup span at (12:1,5 [1] ) - Parent: Tag block at (12:1,5 [1] )
+Markup span at (13:1,6 [1] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (14:1,7 [5] ) - Parent: Markup block at (14:1,7 [5] )
+Markup span at (19:1,12 [2] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (21:2,0 [3] ) - Parent: Tag block at (21:2,0 [3] )
+Markup span at (24:2,3 [19] ) - Parent: Markup block at (0:0,0 [55] )
+Markup span at (43:2,22 [4] ) - Parent: Tag block at (43:2,22 [4] )
+Markup span at (47:2,26 [2] ) - Parent: Markup block at (0:0,0 [55] )
+Markup span at (49:3,0 [6] ) - Parent: Tag block at (49:3,0 [6] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.stree.txt
new file mode 100644
index 00000000000..a3f64cfc87e
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_StartMarkerOnly.stree.txt
@@ -0,0 +1,74 @@
+RazorDocument - [0..55)::55 - [LF<<<<<<< HEADLF
Unresolved conflict
LF
]
+ MarkupBlock - [0..55)::55
+ MarkupElement - [0..55)::55
+ MarkupStartTag - [0..5)::5 - [] - Gen
+ OpenAngle;[<];
+ Text;[div];
+ CloseAngle;[>];
+ MarkupTextLiteral - [5..7)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupElement - [7..8)::1
+ MarkupStartTag - [7..8)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [8..9)::1
+ MarkupStartTag - [8..9)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [9..10)::1
+ MarkupStartTag - [9..10)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [10..11)::1
+ MarkupStartTag - [10..11)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [11..12)::1
+ MarkupStartTag - [11..12)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [12..13)::1
+ MarkupStartTag - [12..13)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [13..21)::8
+ MarkupStartTag - [13..21)::8 - [< HEADLF] - Gen
+ OpenAngle;[<];
+ Text;[];
+ MarkupMinimizedAttributeBlock - [14..19)::5 - [ HEAD]
+ MarkupTextLiteral - [14..15)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [15..19)::4 - [HEAD] - Gen
+ Text;[HEAD];
+ MarkupMiscAttributeContent - [19..21)::2
+ MarkupTextLiteral - [19..21)::2 - [LF] - Gen
+ NewLine;[LF];
+ CloseAngle;[];
+ MarkupElement - [21..47)::26
+ MarkupStartTag - [21..24)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [24..43)::19 - [Unresolved conflict] - Gen
+ Text;[Unresolved];
+ Whitespace;[ ];
+ Text;[conflict];
+ MarkupEndTag - [43..47)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [47..49)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupEndTag - [49..55)::6 - [ ] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[div];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.cspans.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.cspans.txt
new file mode 100644
index 00000000000..95f201c6ef3
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.cspans.txt
@@ -0,0 +1,20 @@
+Markup span at (0:0,0 [5] ) - Parent: Tag block at (0:0,0 [5] )
+Markup span at (5:0,5 [2] ) - Parent: Markup block at (0:0,0 [87] )
+Markup span at (7:1,0 [1] ) - Parent: Tag block at (7:1,0 [1] )
+Markup span at (8:1,1 [1] ) - Parent: Tag block at (8:1,1 [1] )
+Markup span at (9:1,2 [1] ) - Parent: Tag block at (9:1,2 [1] )
+Markup span at (10:1,3 [1] ) - Parent: Tag block at (10:1,3 [1] )
+Markup span at (11:1,4 [1] ) - Parent: Tag block at (11:1,4 [1] )
+Markup span at (12:1,5 [1] ) - Parent: Tag block at (12:1,5 [1] )
+Markup span at (13:1,6 [1] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (14:1,7 [5] ) - Parent: Markup block at (14:1,7 [5] )
+Markup span at (19:1,12 [2] ) - Parent: Tag block at (13:1,6 [8] )
+Markup span at (21:2,0 [3] ) - Parent: Tag block at (21:2,0 [3] )
+Markup span at (24:2,3 [15] ) - Parent: Markup block at (0:0,0 [87] )
+Markup span at (39:2,18 [4] ) - Parent: Tag block at (39:2,18 [4] )
+Markup span at (43:2,22 [11] ) - Parent: Markup block at (0:0,0 [87] )
+Markup span at (54:4,0 [3] ) - Parent: Tag block at (54:4,0 [3] )
+Markup span at (57:4,3 [18] ) - Parent: Markup block at (0:0,0 [87] )
+Markup span at (75:4,21 [4] ) - Parent: Tag block at (75:4,21 [4] )
+Markup span at (79:4,25 [2] ) - Parent: Markup block at (0:0,0 [87] )
+Markup span at (81:5,0 [6] ) - Parent: Tag block at (81:5,0 [6] )
diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.stree.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.stree.txt
new file mode 100644
index 00000000000..b4ba2898f14
--- /dev/null
+++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpBlockTest/GitConflictMarker_WithDividerOnly.stree.txt
@@ -0,0 +1,100 @@
+RazorDocument - [0..87)::87 - [LF<<<<<<< HEADLF
Current changes
LF=======LF
Missing end marker
LF
]
+ MarkupBlock - [0..87)::87
+ MarkupElement - [0..87)::87
+ MarkupStartTag - [0..5)::5 - [] - Gen
+ OpenAngle;[<];
+ Text;[div];
+ CloseAngle;[>];
+ MarkupTextLiteral - [5..7)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupElement - [7..8)::1
+ MarkupStartTag - [7..8)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [8..9)::1
+ MarkupStartTag - [8..9)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [9..10)::1
+ MarkupStartTag - [9..10)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [10..11)::1
+ MarkupStartTag - [10..11)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [11..12)::1
+ MarkupStartTag - [11..12)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [12..13)::1
+ MarkupStartTag - [12..13)::1 - [<] - Gen
+ OpenAngle;[<];
+ Text;[];
+ CloseAngle;[];
+ MarkupElement - [13..21)::8
+ MarkupStartTag - [13..21)::8 - [< HEADLF] - Gen
+ OpenAngle;[<];
+ Text;[];
+ MarkupMinimizedAttributeBlock - [14..19)::5 - [ HEAD]
+ MarkupTextLiteral - [14..15)::1 - [ ] - Gen
+ Whitespace;[ ];
+ MarkupTextLiteral - [15..19)::4 - [HEAD] - Gen
+ Text;[HEAD];
+ MarkupMiscAttributeContent - [19..21)::2
+ MarkupTextLiteral - [19..21)::2 - [LF] - Gen
+ NewLine;[LF];
+ CloseAngle;[];
+ MarkupElement - [21..43)::22
+ MarkupStartTag - [21..24)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [24..39)::15 - [Current changes] - Gen
+ Text;[Current];
+ Whitespace;[ ];
+ Text;[changes];
+ MarkupEndTag - [39..43)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [43..54)::11 - [LF=======LF] - Gen
+ NewLine;[LF];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ Equals;[=];
+ NewLine;[LF];
+ MarkupElement - [54..79)::25
+ MarkupStartTag - [54..57)::3 - [] - Gen
+ OpenAngle;[<];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [57..75)::18 - [Missing end marker] - Gen
+ Text;[Missing];
+ Whitespace;[ ];
+ Text;[end];
+ Whitespace;[ ];
+ Text;[marker];
+ MarkupEndTag - [75..79)::4 - [
] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[p];
+ CloseAngle;[>];
+ MarkupTextLiteral - [79..81)::2 - [LF] - Gen
+ NewLine;[LF];
+ MarkupEndTag - [81..87)::6 - [ ] - Gen
+ OpenAngle;[<];
+ ForwardSlash;[/];
+ Text;[div];
+ CloseAngle;[>];
+ EndOfFile;[];
diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs
index 5a1f31d3322..8506564443a 100644
--- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs
+++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Legacy/RoslynCSharpTokenizer.cs
@@ -630,6 +630,11 @@ bool startsWith(string substring)
}
}
break;
+ case CSharpSyntaxKind.ConflictMarkerTrivia:
+ tokenType = SyntaxKind.ConflictMarkerTrivia;
+ // conflict markers are only parsed by Roslyn if they start the line, and everything on that line is considered part of the marker
+ _isOnlyWhitespaceOnLine = true;
+ break;
case var kind:
throw new InvalidOperationException($"Unexpected trivia kind: {kind}.");
};
diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs
index dbd94b0e806..3222ff52df7 100644
--- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs
+++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Syntax/SyntaxKind.cs
@@ -145,6 +145,7 @@ internal enum SyntaxKind : byte
// New common (Consider condensing when https://github.com/dotnet/razor/issues/8400 is done and we can break the API).
EndOfFile,
+ ConflictMarkerTrivia,
#endregion
// New nodes should go before this one