From 930df9161fff9b0286b93c0eab412f428f6a237b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 20 Jun 2026 12:50:44 +0200 Subject: [PATCH] De-alias the declaration attribute slot to its own kind A declaration's attribute collection (AstNodeCollection) and an attribute section's own attributes (AstNodeCollection) both carried [Slot("Attribute")], so the kind mapped to two child types and the shared Slots.Attribute widened to AstNode. Give the declaration-level slot its own "AttributeSection" kind so every kind maps to a single type; EntityDeclaration's Attributes accessor now reads through the typed Slots.AttributeSection. This was the last child-access keyed on the SlotKind matching enum. Assisted-by: Claude:claude-opus-4-8:Claude Code --- ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs | 2 +- .../CSharp/Syntax/Expressions/LambdaExpression.cs | 2 +- .../CSharp/Syntax/GeneralScope/DelegateDeclaration.cs | 2 +- .../CSharp/Syntax/GeneralScope/TypeDeclaration.cs | 2 +- .../CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs | 2 +- ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs | 2 +- .../CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/DestructorDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/EntityDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/EventDeclaration.cs | 4 ++-- .../CSharp/Syntax/TypeMembers/ExtensionDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/FieldDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/FixedFieldDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/IndexerDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/MethodDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/OperatorDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/ParameterDeclaration.cs | 2 +- .../CSharp/Syntax/TypeMembers/PropertyDeclaration.cs | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs index c805dfc81..941ca72bd 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public const string ReadonlyKeyword = "readonly"; public const string NullableToken = "?"; public const string PointerToken = "*"; - [Slot("Attribute")] + [Slot("AttributeSection")] public partial AstNodeCollection Attributes { get; } /// diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs index f1d479e90..e4dea191a 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax { public const string AsyncModifier = "async"; - [Slot("Attribute")] + [Slot("AttributeSection")] public partial AstNodeCollection Attributes { get; } public bool IsAsync { get; set; } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs index 1bac7e339..5a08a207e 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.TypeDefinition; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs index d4ac8d647..7de217db3 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public ClassType ClassType { get; set; } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Identifier")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs index cc7b87bfc..f40ba7c93 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public const string OutVarianceKeyword = "out"; public const string InVarianceKeyword = "in"; - [Slot("Attribute")] + [Slot("AttributeSection")] public partial AstNodeCollection Attributes { get; } public VarianceModifier Variance { get; set; } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs index 3375fefa1..549bee621 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs @@ -66,7 +66,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax set { } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Body")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs index 5e0185e7d..f79bc079f 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Constructor; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } // The name is just the declaring type name; exclude it from matching (and the inherited Name match). diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/DestructorDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/DestructorDeclaration.cs index 7d8f33c09..8e475c6d7 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/DestructorDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/DestructorDeclaration.cs @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Destructor; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } // The name is just the declaring type name; exclude it from matching (and the inherited Name match). diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs index bbae1c224..33736d7f2 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EntityDeclaration.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public abstract SymbolKind SymbolKind { get; } public virtual AstNodeCollection Attributes { - get { return base.GetChildrenByRole(SlotKind.Attribute); } + get { return base.GetChildren(Slots.AttributeSection); } } public Modifiers Modifiers { get; set; } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs index 1fc2716e1..fa9324f1e 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Field; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Identifier")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EventDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EventDeclaration.cs index 2bbf3e57c..4d1c4e21b 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EventDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EventDeclaration.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Event; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] @@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Event; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ExtensionDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ExtensionDeclaration.cs index 1e7378b37..c4f9cf25e 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ExtensionDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ExtensionDeclaration.cs @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public override SymbolKind SymbolKind => SymbolKind.TypeDefinition; - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("TypeParameter")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FieldDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FieldDeclaration.cs index 1a90e644c..dcc669a86 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FieldDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FieldDeclaration.cs @@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Field; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FixedFieldDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FixedFieldDeclaration.cs index 9d5aa0da3..e5e02396b 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FixedFieldDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/FixedFieldDeclaration.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Field; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/IndexerDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/IndexerDeclaration.cs index ed883314a..cb31a00ae 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/IndexerDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/IndexerDeclaration.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Indexer; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs index b3195396e..6fefc5d22 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/MethodDeclaration.cs @@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax // Slots in document order; inherited contract slots (Attributes, ReturnType, NameToken) are // re-declared override per the flatten model (Part I.3). - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs index 2ded5448d..86bb76c76 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs @@ -142,7 +142,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Operator; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")] diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs index 8b447faff..db37c60dd 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ParameterDeclaration.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public const string InModifier = "in"; public const string ParamsModifier = "params"; - [Slot("Attribute")] + [Slot("AttributeSection")] public partial AstNodeCollection Attributes { get; } public bool HasThisModifier { get; set; } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs index 67aed6624..f5bebcb1b 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax get { return SymbolKind.Property; } } - [Slot("Attribute")] + [Slot("AttributeSection")] public override partial AstNodeCollection Attributes { get; } [Slot("Type")]