Files
2026-08-27 10:56:38 -06:00

1176 lines
46 KiB
C#

using System;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Threading;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CSharp.Emit;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
internal abstract class SourcePropertySymbolBase : PropertySymbol, IAttributeTargetSymbol
{
[Flags]
private enum Flags : byte
{
IsExpressionBodied = 1,
IsAutoProperty = 2,
IsExplicitInterfaceImplementation = 4,
HasInitializer = 8
}
protected const string DefaultIndexerName = "Item";
private readonly SourceMemberContainerTypeSymbol _containingType;
private readonly string _name;
private readonly SyntaxReference _syntaxRef;
protected readonly DeclarationModifiers _modifiers;
private ImmutableArray<CustomModifier> _lazyRefCustomModifiers;
private readonly SourcePropertyAccessorSymbol? _getMethod;
private readonly SourcePropertyAccessorSymbol? _setMethod;
private readonly TypeSymbol _explicitInterfaceType;
private ImmutableArray<PropertySymbol> _lazyExplicitInterfaceImplementations;
private readonly Flags _propertyFlags;
private readonly RefKind _refKind;
private SymbolCompletionState _state;
private ImmutableArray<ParameterSymbol> _lazyParameters;
private TypeWithAnnotations.Boxed _lazyType;
private string _lazySourceName;
private string _lazyDocComment;
private string _lazyExpandedDocComment;
private OverriddenOrHiddenMembersResult _lazyOverriddenOrHiddenMembers;
private SynthesizedSealedPropertyAccessor _lazySynthesizedSealedAccessor;
private CustomAttributesBag<CSharpAttributeData> _lazyCustomAttributesBag;
public Location Location { get; }
protected abstract Location TypeLocation { get; }
internal sealed override ImmutableArray<string> NotNullMembers => GetDecodedWellKnownAttributeData()?.NotNullMembers ?? ImmutableArray<string>.Empty;
internal sealed override ImmutableArray<string> NotNullWhenTrueMembers => GetDecodedWellKnownAttributeData()?.NotNullWhenTrueMembers ?? ImmutableArray<string>.Empty;
internal sealed override ImmutableArray<string> NotNullWhenFalseMembers => GetDecodedWellKnownAttributeData()?.NotNullWhenFalseMembers ?? ImmutableArray<string>.Empty;
internal bool IsExpressionBodied => (_propertyFlags & Flags.IsExpressionBodied) != 0;
public sealed override RefKind RefKind => _refKind;
public sealed override TypeWithAnnotations TypeWithAnnotations
{
get
{
EnsureSignature();
return _lazyType.Value;
}
}
internal bool HasPointerType => TypeWithAnnotations.DefaultType.IsPointerOrFunctionPointer();
public override string Name => _name;
internal string SourceName
{
get
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references)
if (_lazySourceName == null)
{
SyntaxList<AttributeListSyntax> attributeLists = ((IndexerDeclarationSyntax)CSharpSyntaxNode).AttributeLists;
string text = null;
CustomAttributesBag<CSharpAttributeData> lazyCustomAttributesBag = null;
LoadAndValidateAttributes(OneOrMany.Create<SyntaxList<AttributeListSyntax>>(attributeLists), ref lazyCustomAttributesBag, AttributeLocation.None, earlyDecodingOnly: true);
if (lazyCustomAttributesBag != null)
{
PropertyEarlyWellKnownAttributeData propertyEarlyWellKnownAttributeData = (PropertyEarlyWellKnownAttributeData)(object)lazyCustomAttributesBag.EarlyDecodedWellKnownAttributeData;
if (propertyEarlyWellKnownAttributeData != null)
{
text = propertyEarlyWellKnownAttributeData.IndexerName;
}
}
text = text ?? "Item";
InterlockedOperations.Initialize<string>(ref _lazySourceName, text);
}
return _lazySourceName;
}
}
public override string MetadataName => SourceName.Replace(" ", "");
public override Symbol ContainingSymbol => _containingType;
public override NamedTypeSymbol ContainingType => _containingType;
public override ImmutableArray<Location> Locations => ImmutableArray.Create<Location>(Location);
public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences => ImmutableArray.Create<SyntaxReference>(_syntaxRef);
public override bool IsAbstract => (_modifiers & DeclarationModifiers.Abstract) != 0;
public override bool IsExtern => (_modifiers & DeclarationModifiers.Extern) != 0;
public override bool IsStatic => (_modifiers & DeclarationModifiers.Static) != 0;
internal bool IsFixed => false;
public override bool IsIndexer => (_modifiers & DeclarationModifiers.Indexer) != 0;
public override bool IsOverride => (_modifiers & DeclarationModifiers.Override) != 0;
public override bool IsSealed => (_modifiers & DeclarationModifiers.Sealed) != 0;
public override bool IsVirtual => (_modifiers & DeclarationModifiers.Virtual) != 0;
internal sealed override bool IsRequired => (_modifiers & DeclarationModifiers.Required) != 0;
internal bool IsNew => (_modifiers & DeclarationModifiers.New) != 0;
internal bool HasReadOnlyModifier => (_modifiers & DeclarationModifiers.ReadOnly) != 0;
public sealed override MethodSymbol? GetMethod => _getMethod;
public sealed override MethodSymbol? SetMethod => _setMethod;
internal override CallingConvention CallingConvention
{
get
{
if (IsStatic)
{
return (CallingConvention)0;
}
return (CallingConvention)32;
}
}
public sealed override ImmutableArray<ParameterSymbol> Parameters
{
get
{
EnsureSignature();
return _lazyParameters;
}
}
internal override bool IsExplicitInterfaceImplementation => (_propertyFlags & Flags.IsExplicitInterfaceImplementation) != 0;
public sealed override ImmutableArray<PropertySymbol> ExplicitInterfaceImplementations
{
get
{
if (IsExplicitInterfaceImplementation)
{
EnsureSignature();
}
return _lazyExplicitInterfaceImplementations;
}
}
public sealed override ImmutableArray<CustomModifier> RefCustomModifiers
{
get
{
EnsureSignature();
return _lazyRefCustomModifiers;
}
}
public override Accessibility DeclaredAccessibility => ModifierUtils.EffectiveAccessibility(_modifiers);
public bool HasSkipLocalsInitAttribute => GetDecodedWellKnownAttributeData()?.HasSkipLocalsInitAttribute ?? false;
internal bool IsAutoPropertyWithGetAccessor
{
get
{
if (IsAutoProperty)
{
return (object)_getMethod != null;
}
return false;
}
}
protected bool IsAutoProperty => (_propertyFlags & Flags.IsAutoProperty) != 0;
internal SynthesizedBackingFieldSymbol BackingField { get; }
internal override bool MustCallMethodsDirectly => false;
internal SyntaxReference SyntaxReference => _syntaxRef;
internal CSharpSyntaxNode CSharpSyntaxNode => (CSharpSyntaxNode)(object)_syntaxRef.GetSyntax(default(CancellationToken));
internal SyntaxTree SyntaxTree => _syntaxRef.SyntaxTree;
internal override OverriddenOrHiddenMembersResult OverriddenOrHiddenMembers
{
get
{
if (_lazyOverriddenOrHiddenMembers == null)
{
Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
}
return _lazyOverriddenOrHiddenMembers;
}
}
internal SynthesizedSealedPropertyAccessor SynthesizedSealedAccessorOpt
{
get
{
bool flag = (object)GetMethod != null;
bool flag2 = (object)SetMethod != null;
if (!IsSealed || (flag && flag2))
{
return null;
}
if ((object)_lazySynthesizedSealedAccessor == null)
{
Interlocked.CompareExchange(ref _lazySynthesizedSealedAccessor, MakeSynthesizedSealedAccessor(), null);
}
return _lazySynthesizedSealedAccessor;
}
}
public abstract SyntaxList<AttributeListSyntax> AttributeDeclarationSyntaxList { get; }
public abstract IAttributeTargetSymbol AttributesOwner { get; }
IAttributeTargetSymbol IAttributeTargetSymbol.AttributesOwner => AttributesOwner;
AttributeLocation IAttributeTargetSymbol.DefaultAttributeLocation => AttributeLocation.Property;
AttributeLocation IAttributeTargetSymbol.AllowedAttributeLocations
{
get
{
if (!IsAutoPropertyWithGetAccessor)
{
return AttributeLocation.Property;
}
return AttributeLocation.Field | AttributeLocation.Property;
}
}
internal sealed override bool IsDirectlyExcludedFromCodeCoverage
{
get
{
PropertyWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
if (decodedWellKnownAttributeData == null)
{
return false;
}
return ((CommonPropertyWellKnownAttributeData)decodedWellKnownAttributeData).HasExcludeFromCodeCoverageAttribute;
}
}
internal override bool HasSpecialName
{
get
{
PropertyWellKnownAttributeData decodedWellKnownAttributeData = GetDecodedWellKnownAttributeData();
if (decodedWellKnownAttributeData != null)
{
return ((CommonPropertyWellKnownAttributeData)decodedWellKnownAttributeData).HasSpecialNameAttribute;
}
return false;
}
}
internal override ObsoleteAttributeData ObsoleteAttributeData
{
get
{
if (!_containingType.AnyMemberHasAttributes)
{
return null;
}
CustomAttributesBag<CSharpAttributeData> lazyCustomAttributesBag = _lazyCustomAttributesBag;
if (lazyCustomAttributesBag != null && lazyCustomAttributesBag.IsEarlyDecodedWellKnownAttributeDataComputed)
{
PropertyEarlyWellKnownAttributeData obj = (PropertyEarlyWellKnownAttributeData)(object)lazyCustomAttributesBag.EarlyDecodedWellKnownAttributeData;
if (obj == null)
{
return null;
}
return ((CommonPropertyEarlyWellKnownAttributeData)obj).ObsoleteAttributeData;
}
return ObsoleteAttributeData.Uninitialized;
}
}
internal bool HasDisallowNull => GetDecodedWellKnownAttributeData()?.HasDisallowNullAttribute ?? false;
internal bool HasAllowNull => GetDecodedWellKnownAttributeData()?.HasAllowNullAttribute ?? false;
internal bool HasMaybeNull => GetDecodedWellKnownAttributeData()?.HasMaybeNullAttribute ?? false;
internal bool HasNotNull => GetDecodedWellKnownAttributeData()?.HasNotNullAttribute ?? false;
internal SourceAttributeData DisallowNullAttributeIfExists => FindAttribute(AttributeDescription.DisallowNullAttribute);
internal SourceAttributeData AllowNullAttributeIfExists => FindAttribute(AttributeDescription.AllowNullAttribute);
internal SourceAttributeData MaybeNullAttributeIfExists => FindAttribute(AttributeDescription.MaybeNullAttribute);
internal SourceAttributeData NotNullAttributeIfExists => FindAttribute(AttributeDescription.NotNullAttribute);
internal ImmutableArray<SourceAttributeData> MemberNotNullAttributeIfExists => FindAttributes(AttributeDescription.MemberNotNullAttribute);
internal ImmutableArray<SourceAttributeData> MemberNotNullWhenAttributeIfExists => FindAttributes(AttributeDescription.MemberNotNullWhenAttribute);
internal sealed override bool HasUnscopedRefAttribute => GetDecodedWellKnownAttributeData()?.HasUnscopedRefAttribute ?? false;
internal sealed override bool RequiresCompletion => true;
protected SourcePropertySymbolBase(SourceMemberContainerTypeSymbol containingType, CSharpSyntaxNode syntax, bool hasGetAccessor, bool hasSetAccessor, bool isExplicitInterfaceImplementation, TypeSymbol? explicitInterfaceType, string? aliasQualifierOpt, DeclarationModifiers modifiers, bool hasInitializer, bool isAutoProperty, bool isExpressionBodied, bool isInitOnly, RefKind refKind, string memberName, SyntaxList<AttributeListSyntax> indexerNameAttributeLists, Location location, BindingDiagnosticBag diagnostics)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
_syntaxRef = syntax.GetReference();
Location = location;
_containingType = containingType;
_refKind = refKind;
_modifiers = modifiers;
_explicitInterfaceType = explicitInterfaceType;
if (isExplicitInterfaceImplementation)
{
_propertyFlags |= Flags.IsExplicitInterfaceImplementation;
}
else
{
_lazyExplicitInterfaceImplementations = ImmutableArray<PropertySymbol>.Empty;
}
bool isIndexer = IsIndexer;
isAutoProperty = isAutoProperty && (!containingType.IsInterface || IsStatic) && !IsAbstract && !IsExtern && !isIndexer;
if (isAutoProperty)
{
_propertyFlags |= Flags.IsAutoProperty;
}
if (hasInitializer)
{
_propertyFlags |= Flags.HasInitializer;
}
if (isExpressionBodied)
{
_propertyFlags |= Flags.IsExpressionBodied;
}
if (isIndexer)
{
if (indexerNameAttributeLists.Count == 0 || isExplicitInterfaceImplementation)
{
_lazySourceName = memberName;
}
_name = ExplicitInterfaceHelpers.GetMemberName("this[]", _explicitInterfaceType, aliasQualifierOpt);
}
else
{
_name = (_lazySourceName = memberName);
}
if ((isAutoProperty && hasGetAccessor) || hasInitializer)
{
string name = GeneratedNames.MakeBackingFieldName(_name);
BackingField = new SynthesizedBackingFieldSymbol(this, name, (hasGetAccessor && !hasSetAccessor) || isInitOnly, IsStatic, hasInitializer);
}
if (hasGetAccessor)
{
_getMethod = CreateGetAccessorSymbol(isAutoProperty, diagnostics);
}
if (hasSetAccessor)
{
_setMethod = CreateSetAccessorSymbol(isAutoProperty, diagnostics);
}
}
private void EnsureSignatureGuarded(BindingDiagnosticBag diagnostics)
{
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Invalid comparison between Unknown and I4
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
PropertySymbol propertySymbol = null;
_lazyRefCustomModifiers = ImmutableArray<CustomModifier>.Empty;
(TypeWithAnnotations, ImmutableArray<ParameterSymbol>) tuple = MakeParametersAndBindType(diagnostics);
TypeWithAnnotations item = tuple.Item1;
_lazyParameters = tuple.Item2;
_lazyType = new TypeWithAnnotations.Boxed(item);
bool isExplicitInterfaceImplementation = IsExplicitInterfaceImplementation;
if (isExplicitInterfaceImplementation || IsOverride)
{
bool alsoCopyParamsModifier = false;
PropertySymbol propertySymbol2;
if (!isExplicitInterfaceImplementation)
{
alsoCopyParamsModifier = true;
propertySymbol2 = base.OverriddenProperty;
}
else
{
CSharpSyntaxNode cSharpSyntaxNode = CSharpSyntaxNode;
object obj;
if (!IsIndexer)
{
SyntaxToken identifier = ((PropertyDeclarationSyntax)cSharpSyntaxNode).Identifier;
obj = ((SyntaxToken)(ref identifier)).ValueText;
}
else
{
obj = "this[]";
}
string interfacePropertyName = (string)obj;
propertySymbol = this.FindExplicitlyImplementedProperty(_explicitInterfaceType, interfacePropertyName, GetExplicitInterfaceSpecifier(), diagnostics);
this.FindExplicitlyImplementedMemberVerification(propertySymbol, diagnostics);
propertySymbol2 = propertySymbol;
}
if ((object)propertySymbol2 != null)
{
_lazyRefCustomModifiers = (((int)_refKind != 0) ? propertySymbol2.RefCustomModifiers : ImmutableArray<CustomModifier>.Empty);
TypeWithAnnotations typeWithAnnotations = propertySymbol2.TypeWithAnnotations;
if (item.Type.Equals(typeWithAnnotations.Type, (TypeCompareKind)11))
{
item = item.WithTypeAndModifiers(CustomModifierUtils.CopyTypeCustomModifiers(typeWithAnnotations.Type, item.Type, ContainingAssembly), typeWithAnnotations.CustomModifiers);
_lazyType = new TypeWithAnnotations.Boxed(item);
}
_lazyParameters = CustomModifierUtils.CopyParameterCustomModifiers(propertySymbol2.Parameters, _lazyParameters, alsoCopyParamsModifier);
}
}
else if ((int)_refKind == 3)
{
NamedTypeSymbol wellKnownType = Binder.GetWellKnownType(DeclaringCompilation, (WellKnownType)273, diagnostics, TypeLocation);
_lazyRefCustomModifiers = ImmutableArray.Create<CustomModifier>(CSharpCustomModifier.CreateRequired(wellKnownType));
}
_lazyExplicitInterfaceImplementations = (((object)propertySymbol == null) ? ImmutableArray<PropertySymbol>.Empty : ImmutableArray.Create(propertySymbol));
}
private void CheckInitializer(bool isAutoProperty, bool isInterface, bool isStatic, Location location, BindingDiagnosticBag diagnostics)
{
if (isInterface && !isStatic)
{
diagnostics.Add(ErrorCode.ERR_InstancePropertyInitializerInInterface, location);
}
else if (!isAutoProperty)
{
diagnostics.Add(ErrorCode.ERR_InitializerOnNonAutoProperty, location);
}
}
private void EnsureSignature()
{
if (_state.HasComplete(CompletionPart.FinishBaseType))
{
return;
}
lock (_syntaxRef)
{
if (_state.NotePartComplete(CompletionPart.StartBaseType))
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
try
{
EnsureSignatureGuarded(instance);
AddDeclarationDiagnostics(instance);
return;
}
finally
{
_state.NotePartComplete(CompletionPart.FinishBaseType);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
}
}
}
internal override LexicalSortKey GetLexicalSortKey()
{
return new LexicalSortKey(Location, DeclaringCompilation);
}
public sealed override Location TryGetFirstLocation()
{
return Location;
}
protected abstract SourcePropertyAccessorSymbol CreateGetAccessorSymbol(bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics);
protected abstract SourcePropertyAccessorSymbol CreateSetAccessorSymbol(bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics);
internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions, BindingDiagnosticBag diagnostics)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Invalid comparison between Unknown and I4
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Expected O, but got Unknown
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
bool isExplicitInterfaceImplementation = IsExplicitInterfaceImplementation;
CheckAccessibility(Location, diagnostics, isExplicitInterfaceImplementation);
CheckModifiers(isExplicitInterfaceImplementation, Location, IsIndexer, diagnostics);
if ((_propertyFlags & Flags.HasInitializer) != 0)
{
CheckInitializer(IsAutoProperty, ContainingType.IsInterface, IsStatic, Location, diagnostics);
}
if ((int)RefKind != 0 && IsRequired)
{
diagnostics.Add(ErrorCode.ERR_RefReturningPropertiesCannotBeRequired, Location);
}
if (IsAutoPropertyWithGetAccessor)
{
if (!IsStatic)
{
MethodSymbol setMethod = SetMethod;
if ((object)setMethod != null && !setMethod.IsInitOnly)
{
if (ContainingType.IsReadOnly)
{
diagnostics.Add(ErrorCode.ERR_AutoPropsInRoStruct, Location);
}
else if (HasReadOnlyModifier)
{
diagnostics.Add(ErrorCode.ERR_AutoPropertyWithSetterCantBeReadOnly, Location, this);
}
}
}
Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(DeclaringCompilation, (WellKnownMember)112, diagnostics, Location);
if ((int)RefKind != 0)
{
diagnostics.Add(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, Location);
}
if (IsOverride && (object)SetMethod == null && !base.IsReadOnly)
{
diagnostics.Add(ErrorCode.ERR_AutoPropertyMustOverrideSet, Location);
}
}
if (!IsExpressionBodied)
{
bool flag = (object)GetMethod != null;
bool flag2 = (object)SetMethod != null;
if (flag && flag2)
{
if ((int)_refKind != 0)
{
diagnostics.Add(ErrorCode.ERR_RefPropertyCannotHaveSetAccessor, _setMethod.GetFirstLocation());
}
else if ((int)_getMethod.LocalAccessibility != 0 && (int)_setMethod.LocalAccessibility != 0)
{
diagnostics.Add(ErrorCode.ERR_DuplicatePropertyAccessMods, Location, this);
}
else if (_getMethod.LocalDeclaredReadOnly && _setMethod.LocalDeclaredReadOnly)
{
diagnostics.Add(ErrorCode.ERR_DuplicatePropertyReadOnlyMods, Location, this);
}
else if (IsAbstract)
{
CheckAbstractPropertyAccessorNotPrivate(_getMethod, diagnostics);
CheckAbstractPropertyAccessorNotPrivate(_setMethod, diagnostics);
}
}
else
{
if (!flag && !flag2)
{
diagnostics.Add(ErrorCode.ERR_PropertyWithNoAccessors, Location, this);
}
else if ((int)RefKind != 0)
{
if (!flag)
{
diagnostics.Add(ErrorCode.ERR_RefPropertyMustHaveGetAccessor, Location);
}
}
else if (!flag && IsAutoProperty)
{
diagnostics.Add(ErrorCode.ERR_AutoPropertyMustHaveGetAccessor, _setMethod.GetFirstLocation());
}
if (!IsOverride)
{
SourcePropertyAccessorSymbol sourcePropertyAccessorSymbol = _getMethod ?? _setMethod;
if ((object)sourcePropertyAccessorSymbol != null)
{
if ((int)sourcePropertyAccessorSymbol.LocalAccessibility != 0)
{
diagnostics.Add(ErrorCode.ERR_AccessModMissingAccessor, Location, this);
}
if (sourcePropertyAccessorSymbol.LocalDeclaredReadOnly)
{
diagnostics.Add(ErrorCode.ERR_ReadOnlyModMissingAccessor, Location, this);
}
}
}
}
CheckAccessibilityMoreRestrictive(_getMethod, diagnostics);
CheckAccessibilityMoreRestrictive(_setMethod, diagnostics);
}
PropertySymbol propertySymbol = ExplicitInterfaceImplementations.FirstOrDefault();
if ((object)propertySymbol != null)
{
CheckExplicitImplementationAccessor(GetMethod, propertySymbol.GetMethod, propertySymbol, diagnostics);
CheckExplicitImplementationAccessor(SetMethod, propertySymbol.SetMethod, propertySymbol, diagnostics);
}
Location typeLocation = TypeLocation;
CSharpCompilation declaringCompilation = DeclaringCompilation;
if ((object)_explicitInterfaceType != null)
{
ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = GetExplicitInterfaceSpecifier();
_explicitInterfaceType.CheckAllConstraints(declaringCompilation, conversions, (Location)new SourceLocation((SyntaxNode)(object)explicitInterfaceSpecifier.Name), diagnostics);
if ((object)propertySymbol != null)
{
TypeSymbol.CheckModifierMismatchOnImplementingMember(ContainingType, this, propertySymbol, isExplicit: true, diagnostics);
}
}
if ((int)_refKind == 3)
{
declaringCompilation.EnsureIsReadOnlyAttributeExists(diagnostics, typeLocation, modifyCompilation: true);
}
ParameterHelpers.EnsureRefKindAttributesExist(declaringCompilation, Parameters, diagnostics, modifyCompilation: true);
if (declaringCompilation.ShouldEmitNativeIntegerAttributes(base.Type))
{
declaringCompilation.EnsureNativeIntegerAttributeExists(diagnostics, typeLocation, modifyCompilation: true);
}
ParameterHelpers.EnsureNativeIntegerAttributeExists(declaringCompilation, Parameters, diagnostics, modifyCompilation: true);
ParameterHelpers.EnsureScopedRefAttributeExists(declaringCompilation, Parameters, diagnostics, modifyCompilation: true);
if (declaringCompilation.ShouldEmitNullableAttributes(this) && TypeWithAnnotations.NeedsNullableAttribute())
{
declaringCompilation.EnsureNullableAttributeExists(diagnostics, typeLocation, modifyCompilation: true);
}
ParameterHelpers.EnsureNullableAttributeExists(declaringCompilation, this, Parameters, diagnostics, modifyCompilation: true);
}
private void CheckAccessibility(Location location, BindingDiagnosticBag diagnostics, bool isExplicitInterfaceImplementation)
{
ModifierUtils.CheckAccessibility(_modifiers, this, isExplicitInterfaceImplementation, diagnostics, location);
}
private void CheckModifiers(bool isExplicitInterfaceImplementation, Location location, bool isIndexer, BindingDiagnosticBag diagnostics)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Invalid comparison between Unknown and I4
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Invalid comparison between Unknown and I4
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
bool flag = isExplicitInterfaceImplementation && ContainingType.IsInterface;
if ((int)DeclaredAccessibility == 1 && (IsVirtual || (IsAbstract && !flag) || IsOverride))
{
diagnostics.Add(ErrorCode.ERR_VirtualPrivate, location, this);
}
else if (IsStatic && HasReadOnlyModifier)
{
diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
}
else if (IsOverride && (IsNew || IsVirtual))
{
diagnostics.Add(ErrorCode.ERR_OverrideNotNew, location, this);
}
else if (IsSealed && !IsOverride && !(IsAbstract && flag))
{
diagnostics.Add(ErrorCode.ERR_SealedNonOverride, location, this);
}
else if (IsAbstract && (int)ContainingType.TypeKind == 10)
{
diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword));
}
else if (IsVirtual && (int)ContainingType.TypeKind == 10)
{
diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
}
else if (IsAbstract && IsExtern)
{
diagnostics.Add(ErrorCode.ERR_AbstractAndExtern, location, this);
}
else if (IsAbstract && IsSealed && !flag)
{
diagnostics.Add(ErrorCode.ERR_AbstractAndSealed, location, this);
}
else if (IsAbstract && IsVirtual)
{
diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, Kind.Localize(), this);
}
else if (ContainingType.IsSealed && DeclaredAccessibility.HasProtected() && !IsOverride)
{
diagnostics.Add(AccessCheck.GetProtectedMemberInSealedTypeError(ContainingType), location, this);
}
else if (ContainingType.IsStatic && !IsStatic)
{
ErrorCode code = (isIndexer ? ErrorCode.ERR_IndexerInStaticClass : ErrorCode.ERR_InstanceMemberInStaticClass);
diagnostics.Add(code, location, this);
}
}
private void CheckAccessibilityMoreRestrictive(SourcePropertyAccessorSymbol accessor, BindingDiagnosticBag diagnostics)
{
//IL_0004: 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 ((object)accessor != null && !IsAccessibilityMoreRestrictive(DeclaredAccessibility, accessor.LocalAccessibility))
{
diagnostics.Add(ErrorCode.ERR_InvalidPropertyAccessMod, accessor.GetFirstLocation(), accessor, this);
}
}
private static bool IsAccessibilityMoreRestrictive(Accessibility property, Accessibility accessor)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if ((int)accessor == 0)
{
return true;
}
if (accessor < property)
{
if ((int)accessor == 3)
{
return (int)property != 4;
}
return true;
}
return false;
}
private static void CheckAbstractPropertyAccessorNotPrivate(SourcePropertyAccessorSymbol accessor, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)accessor.LocalAccessibility == 1)
{
diagnostics.Add(ErrorCode.ERR_PrivateAbstractAccessor, accessor.GetFirstLocation(), accessor);
}
}
public override string GetDocumentationCommentXml(CultureInfo preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default(CancellationToken))
{
return SourceDocumentationCommentUtils.GetAndCacheDocumentationComment(this, expandIncludes, ref expandIncludes ? ref _lazyExpandedDocComment : ref _lazyDocComment);
}
private void CheckExplicitImplementationAccessor(MethodSymbol thisAccessor, MethodSymbol otherAccessor, PropertySymbol explicitlyImplementedProperty, BindingDiagnosticBag diagnostics)
{
bool flag = (object)thisAccessor != null;
bool flag2 = otherAccessor.IsImplementable();
if (flag2 && !flag)
{
diagnostics.Add(ErrorCode.ERR_ExplicitPropertyMissingAccessor, Location, this, otherAccessor);
}
else if (!flag2 && flag)
{
diagnostics.Add(ErrorCode.ERR_ExplicitPropertyAddingAccessor, thisAccessor.GetFirstLocation(), thisAccessor, explicitlyImplementedProperty);
}
else if (TypeSymbol.HaveInitOnlyMismatch(thisAccessor, otherAccessor))
{
diagnostics.Add(ErrorCode.ERR_ExplicitPropertyMismatchInitOnly, thisAccessor.GetFirstLocation(), thisAccessor, otherAccessor);
}
}
private SynthesizedSealedPropertyAccessor MakeSynthesizedSealedAccessor()
{
if ((object)GetMethod != null)
{
MethodSymbol ownOrInheritedSetMethod = this.GetOwnOrInheritedSetMethod();
if ((object)ownOrInheritedSetMethod != null)
{
return new SynthesizedSealedPropertyAccessor(this, ownOrInheritedSetMethod);
}
return null;
}
if ((object)SetMethod != null)
{
MethodSymbol ownOrInheritedGetMethod = this.GetOwnOrInheritedGetMethod();
if ((object)ownOrInheritedGetMethod != null)
{
return new SynthesizedSealedPropertyAccessor(this, ownOrInheritedGetMethod);
}
return null;
}
return null;
}
private CustomAttributesBag<CSharpAttributeData> GetAttributesBag()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
CustomAttributesBag<CSharpAttributeData> lazyCustomAttributesBag = _lazyCustomAttributesBag;
if (lazyCustomAttributesBag != null && lazyCustomAttributesBag.IsSealed)
{
return lazyCustomAttributesBag;
}
BackingField?.GetAttributes();
if (LoadAndValidateAttributes(OneOrMany.Create<SyntaxList<AttributeListSyntax>>(AttributeDeclarationSyntaxList), ref _lazyCustomAttributesBag))
{
_state.NotePartComplete(CompletionPart.Attributes);
}
return _lazyCustomAttributesBag;
}
public sealed override ImmutableArray<CSharpAttributeData> GetAttributes()
{
return GetAttributesBag().Attributes;
}
private PropertyWellKnownAttributeData GetDecodedWellKnownAttributeData()
{
CustomAttributesBag<CSharpAttributeData> val = _lazyCustomAttributesBag;
if (val == null || !val.IsDecodedWellKnownAttributeDataComputed)
{
val = GetAttributesBag();
}
return (PropertyWellKnownAttributeData)(object)val.DecodedWellKnownAttributeData;
}
internal PropertyEarlyWellKnownAttributeData GetEarlyDecodedWellKnownAttributeData()
{
CustomAttributesBag<CSharpAttributeData> val = _lazyCustomAttributesBag;
if (val == null || !val.IsEarlyDecodedWellKnownAttributeDataComputed)
{
val = GetAttributesBag();
}
return (PropertyEarlyWellKnownAttributeData)(object)val.EarlyDecodedWellKnownAttributeData;
}
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
CSharpCompilation declaringCompilation = DeclaringCompilation;
TypeWithAnnotations typeWithAnnotations = TypeWithAnnotations;
if (typeWithAnnotations.Type.ContainsDynamic())
{
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeDynamicAttribute(typeWithAnnotations.Type, typeWithAnnotations.CustomModifiers.Length + RefCustomModifiers.Length, _refKind));
}
if (declaringCompilation.ShouldEmitNativeIntegerAttributes(typeWithAnnotations.Type))
{
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNativeIntegerAttribute(this, typeWithAnnotations.Type));
}
if (typeWithAnnotations.Type.ContainsTupleNames())
{
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.SynthesizeTupleNamesAttribute(typeWithAnnotations.Type));
}
if (declaringCompilation.ShouldEmitNullableAttributes(this))
{
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, ContainingType.GetNullableContextValue(), typeWithAnnotations));
}
if (base.ReturnsByRefReadonly)
{
Symbol.AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeIsReadOnlyAttribute(this));
}
if (IsRequired)
{
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)469));
}
}
internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
if (Symbol.EarlyDecodeDeprecatedOrExperimentalOrObsoleteAttribute(ref arguments, out CSharpAttributeData attributeData, out BoundAttribute boundAttribute, out ObsoleteAttributeData obsoleteData))
{
if (obsoleteData != null)
{
((CommonPropertyEarlyWellKnownAttributeData)arguments.GetOrCreateData<PropertyEarlyWellKnownAttributeData>()).ObsoleteAttributeData = obsoleteData;
}
return (attributeData, boundAttribute);
}
if (CSharpAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.IndexerNameAttribute))
{
(attributeData, boundAttribute) = arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, null, null, out var generatedDiagnostics);
if (!((AttributeData)attributeData).HasErrors)
{
TypedConstant val = ((AttributeData)attributeData).CommonConstructorArguments[0];
string text = ((TypedConstant)(ref val)).DecodeValue<string>((SpecialType)20);
if (text != null)
{
arguments.GetOrCreateData<PropertyEarlyWellKnownAttributeData>().IndexerName = text;
}
if (!generatedDiagnostics)
{
return (attributeData, boundAttribute);
}
}
return (null, null);
}
return base.EarlyDecodeWellKnownAttribute(ref arguments);
}
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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
BindingDiagnosticBag bindingDiagnosticBag = (BindingDiagnosticBag)(object)arguments.Diagnostics;
CSharpAttributeData attribute = arguments.Attribute;
if (attribute.IsTargetAttribute(this, AttributeDescription.IndexerNameAttribute))
{
ValidateIndexerNameAttribute(attribute, arguments.AttributeSyntaxOpt, bindingDiagnosticBag);
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.SpecialNameAttribute))
{
((CommonPropertyWellKnownAttributeData)arguments.GetOrCreateData<PropertyWellKnownAttributeData>()).HasSpecialNameAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.ExcludeFromCodeCoverageAttribute))
{
((CommonPropertyWellKnownAttributeData)arguments.GetOrCreateData<PropertyWellKnownAttributeData>()).HasExcludeFromCodeCoverageAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.SkipLocalsInitAttribute))
{
CSharpAttributeData.DecodeSkipLocalsInitAttribute<PropertyWellKnownAttributeData>(DeclaringCompilation, ref arguments);
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.DynamicAttribute))
{
bindingDiagnosticBag.Add(ErrorCode.ERR_ExplicitDynamicAttr, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
}
else
{
if (ReportExplicitUseOfReservedAttributes(in arguments, ReservedAttributes.DynamicAttribute | ReservedAttributes.IsReadOnlyAttribute | ReservedAttributes.IsUnmanagedAttribute | ReservedAttributes.IsByRefLikeAttribute | ReservedAttributes.TupleElementNamesAttribute | ReservedAttributes.NullableAttribute | ReservedAttributes.NativeIntegerAttribute | ReservedAttributes.RequiredMemberAttribute | ReservedAttributes.RequiresLocationAttribute))
{
return;
}
if (attribute.IsTargetAttribute(this, AttributeDescription.DisallowNullAttribute))
{
arguments.GetOrCreateData<PropertyWellKnownAttributeData>().HasDisallowNullAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.AllowNullAttribute))
{
arguments.GetOrCreateData<PropertyWellKnownAttributeData>().HasAllowNullAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.MaybeNullAttribute))
{
arguments.GetOrCreateData<PropertyWellKnownAttributeData>().HasMaybeNullAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.NotNullAttribute))
{
arguments.GetOrCreateData<PropertyWellKnownAttributeData>().HasNotNullAttribute = true;
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.MemberNotNullAttribute))
{
MessageID.IDS_FeatureMemberNotNull.CheckFeatureAvailability(bindingDiagnosticBag, (SyntaxNode)(object)arguments.AttributeSyntaxOpt);
CSharpAttributeData.DecodeMemberNotNullAttribute<PropertyWellKnownAttributeData>((TypeSymbol)ContainingType, ref arguments);
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.MemberNotNullWhenAttribute))
{
MessageID.IDS_FeatureMemberNotNull.CheckFeatureAvailability(bindingDiagnosticBag, (SyntaxNode)(object)arguments.AttributeSyntaxOpt);
CSharpAttributeData.DecodeMemberNotNullWhenAttribute<PropertyWellKnownAttributeData>((TypeSymbol)ContainingType, ref arguments);
}
else if (attribute.IsTargetAttribute(this, AttributeDescription.UnscopedRefAttribute))
{
if (IsValidUnscopedRefAttributeTarget())
{
arguments.GetOrCreateData<PropertyWellKnownAttributeData>().HasUnscopedRefAttribute = true;
}
else
{
bindingDiagnosticBag.Add(ErrorCode.ERR_UnscopedRefAttributeUnsupportedMemberTarget, ((SyntaxNode)arguments.AttributeSyntaxOpt).Location);
}
}
}
}
private bool IsValidUnscopedRefAttributeTarget()
{
if (isNullOrValidAccessor(_getMethod))
{
return isNullOrValidAccessor(_setMethod);
}
return false;
static bool isNullOrValidAccessor(MethodSymbol? accessor)
{
return accessor?.IsValidUnscopedRefAttributeTarget() ?? true;
}
}
private SourceAttributeData FindAttribute(AttributeDescription attributeDescription)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return (SourceAttributeData)GetAttributes().First((CSharpAttributeData a) => a.IsTargetAttribute(this, attributeDescription));
}
private ImmutableArray<SourceAttributeData> FindAttributes(AttributeDescription attributeDescription)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
return (from a in GetAttributes()
where a.IsTargetAttribute(this, attributeDescription)
select a).Cast<SourceAttributeData>().ToImmutableArray();
}
internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
{
base.PostDecodeWellKnownAttributes(boundAttributes, allAttributeSyntaxNodes, diagnostics, symbolPart, decodedData);
}
private void ValidateIndexerNameAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics)
{
//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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
if (!IsIndexer || IsExplicitInterfaceImplementation)
{
diagnostics.Add(ErrorCode.ERR_BadIndexerNameAttr, ((SyntaxNode)node.Name).Location, node.GetErrorDisplayName());
return;
}
TypedConstant val = ((AttributeData)attribute).CommonConstructorArguments[0];
string text = ((TypedConstant)(ref val)).DecodeValue<string>((SpecialType)20);
if (text == null || !SyntaxFacts.IsValidIdentifier(text))
{
diagnostics.Add(ErrorCode.ERR_BadArgumentToAttribute, ((SyntaxNode)node.ArgumentList.Arguments[0]).Location, node.GetErrorDisplayName());
}
}
internal sealed override bool HasComplete(CompletionPart part)
{
return _state.HasComplete(part);
}
internal override void ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken)
{
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
CompletionPart nextIncompletePart = _state.NextIncompletePart;
switch (nextIncompletePart)
{
case CompletionPart.Attributes:
GetAttributes();
break;
case CompletionPart.StartBaseType:
case CompletionPart.FinishBaseType:
EnsureSignature();
break;
case CompletionPart.StartInterfaces:
case CompletionPart.FinishInterfaces:
if (_state.NotePartComplete(CompletionPart.StartInterfaces))
{
if (Parameters.Length > 0)
{
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance();
TypeConversions typeConversions2 = ContainingAssembly.CorLibrary.TypeConversions;
ImmutableArray<ParameterSymbol>.Enumerator enumerator = Parameters.GetEnumerator();
while (enumerator.MoveNext())
{
ParameterSymbol current = enumerator.Current;
current.ForceComplete(locationOpt, cancellationToken);
current.Type.CheckAllConstraints(DeclaringCompilation, typeConversions2, current.GetFirstLocation(), instance2);
}
AddDeclarationDiagnostics(instance2);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
}
DeclaringCompilation.SymbolDeclaredEvent(this);
_state.NotePartComplete(CompletionPart.FinishInterfaces);
}
else
{
_state.SpinWaitComplete(CompletionPart.FinishInterfaces, cancellationToken);
}
break;
case CompletionPart.EnumUnderlyingType:
case CompletionPart.TypeArguments:
if (_state.NotePartComplete(CompletionPart.EnumUnderlyingType))
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance();
TypeConversions typeConversions = ContainingAssembly.CorLibrary.TypeConversions;
base.Type.CheckAllConstraints(DeclaringCompilation, typeConversions, Location, instance);
ValidatePropertyType(instance);
AddDeclarationDiagnostics(instance);
_state.NotePartComplete(CompletionPart.TypeArguments);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
else
{
_state.SpinWaitComplete(CompletionPart.TypeArguments, cancellationToken);
}
break;
case CompletionPart.None:
return;
default:
_state.NotePartComplete(CompletionPart.NamespaceSymbolAll | CompletionPart.ReturnTypeAttributes | CompletionPart.Parameters | CompletionPart.Type | CompletionPart.TypeParameters | CompletionPart.TypeMembers | CompletionPart.SynthesizedExplicitImplementations | CompletionPart.StartMemberChecks | CompletionPart.FinishMemberChecks | CompletionPart.MembersCompletedChecksStarted);
break;
}
_state.SpinWaitComplete(nextIncompletePart, cancellationToken);
}
}
protected virtual void ValidatePropertyType(BindingDiagnosticBag diagnostics)
{
TypeSymbol type = base.Type;
if (type.IsRestrictedType(ignoreSpanLikeTypes: true))
{
diagnostics.Add(ErrorCode.ERR_FieldCantBeRefAny, TypeLocation, type);
}
else if (IsAutoPropertyWithGetAccessor && type.IsRefLikeType && (IsStatic || !ContainingType.IsRefLikeType))
{
diagnostics.Add(ErrorCode.ERR_FieldAutoPropCantBeByRefLike, TypeLocation, type);
}
if (type.IsStatic)
{
if ((object)GetMethod != null)
{
diagnostics.Add(ErrorFacts.GetStaticClassReturnCode(ContainingType.IsInterfaceType()), TypeLocation, type);
}
else if ((object)SetMethod != null)
{
diagnostics.Add(ErrorFacts.GetStaticClassParameterCode(ContainingType.IsInterfaceType()), TypeLocation, type);
}
}
}
protected abstract (TypeWithAnnotations Type, ImmutableArray<ParameterSymbol> Parameters) MakeParametersAndBindType(BindingDiagnosticBag diagnostics);
protected static ExplicitInterfaceSpecifierSyntax? GetExplicitInterfaceSpecifier(SyntaxNode syntax)
{
return (syntax as BasePropertyDeclarationSyntax)?.ExplicitInterfaceSpecifier;
}
internal ExplicitInterfaceSpecifierSyntax? GetExplicitInterfaceSpecifier()
{
return GetExplicitInterfaceSpecifier((SyntaxNode)(object)CSharpSyntaxNode);
}
}