diff --git a/src/Generator/Generators/CodeGenerator.cs b/src/Generator/Generators/CodeGenerator.cs index d102055f..61d5cd17 100644 --- a/src/Generator/Generators/CodeGenerator.cs +++ b/src/Generator/Generators/CodeGenerator.cs @@ -83,22 +83,18 @@ namespace CppSharp.Generators public virtual void GenerateDeclarationCommon(Declaration decl) { if (decl.Comment != null) - { GenerateComment(decl.Comment); - GenerateDebug(decl); - } + + GenerateDebug(decl); } public virtual void GenerateDebug(Declaration decl) { if (Options.GenerateDebugOutput && !string.IsNullOrWhiteSpace(decl.DebugText)) { - char[] newLineChars = {'\r', '\n'}; - var text = decl.DebugText; - var index = text.IndexOfAny(newLineChars); - if (index >= 0) - text = text.Substring(0, index); - WriteLine("// DEBUG: " + text); + var debugText = decl.DebugText; + debugText = Regex.Replace(debugText.Trim(), "\r?\n", "\n// DEBUG: "); + WriteLine($"// DEBUG: {debugText}"); } } diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index 52462e7f..9851e3c3 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -53,7 +53,6 @@ namespace CppSharp.Passes (method == null || method.Kind == CXXMethodKind.Normal)) decl.Name = CheckName(decl.Name); - StringHelpers.CleanupText(ref decl.DebugText); return true; } diff --git a/src/Generator/Utils/Utils.cs b/src/Generator/Utils/Utils.cs index c555e2d9..b8f8ed17 100644 --- a/src/Generator/Utils/Utils.cs +++ b/src/Generator/Utils/Utils.cs @@ -43,20 +43,6 @@ namespace CppSharp return ss[0]; // all strings identical } - public static void CleanupText(ref string debugText) - { - // Strip off newlines from the debug text. - if (string.IsNullOrWhiteSpace(debugText)) - { - debugText = string.Empty; - return; - } - - // TODO: Make this transformation in the output. - debugText = Regex.Replace(debugText, " {2,}", " "); - debugText = debugText.Replace("\n", ""); - } - public static string[] SplitCamelCase(string input) { var str = Regex.Replace(input, "([A-Z])", " $1", RegexOptions.Compiled);