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 @@ -140,7 +140,7 @@ namespace CppSharp.Generator.Tests.Passes
var textGenerator2 = new TextGenerator();
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(
"/// <summary>Gets a value</summary>\n" +
"/// <returns>One</returns>"
@ -149,7 +149,7 @@ namespace CppSharp.Generator.Tests.Passes @@ -149,7 +149,7 @@ namespace CppSharp.Generator.Tests.Passes
var textGenerator3 = new TextGenerator();
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(
"/// <summary>Sets a value. Get it with <see cref=\"GetValueWithComment\"/></summary>\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 @@ -39,6 +39,7 @@ namespace CppSharp.Generators.CSharp
case CommentCommandKind.Brief:
sections.Add(new Section(CommentElement.Summary));
blockCommandComment.ParagraphComment.GetCommentSections(sections);
sections.Add(new Section(CommentElement.Remarks));
break;
case CommentCommandKind.Return:
case CommentCommandKind.Returns:
@ -87,11 +88,12 @@ namespace CppSharp.Generators.CSharp @@ -87,11 +88,12 @@ namespace CppSharp.Generators.CSharp
}
case DocumentationCommentKind.ParagraphComment:
{
bool summaryParagraph = false;
bool assumeSummary = false;
if (sections.Count == 0)
{
assumeSummary = true;
sections.Add(new Section(CommentElement.Summary));
summaryParagraph = true;
}
var lastParagraphSection = sections.Last();
@ -102,18 +104,22 @@ namespace CppSharp.Generators.CSharp @@ -102,18 +104,22 @@ namespace CppSharp.Generators.CSharp
if (inlineContentComment.HasTrailingNewline)
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()))
lastParagraphSection.NewLine();
if (sections[0].GetLines().Count > 0 && summaryParagraph)
{
sections[0].GetLines().AddRange(sections.Skip(1).SelectMany(s => s.GetLines()));
sections.RemoveRange(1, sections.Count - 1);
// The next paragraph should be a remarks section
if (assumeSummary)
sections.Add(new Section(CommentElement.Remarks));
}
break;
}

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

@ -157,7 +157,7 @@ public class NamespaceDerivedTests @@ -157,7 +157,7 @@ public class NamespaceDerivedTests
"The context of the specified window must not be current on any other",
"thread when this function is called.",
"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`."
}));
XElement window = method.Element("param");

Loading…
Cancel
Save