Skip to content

Commit e2ad352

Browse files
authored
Merge pull request #176 from octokit/doc-comments-escape-xml-characters
Escaping doc comments with xml characters
2 parents 85bf2d4 + 15feaf5 commit e2ad352

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

Octokit.GraphQL.Core.Generation.UnitTests/EntityGenerationTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,34 @@ public void Generates_Doc_Comments_For_Property()
16321632
CompareModel("Entity.cs", expected, result);
16331633
}
16341634

1635+
[Fact]
1636+
public void Generates_Doc_Comments_For_Property_With_XmlCharacters()
1637+
{
1638+
var expected = FormatMemberTemplate(@"/// <summary>
1639+
/// Testing if doc comments are generated &lt;http://localhost&gt;.
1640+
/// </summary>
1641+
public Other Foo => this.CreateProperty(x => x.Foo, Test.Other.Create);");
1642+
1643+
var model = new TypeModel
1644+
{
1645+
Name = "Entity",
1646+
Kind = TypeKind.Object,
1647+
Fields = new[]
1648+
{
1649+
new FieldModel
1650+
{
1651+
Name = "Foo",
1652+
Description = "Testing if doc comments are generated <http://localhost>.",
1653+
Type = TypeModel.Object("Other")
1654+
},
1655+
}
1656+
};
1657+
1658+
var result = CodeGenerator.Generate(model, "Test", null);
1659+
1660+
CompareModel("Entity.cs", expected, result);
1661+
}
1662+
16351663
[Fact]
16361664
public void Generates_Doc_Comments_For_Method()
16371665
{

Octokit.GraphQL.Core.Generation/DocCommentGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public static void GenerateSummary(string summary, int indentation, StringBuilde
2020

2121
private static void GenerateCommentBlock(string text, string indent, StringBuilder builder)
2222
{
23+
text = text.Replace("<", "&lt;").Replace(">", "&gt;");
24+
2325
foreach (var line in text.Split('\r', '\n'))
2426
{
2527
if (!string.IsNullOrWhiteSpace(line))

Octokit.GraphQL/Model/License.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public License(Expression expression) : base(expression)
5858
public IQueryableList<LicenseRule> Limitations => this.CreateProperty(x => x.Limitations);
5959

6060
/// <summary>
61-
/// The license full name specified by <https://spdx.org/licenses>
61+
/// The license full name specified by &lt;https://spdx.org/licenses&gt;
6262
/// </summary>
6363
public string Name { get; }
6464

@@ -78,12 +78,12 @@ public License(Expression expression) : base(expression)
7878
public bool PseudoLicense { get; }
7979

8080
/// <summary>
81-
/// Short identifier specified by <https://spdx.org/licenses>
81+
/// Short identifier specified by &lt;https://spdx.org/licenses&gt;
8282
/// </summary>
8383
public string SpdxId { get; }
8484

8585
/// <summary>
86-
/// URL to the license on <https://choosealicense.com>
86+
/// URL to the license on &lt;https://choosealicense.com&gt;
8787
/// </summary>
8888
public string Url { get; }
8989

0 commit comments

Comments
 (0)