583 lines
27 KiB
C#
583 lines
27 KiB
C#
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Microsoft.CodeAnalysis.CSharp.Emit;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal class SourcePropertyAccessorSymbol : SourceMemberMethodSymbol
|
|
{
|
|
private readonly SourcePropertySymbolBase _property;
|
|
|
|
private ImmutableArray<ParameterSymbol> _lazyParameters;
|
|
|
|
private TypeWithAnnotations _lazyReturnType;
|
|
|
|
private ImmutableArray<CustomModifier> _lazyRefCustomModifiers;
|
|
|
|
private ImmutableArray<MethodSymbol> _lazyExplicitInterfaceImplementations;
|
|
|
|
private string _lazyName;
|
|
|
|
private readonly bool _isAutoPropertyAccessor;
|
|
|
|
private readonly bool _usesInit;
|
|
|
|
internal sealed override ImmutableArray<string> NotNullMembers => ImmutableArrayExtensions.Concat<string>(_property.NotNullMembers, base.NotNullMembers);
|
|
|
|
internal sealed override ImmutableArray<string> NotNullWhenTrueMembers => ImmutableArrayExtensions.Concat<string>(_property.NotNullWhenTrueMembers, base.NotNullWhenTrueMembers);
|
|
|
|
internal sealed override ImmutableArray<string> NotNullWhenFalseMembers => ImmutableArrayExtensions.Concat<string>(_property.NotNullWhenFalseMembers, base.NotNullWhenFalseMembers);
|
|
|
|
public sealed override Accessibility DeclaredAccessibility
|
|
{
|
|
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_0012: 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)
|
|
Accessibility localAccessibility = LocalAccessibility;
|
|
if ((int)localAccessibility != 0)
|
|
{
|
|
return localAccessibility;
|
|
}
|
|
return _property.DeclaredAccessibility;
|
|
}
|
|
}
|
|
|
|
public sealed override Symbol AssociatedSymbol => _property;
|
|
|
|
public sealed override bool ReturnsVoid => base.ReturnType.IsVoidType();
|
|
|
|
public sealed override ImmutableArray<ParameterSymbol> Parameters
|
|
{
|
|
get
|
|
{
|
|
LazyMethodChecks();
|
|
return _lazyParameters;
|
|
}
|
|
}
|
|
|
|
public sealed override ImmutableArray<TypeParameterSymbol> TypeParameters => ImmutableArray<TypeParameterSymbol>.Empty;
|
|
|
|
public sealed override TypeWithAnnotations ReturnTypeWithAnnotations
|
|
{
|
|
get
|
|
{
|
|
LazyMethodChecks();
|
|
return _lazyReturnType;
|
|
}
|
|
}
|
|
|
|
public sealed override FlowAnalysisAnnotations ReturnTypeFlowAnalysisAnnotations
|
|
{
|
|
get
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0008: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 12)
|
|
{
|
|
return FlowAnalysisAnnotations.None;
|
|
}
|
|
FlowAnalysisAnnotations flowAnalysisAnnotations = FlowAnalysisAnnotations.None;
|
|
if (_property.HasMaybeNull)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.MaybeNull;
|
|
}
|
|
if (_property.HasNotNull)
|
|
{
|
|
flowAnalysisAnnotations |= FlowAnalysisAnnotations.NotNull;
|
|
}
|
|
return flowAnalysisAnnotations;
|
|
}
|
|
}
|
|
|
|
public sealed override ImmutableHashSet<string> ReturnNotNullIfParameterNotNull => ImmutableHashSet<string>.Empty;
|
|
|
|
public sealed override ImmutableArray<CustomModifier> RefCustomModifiers
|
|
{
|
|
get
|
|
{
|
|
LazyMethodChecks();
|
|
return _lazyRefCustomModifiers;
|
|
}
|
|
}
|
|
|
|
internal Accessibility LocalAccessibility => ModifierUtils.EffectiveAccessibility(DeclarationModifiers);
|
|
|
|
internal bool LocalDeclaredReadOnly => (DeclarationModifiers & DeclarationModifiers.ReadOnly) != 0;
|
|
|
|
internal sealed override bool IsDeclaredReadOnly
|
|
{
|
|
get
|
|
{
|
|
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Invalid comparison between Unknown and I4
|
|
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b4: Invalid comparison between Unknown and I4
|
|
if (LocalDeclaredReadOnly || (_property.HasReadOnlyModifier && base.IsValidReadOnlyTarget))
|
|
{
|
|
return true;
|
|
}
|
|
if (!((CSharpParseOptions)(object)base.SyntaxTree.Options).IsFeatureEnabled(MessageID.IDS_FeatureReadOnlyMembers))
|
|
{
|
|
return false;
|
|
}
|
|
if (!(DeclaringCompilation.GetWellKnownTypeMember((WellKnownMember)394) != null) && ((int)((CompilationOptions)DeclaringCompilation.Options).OutputKind == 3 || !(DeclaringCompilation.GetWellKnownType((WellKnownType)270) is MissingMetadataTypeSymbol)))
|
|
{
|
|
return false;
|
|
}
|
|
if (ContainingType.IsStructType() && !_property.IsStatic && _isAutoPropertyAccessor)
|
|
{
|
|
return (int)MethodKind == 11;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool IsInitOnly
|
|
{
|
|
get
|
|
{
|
|
if (!IsStatic)
|
|
{
|
|
return _usesInit;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool IsExplicitInterfaceImplementation => _property.IsExplicitInterfaceImplementation;
|
|
|
|
public sealed override ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations
|
|
{
|
|
get
|
|
{
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003c: Invalid comparison between Unknown and I4
|
|
if (_lazyExplicitInterfaceImplementations.IsDefault)
|
|
{
|
|
PropertySymbol propertySymbol = (IsExplicitInterfaceImplementation ? _property.ExplicitInterfaceImplementations.FirstOrDefault() : null);
|
|
ImmutableArray<MethodSymbol> value;
|
|
if ((object)propertySymbol == null)
|
|
{
|
|
value = ImmutableArray<MethodSymbol>.Empty;
|
|
}
|
|
else
|
|
{
|
|
MethodSymbol methodSymbol = (((int)MethodKind == 11) ? propertySymbol.GetMethod : propertySymbol.SetMethod);
|
|
value = (((object)methodSymbol == null) ? ImmutableArray<MethodSymbol>.Empty : ImmutableArray.Create(methodSymbol));
|
|
}
|
|
ImmutableInterlocked.InterlockedInitialize(ref _lazyExplicitInterfaceImplementations, value);
|
|
}
|
|
return _lazyExplicitInterfaceImplementations;
|
|
}
|
|
}
|
|
|
|
public sealed override string Name
|
|
{
|
|
get
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Invalid comparison between Unknown and I4
|
|
if (_lazyName == null)
|
|
{
|
|
bool flag = (int)MethodKind == 11;
|
|
string text = null;
|
|
if (IsExplicitInterfaceImplementation)
|
|
{
|
|
PropertySymbol propertySymbol = _property.ExplicitInterfaceImplementations.FirstOrDefault();
|
|
if ((object)propertySymbol != null)
|
|
{
|
|
MethodSymbol methodSymbol = (flag ? propertySymbol.GetMethod : propertySymbol.SetMethod);
|
|
text = ExplicitInterfaceHelpers.GetMemberName(((object)methodSymbol != null) ? methodSymbol.Name : GetAccessorName(propertySymbol.MetadataName, flag, _property.IsCompilationOutputWinMdObj()), aliasQualifierOpt: _property.GetExplicitInterfaceSpecifier()?.Name.GetAliasQualifierOpt(), explicitInterfaceTypeOpt: propertySymbol.ContainingType);
|
|
}
|
|
}
|
|
else if (IsOverride)
|
|
{
|
|
MethodSymbol overriddenMethod = base.OverriddenMethod;
|
|
if ((object)overriddenMethod != null)
|
|
{
|
|
text = overriddenMethod.Name;
|
|
}
|
|
}
|
|
if (text == null)
|
|
{
|
|
text = GetAccessorName(_property.SourceName, flag, _property.IsCompilationOutputWinMdObj());
|
|
}
|
|
InterlockedOperations.Initialize<string>(ref _lazyName, text);
|
|
}
|
|
return _lazyName;
|
|
}
|
|
}
|
|
|
|
public sealed override bool IsImplicitlyDeclared
|
|
{
|
|
get
|
|
{
|
|
SyntaxKind syntaxKind = GetSyntax().Kind();
|
|
if (syntaxKind - 8896 <= SyntaxKind.List || syntaxKind == SyntaxKind.ArrowExpressionClause || syntaxKind == SyntaxKind.InitAccessorDeclaration)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal sealed override bool GenerateDebugInfo => true;
|
|
|
|
public sealed override bool AreLocalsZeroed
|
|
{
|
|
get
|
|
{
|
|
if (!_property.HasSkipLocalsInitAttribute)
|
|
{
|
|
return base.AreLocalsZeroed;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(NamedTypeSymbol containingType, SourcePropertySymbol property, DeclarationModifiers propertyModifiers, AccessorDeclarationSyntax syntax, bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
|
MethodKind methodKind = (MethodKind)((syntax.Kind() == SyntaxKind.GetAccessorDeclaration) ? 11 : 12);
|
|
bool hasBlockBody = syntax.Body != null;
|
|
bool hasExpressionBody = syntax.ExpressionBody != null;
|
|
bool isNullableAnalysisEnabled = containingType.DeclaringCompilation.IsNullableAnalysisEnabledIn((SyntaxNode)(object)syntax);
|
|
Symbol.CheckForBlockAndExpressionBody(syntax.Body, syntax.ExpressionBody, syntax, diagnostics);
|
|
SyntaxToken keyword = syntax.Keyword;
|
|
return new SourcePropertyAccessorSymbol(containingType, property, propertyModifiers, ((SyntaxToken)(ref keyword)).GetLocation(), syntax, hasBlockBody, hasExpressionBody, SyntaxFacts.HasYieldOperations((SyntaxNode?)(object)syntax.Body), syntax.Modifiers, methodKind, syntax.Keyword.IsKind(SyntaxKind.InitKeyword), isAutoPropertyAccessor, isNullableAnalysisEnabled, diagnostics);
|
|
}
|
|
|
|
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(NamedTypeSymbol containingType, SourcePropertySymbol property, DeclarationModifiers propertyModifiers, ArrowExpressionClauseSyntax syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
bool isNullableAnalysisEnabled = containingType.DeclaringCompilation.IsNullableAnalysisEnabledIn((SyntaxNode)(object)syntax);
|
|
return new SourcePropertyAccessorSymbol(containingType, property, propertyModifiers, syntax.Expression.GetLocation(), syntax, isNullableAnalysisEnabled, diagnostics);
|
|
}
|
|
|
|
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(bool isGetMethod, bool usesInit, NamedTypeSymbol containingType, SynthesizedRecordPropertySymbol property, DeclarationModifiers propertyModifiers, Location location, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0009: 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_001d: 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)
|
|
MethodKind methodKind = (MethodKind)(isGetMethod ? 11 : 12);
|
|
return new SourcePropertyAccessorSymbol(containingType, property, propertyModifiers, location, syntax, hasBlockBody: false, hasExpressionBody: false, isIterator: false, default(SyntaxTokenList), methodKind, usesInit, isAutoPropertyAccessor: true, isNullableAnalysisEnabled: false, diagnostics);
|
|
}
|
|
|
|
public static SourcePropertyAccessorSymbol CreateAccessorSymbol(NamedTypeSymbol containingType, SynthesizedRecordEqualityContractProperty property, DeclarationModifiers propertyModifiers, Location location, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
return new SynthesizedRecordEqualityContractProperty.GetAccessorSymbol(containingType, property, propertyModifiers, location, syntax, diagnostics);
|
|
}
|
|
|
|
private SourcePropertyAccessorSymbol(NamedTypeSymbol containingType, SourcePropertySymbol property, DeclarationModifiers propertyModifiers, Location location, ArrowExpressionClauseSyntax syntax, bool isNullableAnalysisEnabled, BindingDiagnosticBag diagnostics)
|
|
: base(containingType, syntax.GetReference(), location, isIterator: false, MakeModifiersAndFlags(property, propertyModifiers, isNullableAnalysisEnabled))
|
|
{
|
|
_property = property;
|
|
_isAutoPropertyAccessor = false;
|
|
CheckFeatureAvailabilityAndRuntimeSupport((SyntaxNode)(object)syntax, location, hasBody: true, diagnostics);
|
|
CheckModifiersForBody(location, diagnostics);
|
|
ModifierUtils.CheckAccessibility(DeclarationModifiers, this, property.IsExplicitInterfaceImplementation, diagnostics, location);
|
|
CheckModifiers(location, hasBody: true, isAutoPropertyOrExpressionBodied: true, diagnostics);
|
|
}
|
|
|
|
private static (DeclarationModifiers, Flags) MakeModifiersAndFlags(SourcePropertySymbol property, DeclarationModifiers propertyModifiers, bool isNullableAnalysisEnabled)
|
|
{
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
DeclarationModifiers accessorModifiers = GetAccessorModifiers(propertyModifiers);
|
|
Flags item = SourceMemberMethodSymbol.MakeFlags((MethodKind)11, property.RefKind, accessorModifiers, returnsVoid: false, returnsVoidIsSet: false, isExpressionBodied: true, isExtensionMethod: false, isNullableAnalysisEnabled, isVarArg: false, property.IsExplicitInterfaceImplementation);
|
|
return (accessorModifiers, item);
|
|
}
|
|
|
|
protected SourcePropertyAccessorSymbol(NamedTypeSymbol containingType, SourcePropertySymbolBase property, DeclarationModifiers propertyModifiers, Location location, CSharpSyntaxNode syntax, bool hasBlockBody, bool hasExpressionBody, bool isIterator, SyntaxTokenList modifiers, MethodKind methodKind, bool usesInit, bool isAutoPropertyAccessor, bool isNullableAnalysisEnabled, BindingDiagnosticBag diagnostics)
|
|
: base(containingType, syntax.GetReference(), location, isIterator, MakeModifiersAndFlags(containingType, property, propertyModifiers, location, hasBlockBody, hasExpressionBody, modifiers, methodKind, isNullableAnalysisEnabled, diagnostics, out var modifierErrors))
|
|
{
|
|
//IL_0016: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
_property = property;
|
|
_isAutoPropertyAccessor = isAutoPropertyAccessor;
|
|
bool flag = hasBlockBody || hasExpressionBody;
|
|
_usesInit = usesInit;
|
|
if (_usesInit)
|
|
{
|
|
Binder.CheckFeatureAvailability((SyntaxNode)(object)syntax, MessageID.IDS_FeatureInitOnlySetters, diagnostics, location);
|
|
}
|
|
CheckFeatureAvailabilityAndRuntimeSupport((SyntaxNode)(object)syntax, location, flag || isAutoPropertyAccessor, diagnostics);
|
|
if (flag)
|
|
{
|
|
CheckModifiersForBody(location, diagnostics);
|
|
}
|
|
ModifierUtils.CheckAccessibility(DeclarationModifiers, this, property.IsExplicitInterfaceImplementation, diagnostics, location);
|
|
if (!modifierErrors)
|
|
{
|
|
CheckModifiers(location, flag, isAutoPropertyAccessor, diagnostics);
|
|
}
|
|
if (((SyntaxTokenList)(ref modifiers)).Count > 0)
|
|
{
|
|
MessageID.IDS_FeaturePropertyAccessorMods.CheckFeatureAvailability(diagnostics, ((SyntaxTokenList)(ref modifiers))[0]);
|
|
}
|
|
}
|
|
|
|
private static (DeclarationModifiers, Flags) MakeModifiersAndFlags(NamedTypeSymbol containingType, SourcePropertySymbolBase property, DeclarationModifiers propertyModifiers, Location location, bool hasBlockBody, bool hasExpressionBody, SyntaxTokenList modifiers, MethodKind methodKind, bool isNullableAnalysisEnabled, BindingDiagnosticBag diagnostics, out bool modifierErrors)
|
|
{
|
|
//IL_0017: 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_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
bool isExpressionBodied = !hasBlockBody && hasExpressionBody;
|
|
bool hasBody = hasBlockBody || hasExpressionBody;
|
|
bool isExplicitInterfaceImplementation = property.IsExplicitInterfaceImplementation;
|
|
DeclarationModifiers declarationModifiers = MakeModifiers(containingType, modifiers, isExplicitInterfaceImplementation, hasBody, location, diagnostics, out modifierErrors);
|
|
declarationModifiers = (DeclarationModifiers)((uint)declarationModifiers | ((uint)GetAccessorModifiers(propertyModifiers) & 0xFFFFFC0Fu));
|
|
if ((declarationModifiers & DeclarationModifiers.Private) != DeclarationModifiers.None)
|
|
{
|
|
declarationModifiers = (DeclarationModifiers)((uint)declarationModifiers & 0xFFFDFFFFu);
|
|
}
|
|
Flags item = SourceMemberMethodSymbol.MakeFlags(methodKind, property.RefKind, declarationModifiers, returnsVoid: false, returnsVoidIsSet: false, isExpressionBodied, isExtensionMethod: false, isNullableAnalysisEnabled, isVarArg: false, isExplicitInterfaceImplementation);
|
|
return (declarationModifiers, item);
|
|
}
|
|
|
|
private static DeclarationModifiers GetAccessorModifiers(DeclarationModifiers propertyModifiers)
|
|
{
|
|
return (DeclarationModifiers)((uint)propertyModifiers & 0xFFF7FBFFu);
|
|
}
|
|
|
|
internal override ExecutableCodeBinder TryGetBodyBinder(BinderFactory binderFactoryOpt = null, bool ignoreAccessibility = false)
|
|
{
|
|
return TryGetBodyBinderFromSyntax(binderFactoryOpt, ignoreAccessibility);
|
|
}
|
|
|
|
protected sealed override void MethodChecks(BindingDiagnosticBag diagnostics)
|
|
{
|
|
_lazyParameters = ComputeParameters();
|
|
_lazyReturnType = ComputeReturnType(diagnostics);
|
|
_lazyRefCustomModifiers = ImmutableArray<CustomModifier>.Empty;
|
|
ImmutableArray<MethodSymbol> explicitInterfaceImplementations = ExplicitInterfaceImplementations;
|
|
if (explicitInterfaceImplementations.Length > 0)
|
|
{
|
|
CustomModifierUtils.CopyMethodCustomModifiers(explicitInterfaceImplementations[0], this, out _lazyReturnType, out _lazyRefCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: false);
|
|
}
|
|
else if (IsOverride)
|
|
{
|
|
MethodSymbol overriddenMethod = base.OverriddenMethod;
|
|
if ((object)overriddenMethod != null)
|
|
{
|
|
CustomModifierUtils.CopyMethodCustomModifiers(overriddenMethod, this, out _lazyReturnType, out _lazyRefCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: true);
|
|
}
|
|
}
|
|
else if (!_lazyReturnType.IsVoidType())
|
|
{
|
|
PropertySymbol property = _property;
|
|
TypeWithAnnotations typeWithAnnotations = property.TypeWithAnnotations;
|
|
_lazyReturnType = _lazyReturnType.WithTypeAndModifiers(CustomModifierUtils.CopyTypeCustomModifiers(typeWithAnnotations.Type, _lazyReturnType.Type, ContainingAssembly), typeWithAnnotations.CustomModifiers);
|
|
_lazyRefCustomModifiers = property.RefCustomModifiers;
|
|
}
|
|
}
|
|
|
|
public sealed override ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
|
|
{
|
|
return ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
|
|
}
|
|
|
|
public sealed override ImmutableArray<TypeParameterConstraintKind> GetTypeParameterConstraintKinds()
|
|
{
|
|
return ImmutableArray<TypeParameterConstraintKind>.Empty;
|
|
}
|
|
|
|
private TypeWithAnnotations ComputeReturnType(BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0008: Invalid comparison between Unknown and I4
|
|
if ((int)MethodKind == 11)
|
|
{
|
|
return _property.TypeWithAnnotations;
|
|
}
|
|
TypeWithAnnotations result = TypeWithAnnotations.Create(GetBinder().GetSpecialType((SpecialType)6, diagnostics, (SyntaxNode)(object)GetSyntax()));
|
|
if (IsInitOnly)
|
|
{
|
|
ImmutableArray<CustomModifier> customModifiers = ImmutableArray.Create<CustomModifier>(CSharpCustomModifier.CreateRequired(Binder.GetWellKnownType(DeclaringCompilation, (WellKnownType)304, diagnostics, _location)));
|
|
result = result.WithModifiers(customModifiers);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private Binder GetBinder()
|
|
{
|
|
CSharpSyntaxNode syntax = GetSyntax();
|
|
return DeclaringCompilation.GetBinderFactory(syntax.SyntaxTree).GetBinder((SyntaxNode)(object)syntax);
|
|
}
|
|
|
|
private static DeclarationModifiers MakeModifiers(NamedTypeSymbol containingType, SyntaxTokenList modifiers, bool isExplicitInterfaceImplementation, bool hasBody, Location location, BindingDiagnosticBag diagnostics, out bool modifierErrors)
|
|
{
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
|
DeclarationModifiers declarationModifiers = ((!isExplicitInterfaceImplementation) ? DeclarationModifiers.AccessibilityMask : DeclarationModifiers.None);
|
|
if (containingType.IsStructType())
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.ReadOnly;
|
|
}
|
|
DeclarationModifiers defaultInterfaceImplementationModifiers = DeclarationModifiers.None;
|
|
bool isInterface = containingType.IsInterface;
|
|
if (isInterface && !isExplicitInterfaceImplementation)
|
|
{
|
|
defaultInterfaceImplementationModifiers = DeclarationModifiers.AccessibilityMask;
|
|
}
|
|
DeclarationModifiers declarationModifiers2 = ModifierUtils.MakeAndCheckNonTypeMemberModifiers(isOrdinaryMethod: false, isInterface, modifiers, DeclarationModifiers.None, declarationModifiers, location, diagnostics, out modifierErrors);
|
|
ModifierUtils.ReportDefaultInterfaceImplementationModifiers(hasBody, declarationModifiers2, defaultInterfaceImplementationModifiers, location, diagnostics);
|
|
return declarationModifiers2;
|
|
}
|
|
|
|
private void CheckModifiers(Location location, bool hasBody, bool isAutoPropertyOrExpressionBodied, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//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_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Invalid comparison between Unknown and I4
|
|
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Invalid comparison between Unknown and I4
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Invalid comparison between Unknown and I4
|
|
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ae: Invalid comparison between Unknown and I4
|
|
Accessibility localAccessibility = LocalAccessibility;
|
|
if (IsAbstract && !ContainingType.IsAbstract && ((int)ContainingType.TypeKind == 2 || (int)ContainingType.TypeKind == 12))
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_AbstractInConcreteClass, location, this, ContainingType);
|
|
}
|
|
else if (IsVirtual && ContainingType.IsSealed && (int)ContainingType.TypeKind != 10)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_NewVirtualInSealed, location, this, ContainingType);
|
|
}
|
|
else if (!hasBody && !IsExtern && !IsAbstract && !isAutoPropertyOrExpressionBodied)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, location, this);
|
|
}
|
|
else if (ContainingType.IsSealed && localAccessibility.HasProtected() && !IsOverride)
|
|
{
|
|
diagnostics.Add(AccessCheck.GetProtectedMemberInSealedTypeError(ContainingType), location, this);
|
|
}
|
|
else if (LocalDeclaredReadOnly && _property.HasReadOnlyModifier)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_InvalidPropertyReadOnlyMods, location, _property);
|
|
}
|
|
else if (LocalDeclaredReadOnly && IsStatic)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_StaticMemberCantBeReadOnly, location, this);
|
|
}
|
|
else if (LocalDeclaredReadOnly && IsInitOnly)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_InitCannotBeReadonly, location, _property);
|
|
}
|
|
else if (LocalDeclaredReadOnly && _isAutoPropertyAccessor && (int)MethodKind == 12)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_AutoSetterCantBeReadOnly, location, this);
|
|
}
|
|
else if (_usesInit && IsStatic)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadInitAccessor, location);
|
|
}
|
|
}
|
|
|
|
internal static string GetAccessorName(string propertyName, bool getNotSet, bool isWinMdOutput)
|
|
{
|
|
return (getNotSet ? "get_" : (isWinMdOutput ? "put_" : "set_")) + propertyName;
|
|
}
|
|
|
|
internal CSharpSyntaxNode GetSyntax()
|
|
{
|
|
return (CSharpSyntaxNode)(object)syntaxReferenceOpt.GetSyntax(default(CancellationToken));
|
|
}
|
|
|
|
internal sealed override OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations()
|
|
{
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002b: 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)
|
|
CSharpSyntaxNode syntax = GetSyntax();
|
|
SyntaxKind syntaxKind = syntax.Kind();
|
|
if (syntaxKind - 8896 <= SyntaxKind.List || syntaxKind == SyntaxKind.InitAccessorDeclaration)
|
|
{
|
|
return OneOrMany.Create<SyntaxList<AttributeListSyntax>>(((AccessorDeclarationSyntax)syntax).AttributeLists);
|
|
}
|
|
return base.GetAttributeDeclarations();
|
|
}
|
|
|
|
private ImmutableArray<ParameterSymbol> ComputeParameters()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0008: Invalid comparison between Unknown and I4
|
|
bool flag = (int)MethodKind == 11;
|
|
ImmutableArray<ParameterSymbol> parameters = _property.Parameters;
|
|
int num = parameters.Length + ((!flag) ? 1 : 0);
|
|
if (num == 0)
|
|
{
|
|
return ImmutableArray<ParameterSymbol>.Empty;
|
|
}
|
|
ArrayBuilder<ParameterSymbol> instance = ArrayBuilder<ParameterSymbol>.GetInstance(num);
|
|
ImmutableArray<ParameterSymbol>.Enumerator enumerator = parameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
SourceParameterSymbol originalParam = (SourceParameterSymbol)enumerator.Current;
|
|
instance.Add((ParameterSymbol)new SourcePropertyClonedParameterSymbolForAccessors(originalParam, this));
|
|
}
|
|
if (!flag)
|
|
{
|
|
instance.Add((ParameterSymbol)new SynthesizedAccessorValueParameterSymbol(this, _property.TypeWithAnnotations, instance.Count));
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
|
|
internal sealed override void AddSynthesizedReturnTypeAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
|
{
|
|
base.AddSynthesizedReturnTypeAttributes(moduleBuilder, ref attributes);
|
|
FlowAnalysisAnnotations returnTypeFlowAnalysisAnnotations = ReturnTypeFlowAnalysisAnnotations;
|
|
if ((returnTypeFlowAnalysisAnnotations & FlowAnalysisAnnotations.MaybeNull) != FlowAnalysisAnnotations.None)
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(_property.MaybeNullAttributeIfExists));
|
|
}
|
|
if ((returnTypeFlowAnalysisAnnotations & FlowAnalysisAnnotations.NotNull) != FlowAnalysisAnnotations.None)
|
|
{
|
|
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(_property.NotNullAttributeIfExists));
|
|
}
|
|
}
|
|
|
|
internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<SynthesizedAttributeData> attributes)
|
|
{
|
|
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
|
|
if (_isAutoPropertyAccessor)
|
|
{
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)112));
|
|
}
|
|
if (!NotNullMembers.IsEmpty)
|
|
{
|
|
ImmutableArray<SourceAttributeData>.Enumerator enumerator = _property.MemberNotNullAttributeIfExists.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
SourceAttributeData current = enumerator.Current;
|
|
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(current));
|
|
}
|
|
}
|
|
if (!NotNullWhenTrueMembers.IsEmpty || !NotNullWhenFalseMembers.IsEmpty)
|
|
{
|
|
ImmutableArray<SourceAttributeData>.Enumerator enumerator = _property.MemberNotNullWhenAttributeIfExists.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
SourceAttributeData current2 = enumerator.Current;
|
|
Symbol.AddSynthesizedAttribute(ref attributes, new SynthesizedAttributeData(current2));
|
|
}
|
|
}
|
|
}
|
|
}
|