diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 0e61cd7f..93b4e1fc 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -5,7 +5,6 @@ using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using System.Web.Util; using CppSharp.AST; using CppSharp.AST.Extensions; using CppSharp.Types; @@ -338,69 +337,14 @@ namespace CppSharp.Generators.CSharp } } - public void GenerateDeclarationCommon(Declaration decl) + public override void GenerateDeclarationCommon(Declaration decl) { - if (decl.Comment != null) - { - GenerateComment(decl.Comment); - GenerateDebug(decl); - } + base.GenerateDeclarationCommon(decl); foreach (Attribute attribute in decl.Attributes) WriteLine("[{0}({1})]", attribute.Type.FullName, attribute.Value); } - public void GenerateDebug(Declaration decl) - { - if (Options.GenerateDebugOutput && !string.IsNullOrWhiteSpace(decl.DebugText)) - WriteLine("// DEBUG: " + decl.DebugText); - } - - public void GenerateComment(RawComment comment) - { - if (comment.FullComment != null) - { - PushBlock(BlockKind.BlockComment); - WriteLine(comment.FullComment.CommentToString(Options.CommentPrefix)); - PopBlock(); - return; - } - - if (string.IsNullOrWhiteSpace(comment.BriefText)) - return; - - PushBlock(BlockKind.BlockComment); - WriteLine("{0} ", Options.CommentPrefix); - foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( - Environment.NewLine.ToCharArray())) - WriteLine("{0} {1}", Options.CommentPrefix, line); - WriteLine("{0} ", Options.CommentPrefix); - PopBlock(); - } - - public void GenerateInlineSummary(RawComment comment) - { - if (comment == null) return; - - if (string.IsNullOrWhiteSpace(comment.BriefText)) - return; - - PushBlock(BlockKind.InlineComment); - if (comment.BriefText.Contains("\n")) - { - WriteLine("{0} ", Options.CommentPrefix); - foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( - Environment.NewLine.ToCharArray())) - WriteLine("{0} {1}", Options.CommentPrefix, line); - WriteLine("{0} ", Options.CommentPrefix); - } - else - { - WriteLine("{0} {1}", Options.CommentPrefix, comment.BriefText); - } - PopBlock(); - } - #region Classes public override bool VisitClassDecl(Class @class) @@ -3053,7 +2997,7 @@ namespace CppSharp.Generators.CSharp if (@enum.IsFlags) WriteLine("[Flags]"); - Write(Helpers.GetAccess(@enum.Access)); + Write(Helpers.GetAccess(@enum.Access)); // internal P/Invoke declarations must see protected enums if (@enum.Access == AccessSpecifier.Protected) Write("internal "); diff --git a/src/Generator/Generators/CodeGenerator.cs b/src/Generator/Generators/CodeGenerator.cs index e524303e..938cf571 100644 --- a/src/Generator/Generators/CodeGenerator.cs +++ b/src/Generator/Generators/CodeGenerator.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Web.Util; using CppSharp.AST; +using CppSharp.Generators.CSharp; namespace CppSharp.Generators { @@ -40,7 +42,67 @@ namespace CppSharp.Generators return base.Generate(); } - public void GenerateMultiLineComment(List lines, CommentKind kind) + public virtual void GenerateDeclarationCommon(Declaration decl) + { + if (decl.Comment != null) + { + GenerateComment(decl.Comment); + GenerateDebug(decl); + } + } + + public virtual void GenerateDebug(Declaration decl) + { + if (Options.GenerateDebugOutput && !string.IsNullOrWhiteSpace(decl.DebugText)) + WriteLine("// DEBUG: " + decl.DebugText); + } + + public void GenerateInlineSummary(RawComment comment) + { + if (comment == null) return; + + if (string.IsNullOrWhiteSpace(comment.BriefText)) + return; + + PushBlock(BlockKind.InlineComment); + if (comment.BriefText.Contains("\n")) + { + WriteLine("{0} ", Options.CommentPrefix); + foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( + Environment.NewLine.ToCharArray())) + WriteLine("{0} {1}", Options.CommentPrefix, line); + WriteLine("{0} ", Options.CommentPrefix); + } + else + { + WriteLine("{0} {1}", Options.CommentPrefix, comment.BriefText); + } + PopBlock(); + } + + public virtual void GenerateComment(RawComment comment) + { + if (comment.FullComment != null) + { + PushBlock(BlockKind.BlockComment); + WriteLine(comment.FullComment.CommentToString(Options.CommentPrefix)); + PopBlock(); + return; + } + + if (string.IsNullOrWhiteSpace(comment.BriefText)) + return; + + PushBlock(BlockKind.BlockComment); + WriteLine("{0} ", Options.CommentPrefix); + foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( + Environment.NewLine.ToCharArray())) + WriteLine("{0} {1}", Options.CommentPrefix, line); + WriteLine("{0} ", Options.CommentPrefix); + PopBlock(); + } + + public virtual void GenerateMultiLineComment(List lines, CommentKind kind) { var lineCommentPrologue = Comment.GetLineCommentPrologue(kind); if (!string.IsNullOrWhiteSpace(lineCommentPrologue))