diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 30448a8068..c675ad8bf8 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -551,7 +551,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Indent(); OutputModifier(propertyGetRegion.Modifier); outputFormatter.PrintText("get"); - OutputBlockAllowInline(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle); + if (prettyPrintOptions.AllowPropertyGetBlockInline) { + OutputBlockAllowInline(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle); + } else { + OutputBlock(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle); + } return null; } @@ -561,7 +565,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Indent(); OutputModifier(propertySetRegion.Modifier); outputFormatter.PrintText("set"); - OutputBlockAllowInline(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle); + if (prettyPrintOptions.AllowPropertySetBlockInline) { + OutputBlockAllowInline(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle); + } else { + OutputBlock(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle); + } return null; } @@ -606,7 +614,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter VisitAttributes(eventAddRegion.Attributes, data); outputFormatter.Indent(); outputFormatter.PrintText("add"); - OutputBlockAllowInline(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle); + if (prettyPrintOptions.AllowEventAddBlockInline) { + OutputBlockAllowInline(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle); + } else { + OutputBlock(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle); + } return null; } @@ -615,7 +627,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter VisitAttributes(eventRemoveRegion.Attributes, data); outputFormatter.Indent(); outputFormatter.PrintText("remove"); - OutputBlockAllowInline(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle); + if (prettyPrintOptions.AllowEventRemoveBlockInline) { + OutputBlockAllowInline(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle); + } else { + OutputBlock(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle); + } return null; } diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs index 06975660da..7a4cb2ccab 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs @@ -31,10 +31,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter BraceStyle methodBraceStyle = BraceStyle.NextLine; BraceStyle propertyBraceStyle = BraceStyle.EndOfLine; + bool allowPropertyGetBlockInline = true; BraceStyle propertyGetBraceStyle = BraceStyle.EndOfLine; + bool allowPropertySetBlockInline = true; BraceStyle propertySetBraceStyle = BraceStyle.EndOfLine; + BraceStyle eventBraceStyle = BraceStyle.EndOfLine; + bool allowEventAddBlockInline = true; BraceStyle eventAddBraceStyle = BraceStyle.EndOfLine; + bool allowEventRemoveBlockInline = true; BraceStyle eventRemoveBraceStyle = BraceStyle.EndOfLine; BraceStyle statementBraceStyle = BraceStyle.EndOfLine; @@ -137,6 +142,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter propertyGetBraceStyle = value; } } + + public bool AllowPropertyGetBlockInline { + get { + return allowPropertyGetBlockInline; + } + set { + allowPropertyGetBlockInline = value; + } + } + public BraceStyle PropertySetBraceStyle { get { return propertySetBraceStyle; @@ -145,6 +160,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter propertySetBraceStyle = value; } } + public bool AllowPropertySetBlockInline { + get { + return allowPropertySetBlockInline; + } + set { + allowPropertySetBlockInline = value; + } + } + + public BraceStyle EventBraceStyle { + get { + return eventBraceStyle; + } + set { + eventBraceStyle = value; + } + } public BraceStyle EventAddBraceStyle { get { @@ -154,6 +186,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter eventAddBraceStyle = value; } } + public bool AllowEventAddBlockInline { + get { + return allowEventAddBlockInline; + } + set { + allowEventAddBlockInline = value; + } + } + public BraceStyle EventRemoveBraceStyle { get { return eventRemoveBraceStyle; @@ -162,6 +203,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter eventRemoveBraceStyle = value; } } + public bool AllowEventRemoveBlockInline { + get { + return allowEventRemoveBlockInline; + } + set { + allowEventRemoveBlockInline = value; + } + } #endregion #region Before Parentheses