1490 lines
68 KiB
C#
1490 lines
68 KiB
C#
using System;
|
|
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal abstract class SourceComplexParameterSymbolBase : SourceParameterSymbol, IAttributeTargetSymbol
|
|
{
|
|
[Flags]
|
|
private enum ParameterSyntaxKind : byte
|
|
{
|
|
Regular = 0,
|
|
ParamsParameter = 1,
|
|
ExtensionThisParameter = 2,
|
|
DefaultParameter = 4
|
|
}
|
|
|
|
private readonly SyntaxReference _syntaxRef;
|
|
|
|
private readonly ParameterSyntaxKind _parameterSyntaxKind;
|
|
|
|
private ThreeState _lazyHasOptionalAttribute;
|
|
|
|
private CustomAttributesBag<CSharpAttributeData> _lazyCustomAttributesBag;
|
|
|
|
protected ConstantValue _lazyDefaultSyntaxValue;
|
|
|
|
private Binder WithTypeParametersBinderOpt => (ContainingSymbol as SourceMethodSymbolWithAttributes)?.WithTypeParametersBinder;
|
|
|
|
internal sealed override SyntaxReference SyntaxReference => _syntaxRef;
|
|
|
|
private ParameterSyntax CSharpSyntaxNode
|
|
{
|
|
get
|
|
{
|
|
SyntaxReference syntaxRef = _syntaxRef;
|
|
return (ParameterSyntax)(object)((syntaxRef != null) ? syntaxRef.GetSyntax(default(CancellationToken)) : null);
|
|
}
|
|
}
|
|
|
|
public override bool IsDiscard => false;
|
|
|
|
internal sealed override ConstantValue ExplicitDefaultConstantValue => DefaultSyntaxValue ?? DefaultValueFromAttributes;
|
|
|
|
internal sealed override ConstantValue DefaultValueFromAttributes
|
|
{
|
|
get
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData == null || !(((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).DefaultParameterValue != ConstantValue.Unset))
|
|
{
|
|
return null;
|
|
}
|
|
return ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).DefaultParameterValue;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool IsIDispatchConstant
|
|
{
|
|
get
|
|
{
|
|
ParameterWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
|
|
if (decodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterWellKnownAttributeData)decodedWellKnownAttributeData).HasIDispatchConstantAttribute;
|
|
}
|
|
}
|
|
|
|
internal override bool IsIUnknownConstant
|
|
{
|
|
get
|
|
{
|
|
ParameterWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
|
|
if (decodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterWellKnownAttributeData)decodedWellKnownAttributeData).HasIUnknownConstantAttribute;
|
|
}
|
|
}
|
|
|
|
internal override bool IsCallerLineNumber
|
|
{
|
|
get
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).HasCallerLineNumberAttribute;
|
|
}
|
|
}
|
|
|
|
internal override bool IsCallerFilePath
|
|
{
|
|
get
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).HasCallerFilePathAttribute;
|
|
}
|
|
}
|
|
|
|
internal override bool IsCallerMemberName
|
|
{
|
|
get
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).HasCallerMemberNameAttribute;
|
|
}
|
|
}
|
|
|
|
internal override int CallerArgumentExpressionParameterIndex
|
|
{
|
|
get
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData == null)
|
|
{
|
|
return -1;
|
|
}
|
|
return ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).CallerArgumentExpressionParameterIndex;
|
|
}
|
|
}
|
|
|
|
internal override ImmutableArray<int> InterpolatedStringHandlerArgumentIndexes => ImmutableArrayExtensions.NullToEmpty<int>(GetDecodedWellKnownAttributeData()?.InterpolatedStringHandlerArguments);
|
|
|
|
internal override bool HasInterpolatedStringHandlerArgumentError => GetDecodedWellKnownAttributeData()?.InterpolatedStringHandlerArguments.IsDefault ?? false;
|
|
|
|
internal override FlowAnalysisAnnotations FlowAnalysisAnnotations => DecodeFlowAnalysisAttributes(GetDecodedWellKnownAttributeData());
|
|
|
|
internal override ImmutableHashSet<string> NotNullIfParameterNotNull => GetDecodedWellKnownAttributeData()?.NotNullIfParameterNotNull ?? ImmutableHashSet<string>.Empty;
|
|
|
|
internal bool HasEnumeratorCancellationAttribute => GetDecodedWellKnownAttributeData()?.HasEnumeratorCancellationAttribute ?? false;
|
|
|
|
internal sealed override ScopedKind EffectiveScope
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
ScopedKind val = CalculateEffectiveScopeIgnoringAttributes();
|
|
if ((int)val != 0 && HasUnscopedRefAttribute)
|
|
{
|
|
return (ScopedKind)0;
|
|
}
|
|
return val;
|
|
}
|
|
}
|
|
|
|
internal override bool HasUnscopedRefAttribute => GetEarlyDecodedWellKnownAttributeData()?.HasUnscopedRefAttribute ?? false;
|
|
|
|
private ConstantValue DefaultSyntaxValue
|
|
{
|
|
get
|
|
{
|
|
if (state.NotePartComplete(CompletionPart.Members))
|
|
{
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
|
|
Interlocked.CompareExchange(ref _lazyDefaultSyntaxValue, MakeDefaultExpression(instance, out Binder binder, out BoundParameterEqualsValue parameterEqualsValue), ConstantValue.Unset);
|
|
state.NotePartComplete(CompletionPart.TypeMembers);
|
|
if (parameterEqualsValue != null)
|
|
{
|
|
if (binder != null)
|
|
{
|
|
SyntaxNode defaultValueSyntaxForIsNullableAnalysisEnabled = GetDefaultValueSyntaxForIsNullableAnalysisEnabled(CSharpSyntaxNode);
|
|
if (defaultValueSyntaxForIsNullableAnalysisEnabled != null)
|
|
{
|
|
NullableWalker.AnalyzeIfNeeded(binder, parameterEqualsValue, defaultValueSyntaxForIsNullableAnalysisEnabled, ((BindingDiagnosticBag)instance).DiagnosticBag);
|
|
}
|
|
}
|
|
if (!_lazyDefaultSyntaxValue.IsBad)
|
|
{
|
|
VerifyParamDefaultValueMatchesAttributeIfAny(_lazyDefaultSyntaxValue, parameterEqualsValue.Value.Syntax, instance);
|
|
if (_lazyDefaultSyntaxValue.IsDecimal && DefaultValueFromAttributes == (ConstantValue)null)
|
|
{
|
|
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(DeclaringCompilation, (WellKnownMember)109, instance, parameterEqualsValue.Value.Syntax.Location);
|
|
}
|
|
}
|
|
}
|
|
AddDeclarationDiagnostics(instance);
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
|
state.NotePartComplete(CompletionPart.SynthesizedExplicitImplementations);
|
|
}
|
|
state.SpinWaitComplete(CompletionPart.TypeMembers, default(CancellationToken));
|
|
return _lazyDefaultSyntaxValue;
|
|
}
|
|
}
|
|
|
|
public override string MetadataName
|
|
{
|
|
get
|
|
{
|
|
if (!(ContainingSymbol is SourceOrdinaryMethodSymbol { SourcePartialDefinition: var sourcePartialDefinition }))
|
|
{
|
|
return base.MetadataName;
|
|
}
|
|
if ((object)sourcePartialDefinition == null)
|
|
{
|
|
return base.MetadataName;
|
|
}
|
|
return sourcePartialDefinition.Parameters[Ordinal].MetadataName;
|
|
}
|
|
}
|
|
|
|
protected virtual IAttributeTargetSymbol AttributeOwner => this;
|
|
|
|
IAttributeTargetSymbol IAttributeTargetSymbol.AttributesOwner => AttributeOwner;
|
|
|
|
AttributeLocation IAttributeTargetSymbol.DefaultAttributeLocation => AttributeLocation.Parameter;
|
|
|
|
AttributeLocation IAttributeTargetSymbol.AllowedAttributeLocations
|
|
{
|
|
get
|
|
{
|
|
if (SynthesizedRecordPropertySymbol.HaveCorrespondingSynthesizedRecordPropertySymbol(this))
|
|
{
|
|
return AttributeLocation.Field | AttributeLocation.Property | AttributeLocation.Parameter;
|
|
}
|
|
return AttributeLocation.Parameter;
|
|
}
|
|
}
|
|
|
|
private SourceParameterSymbol BoundAttributesSource
|
|
{
|
|
get
|
|
{
|
|
if (!(ContainingSymbol is SourceOrdinaryMethodSymbol { SourcePartialImplementation: var sourcePartialImplementation }))
|
|
{
|
|
return null;
|
|
}
|
|
if ((object)sourcePartialImplementation == null)
|
|
{
|
|
return null;
|
|
}
|
|
return (SourceParameterSymbol)sourcePartialImplementation.Parameters[Ordinal];
|
|
}
|
|
}
|
|
|
|
internal sealed override SyntaxList<AttributeListSyntax> AttributeDeclarationList => CSharpSyntaxNode?.AttributeLists ?? default(SyntaxList<AttributeListSyntax>);
|
|
|
|
internal override bool HasDefaultArgumentSyntax => (_parameterSyntaxKind & ParameterSyntaxKind.DefaultParameter) != 0;
|
|
|
|
internal sealed override bool HasOptionalAttribute
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((int)_lazyHasOptionalAttribute == 0)
|
|
{
|
|
SourceParameterSymbol boundAttributesSource = BoundAttributesSource;
|
|
if ((object)boundAttributesSource != null)
|
|
{
|
|
_lazyHasOptionalAttribute = ThreeStateHelpers.ToThreeState(boundAttributesSource.HasOptionalAttribute);
|
|
}
|
|
else if (!GetAttributes().Any())
|
|
{
|
|
_lazyHasOptionalAttribute = (ThreeState)1;
|
|
}
|
|
}
|
|
return ThreeStateHelpers.Value(_lazyHasOptionalAttribute);
|
|
}
|
|
}
|
|
|
|
internal override bool IsMetadataOptional
|
|
{
|
|
get
|
|
{
|
|
if (!HasDefaultArgumentSyntax)
|
|
{
|
|
return HasOptionalAttribute;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool IsMetadataIn
|
|
{
|
|
get
|
|
{
|
|
if (!base.IsMetadataIn)
|
|
{
|
|
ParameterWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
|
|
if (decodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterWellKnownAttributeData)decodedWellKnownAttributeData).HasInAttribute;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool IsMetadataOut
|
|
{
|
|
get
|
|
{
|
|
if (!base.IsMetadataOut)
|
|
{
|
|
ParameterWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
|
|
if (decodedWellKnownAttributeData == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ((CommonParameterWellKnownAttributeData)decodedWellKnownAttributeData).HasOutAttribute;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal sealed override MarshalPseudoCustomAttributeData MarshallingInformation
|
|
{
|
|
get
|
|
{
|
|
ParameterWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
|
|
if (decodedWellKnownAttributeData == null)
|
|
{
|
|
return null;
|
|
}
|
|
return ((CommonParameterWellKnownAttributeData)decodedWellKnownAttributeData).MarshallingInformation;
|
|
}
|
|
}
|
|
|
|
public sealed override bool IsParams => (_parameterSyntaxKind & ParameterSyntaxKind.ParamsParameter) != 0;
|
|
|
|
internal override bool IsExtensionMethodThis => (_parameterSyntaxKind & ParameterSyntaxKind.ExtensionThisParameter) != 0;
|
|
|
|
public abstract override ImmutableArray<CustomModifier> RefCustomModifiers { get; }
|
|
|
|
protected SourceComplexParameterSymbolBase(Symbol owner, int ordinal, TypeWithAnnotations parameterType, RefKind refKind, string name, Location location, SyntaxReference syntaxRef, bool isParams, bool isExtensionMethodThis, ScopedKind scope)
|
|
: base(owner, parameterType, ordinal, refKind, scope, name, location)
|
|
{
|
|
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
_lazyHasOptionalAttribute = (ThreeState)0;
|
|
_syntaxRef = syntaxRef;
|
|
if (isParams)
|
|
{
|
|
_parameterSyntaxKind |= ParameterSyntaxKind.ParamsParameter;
|
|
}
|
|
if (isExtensionMethodThis)
|
|
{
|
|
_parameterSyntaxKind |= ParameterSyntaxKind.ExtensionThisParameter;
|
|
}
|
|
ParameterSyntax cSharpSyntaxNode = CSharpSyntaxNode;
|
|
if (cSharpSyntaxNode != null && cSharpSyntaxNode.Default != null)
|
|
{
|
|
_parameterSyntaxKind |= ParameterSyntaxKind.DefaultParameter;
|
|
}
|
|
_lazyDefaultSyntaxValue = ConstantValue.Unset;
|
|
}
|
|
|
|
private static FlowAnalysisAnnotations DecodeFlowAnalysisAttributes(ParameterWellKnownAttributeData attributeData)
|
|
{
|
|
if (attributeData == null)
|
|
{
|
|
return FlowAnalysisAnnotations.None;
|
|
}
|
|
FlowAnalysisAnnotations flowAnalysisAnnotations = FlowAnalysisAnnotations.None;
|
|
if (attributeData.HasAllowNullAttribute)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.AllowNull;
|
|
}
|
|
if (attributeData.HasDisallowNullAttribute)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.DisallowNull;
|
|
}
|
|
bool? maybeNullWhenAttribute;
|
|
if (attributeData.HasMaybeNullAttribute)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.MaybeNull;
|
|
}
|
|
else
|
|
{
|
|
maybeNullWhenAttribute = attributeData.MaybeNullWhenAttribute;
|
|
if (maybeNullWhenAttribute.HasValue)
|
|
{
|
|
bool valueOrDefault = maybeNullWhenAttribute == true;
|
|
flowAnalysisAnnotations = (FlowAnalysisAnnotations)((int)flowAnalysisAnnotations | (valueOrDefault ? 4 : 8));
|
|
}
|
|
}
|
|
if (attributeData.HasNotNullAttribute)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.NotNull;
|
|
}
|
|
else
|
|
{
|
|
maybeNullWhenAttribute = attributeData.NotNullWhenAttribute;
|
|
if (maybeNullWhenAttribute.HasValue)
|
|
{
|
|
bool valueOrDefault2 = maybeNullWhenAttribute == true;
|
|
flowAnalysisAnnotations = (FlowAnalysisAnnotations)((int)flowAnalysisAnnotations | (valueOrDefault2 ? 16 : 32));
|
|
}
|
|
}
|
|
maybeNullWhenAttribute = attributeData.DoesNotReturnIfAttribute;
|
|
if (maybeNullWhenAttribute.HasValue)
|
|
{
|
|
bool valueOrDefault3 = maybeNullWhenAttribute == true;
|
|
flowAnalysisAnnotations = (FlowAnalysisAnnotations)((int)flowAnalysisAnnotations | (valueOrDefault3 ? 128 : 64));
|
|
}
|
|
return flowAnalysisAnnotations;
|
|
}
|
|
|
|
internal static SyntaxNode? GetDefaultValueSyntaxForIsNullableAnalysisEnabled(ParameterSyntax? parameterSyntax)
|
|
{
|
|
return (SyntaxNode?)(object)parameterSyntax?.Default?.Value;
|
|
}
|
|
|
|
public BoundParameterEqualsValue? BindParameterEqualsValue()
|
|
{
|
|
MakeDefaultExpression(BindingDiagnosticBag.Discarded, out Binder _, out BoundParameterEqualsValue parameterEqualsValue);
|
|
return parameterEqualsValue;
|
|
}
|
|
|
|
private Binder GetDefaultParameterValueBinder(SyntaxNode syntax)
|
|
{
|
|
Binder binder = WithTypeParametersBinderOpt;
|
|
if (binder == null)
|
|
{
|
|
binder = DeclaringCompilation.GetBinderFactory(syntax.SyntaxTree).GetBinder(syntax);
|
|
}
|
|
return binder;
|
|
}
|
|
|
|
private void NullableAnalyzeParameterDefaultValueFromAttributes()
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
ParameterSyntax cSharpSyntaxNode = CSharpSyntaxNode;
|
|
if (cSharpSyntaxNode == null)
|
|
{
|
|
return;
|
|
}
|
|
SyntaxNode node = cSharpSyntaxNode.AttributeLists.Node;
|
|
if (node != null && NullableWalker.NeedsAnalysis(DeclaringCompilation, node))
|
|
{
|
|
ConstantValue defaultValueFromAttributes = DefaultValueFromAttributes;
|
|
if (!(defaultValueFromAttributes == (ConstantValue)null) && !defaultValueFromAttributes.IsBad)
|
|
{
|
|
Binder defaultParameterValueBinder = GetDefaultParameterValueBinder((SyntaxNode)(object)cSharpSyntaxNode);
|
|
BoundParameterEqualsValue node2 = new BoundParameterEqualsValue((SyntaxNode)(object)cSharpSyntaxNode, this, ImmutableArray<LocalSymbol>.Empty, new BoundLiteral((SyntaxNode)(object)cSharpSyntaxNode, defaultValueFromAttributes, base.Type));
|
|
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies: false);
|
|
NullableWalker.AnalyzeIfNeeded(defaultParameterValueBinder, node2, (SyntaxNode)(object)cSharpSyntaxNode, ((BindingDiagnosticBag)instance).DiagnosticBag);
|
|
AddDeclarationDiagnostics(instance);
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
|
|
}
|
|
}
|
|
}
|
|
|
|
private ConstantValue MakeDefaultExpression(BindingDiagnosticBag diagnostics, out Binder? binder, out BoundParameterEqualsValue? parameterEqualsValue)
|
|
{
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
|
binder = null;
|
|
parameterEqualsValue = null;
|
|
ParameterSyntax cSharpSyntaxNode = CSharpSyntaxNode;
|
|
if (cSharpSyntaxNode == null)
|
|
{
|
|
return null;
|
|
}
|
|
EqualsValueClauseSyntax equalsValueClauseSyntax = cSharpSyntaxNode.Default;
|
|
if (equalsValueClauseSyntax == null)
|
|
{
|
|
return null;
|
|
}
|
|
MessageID.IDS_FeatureOptionalParameter.CheckFeatureAvailability(diagnostics, equalsValueClauseSyntax.EqualsToken);
|
|
binder = GetDefaultParameterValueBinder((SyntaxNode)(object)equalsValueClauseSyntax);
|
|
binder = binder.CreateBinderForParameterDefaultValue(this, equalsValueClauseSyntax);
|
|
parameterEqualsValue = binder.BindParameterDefaultValue(equalsValueClauseSyntax, this, diagnostics, out var valueBeforeConversion);
|
|
if (valueBeforeConversion.HasErrors)
|
|
{
|
|
return ConstantValue.Bad;
|
|
}
|
|
BoundExpression boundExpression = parameterEqualsValue.Value;
|
|
if (ParameterHelpers.ReportDefaultParameterErrors(binder, ContainingSymbol, cSharpSyntaxNode, this, valueBeforeConversion, boundExpression, diagnostics))
|
|
{
|
|
return ConstantValue.Bad;
|
|
}
|
|
if (boundExpression.ConstantValueOpt == (ConstantValue)null && boundExpression.Kind == BoundKind.Conversion && ((BoundConversion)boundExpression).ConversionKind != ConversionKind.DefaultLiteral && parameterType.Type.IsNullableType())
|
|
{
|
|
boundExpression = binder.GenerateConversionForAssignment(parameterType.Type.GetNullableUnderlyingType(), valueBeforeConversion, diagnostics, Binder.ConversionForAssignmentFlags.DefaultParameter);
|
|
}
|
|
return boundExpression.ConstantValueOpt ?? ConstantValue.Null;
|
|
}
|
|
|
|
internal virtual OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<AttributeListSyntax> attributeDeclarationList = AttributeDeclarationList;
|
|
if (!(ContainingSymbol is SourceOrdinaryMethodSymbol { OtherPartOfPartial: var otherPartOfPartial }))
|
|
{
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(attributeDeclarationList);
|
|
}
|
|
SyntaxList<AttributeListSyntax> val = (((object)otherPartOfPartial == null) ? default(SyntaxList<AttributeListSyntax>) : ((SourceParameterSymbol)otherPartOfPartial.Parameters[Ordinal]).AttributeDeclarationList);
|
|
if (attributeDeclarationList.Equals(default(SyntaxList<AttributeListSyntax>)))
|
|
{
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(val);
|
|
}
|
|
if (val.Equals(default(SyntaxList<AttributeListSyntax>)))
|
|
{
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(attributeDeclarationList);
|
|
}
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(ImmutableArray.Create<SyntaxList<AttributeListSyntax>>(attributeDeclarationList, val));
|
|
}
|
|
|
|
internal ParameterWellKnownAttributeData GetDecodedWellKnownAttributeData()
|
|
{
|
|
CustomAttributesBag<CSharpAttributeData> val = _lazyCustomAttributesBag;
|
|
if (val == null || !val.IsDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
val = GetAttributesBag();
|
|
}
|
|
return (ParameterWellKnownAttributeData)(object)val.DecodedWellKnownAttributeData;
|
|
}
|
|
|
|
internal ParameterEarlyWellKnownAttributeData GetEarlyDecodedWellKnownAttributeData()
|
|
{
|
|
CustomAttributesBag<CSharpAttributeData> val = _lazyCustomAttributesBag;
|
|
if (val == null || !val.IsEarlyDecodedWellKnownAttributeDataComputed)
|
|
{
|
|
val = GetAttributesBag();
|
|
}
|
|
return (ParameterEarlyWellKnownAttributeData)(object)val.EarlyDecodedWellKnownAttributeData;
|
|
}
|
|
|
|
internal sealed override CustomAttributesBag<CSharpAttributeData> GetAttributesBag()
|
|
{
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
|
if (_lazyCustomAttributesBag == null || !_lazyCustomAttributesBag.IsSealed)
|
|
{
|
|
SourceParameterSymbol boundAttributesSource = BoundAttributesSource;
|
|
bool flag;
|
|
if ((object)boundAttributesSource != null)
|
|
{
|
|
CustomAttributesBag<CSharpAttributeData> attributesBag = boundAttributesSource.GetAttributesBag();
|
|
flag = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null;
|
|
}
|
|
else
|
|
{
|
|
OneOrMany<SyntaxList<AttributeListSyntax>> attributeDeclarations = GetAttributeDeclarations();
|
|
flag = LoadAndValidateAttributes(attributeDeclarations, ref _lazyCustomAttributesBag, AttributeLocation.None, earlyDecodingOnly: false, WithTypeParametersBinderOpt);
|
|
}
|
|
if (flag)
|
|
{
|
|
NullableAnalyzeParameterDefaultValueFromAttributes();
|
|
state.NotePartComplete(CompletionPart.Attributes);
|
|
}
|
|
}
|
|
return _lazyCustomAttributesBag;
|
|
}
|
|
|
|
public ImmutableArray<(CSharpAttributeData, BoundAttribute)> BindParameterAttributes()
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return BindAttributes(GetAttributeDeclarations(), WithTypeParametersBinderOpt);
|
|
}
|
|
|
|
internal override void EarlyDecodeWellKnownAttributeType(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(attributeType, attributeSyntax, AttributeDescription.OptionalAttribute))
|
|
{
|
|
_lazyHasOptionalAttribute = (ThreeState)2;
|
|
}
|
|
}
|
|
|
|
internal override void PostEarlyDecodeWellKnownAttributeTypes()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((int)_lazyHasOptionalAttribute == 0)
|
|
{
|
|
_lazyHasOptionalAttribute = (ThreeState)1;
|
|
}
|
|
base.PostEarlyDecodeWellKnownAttributeTypes();
|
|
}
|
|
|
|
internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments)
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.DefaultParameterValueAttribute))
|
|
{
|
|
return EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription.DefaultParameterValueAttribute, ref arguments);
|
|
}
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.DecimalConstantAttribute))
|
|
{
|
|
return EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription.DecimalConstantAttribute, ref arguments);
|
|
}
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.DateTimeConstantAttribute))
|
|
{
|
|
return EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription.DateTimeConstantAttribute, ref arguments);
|
|
}
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.UnscopedRefAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>().HasUnscopedRefAttribute = true;
|
|
return (null, null);
|
|
}
|
|
if (!IsOnPartialImplementation(arguments.AttributeSyntax))
|
|
{
|
|
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerLineNumberAttribute))
|
|
{
|
|
((CommonParameterEarlyWellKnownAttributeData)arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>()).HasCallerLineNumberAttribute = true;
|
|
}
|
|
else if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerFilePathAttribute))
|
|
{
|
|
((CommonParameterEarlyWellKnownAttributeData)arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>()).HasCallerFilePathAttribute = true;
|
|
}
|
|
else if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerMemberNameAttribute))
|
|
{
|
|
((CommonParameterEarlyWellKnownAttributeData)arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>()).HasCallerMemberNameAttribute = true;
|
|
}
|
|
else if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerArgumentExpressionAttribute))
|
|
{
|
|
int callerArgumentExpressionParameterIndex = -1;
|
|
bool generatedDiagnostics;
|
|
CSharpAttributeData item = arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, null, null, out generatedDiagnostics).Item1;
|
|
if (!((AttributeData)item).HasErrors)
|
|
{
|
|
TypedConstant val = ((AttributeData)item).CommonConstructorArguments[0];
|
|
string value = default(string);
|
|
if (((TypedConstant)(ref val)).TryDecodeValue<string>((SpecialType)20, ref value))
|
|
{
|
|
ImmutableArray<ParameterSymbol> parameters = ContainingSymbol.GetParameters();
|
|
for (int i = 0; i < parameters.Length; i++)
|
|
{
|
|
if (parameters[i].Name.Equals(value, StringComparison.Ordinal))
|
|
{
|
|
callerArgumentExpressionParameterIndex = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
((CommonParameterEarlyWellKnownAttributeData)arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>()).CallerArgumentExpressionParameterIndex = callerArgumentExpressionParameterIndex;
|
|
}
|
|
}
|
|
return base.EarlyDecodeWellKnownAttribute(ref arguments);
|
|
}
|
|
|
|
private (CSharpAttributeData?, BoundAttribute?) EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription description, ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments)
|
|
{
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
var (cSharpAttributeData, item) = arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, null, null, out var generatedDiagnostics);
|
|
ConstantValue defaultParameterValue;
|
|
if (((AttributeData)cSharpAttributeData).HasErrors)
|
|
{
|
|
defaultParameterValue = ConstantValue.Bad;
|
|
generatedDiagnostics = true;
|
|
}
|
|
else
|
|
{
|
|
defaultParameterValue = DecodeDefaultParameterValueAttribute(description, cSharpAttributeData, arguments.AttributeSyntax, diagnose: false, null);
|
|
}
|
|
ParameterEarlyWellKnownAttributeData orCreateData = arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>();
|
|
if (((CommonParameterEarlyWellKnownAttributeData)orCreateData).DefaultParameterValue == ConstantValue.Unset)
|
|
{
|
|
((CommonParameterEarlyWellKnownAttributeData)orCreateData).DefaultParameterValue = defaultParameterValue;
|
|
}
|
|
if (generatedDiagnostics)
|
|
{
|
|
return (null, null);
|
|
}
|
|
return (cSharpAttributeData, item);
|
|
}
|
|
|
|
protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
|
|
{
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpAttributeData attribute = arguments.Attribute;
|
|
BindingDiagnosticBag bindingDiagnosticBag = (BindingDiagnosticBag)(object)arguments.Diagnostics;
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.DefaultParameterValueAttribute))
|
|
{
|
|
DecodeDefaultParameterValueAttribute(AttributeDescription.DefaultParameterValueAttribute, ref arguments);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.DecimalConstantAttribute))
|
|
{
|
|
DecodeDefaultParameterValueAttribute(AttributeDescription.DecimalConstantAttribute, ref arguments);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.DateTimeConstantAttribute))
|
|
{
|
|
DecodeDefaultParameterValueAttribute(AttributeDescription.DateTimeConstantAttribute, ref arguments);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.OptionalAttribute))
|
|
{
|
|
if (HasDefaultArgumentSyntax)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_DefaultValueUsedWithAttributes, ((SyntaxNode)arguments.AttributeSyntaxOpt.Name).Location);
|
|
}
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.ParamArrayAttribute))
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_ExplicitParamArray, ((SyntaxNode)arguments.AttributeSyntaxOpt.Name).Location);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.InAttribute))
|
|
{
|
|
((CommonParameterWellKnownAttributeData)arguments.GetOrCreateData<ParameterWellKnownAttributeData>()).HasInAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.OutAttribute))
|
|
{
|
|
((CommonParameterWellKnownAttributeData)arguments.GetOrCreateData<ParameterWellKnownAttributeData>()).HasOutAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.MarshalAsAttribute))
|
|
{
|
|
MarshalAsAttributeDecoder<ParameterWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.Parameter, (CommonMessageProvider)(object)MessageProvider.Instance);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.IDispatchConstantAttribute))
|
|
{
|
|
((CommonParameterWellKnownAttributeData)arguments.GetOrCreateData<ParameterWellKnownAttributeData>()).HasIDispatchConstantAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.IUnknownConstantAttribute))
|
|
{
|
|
((CommonParameterWellKnownAttributeData)arguments.GetOrCreateData<ParameterWellKnownAttributeData>()).HasIUnknownConstantAttribute = true;
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CallerLineNumberAttribute))
|
|
{
|
|
ValidateCallerLineNumberAttribute(arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CallerFilePathAttribute))
|
|
{
|
|
ValidateCallerFilePathAttribute(arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CallerMemberNameAttribute))
|
|
{
|
|
ValidateCallerMemberNameAttribute(arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.CallerArgumentExpressionAttribute))
|
|
{
|
|
ValidateCallerArgumentExpressionAttribute(arguments.AttributeSyntaxOpt, attribute, bindingDiagnosticBag);
|
|
}
|
|
else
|
|
{
|
|
if (ReportExplicitUseOfReservedAttributes(in arguments, ReservedAttributes.DynamicAttribute | ReservedAttributes.IsReadOnlyAttribute | ReservedAttributes.IsUnmanagedAttribute | ReservedAttributes.IsByRefLikeAttribute | ReservedAttributes.TupleElementNamesAttribute | ReservedAttributes.NullableAttribute | ReservedAttributes.NativeIntegerAttribute | ReservedAttributes.ScopedRefAttribute | ReservedAttributes.RequiresLocationAttribute))
|
|
{
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.AllowNullAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().HasAllowNullAttribute = true;
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.DisallowNullAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().HasDisallowNullAttribute = true;
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.MaybeNullAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().HasMaybeNullAttribute = true;
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.MaybeNullWhenAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().MaybeNullWhenAttribute = DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(attribute);
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.NotNullAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().HasNotNullAttribute = true;
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.NotNullWhenAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().NotNullWhenAttribute = DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(attribute);
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.DoesNotReturnIfAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().DoesNotReturnIfAttribute = DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(attribute);
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.NotNullIfNotNullAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().AddNotNullIfParameterNotNull(attribute.DecodeNotNullIfNotNullAttribute());
|
|
return;
|
|
}
|
|
if (attribute.IsTargetAttribute(this, AttributeDescription.EnumeratorCancellationAttribute))
|
|
{
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().HasEnumeratorCancellationAttribute = true;
|
|
ValidateCancellationTokenAttribute(arguments.AttributeSyntaxOpt, (BindingDiagnosticBag)(object)arguments.Diagnostics);
|
|
return;
|
|
}
|
|
int targetAttributeSignatureIndex = attribute.GetTargetAttributeSignatureIndex(this, AttributeDescription.InterpolatedStringHandlerArgumentAttribute);
|
|
if ((uint)targetAttributeSignatureIndex <= 1u)
|
|
{
|
|
DecodeInterpolatedStringHandlerArgumentAttribute(ref arguments, bindingDiagnosticBag, targetAttributeSignatureIndex);
|
|
}
|
|
else if (attribute.IsTargetAttribute(this, AttributeDescription.UnscopedRefAttribute))
|
|
{
|
|
if (!IsValidUnscopedRefAttributeTarget())
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedTarget, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
}
|
|
else if ((int)base.DeclaredScope != 0)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.ERR_UnscopedScoped, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool IsValidUnscopedRefAttributeTarget()
|
|
{
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Invalid comparison between Unknown and I4
|
|
if (UseUpdatedEscapeRules)
|
|
{
|
|
return (int)RefKind > 0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool? DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(CSharpAttributeData attribute)
|
|
{
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<TypedConstant> commonConstructorArguments = ((AttributeData)attribute).CommonConstructorArguments;
|
|
if (commonConstructorArguments.Length == 1)
|
|
{
|
|
TypedConstant val = commonConstructorArguments[0];
|
|
bool value = default(bool);
|
|
if (((TypedConstant)(ref val)).TryDecodeValue<bool>((SpecialType)7, ref value))
|
|
{
|
|
return value;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void DecodeDefaultParameterValueAttribute(AttributeDescription description, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
|
|
{
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003e: Invalid comparison between Unknown and I4
|
|
CSharpAttributeData attribute = arguments.Attribute;
|
|
AttributeSyntax attributeSyntaxOpt = arguments.AttributeSyntaxOpt;
|
|
BindingDiagnosticBag bindingDiagnosticBag = (BindingDiagnosticBag)(object)arguments.Diagnostics;
|
|
ConstantValue val = DecodeDefaultParameterValueAttribute(description, attribute, attributeSyntaxOpt, diagnose: true, bindingDiagnosticBag);
|
|
if (!val.IsBad)
|
|
{
|
|
VerifyParamDefaultValueMatchesAttributeIfAny(val, (SyntaxNode)(object)attributeSyntaxOpt, bindingDiagnosticBag);
|
|
if ((int)RefKind == 4 && base.IsOptional && CSharpSyntaxNode.Default == null)
|
|
{
|
|
bindingDiagnosticBag.Add(ErrorCode.WRN_RefReadonlyParameterDefaultValue, (SyntaxNode)(object)attributeSyntaxOpt, Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void VerifyParamDefaultValueMatchesAttributeIfAny(ConstantValue value, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData != null)
|
|
{
|
|
ConstantValue defaultParameterValue = ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).DefaultParameterValue;
|
|
if (defaultParameterValue != ConstantValue.Unset && value != defaultParameterValue)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_ParamDefaultValueDiffersFromAttribute, syntax.Location);
|
|
}
|
|
}
|
|
}
|
|
|
|
private unsafe ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
object obj = AttributeDescription.DefaultParameterValueAttribute;
|
|
if (((object)(*(AttributeDescription*)(&description))/*cast due to constrained. prefix*/).Equals(obj))
|
|
{
|
|
return DecodeDefaultParameterValueAttribute(attribute, node, diagnose, diagnosticsOpt);
|
|
}
|
|
object obj2 = AttributeDescription.DecimalConstantAttribute;
|
|
if (((object)(*(AttributeDescription*)(&description))/*cast due to constrained. prefix*/).Equals(obj2))
|
|
{
|
|
return ((AttributeData)attribute).DecodeDecimalConstantValue();
|
|
}
|
|
return ((AttributeData)attribute).DecodeDateTimeConstantValue();
|
|
}
|
|
|
|
private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt)
|
|
{
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Invalid comparison between Unknown and I4
|
|
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0086: Invalid comparison between Unknown and I4
|
|
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0090: Invalid comparison between Unknown and I4
|
|
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
|
|
if (HasDefaultArgumentSyntax)
|
|
{
|
|
if (diagnose)
|
|
{
|
|
diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueUsedWithAttributes, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
return ConstantValue.Bad;
|
|
}
|
|
TypedConstant val = ((AttributeData)attribute).CommonConstructorArguments[0];
|
|
SpecialType val2 = (((int)((TypedConstant)(ref val)).Kind == 2) ? ((NamedTypeSymbol)(object)((TypedConstant)(ref val)).TypeInternal).EnumUnderlyingType.SpecialType : ((TypedConstant)(ref val)).TypeInternal.SpecialType);
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
ConstantValueTypeDiscriminator val3 = ConstantValue.GetDiscriminator(val2);
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnosticsOpt, ContainingAssembly);
|
|
if ((int)val3 == 1)
|
|
{
|
|
if ((int)((TypedConstant)(ref val)).Kind == 4 || ((TypedConstant)(ref val)).ValueInternal != null)
|
|
{
|
|
if (diagnose)
|
|
{
|
|
diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueBadValueType, ((SyntaxNode)node.Name).Location, ((TypedConstant)(ref val)).TypeInternal);
|
|
}
|
|
return ConstantValue.Bad;
|
|
}
|
|
if (!base.Type.IsReferenceType)
|
|
{
|
|
if (diagnose)
|
|
{
|
|
diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueTypeMustMatch, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
return ConstantValue.Bad;
|
|
}
|
|
val3 = (ConstantValueTypeDiscriminator)0;
|
|
}
|
|
else if (!declaringCompilation.Conversions.ClassifyConversionFromType((TypeSymbol)(object)((TypedConstant)(ref val)).TypeInternal, base.Type, isChecked: false, ref useSiteInfo).Kind.IsImplicitConversion())
|
|
{
|
|
if (diagnose)
|
|
{
|
|
diagnosticsOpt.Add(ErrorCode.ERR_DefaultValueTypeMustMatch, ((SyntaxNode)node.Name).Location);
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnosticsOpt).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
return ConstantValue.Bad;
|
|
}
|
|
if (diagnose)
|
|
{
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnosticsOpt).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
return ConstantValue.Create(((TypedConstant)(ref val)).ValueInternal, val3);
|
|
}
|
|
|
|
private bool IsValidCallerInfoContext(AttributeSyntax node)
|
|
{
|
|
if (!ContainingSymbol.IsExplicitInterfaceImplementation() && !ContainingSymbol.IsOperator())
|
|
{
|
|
return !IsOnPartialImplementation(node);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsOnPartialImplementation(AttributeSyntax node)
|
|
{
|
|
if (!(ContainingSymbol is MethodSymbol methodSymbol))
|
|
{
|
|
return false;
|
|
}
|
|
MethodSymbol methodSymbol2 = (methodSymbol.IsPartialImplementation() ? methodSymbol : methodSymbol.PartialImplementationPart);
|
|
if ((object)methodSymbol2 == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!(node.Parent.Parent.Parent is ParameterListSyntax parameterListSyntax))
|
|
{
|
|
return false;
|
|
}
|
|
if (!(parameterListSyntax.Parent is MethodDeclarationSyntax methodDeclarationSyntax))
|
|
{
|
|
return false;
|
|
}
|
|
ImmutableArray<SyntaxReference>.Enumerator enumerator = methodSymbol2.DeclaringSyntaxReferences.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
if ((object)enumerator.Current.GetSyntax(default(CancellationToken)) == methodDeclarationSyntax)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void ValidateCallerLineNumberAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, ContainingAssembly);
|
|
if (!IsValidCallerInfoContext(node))
|
|
{
|
|
Location location = ((SyntaxNode)node.Name).Location;
|
|
object[] array = new object[1];
|
|
SyntaxToken identifier = CSharpSyntaxNode.Identifier;
|
|
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerLineNumberParamForUnconsumedLocation, location, array);
|
|
}
|
|
else if (!declaringCompilation.Conversions.HasCallerLineNumberConversion(TypeWithAnnotations.Type, ref useSiteInfo))
|
|
{
|
|
TypeSymbol specialType = declaringCompilation.GetSpecialType((SpecialType)13);
|
|
diagnostics.Add(ErrorCode.ERR_NoConversionForCallerLineNumberParam, ((SyntaxNode)node.Name).Location, specialType, TypeWithAnnotations.Type);
|
|
}
|
|
else if (!base.HasExplicitDefaultValue && !ContainingSymbol.IsPartialImplementation())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadCallerLineNumberParamWithoutDefaultValue, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
|
|
private void ValidateCallerFilePathAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, ContainingAssembly);
|
|
SyntaxToken identifier;
|
|
if (!IsValidCallerInfoContext(node))
|
|
{
|
|
Location location = ((SyntaxNode)node.Name).Location;
|
|
object[] array = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerFilePathParamForUnconsumedLocation, location, array);
|
|
}
|
|
else if (!declaringCompilation.Conversions.HasCallerInfoStringConversion(TypeWithAnnotations.Type, ref useSiteInfo))
|
|
{
|
|
TypeSymbol specialType = declaringCompilation.GetSpecialType((SpecialType)20);
|
|
diagnostics.Add(ErrorCode.ERR_NoConversionForCallerFilePathParam, ((SyntaxNode)node.Name).Location, specialType, TypeWithAnnotations.Type);
|
|
}
|
|
else if (!base.HasExplicitDefaultValue && !ContainingSymbol.IsPartialImplementation())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadCallerFilePathParamWithoutDefaultValue, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
else if (IsCallerLineNumber)
|
|
{
|
|
Location location2 = ((SyntaxNode)node.Name).Location;
|
|
object[] array2 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array2[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerFilePath, location2, array2);
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
|
|
private void ValidateCallerMemberNameAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, ContainingAssembly);
|
|
SyntaxToken identifier;
|
|
if (!IsValidCallerInfoContext(node))
|
|
{
|
|
Location location = ((SyntaxNode)node.Name).Location;
|
|
object[] array = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerMemberNameParamForUnconsumedLocation, location, array);
|
|
}
|
|
else if (!declaringCompilation.Conversions.HasCallerInfoStringConversion(TypeWithAnnotations.Type, ref useSiteInfo))
|
|
{
|
|
TypeSymbol specialType = declaringCompilation.GetSpecialType((SpecialType)20);
|
|
diagnostics.Add(ErrorCode.ERR_NoConversionForCallerMemberNameParam, ((SyntaxNode)node.Name).Location, specialType, TypeWithAnnotations.Type);
|
|
}
|
|
else if (!base.HasExplicitDefaultValue && !ContainingSymbol.IsPartialImplementation())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadCallerMemberNameParamWithoutDefaultValue, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
else if (IsCallerLineNumber)
|
|
{
|
|
Location location2 = ((SyntaxNode)node.Name).Location;
|
|
object[] array2 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array2[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerMemberName, location2, array2);
|
|
}
|
|
else if (IsCallerFilePath)
|
|
{
|
|
Location location3 = ((SyntaxNode)node.Name).Location;
|
|
object[] array3 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array3[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerFilePathPreferredOverCallerMemberName, location3, array3);
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
|
|
private void ValidateCallerArgumentExpressionAttribute(AttributeSyntax node, CSharpAttributeData attribute, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, ContainingAssembly);
|
|
SyntaxToken identifier;
|
|
if (!IsValidCallerInfoContext(node))
|
|
{
|
|
Location location = ((SyntaxNode)node.Name).Location;
|
|
object[] array = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionParamForUnconsumedLocation, location, array);
|
|
}
|
|
else if (!declaringCompilation.Conversions.HasCallerInfoStringConversion(TypeWithAnnotations.Type, ref useSiteInfo))
|
|
{
|
|
TypeSymbol specialType = declaringCompilation.GetSpecialType((SpecialType)20);
|
|
diagnostics.Add(ErrorCode.ERR_NoConversionForCallerArgumentExpressionParam, ((SyntaxNode)node.Name).Location, specialType, TypeWithAnnotations.Type);
|
|
}
|
|
else if (!base.HasExplicitDefaultValue && !ContainingSymbol.IsPartialImplementation())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadCallerArgumentExpressionParamWithoutDefaultValue, ((SyntaxNode)node.Name).Location);
|
|
}
|
|
else if (IsCallerLineNumber)
|
|
{
|
|
Location location2 = ((SyntaxNode)node.Name).Location;
|
|
object[] array2 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array2[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerLineNumberPreferredOverCallerArgumentExpression, location2, array2);
|
|
}
|
|
else if (IsCallerFilePath)
|
|
{
|
|
Location location3 = ((SyntaxNode)node.Name).Location;
|
|
object[] array3 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array3[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerFilePathPreferredOverCallerArgumentExpression, location3, array3);
|
|
}
|
|
else if (IsCallerMemberName)
|
|
{
|
|
Location location4 = ((SyntaxNode)node.Name).Location;
|
|
object[] array4 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array4[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerMemberNamePreferredOverCallerArgumentExpression, location4, array4);
|
|
}
|
|
else
|
|
{
|
|
if (((AttributeData)attribute).CommonConstructorArguments.Length == 1)
|
|
{
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData = GetEarlyDecodedWellKnownAttributeData();
|
|
if (earlyDecodedWellKnownAttributeData != null && ((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData).CallerArgumentExpressionParameterIndex == -1)
|
|
{
|
|
Location location5 = ((SyntaxNode)node.Name).Location;
|
|
object[] array5 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array5[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionAttributeHasInvalidParameterName, location5, array5);
|
|
goto IL_0276;
|
|
}
|
|
}
|
|
ParameterEarlyWellKnownAttributeData earlyDecodedWellKnownAttributeData2 = GetEarlyDecodedWellKnownAttributeData();
|
|
if (((earlyDecodedWellKnownAttributeData2 != null) ? new int?(((CommonParameterEarlyWellKnownAttributeData)earlyDecodedWellKnownAttributeData2).CallerArgumentExpressionParameterIndex) : ((int?)null)) == Ordinal)
|
|
{
|
|
Location location6 = ((SyntaxNode)node.Name).Location;
|
|
object[] array6 = new object[1];
|
|
identifier = CSharpSyntaxNode.Identifier;
|
|
array6[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_CallerArgumentExpressionAttributeSelfReferential, location6, array6);
|
|
}
|
|
}
|
|
goto IL_0276;
|
|
IL_0276:
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add((SyntaxNode)(object)node.Name, useSiteInfo);
|
|
}
|
|
|
|
private void ValidateCancellationTokenAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
if (needsReporting())
|
|
{
|
|
Location location = ((SyntaxNode)node.Name).Location;
|
|
object[] array = new object[1];
|
|
SyntaxToken identifier = CSharpSyntaxNode.Identifier;
|
|
array[0] = ((SyntaxToken)(ref identifier)).ValueText;
|
|
diagnostics.Add(ErrorCode.WRN_UnconsumedEnumeratorCancellationAttributeUsage, location, array);
|
|
}
|
|
bool needsReporting()
|
|
{
|
|
if (!base.Type.Equals(DeclaringCompilation.GetWellKnownType((WellKnownType)298)))
|
|
{
|
|
return true;
|
|
}
|
|
if (ContainingSymbol is MethodSymbol { IsAsync: not false } methodSymbol && methodSymbol.ReturnType.OriginalDefinition.Equals(DeclaringCompilation.GetWellKnownType((WellKnownType)288)))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private void DecodeInterpolatedStringHandlerArgumentAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, BindingDiagnosticBag diagnostics, int attributeIndex)
|
|
{
|
|
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
|
|
ImmutableArray<ParameterSymbol> containingSymbolParameters;
|
|
if (base.Type is NamedTypeSymbol { IsInterpolatedStringHandlerType: not false })
|
|
{
|
|
if (this is LambdaParameterSymbol)
|
|
{
|
|
diagnostics.Add(ErrorCode.WRN_InterpolatedStringHandlerArgumentAttributeIgnoredOnLambdaParameters, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
}
|
|
TypedConstant constant = ((AttributeData)arguments.Attribute).CommonConstructorArguments[0];
|
|
containingSymbolParameters = ContainingSymbol.GetParameters();
|
|
ImmutableArray<int> interpolatedStringHandlerArguments;
|
|
switch (attributeIndex)
|
|
{
|
|
case 0:
|
|
{
|
|
(int, ParameterSymbol)? tuple = decodeName(constant, ref arguments);
|
|
if (tuple.HasValue)
|
|
{
|
|
(int, ParameterSymbol) valueOrDefault = tuple.GetValueOrDefault();
|
|
int item = valueOrDefault.Item1;
|
|
ParameterSymbol item2 = valueOrDefault.Item2;
|
|
interpolatedStringHandlerArguments = ImmutableArray.Create(item);
|
|
ArrayBuilder<ParameterSymbol> instance = ArrayBuilder<ParameterSymbol>.GetInstance(1);
|
|
instance.Add(item2);
|
|
break;
|
|
}
|
|
setInterpolatedStringHandlerAttributeError(ref arguments);
|
|
return;
|
|
}
|
|
case 1:
|
|
{
|
|
if (((TypedConstant)(ref constant)).IsNull)
|
|
{
|
|
setInterpolatedStringHandlerAttributeError(ref arguments);
|
|
diagnostics.Add(ErrorCode.ERR_NullInvalidInterpolatedStringHandlerArgumentName, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
|
|
return;
|
|
}
|
|
bool flag = false;
|
|
ArrayBuilder<ParameterSymbol> instance = ArrayBuilder<ParameterSymbol>.GetInstance(((TypedConstant)(ref constant)).Values.Length);
|
|
ArrayBuilder<int> instance2 = ArrayBuilder<int>.GetInstance(((TypedConstant)(ref constant)).Values.Length);
|
|
ImmutableArray<TypedConstant>.Enumerator enumerator = ((TypedConstant)(ref constant)).Values.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
TypedConstant current = enumerator.Current;
|
|
(int, ParameterSymbol)? tuple = decodeName(current, ref arguments);
|
|
if (tuple.HasValue)
|
|
{
|
|
var (num, parameterSymbol) = tuple.GetValueOrDefault();
|
|
if (!flag)
|
|
{
|
|
instance.Add(parameterSymbol);
|
|
instance2.Add(num);
|
|
continue;
|
|
}
|
|
}
|
|
flag = true;
|
|
}
|
|
if (flag)
|
|
{
|
|
instance.Free();
|
|
instance2.Free();
|
|
setInterpolatedStringHandlerAttributeError(ref arguments);
|
|
return;
|
|
}
|
|
interpolatedStringHandlerArguments = instance2.ToImmutableAndFree();
|
|
break;
|
|
}
|
|
default:
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs", 1314);
|
|
}
|
|
arguments.GetOrCreateData<ParameterWellKnownAttributeData>().InterpolatedStringHandlerArguments = interpolatedStringHandlerArguments;
|
|
}
|
|
else
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_TypeIsNotAnInterpolatedStringHandlerType, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location, base.Type);
|
|
setInterpolatedStringHandlerAttributeError(ref arguments);
|
|
}
|
|
(int Ordinal, ParameterSymbol? Parameter)? decodeName(TypedConstant val, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> reference)
|
|
{
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Invalid comparison between Unknown and I4
|
|
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0099: Invalid comparison between Unknown and I4
|
|
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009e: Invalid comparison between Unknown and I4
|
|
if (((TypedConstant)(ref val)).IsNull)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_NullInvalidInterpolatedStringHandlerArgumentName, ((SyntaxNode)reference.AttributeSyntaxOpt).Location);
|
|
return null;
|
|
}
|
|
ITypeSymbolInternal typeInternal = ((TypedConstant)(ref val)).TypeInternal;
|
|
if (typeInternal == null || (int)typeInternal.SpecialType != 20)
|
|
{
|
|
return null;
|
|
}
|
|
string text = ((TypedConstant)(ref val)).DecodeValue<string>((SpecialType)20);
|
|
if (text == "")
|
|
{
|
|
bool flag2 = !ContainingSymbol.RequiresInstanceReceiver();
|
|
if (!flag2)
|
|
{
|
|
bool flag3 = ((ContainingSymbol is MethodSymbol { MethodKind: var methodKind } && ((int)methodKind <= 1 || (int)methodKind == 3)) ? true : false);
|
|
flag2 = flag3;
|
|
}
|
|
if (flag2)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_NotInstanceInvalidInterpolatedStringHandlerArgumentName, ((SyntaxNode)reference.AttributeSyntaxOpt).Location, ContainingSymbol);
|
|
return null;
|
|
}
|
|
return (-1, null);
|
|
}
|
|
ParameterSymbol parameterSymbol2 = ImmutableArrayExtensions.FirstOrDefault<ParameterSymbol, string>(containingSymbolParameters, (Func<ParameterSymbol, string, bool>)((ParameterSymbol param, string name) => string.Equals(param.Name, name, StringComparison.Ordinal)), text);
|
|
if ((object)parameterSymbol2 == null)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_InvalidInterpolatedStringHandlerArgumentName, ((SyntaxNode)reference.AttributeSyntaxOpt).Location, text, ContainingSymbol);
|
|
return null;
|
|
}
|
|
if ((object)parameterSymbol2 == this)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_CannotUseSelfAsInterpolatedStringHandlerArgument, ((SyntaxNode)reference.AttributeSyntaxOpt).Location);
|
|
return null;
|
|
}
|
|
if (parameterSymbol2.Ordinal > Ordinal)
|
|
{
|
|
diagnostics.Add(ErrorCode.WRN_ParameterOccursAfterInterpolatedStringHandlerParameter, ((SyntaxNode)reference.AttributeSyntaxOpt).Location, parameterSymbol2.Name, Name);
|
|
}
|
|
return (parameterSymbol2.Ordinal, parameterSymbol2);
|
|
}
|
|
static void setInterpolatedStringHandlerAttributeError(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> reference)
|
|
{
|
|
reference.GetOrCreateData<ParameterWellKnownAttributeData>().InterpolatedStringHandlerArguments = default(ImmutableArray<int>);
|
|
}
|
|
}
|
|
|
|
internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
|
|
{
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Expected I4, but got Unknown
|
|
ParameterWellKnownAttributeData parameterWellKnownAttributeData = (ParameterWellKnownAttributeData)(object)decodedData;
|
|
if (parameterWellKnownAttributeData != null)
|
|
{
|
|
RefKind refKind = RefKind;
|
|
switch (refKind - 1)
|
|
{
|
|
case 0:
|
|
if (((CommonParameterWellKnownAttributeData)parameterWellKnownAttributeData).HasOutAttribute && !((CommonParameterWellKnownAttributeData)parameterWellKnownAttributeData).HasInAttribute)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_OutAttrOnRefParam, GetFirstLocation());
|
|
}
|
|
break;
|
|
case 1:
|
|
if (((CommonParameterWellKnownAttributeData)parameterWellKnownAttributeData).HasInAttribute)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_InAttrOnOutParam, GetFirstLocation());
|
|
}
|
|
break;
|
|
case 2:
|
|
if (((CommonParameterWellKnownAttributeData)parameterWellKnownAttributeData).HasOutAttribute)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_OutAttrOnInParam, GetFirstLocation());
|
|
}
|
|
break;
|
|
case 3:
|
|
if (((CommonParameterWellKnownAttributeData)parameterWellKnownAttributeData).HasOutAttribute)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_OutAttrOnRefReadonlyParam, GetFirstLocation());
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
base.PostDecodeWellKnownAttributes(boundAttributes, allAttributeSyntaxNodes, diagnostics, symbolPart, decodedData);
|
|
}
|
|
|
|
internal override void ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
|
|
{
|
|
GetAttributes();
|
|
_ = ExplicitDefaultConstantValue;
|
|
state.SpinWaitComplete(CompletionPart.ComplexParameterSymbolAll, cancellationToken);
|
|
}
|
|
}
|