From 780ebde69cd890c070a05f7b80a81249f30ec58c Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 14 May 2024 16:06:13 -0700 Subject: [PATCH] fix --- .../Symbols/Source/SourceComplexParameterSymbol.cs | 3 +-- .../Symbols/Source/SourcePropertyAccessorSymbol.cs | 9 ++++++++- .../SynthesizedAccessorValueParameterSymbol.cs | 10 ++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs index 1f182b73abc9b..e8a8c612f1210 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs @@ -506,7 +506,7 @@ protected SourceParameterSymbol? PartialDefinitionPart } } - internal override SyntaxList AttributeDeclarationList + internal sealed override SyntaxList AttributeDeclarationList { get { @@ -520,7 +520,6 @@ internal override SyntaxList AttributeDeclarationList /// internal virtual OneOrMany> GetAttributeDeclarations() { - // TODO2: should this be non-virtual and subtypes override 'AttributeDeclarationList' instead? Debug.Assert(PartialImplementationPart is null); if (PartialDefinitionPart is { } definitionPart) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs index acf4d7ab312d3..7460e057701c0 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs @@ -631,12 +631,19 @@ public sealed override ImmutableArray ExplicitInterfaceImplementat internal sealed override OneOrMany> GetAttributeDeclarations() { - Debug.Assert(PartialDefinitionPart is null); if (PartialImplementationPart is { } implementation) { return OneOrMany.Create(AttributeDeclarationList, ((SourcePropertyAccessorSymbol)implementation).AttributeDeclarationList); } + // If we are asking this question on a partial implementation symbol, + // it must be from a context which prefers to order implementation attributes before definition attributes. + // For example, the 'value' parameter of a set accessor. + if (PartialDefinitionPart is { } definition) + { + return OneOrMany.Create(AttributeDeclarationList, ((SourcePropertyAccessorSymbol)definition).AttributeDeclarationList); + } + return OneOrMany.Create(AttributeDeclarationList); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs index bfe1cb85ababc..7252c0fee9068 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs @@ -70,13 +70,11 @@ protected override IAttributeTargetSymbol AttributeOwner get { return (SourceMemberMethodSymbol)this.ContainingSymbol; } } - internal sealed override SyntaxList AttributeDeclarationList + internal override OneOrMany> GetAttributeDeclarations() { - get - { - var accessor = (SourcePropertyAccessorSymbol)this.ContainingSymbol; - return accessor.AttributeDeclarationList; - } + // Bind the attributes on the accessor's attribute syntax list with "param" target specifier. + var accessor = (SourceMemberMethodSymbol)this.ContainingSymbol; + return accessor.GetAttributeDeclarations(); } internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder attributes)