diff --git a/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterEarlyWellKnownAttributeData.cs b/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterEarlyWellKnownAttributeData.cs index 3bcfe343f2c40..13a6d13e597c1 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterEarlyWellKnownAttributeData.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterEarlyWellKnownAttributeData.cs @@ -11,5 +11,20 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols /// internal sealed class ParameterEarlyWellKnownAttributeData : CommonParameterEarlyWellKnownAttributeData { + private bool _hasRefEscapesAttribute; + public bool HasRefEscapesAttribute + { + get + { + VerifySealed(expected: true); + return _hasRefEscapesAttribute; + } + set + { + VerifySealed(expected: false); + _hasRefEscapesAttribute = value; + SetDataStored(); + } + } } } diff --git a/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterWellKnownAttributeData.cs b/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterWellKnownAttributeData.cs index c59ed4004098e..2275e9dc1c290 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterWellKnownAttributeData.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/ParameterWellKnownAttributeData.cs @@ -142,22 +142,6 @@ public bool HasEnumeratorCancellationAttribute } } - private bool _hasRefEscapesAttribute; - public bool HasRefEscapesAttribute - { - get - { - VerifySealed(expected: true); - return _hasRefEscapesAttribute; - } - set - { - VerifySealed(expected: false); - _hasRefEscapesAttribute = value; - SetDataStored(); - } - } - private ImmutableHashSet _notNullIfParameterNotNull = ImmutableHashSet.Empty; public ImmutableHashSet NotNullIfParameterNotNull { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs index 0dd6a825fa54a..9c4e1775400c7 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs @@ -196,7 +196,7 @@ internal bool HasEnumeratorCancellationAttribute } } - internal bool HasRefEscapesAttribute => GetDecodedWellKnownAttributeData()?.HasRefEscapesAttribute == true; + internal bool HasRefEscapesAttribute => GetEarlyDecodedWellKnownAttributeData()?.HasRefEscapesAttribute == true; #nullable enable @@ -595,6 +595,10 @@ internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAt { return EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription.DateTimeConstantAttribute, ref arguments); } + else if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.RefEscapesAttribute)) + { + return arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, beforeAttributePartBound: null, afterAttributePartBound: null, out bool _); + } else if (!IsOnPartialImplementation(arguments.AttributeSyntax)) { if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerLineNumberAttribute)) @@ -794,11 +798,6 @@ protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttribut { DecodeInterpolatedStringHandlerArgumentAttribute(ref arguments, diagnostics, index); } - else if (attribute.IsTargetAttribute(this, AttributeDescription.RefEscapesAttribute)) - { - // PROTOTYPE: Should this be an early decoded attribute? Create a test that manifests a difference. - arguments.GetOrCreateData().HasRefEscapesAttribute = true; - } } private static bool? DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(AttributeDescription description, CSharpAttributeData attribute)