Browse Source

Do not use single-line formatting for auto properties/indexers if there are attributes.

pull/2316/head
Siegfried Pammer 4 years ago
parent
commit
e6c351c43d
  1. 9
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

9
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -273,6 +273,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
if (!(role == PropertyDeclaration.GetterRole || role == PropertyDeclaration.SetterRole))
return false;
bool isAutoProperty = accessor.Body.IsNull
&& !accessor.Attributes.Any()
&& policy.AutoPropertyFormatting == PropertyFormatting.SingleLine;
return isAutoProperty;
}
@ -2434,7 +2435,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
bool isSingleLine =
(policy.AutoPropertyFormatting == PropertyFormatting.SingleLine)
&& (indexerDeclaration.Getter.IsNull || indexerDeclaration.Getter.Body.IsNull)
&& (indexerDeclaration.Setter.IsNull || indexerDeclaration.Setter.Body.IsNull);
&& (indexerDeclaration.Setter.IsNull || indexerDeclaration.Setter.Body.IsNull)
&& !indexerDeclaration.Getter.Attributes.Any()
&& !indexerDeclaration.Setter.Attributes.Any();
OpenBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, newLine: !isSingleLine);
if (isSingleLine)
Space();
@ -2575,7 +2578,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
bool isSingleLine =
(policy.AutoPropertyFormatting == PropertyFormatting.SingleLine)
&& (propertyDeclaration.Getter.IsNull || propertyDeclaration.Getter.Body.IsNull)
&& (propertyDeclaration.Setter.IsNull || propertyDeclaration.Setter.Body.IsNull);
&& (propertyDeclaration.Setter.IsNull || propertyDeclaration.Setter.Body.IsNull)
&& !propertyDeclaration.Getter.Attributes.Any()
&& !propertyDeclaration.Setter.Attributes.Any();
OpenBrace(isSingleLine ? BraceStyle.EndOfLine : policy.PropertyBraceStyle, newLine: !isSingleLine);
if (isSingleLine)
Space();

Loading…
Cancel
Save