Browse Source

Convert trivial scalar properties to auto-properties

Scalar value properties that merely forwarded to a private backing field
(IsAsync, Operator and the operator-type enums, Format, ClassType, Variance,
ParameterModifier, the parameter bool flags, and similar) become
auto-properties, formatted on a single line. Behavior is identical;
PrimitiveExpression's constructor sets the property instead of the dropped
field.
Assisted-by: Claude:claude-opus-4-8:Claude Code
pull/3807/head
Siegfried Pammer 3 weeks ago committed by Siegfried Pammer
parent
commit
55a2637985
  1. 24
      ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
  2. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
  3. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
  4. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
  5. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
  6. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
  7. 10
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
  8. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
  9. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
  10. 5
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs
  11. 12
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs
  12. 10
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs
  13. 8
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs
  14. 6
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs
  15. 10
      ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs
  16. 5
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs
  17. 5
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs
  18. 8
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs
  19. 32
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs

24
ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs

@ -35,9 +35,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class DocumentationReference : AstNode public partial class DocumentationReference : AstNode
{ {
SymbolKind symbolKind;
OperatorType operatorType;
bool hasParameterList;
/// <summary> /// <summary>
/// Gets/Sets the entity type. /// Gets/Sets the entity type.
@ -47,33 +44,18 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <c>SymbolKind.TypeDefinition</c> for references to primitive types, /// <c>SymbolKind.TypeDefinition</c> for references to primitive types,
/// and <c>SymbolKind.None</c> for everything else. /// and <c>SymbolKind.None</c> for everything else.
/// </summary> /// </summary>
public SymbolKind SymbolKind { public SymbolKind SymbolKind { get; set; }
get { return symbolKind; }
set {
symbolKind = value;
}
}
/// <summary> /// <summary>
/// Gets/Sets the operator type. /// Gets/Sets the operator type.
/// This property is only used when SymbolKind==Operator. /// This property is only used when SymbolKind==Operator.
/// </summary> /// </summary>
public OperatorType OperatorType { public OperatorType OperatorType { get; set; }
get { return operatorType; }
set {
operatorType = value;
}
}
/// <summary> /// <summary>
/// Gets/Sets whether a parameter list was provided. /// Gets/Sets whether a parameter list was provided.
/// </summary> /// </summary>
public bool HasParameterList { public bool HasParameterList { get; set; }
get { return hasParameterList; }
set {
hasParameterList = value;
}
}
/// <summary> /// <summary>
/// Gets/Sets the declaring type. /// Gets/Sets the declaring type.

6
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs

@ -38,12 +38,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public const string DelegateKeyword = "delegate"; public const string DelegateKeyword = "delegate";
public const string AsyncModifier = LambdaExpression.AsyncModifier; public const string AsyncModifier = LambdaExpression.AsyncModifier;
bool isAsync;
public bool IsAsync { public bool IsAsync { get; set; }
get { return isAsync; }
set { isAsync = value; }
}
// used to tell the difference between delegate {} and delegate () {} // used to tell the difference between delegate {} and delegate () {}
bool hasParameterList; bool hasParameterList;

5
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs

@ -62,10 +62,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("LeftRole")] [Slot("LeftRole")]
public partial Expression Left { get; set; } public partial Expression Left { get; set; }
public AssignmentOperatorType Operator { public AssignmentOperatorType Operator { get; set; }
get;
set;
}
[Slot("RightRole")] [Slot("RightRole")]
public partial Expression Right { get; set; } public partial Expression Right { get; set; }

5
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs

@ -66,10 +66,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("LeftRole")] [Slot("LeftRole")]
public partial Expression? Left { get; set; } public partial Expression? Left { get; set; }
public BinaryOperatorType Operator { public BinaryOperatorType Operator { get; set; }
get;
set;
}
[Slot("RightRole")] [Slot("RightRole")]
public partial Expression? Right { get; set; } public partial Expression? Right { get; set; }

5
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs

@ -44,10 +44,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public const string OutKeyword = "out"; public const string OutKeyword = "out";
public const string InKeyword = "in"; public const string InKeyword = "in";
public FieldDirection FieldDirection { public FieldDirection FieldDirection { get; set; }
get;
set;
}
[Slot("Roles.Expression")] [Slot("Roles.Expression")]
public partial Expression Expression { get; set; } public partial Expression Expression { get; set; }

6
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs

@ -34,15 +34,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public const string AsyncModifier = "async"; public const string AsyncModifier = "async";
bool isAsync;
[Slot("AttributeRole")] [Slot("AttributeRole")]
public partial AstNodeCollection<AttributeSection> Attributes { get; } public partial AstNodeCollection<AttributeSection> Attributes { get; }
public bool IsAsync { public bool IsAsync { get; set; }
get { return isAsync; }
set { isAsync = value; }
}
[Slot("Roles.Parameter")] [Slot("Roles.Parameter")]
public partial AstNodeCollection<ParameterDeclaration> Parameters { get; } public partial AstNodeCollection<ParameterDeclaration> Parameters { get; }

10
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs

@ -73,7 +73,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
object value; object value;
LiteralFormat format;
public object Value { public object Value {
get { return this.value; } get { return this.value; }
@ -82,12 +81,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public LiteralFormat Format { public LiteralFormat Format { get; set; }
get { return format; }
set {
format = value;
}
}
public PrimitiveExpression(object value) public PrimitiveExpression(object value)
{ {
@ -97,7 +91,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public PrimitiveExpression(object value, LiteralFormat format) public PrimitiveExpression(object value, LiteralFormat format)
{ {
this.Value = value; this.Value = value;
this.format = format; this.Format = format;
} }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)

5
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs

@ -167,10 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("Roles.Expression")] [Slot("Roles.Expression")]
public partial Expression Expression { get; set; } public partial Expression Expression { get; set; }
public QueryOrderingDirection Direction { public QueryOrderingDirection Direction { get; set; }
get;
set;
}
} }
public enum QueryOrderingDirection public enum QueryOrderingDirection

5
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs

@ -56,10 +56,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public const string SuppressNullableWarningToken = "!"; public const string SuppressNullableWarningToken = "!";
public const string IndexFromEndToken = "^"; public const string IndexFromEndToken = "^";
public const string PatternNotKeyword = "not"; public const string PatternNotKeyword = "not";
public UnaryOperatorType Operator { public UnaryOperatorType Operator { get; set; }
get;
set;
}
[Slot("Roles.Expression")] [Slot("Roles.Expression")]
public partial Expression Expression { get; set; } public partial Expression Expression { get; set; }

5
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs

@ -42,10 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial AstNodeCollection<Expression> Arguments { get; } public partial AstNodeCollection<Expression> Arguments { get; }
// HasArgumentList == false: [Empty] // HasArgumentList == false: [Empty]
public bool HasArgumentList { public bool HasArgumentList { get; set; }
get;
set;
}
public override string ToString(CSharpFormattingOptions formattingOptions) public override string ToString(CSharpFormattingOptions formattingOptions)
{ {

12
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs

@ -57,19 +57,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class Comment : Trivia public partial class Comment : Trivia
{ {
CommentType commentType;
public CommentType CommentType { public CommentType CommentType { get; set; }
get { return commentType; }
set { commentType = value; }
}
string content;
public string Content { public string Content { get; set; }
get { return content; }
set { content = value; }
}
public Comment(string content, CommentType type = CommentType.SingleLine) public Comment(string content, CommentType type = CommentType.SingleLine)
{ {

10
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs

@ -102,15 +102,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class PreProcessorDirective : Trivia public partial class PreProcessorDirective : Trivia
{ {
public PreProcessorDirectiveType Type { public PreProcessorDirectiveType Type { get; set; }
get;
set;
}
public string Argument { public string Argument { get; set; }
get;
set;
}
public PreProcessorDirective(PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation) : base(startLocation, endLocation) public PreProcessorDirective(PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation) : base(startLocation, endLocation)
{ {

8
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs

@ -55,14 +55,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return SymbolKind.TypeDefinition; } get { return SymbolKind.TypeDefinition; }
} }
ClassType classType;
public ClassType ClassType { public ClassType ClassType { get; set; }
get { return classType; }
set {
classType = value;
}
}
[Slot("AttributeRole")] [Slot("AttributeRole")]
public override partial AstNodeCollection<AttributeSection> Attributes { get; } public override partial AstNodeCollection<AttributeSection> Attributes { get; }

6
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs

@ -35,12 +35,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("AttributeRole")] [Slot("AttributeRole")]
public partial AstNodeCollection<AttributeSection> Attributes { get; } public partial AstNodeCollection<AttributeSection> Attributes { get; }
VarianceModifier variance;
public VarianceModifier Variance { public VarianceModifier Variance { get; set; }
get { return variance; }
set { variance = value; }
}
[NameSlot("Roles.Identifier")] [NameSlot("Roles.Identifier")]
public partial string Name { get; set; } public partial string Name { get; set; }

10
ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs

@ -35,14 +35,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class MemberType : AstType public partial class MemberType : AstType
{ {
bool isDoubleColon;
public bool IsDoubleColon { get; set; }
public bool IsDoubleColon {
get { return isDoubleColon; }
set {
isDoubleColon = value;
}
}
[Slot("TargetRole")] [Slot("TargetRole")]
public partial AstType Target { get; set; } public partial AstType Target { get; set; }

5
ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs

@ -32,10 +32,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[DecompilerAstNode(hasNullNode: false)] [DecompilerAstNode(hasNullNode: false)]
public partial class EmptyStatement : Statement public partial class EmptyStatement : Statement
{ {
public TextLocation Location { public TextLocation Location { get; set; }
get;
set;
}
public override TextLocation StartLocation { public override TextLocation StartLocation {
get { get {

5
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs

@ -75,10 +75,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public const string BaseKeyword = "base"; public const string BaseKeyword = "base";
public const string ThisKeyword = "this"; public const string ThisKeyword = "this";
public ConstructorInitializerType ConstructorInitializerType { public ConstructorInitializerType ConstructorInitializerType { get; set; }
get;
set;
}
[Slot("Roles.Argument")] [Slot("Roles.Argument")]
public partial AstNodeCollection<Expression> Arguments { get; } public partial AstNodeCollection<Expression> Arguments { get; }

8
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs

@ -155,14 +155,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("PrivateImplementationTypeRole")] [Slot("PrivateImplementationTypeRole")]
public partial AstType? PrivateImplementationType { get; set; } public partial AstType? PrivateImplementationType { get; set; }
OperatorType operatorType;
public OperatorType OperatorType { public OperatorType OperatorType { get; set; }
get { return operatorType; }
set {
operatorType = value;
}
}
[Slot("Roles.Parameter")] [Slot("Roles.Parameter")]
public partial AstNodeCollection<ParameterDeclaration> Parameters { get; } public partial AstNodeCollection<ParameterDeclaration> Parameters { get; }

32
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs

@ -48,39 +48,15 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("AttributeRole")] [Slot("AttributeRole")]
public partial AstNodeCollection<AttributeSection> Attributes { get; } public partial AstNodeCollection<AttributeSection> Attributes { get; }
bool hasThisModifier;
bool isParams;
bool isScopedRef;
public bool HasThisModifier { public bool HasThisModifier { get; set; }
get { return hasThisModifier; }
set {
hasThisModifier = value;
}
}
public bool IsParams { public bool IsParams { get; set; }
get { return isParams; }
set {
isParams = value;
}
}
public bool IsScopedRef { public bool IsScopedRef { get; set; }
get { return isScopedRef; }
set {
isScopedRef = value;
}
}
ReferenceKind parameterModifier;
public ReferenceKind ParameterModifier { public ReferenceKind ParameterModifier { get; set; }
get { return parameterModifier; }
set {
parameterModifier = value;
}
}
[Slot("Roles.Type")] [Slot("Roles.Type")]
public partial AstType? Type { get; set; } public partial AstType? Type { get; set; }

Loading…
Cancel
Save