From 5ca49e3c3e251853931238509137c6213b5d7497 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 9 Dec 2015 04:55:34 +0200 Subject: [PATCH] Moved the prepending of the comment prefix to the comments themselves. Signed-off-by: Dimitar Dobrev --- .../Generators/CSharp/CSharpCommentPrinter.cs | 23 +++++++++++-------- .../Generators/CSharp/CSharpTextTemplate.cs | 8 +++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpCommentPrinter.cs b/src/Generator/Generators/CSharp/CSharpCommentPrinter.cs index 1b1ba229..e40521fc 100644 --- a/src/Generator/Generators/CSharp/CSharpCommentPrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpCommentPrinter.cs @@ -6,15 +6,16 @@ namespace CppSharp.Generators.CSharp { public static class CSharpCommentPrinter { - public static string CommentToString(this Comment comment) + public static string CommentToString(this Comment comment, string commentPrefix) { var summaryAdded = false; var remarksAdded = false; - return CommentToString(comment, ref summaryAdded, ref remarksAdded).ToString(); + return CommentToString( + comment, ref summaryAdded, ref remarksAdded, commentPrefix).ToString(); } private static StringBuilder CommentToString(Comment comment, - ref bool summaryAdded, ref bool remarksAdded) + ref bool summaryAdded, ref bool remarksAdded, string commentPrefix) { var commentBuilder = new StringBuilder(); switch (comment.Kind) @@ -23,9 +24,9 @@ namespace CppSharp.Generators.CSharp var fullComment = (FullComment) comment; foreach (var block in fullComment.Blocks) commentBuilder.Append(CommentToString(block, - ref summaryAdded, ref remarksAdded)); + ref summaryAdded, ref remarksAdded, commentPrefix)); if (remarksAdded) - commentBuilder.Append(""); + commentBuilder.AppendFormat("{0} ", commentPrefix); break; case CommentKind.BlockCommandComment: break; @@ -41,7 +42,7 @@ namespace CppSharp.Generators.CSharp var paragraphComment = (ParagraphComment) comment; foreach (var inlineContentComment in paragraphComment.Content) commentBuilder.Append(CommentToString(inlineContentComment, - ref summaryAdded, ref remarksAdded)); + ref summaryAdded, ref remarksAdded, commentPrefix)); break; case CommentKind.HTMLTagComment: break; @@ -51,16 +52,18 @@ namespace CppSharp.Generators.CSharp break; case CommentKind.TextComment: if (!summaryAdded) - commentBuilder.AppendLine(""); + commentBuilder.AppendFormat("{0} ", commentPrefix).AppendLine(); if (summaryAdded && !remarksAdded) { - commentBuilder.AppendLine(""); + commentBuilder.AppendFormat("{0} ", commentPrefix).AppendLine(); remarksAdded = true; } - commentBuilder.Append("" + GetText(comment) + "").AppendLine(); + commentBuilder.AppendFormat( + "{0} {1}", commentPrefix, GetText(comment)); + commentBuilder.AppendLine(); if (!summaryAdded) { - commentBuilder.AppendLine(""); + commentBuilder.AppendFormat("{0} ", commentPrefix).AppendLine(); summaryAdded = true; } break; diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 5c700740..7ac8d4b4 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -275,7 +275,7 @@ namespace CppSharp.Generators.CSharp if (comment.FullComment != null) { PushBlock(BlockKind.BlockComment); - WriteLine(comment.FullComment.CommentToString()); + WriteLine(comment.FullComment.CommentToString(Options.CommentPrefix)); PopBlock(); } else @@ -284,11 +284,11 @@ namespace CppSharp.Generators.CSharp return; PushBlock(BlockKind.BlockComment); - WriteLine(""); + WriteLine("{0} ", Options.CommentPrefix); foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( Environment.NewLine.ToCharArray())) - WriteLine("{0}", line); - WriteLine(""); + WriteLine("{0} {1}", Options.CommentPrefix, line); + WriteLine("{0} ", Options.CommentPrefix); PopBlock(); } }