Browse Source

Fix test errors

pull/1928/head
duckdoom5 4 months ago
parent
commit
aed800c31c
  1. 4
      src/Generator.Tests/Passes/TestPasses.cs
  2. 22
      src/Generator/Generators/CSharp/CSharpCommentPrinter.cs
  3. 2
      tests/dotnet/NamespacesDerived/NamespacesDerived.Tests.cs

4
src/Generator.Tests/Passes/TestPasses.cs

@ -140,7 +140,7 @@ namespace CppSharp.Generator.Tests.Passes
var textGenerator2 = new TextGenerator(); var textGenerator2 = new TextGenerator();
textGenerator2.Print(c2.Methods[0].Comment.FullComment, CommentKind.BCPLSlash); textGenerator2.Print(c2.Methods[0].Comment.FullComment, CommentKind.BCPLSlash);
Assert.That(textGenerator2.StringBuilder.ToString().Trim(), Assert.That(textGenerator2.StringBuilder.ToString().Trim().Replace("\r\n", "\n"),
Is.EqualTo( Is.EqualTo(
"/// <summary>Gets a value</summary>\n" + "/// <summary>Gets a value</summary>\n" +
"/// <returns>One</returns>" "/// <returns>One</returns>"
@ -149,7 +149,7 @@ namespace CppSharp.Generator.Tests.Passes
var textGenerator3 = new TextGenerator(); var textGenerator3 = new TextGenerator();
textGenerator3.Print(c2.Methods[1].Comment.FullComment, CommentKind.BCPLSlash); textGenerator3.Print(c2.Methods[1].Comment.FullComment, CommentKind.BCPLSlash);
Assert.That(textGenerator3.StringBuilder.ToString().Trim(), Assert.That(textGenerator3.StringBuilder.ToString().Trim().Replace("\r\n", "\n"),
Is.EqualTo( Is.EqualTo(
"/// <summary>Sets a value. Get it with <see cref=\"GetValueWithComment\"/></summary>\n" + "/// <summary>Sets a value. Get it with <see cref=\"GetValueWithComment\"/></summary>\n" +
"/// <param name=\"value\">The value to set</param>\n" + "/// <param name=\"value\">The value to set</param>\n" +

22
src/Generator/Generators/CSharp/CSharpCommentPrinter.cs

@ -39,6 +39,7 @@ namespace CppSharp.Generators.CSharp
case CommentCommandKind.Brief: case CommentCommandKind.Brief:
sections.Add(new Section(CommentElement.Summary)); sections.Add(new Section(CommentElement.Summary));
blockCommandComment.ParagraphComment.GetCommentSections(sections); blockCommandComment.ParagraphComment.GetCommentSections(sections);
sections.Add(new Section(CommentElement.Remarks));
break; break;
case CommentCommandKind.Return: case CommentCommandKind.Return:
case CommentCommandKind.Returns: case CommentCommandKind.Returns:
@ -87,11 +88,12 @@ namespace CppSharp.Generators.CSharp
} }
case DocumentationCommentKind.ParagraphComment: case DocumentationCommentKind.ParagraphComment:
{ {
bool summaryParagraph = false; bool assumeSummary = false;
if (sections.Count == 0) if (sections.Count == 0)
{ {
assumeSummary = true;
sections.Add(new Section(CommentElement.Summary)); sections.Add(new Section(CommentElement.Summary));
summaryParagraph = true;
} }
var lastParagraphSection = sections.Last(); var lastParagraphSection = sections.Last();
@ -102,18 +104,22 @@ namespace CppSharp.Generators.CSharp
if (inlineContentComment.HasTrailingNewline) if (inlineContentComment.HasTrailingNewline)
lastParagraphSection.NewLine(); lastParagraphSection.NewLine();
lastParagraphSection = sections.Last(); var newSection = sections.Last();
if (lastParagraphSection == newSection)
continue;
if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString()))
lastParagraphSection.NewLine();
lastParagraphSection = newSection;
} }
if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString())) if (!string.IsNullOrEmpty(lastParagraphSection.CurrentLine.ToString()))
lastParagraphSection.NewLine(); lastParagraphSection.NewLine();
if (sections[0].GetLines().Count > 0 && summaryParagraph) // The next paragraph should be a remarks section
{ if (assumeSummary)
sections[0].GetLines().AddRange(sections.Skip(1).SelectMany(s => s.GetLines()));
sections.RemoveRange(1, sections.Count - 1);
sections.Add(new Section(CommentElement.Remarks)); sections.Add(new Section(CommentElement.Remarks));
}
break; break;
} }

2
tests/dotnet/NamespacesDerived/NamespacesDerived.Tests.cs

@ -157,7 +157,7 @@ public class NamespaceDerivedTests
"The context of the specified window must not be current on any other", "The context of the specified window must not be current on any other",
"thread when this function is called.", "thread when this function is called.",
"This function must not be called from a callback.", "This function must not be called from a callback.",
"_safety This function must only be called from the main thread.", "This function must only be called from the main thread.",
"Added in version 3.0. Replaces `glfwCloseWindow`." "Added in version 3.0. Replaces `glfwCloseWindow`."
})); }));
XElement window = method.Element("param"); XElement window = method.Element("param");

Loading…
Cancel
Save