diff --git a/Google.Api.Generator.Utils.Tests/Formatting/XmlDocSplitterTest.cs b/Google.Api.Generator.Utils.Tests/Formatting/XmlDocSplitterTest.cs
index 5130672c..c75b4112 100644
--- a/Google.Api.Generator.Utils.Tests/Formatting/XmlDocSplitterTest.cs
+++ b/Google.Api.Generator.Utils.Tests/Formatting/XmlDocSplitterTest.cs
@@ -46,9 +46,17 @@ public void MultiLine()
[Fact]
public void Preformatted()
{
- // Whitespace around " Line 2 " is delibrate, to test extra whitespace removal at end of lines only.
+ // Whitespace around " Line 2 " is deliberate, to test extra whitespace removal at end of lines only.
var s = XmlDocSplitter.Split(s_indent4, 40, TrivList(XmlDoc.SummaryPreFormatted(new[] { "Line 1", " Line 2 " }))).ToFullString();
Assert.Equal($" /// {s_nl} /// Line 1{s_nl} /// Line 2{s_nl} /// {s_nl}", s);
}
+
+ [Fact]
+ public void PreformattedWithAngleBrackets()
+ {
+ var summary = XmlDoc.SummaryPreFormatted(new[] { "Before after" });
+ var split = XmlDocSplitter.Split(s_indent4, 80, TrivList(summary)).ToFullString();
+ Assert.Equal($" /// {s_nl} /// Before <angles> after{s_nl} /// {s_nl}", split);
+ }
}
}
diff --git a/Google.Api.Generator.Utils/Formatting/XmlDocSplitter.cs b/Google.Api.Generator.Utils/Formatting/XmlDocSplitter.cs
index ac8d0379..1a037396 100644
--- a/Google.Api.Generator.Utils/Formatting/XmlDocSplitter.cs
+++ b/Google.Api.Generator.Utils/Formatting/XmlDocSplitter.cs
@@ -85,7 +85,10 @@ private IEnumerable SplitPreformatted(Document
{
if (node is XmlTextSyntax text)
{
- yield return OneLine(XmlText(string.Join("", text.GetText().Lines).TrimEnd()));
+ // Create an XmlTextLiteral with exactly the value we've fetched. This avoids
+ // double-escaping < to < when it should just be <
+ string value = string.Join("", text.GetText().Lines).TrimEnd();
+ yield return OneLine(XmlText(XmlTextLiteral(value, value)));
}
else
{