From f80f1641180cae11244b446d53af2c4b4c1a4ca2 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 30 Nov 2017 15:44:55 +0100 Subject: [PATCH] Add CSharpFormattingOptions.IndentationString --- .../CSharp/OutputVisitor/CSharpFormattingOptions.cs | 2 ++ .../CSharp/OutputVisitor/CSharpOutputVisitor.cs | 2 +- ILSpy/TextView/AvalonEditTextOutput.cs | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs index f5bd39d48..9d7e29e36 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpFormattingOptions.cs @@ -86,6 +86,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor } #region Indentation + public string IndentationString { get; set; } = "\t"; + public bool IndentNamespaceBody { // tested get; set; diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs index 1b8d4cab5..204d54251 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor if (formattingPolicy == null) { throw new ArgumentNullException ("formattingPolicy"); } - this.writer = TokenWriter.Create(textWriter); + this.writer = TokenWriter.Create(textWriter, formattingPolicy.IndentationString); this.policy = formattingPolicy; } diff --git a/ILSpy/TextView/AvalonEditTextOutput.cs b/ILSpy/TextView/AvalonEditTextOutput.cs index c7f64093e..21dc101b2 100644 --- a/ILSpy/TextView/AvalonEditTextOutput.cs +++ b/ILSpy/TextView/AvalonEditTextOutput.cs @@ -76,6 +76,8 @@ namespace ICSharpCode.ILSpy.TextView int indent; /// Whether indentation should be inserted on the next write bool needsIndent; + + public string IndentationString { get; set; } = "\t"; internal readonly List elementGenerators = new List(); @@ -176,7 +178,7 @@ namespace ICSharpCode.ILSpy.TextView if (needsIndent) { needsIndent = false; for (int i = 0; i < indent; i++) { - b.Append('\t'); + b.Append(IndentationString); } } }