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

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

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

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

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

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

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

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

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

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

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

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

@ -73,7 +73,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -73,7 +73,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
object value;
LiteralFormat format;
public object Value {
get { return this.value; }
@ -82,12 +81,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -82,12 +81,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
public LiteralFormat Format {
get { return format; }
set {
format = value;
}
}
public LiteralFormat Format { get; set; }
public PrimitiveExpression(object value)
{
@ -97,7 +91,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -97,7 +91,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public PrimitiveExpression(object value, LiteralFormat format)
{
this.Value = value;
this.format = format;
this.Format = format;
}
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 @@ -167,10 +167,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
[Slot("Roles.Expression")]
public partial Expression Expression { get; set; }
public QueryOrderingDirection Direction {
get;
set;
}
public QueryOrderingDirection Direction { get; set; }
}
public enum QueryOrderingDirection

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

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

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

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

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

@ -57,19 +57,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -57,19 +57,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class Comment : Trivia
{
CommentType commentType;
public CommentType CommentType {
get { return commentType; }
set { commentType = value; }
}
public CommentType CommentType { get; set; }
string content;
public string Content {
get { return content; }
set { content = value; }
}
public string Content { get; set; }
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 @@ -102,15 +102,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public partial class PreProcessorDirective : Trivia
{
public PreProcessorDirectiveType Type {
get;
set;
}
public PreProcessorDirectiveType Type { get; set; }
public string Argument {
get;
set;
}
public string Argument { get; set; }
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 @@ -55,14 +55,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return SymbolKind.TypeDefinition; }
}
ClassType classType;
public ClassType ClassType {
get { return classType; }
set {
classType = value;
}
}
public ClassType ClassType { get; set; }
[Slot("AttributeRole")]
public override partial AstNodeCollection<AttributeSection> Attributes { get; }

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save