Skip to content

Commit aed800c

Browse files
committed
Fix test errors
1 parent 2638651 commit aed800c

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/Generator.Tests/Passes/TestPasses.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void TestCleanCommentsPass()
140140
var textGenerator2 = new TextGenerator();
141141
textGenerator2.Print(c2.Methods[0].Comment.FullComment, CommentKind.BCPLSlash);
142142

143-
Assert.That(textGenerator2.StringBuilder.ToString().Trim(),
143+
Assert.That(textGenerator2.StringBuilder.ToString().Trim().Replace("\r\n", "\n"),
144144
Is.EqualTo(
145145
"/// <summary>Gets a value</summary>\n" +
146146
"/// <returns>One</returns>"
@@ -149,7 +149,7 @@ public void TestCleanCommentsPass()
149149
var textGenerator3 = new TextGenerator();
150150
textGenerator3.Print(c2.Methods[1].Comment.FullComment, CommentKind.BCPLSlash);
151151

152-
Assert.That(textGenerator3.StringBuilder.ToString().Trim(),
152+
Assert.That(textGenerator3.StringBuilder.ToString().Trim().Replace("\r\n", "\n"),
153153
Is.EqualTo(
154154
"/// <summary>Sets a value. Get it with <see cref=\"GetValueWithComment\"/></summary>\n" +
155155
"/// <param name=\"value\">The value to set</param>\n" +

src/Generator/Generators/CSharp/CSharpCommentPrinter.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private static void GetCommentSections(this Comment comment, List<Section> secti
3939
case CommentCommandKind.Brief:
4040
sections.Add(new Section(CommentElement.Summary));
4141
blockCommandComment.ParagraphComment.GetCommentSections(sections);
42+
sections.Add(new Section(CommentElement.Remarks));
4243
break;
4344
case CommentCommandKind.Return:
4445
case CommentCommandKind.Returns:
@@ -87,11 +88,12 @@ private static void GetCommentSections(this Comment comment, List<Section> secti
8788
}
8889
case DocumentationCommentKind.ParagraphComment:
8990
{
90-
bool summaryParagraph = false;
91+
bool assumeSummary = false;
92+
9193
if (sections.Count == 0)
9294
{
95+
assumeSummary = true;
9396
sections.Add(new Section(CommentElement.Summary));
94-
summaryParagraph = true;
9597
}
9698

9799
var lastParagraphSection = sections.Last();
@@ -102,18 +104,22 @@ private static void GetCommentSections(this Comment comment, List<Section> secti
102104
if (inlineContentComment.HasTrailingNewline)
103105
lastParagraphSection.NewLine();
104106

105-
lastParagraphSection = sections.Last();
107+
var newSection = sections.Last();
108+
if (lastParagraphSection == newSection)
109+
continue;
110+
111+
if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString()))
112+
lastParagraphSection.NewLine();
113+
114+
lastParagraphSection = newSection;
106115
}
107116

108117
if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString()))
109118
lastParagraphSection.NewLine();
110119

111-
if (sections[0].GetLines().Count > 0 && summaryParagraph)
112-
{
113-
sections[0].GetLines().AddRange(sections.Skip(1).SelectMany(s => s.GetLines()));
114-
sections.RemoveRange(1, sections.Count - 1);
120+
// The next paragraph should be a remarks section
121+
if (assumeSummary)
115122
sections.Add(new Section(CommentElement.Remarks));
116-
}
117123

118124
break;
119125
}

tests/dotnet/NamespacesDerived/NamespacesDerived.Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private static void TestGlfwDestroyWindow(Type testCommentsType, XElement member
157157
"The context of the specified window must not be current on any other",
158158
"thread when this function is called.",
159159
"This function must not be called from a callback.",
160-
"_safety This function must only be called from the main thread.",
160+
"This function must only be called from the main thread.",
161161
"Added in version 3.0. Replaces `glfwCloseWindow`."
162162
}));
163163
XElement window = method.Element("param");

0 commit comments

Comments
 (0)