441 lines
23 KiB
C#
441 lines
23 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal sealed class SourcePropertySymbol : SourcePropertySymbolBase
|
|
{
|
|
protected override Location TypeLocation => ((SyntaxNode)GetTypeSyntax((SyntaxNode)(object)base.CSharpSyntaxNode)).Location;
|
|
|
|
public override SyntaxList<AttributeListSyntax> AttributeDeclarationSyntaxList => ((BasePropertyDeclarationSyntax)base.CSharpSyntaxNode).AttributeLists;
|
|
|
|
public override IAttributeTargetSymbol AttributesOwner => this;
|
|
|
|
internal static SourcePropertySymbol Create(SourceMemberContainerTypeSymbol containingType, Binder bodyBinder, PropertyDeclarationSyntax syntax, 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)
|
|
SyntaxToken identifier = syntax.Identifier;
|
|
Location location = ((SyntaxToken)(ref identifier)).GetLocation();
|
|
return Create(containingType, bodyBinder, syntax, ((SyntaxToken)(ref identifier)).ValueText, location, diagnostics);
|
|
}
|
|
|
|
internal static SourcePropertySymbol Create(SourceMemberContainerTypeSymbol containingType, Binder bodyBinder, IndexerDeclarationSyntax syntax, 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)
|
|
SyntaxToken thisKeyword = syntax.ThisKeyword;
|
|
Location location = ((SyntaxToken)(ref thisKeyword)).GetLocation();
|
|
return Create(containingType, bodyBinder, syntax, "Item", location, diagnostics);
|
|
}
|
|
|
|
private static SourcePropertySymbol Create(SourceMemberContainerTypeSymbol containingType, Binder binder, BasePropertyDeclarationSyntax syntax, string name, Location location, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_001d: 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_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
GetAccessorDeclarations(syntax, diagnostics, out bool isAutoProperty, out bool hasAccessorList, out bool accessorsHaveImplementation, out bool isInitOnly, out CSharpSyntaxNode getSyntax, out CSharpSyntaxNode setSyntax);
|
|
ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = SourcePropertySymbolBase.GetExplicitInterfaceSpecifier((SyntaxNode)(object)syntax);
|
|
SyntaxTokenList modifierTokensSyntax = GetModifierTokensSyntax((SyntaxNode)(object)syntax);
|
|
bool isExplicitInterfaceImplementation = explicitInterfaceSpecifier != null;
|
|
bool modifierErrors;
|
|
DeclarationModifiers modifiers = MakeModifiers(containingType, modifierTokensSyntax, isExplicitInterfaceImplementation, syntax.Kind() == SyntaxKind.IndexerDeclaration, accessorsHaveImplementation, location, diagnostics, out modifierErrors);
|
|
bool flag = !hasAccessorList && GetArrowExpression((SyntaxNode)(object)syntax) != null;
|
|
binder = binder.WithUnsafeRegionIfNecessary(modifierTokensSyntax);
|
|
TypeSymbol explicitInterfaceTypeOpt;
|
|
string aliasQualifierOpt;
|
|
string memberNameAndInterfaceSymbol = ExplicitInterfaceHelpers.GetMemberNameAndInterfaceSymbol(binder, explicitInterfaceSpecifier, name, diagnostics, out explicitInterfaceTypeOpt, out aliasQualifierOpt);
|
|
return new SourcePropertySymbol(containingType, syntax, getSyntax != null || flag, setSyntax != null, isExplicitInterfaceImplementation, explicitInterfaceTypeOpt, aliasQualifierOpt, modifiers, isAutoProperty, flag, isInitOnly, memberNameAndInterfaceSymbol, location, diagnostics);
|
|
}
|
|
|
|
private SourcePropertySymbol(SourceMemberContainerTypeSymbol containingType, BasePropertyDeclarationSyntax syntax, bool hasGetAccessor, bool hasSetAccessor, bool isExplicitInterfaceImplementation, TypeSymbol? explicitInterfaceType, string? aliasQualifierOpt, DeclarationModifiers modifiers, bool isAutoProperty, bool isExpressionBodied, bool isInitOnly, string memberName, Location location, BindingDiagnosticBag diagnostics)
|
|
: base(containingType, syntax, hasGetAccessor, hasSetAccessor, isExplicitInterfaceImplementation, explicitInterfaceType, aliasQualifierOpt, modifiers, HasInitializer((SyntaxNode)(object)syntax), isAutoProperty, isExpressionBodied, isInitOnly, syntax.Type.SkipScoped(out var _).GetRefKindInLocalOrReturn(diagnostics), memberName, syntax.AttributeLists, location, diagnostics)
|
|
{
|
|
//IL_0029: 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_0095: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.IsAutoProperty)
|
|
{
|
|
Binder.CheckFeatureAvailability((SyntaxNode)(object)syntax, (hasGetAccessor && !hasSetAccessor) ? MessageID.IDS_FeatureReadonlyAutoImplementedProperties : MessageID.IDS_FeatureAutoImplementedProperties, diagnostics, location);
|
|
}
|
|
Symbol.CheckForBlockAndExpressionBody(syntax.AccessorList, syntax.GetExpressionBodySyntax(), syntax, diagnostics);
|
|
if (syntax is PropertyDeclarationSyntax propertyDeclarationSyntax)
|
|
{
|
|
EqualsValueClauseSyntax initializer = propertyDeclarationSyntax.Initializer;
|
|
if (initializer != null)
|
|
{
|
|
MessageID.IDS_FeatureAutoPropertyInitializer.CheckFeatureAvailability(diagnostics, initializer.EqualsToken);
|
|
}
|
|
}
|
|
}
|
|
|
|
private TypeSyntax GetTypeSyntax(SyntaxNode syntax)
|
|
{
|
|
return ((BasePropertyDeclarationSyntax)(object)syntax).Type;
|
|
}
|
|
|
|
private static SyntaxTokenList GetModifierTokensSyntax(SyntaxNode syntax)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return ((BasePropertyDeclarationSyntax)(object)syntax).Modifiers;
|
|
}
|
|
|
|
private static ArrowExpressionClauseSyntax? GetArrowExpression(SyntaxNode syntax)
|
|
{
|
|
if (!(syntax is PropertyDeclarationSyntax propertyDeclarationSyntax))
|
|
{
|
|
if (syntax is IndexerDeclarationSyntax indexerDeclarationSyntax)
|
|
{
|
|
return indexerDeclarationSyntax.ExpressionBody;
|
|
}
|
|
throw ExceptionUtilities.UnexpectedValue((object)syntax.Kind());
|
|
}
|
|
return propertyDeclarationSyntax.ExpressionBody;
|
|
}
|
|
|
|
private static bool HasInitializer(SyntaxNode syntax)
|
|
{
|
|
if (syntax is PropertyDeclarationSyntax propertyDeclarationSyntax)
|
|
{
|
|
return propertyDeclarationSyntax.Initializer != null;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static void GetAccessorDeclarations(CSharpSyntaxNode syntaxNode, BindingDiagnosticBag diagnostics, out bool isAutoProperty, out bool hasAccessorList, out bool accessorsHaveImplementation, out bool isInitOnly, out CSharpSyntaxNode? getSyntax, out CSharpSyntaxNode? setSyntax)
|
|
{
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: 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_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
|
BasePropertyDeclarationSyntax basePropertyDeclarationSyntax = (BasePropertyDeclarationSyntax)syntaxNode;
|
|
isAutoProperty = true;
|
|
hasAccessorList = basePropertyDeclarationSyntax.AccessorList != null;
|
|
getSyntax = null;
|
|
setSyntax = null;
|
|
isInitOnly = false;
|
|
if (hasAccessorList)
|
|
{
|
|
accessorsHaveImplementation = false;
|
|
Enumerator<AccessorDeclarationSyntax> enumerator = basePropertyDeclarationSyntax.AccessorList.Accessors.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
AccessorDeclarationSyntax current = enumerator.Current;
|
|
SyntaxToken keyword;
|
|
switch (current.Kind())
|
|
{
|
|
case SyntaxKind.GetAccessorDeclaration:
|
|
if (getSyntax == null)
|
|
{
|
|
getSyntax = current;
|
|
break;
|
|
}
|
|
keyword = current.Keyword;
|
|
diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, ((SyntaxToken)(ref keyword)).GetLocation());
|
|
break;
|
|
case SyntaxKind.SetAccessorDeclaration:
|
|
case SyntaxKind.InitAccessorDeclaration:
|
|
if (setSyntax == null)
|
|
{
|
|
setSyntax = current;
|
|
if (current.Keyword.IsKind(SyntaxKind.InitKeyword))
|
|
{
|
|
isInitOnly = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
keyword = current.Keyword;
|
|
diagnostics.Add(ErrorCode.ERR_DuplicateAccessor, ((SyntaxToken)(ref keyword)).GetLocation());
|
|
}
|
|
break;
|
|
case SyntaxKind.AddAccessorDeclaration:
|
|
case SyntaxKind.RemoveAccessorDeclaration:
|
|
keyword = current.Keyword;
|
|
diagnostics.Add(ErrorCode.ERR_GetOrSetExpected, ((SyntaxToken)(ref keyword)).GetLocation());
|
|
continue;
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)current.Kind());
|
|
case SyntaxKind.UnknownAccessorDeclaration:
|
|
continue;
|
|
}
|
|
if (current.Body != null || current.ExpressionBody != null)
|
|
{
|
|
isAutoProperty = false;
|
|
accessorsHaveImplementation = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
isAutoProperty = false;
|
|
accessorsHaveImplementation = GetArrowExpression((SyntaxNode)(object)basePropertyDeclarationSyntax) != null;
|
|
}
|
|
}
|
|
|
|
private static AccessorDeclarationSyntax GetGetAccessorDeclaration(BasePropertyDeclarationSyntax syntax)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: 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)
|
|
Enumerator<AccessorDeclarationSyntax> enumerator = syntax.AccessorList.Accessors.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
AccessorDeclarationSyntax current = enumerator.Current;
|
|
if (current.Kind() == SyntaxKind.GetAccessorDeclaration)
|
|
{
|
|
return current;
|
|
}
|
|
}
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs", 249);
|
|
}
|
|
|
|
private static AccessorDeclarationSyntax GetSetAccessorDeclaration(BasePropertyDeclarationSyntax syntax)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: 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)
|
|
Enumerator<AccessorDeclarationSyntax> enumerator = syntax.AccessorList.Accessors.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
AccessorDeclarationSyntax current = enumerator.Current;
|
|
SyntaxKind syntaxKind = current.Kind();
|
|
if (syntaxKind == SyntaxKind.SetAccessorDeclaration || syntaxKind == SyntaxKind.InitAccessorDeclaration)
|
|
{
|
|
return current;
|
|
}
|
|
}
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs", 264);
|
|
}
|
|
|
|
private static DeclarationModifiers MakeModifiers(NamedTypeSymbol containingType, SyntaxTokenList modifiers, bool isExplicitInterfaceImplementation, bool isIndexer, bool accessorsHaveImplementation, Location location, BindingDiagnosticBag diagnostics, out bool modifierErrors)
|
|
{
|
|
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
|
|
bool isInterface = containingType.IsInterface;
|
|
DeclarationModifiers defaultAccess = ((isInterface && !isExplicitInterfaceImplementation) ? DeclarationModifiers.Public : DeclarationModifiers.Private);
|
|
DeclarationModifiers declarationModifiers = DeclarationModifiers.Unsafe;
|
|
DeclarationModifiers declarationModifiers2 = DeclarationModifiers.None;
|
|
if (!isExplicitInterfaceImplementation)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.AccessibilityMask | DeclarationModifiers.Abstract | DeclarationModifiers.Sealed | DeclarationModifiers.New | DeclarationModifiers.Virtual;
|
|
if (!isIndexer)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.Static;
|
|
}
|
|
if (!isInterface)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.Override;
|
|
if (!isIndexer)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.Required;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
defaultAccess = DeclarationModifiers.None;
|
|
declarationModifiers2 = (DeclarationModifiers)((uint)declarationModifiers2 | (uint)(3 | ((!isIndexer) ? 4 : 0) | 0x20000 | 0x2000 | 0x3F0));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (isInterface)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.Abstract;
|
|
}
|
|
if (!isIndexer)
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.Static;
|
|
}
|
|
}
|
|
if (containingType.IsStructType())
|
|
{
|
|
declarationModifiers |= DeclarationModifiers.ReadOnly;
|
|
}
|
|
declarationModifiers |= DeclarationModifiers.Extern;
|
|
DeclarationModifiers declarationModifiers3 = ModifierUtils.MakeAndCheckNonTypeMemberModifiers(isOrdinaryMethod: false, isInterface, modifiers, defaultAccess, declarationModifiers, location, diagnostics, out modifierErrors);
|
|
ModifierUtils.CheckFeatureAvailabilityForStaticAbstractMembersInInterfacesIfNeeded(declarationModifiers3, isExplicitInterfaceImplementation, location, diagnostics);
|
|
containingType.CheckUnsafeModifier(declarationModifiers3, location, diagnostics);
|
|
ModifierUtils.ReportDefaultInterfaceImplementationModifiers(accessorsHaveImplementation, declarationModifiers3, declarationModifiers2, location, diagnostics);
|
|
if (isInterface)
|
|
{
|
|
declarationModifiers3 = ModifierUtils.AdjustModifiersForAnInterfaceMember(declarationModifiers3, accessorsHaveImplementation, isExplicitInterfaceImplementation);
|
|
}
|
|
if (isIndexer)
|
|
{
|
|
declarationModifiers3 |= DeclarationModifiers.Indexer;
|
|
}
|
|
if ((declarationModifiers3 & DeclarationModifiers.Static) != DeclarationModifiers.None && (declarationModifiers3 & DeclarationModifiers.Required) != DeclarationModifiers.None)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.RequiredKeyword));
|
|
declarationModifiers3 = (DeclarationModifiers)((uint)declarationModifiers3 & 0xFFBFFFFFu);
|
|
}
|
|
return declarationModifiers3;
|
|
}
|
|
|
|
protected override SourcePropertyAccessorSymbol CreateGetAccessorSymbol(bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics)
|
|
{
|
|
BasePropertyDeclarationSyntax basePropertyDeclarationSyntax = (BasePropertyDeclarationSyntax)base.CSharpSyntaxNode;
|
|
ArrowExpressionClauseSyntax arrowExpression = GetArrowExpression((SyntaxNode)(object)basePropertyDeclarationSyntax);
|
|
if (basePropertyDeclarationSyntax.AccessorList == null && arrowExpression != null)
|
|
{
|
|
return CreateExpressionBodiedAccessor(arrowExpression, diagnostics);
|
|
}
|
|
return CreateAccessorSymbol(GetGetAccessorDeclaration(basePropertyDeclarationSyntax), isAutoPropertyAccessor, diagnostics);
|
|
}
|
|
|
|
protected override SourcePropertyAccessorSymbol CreateSetAccessorSymbol(bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics)
|
|
{
|
|
BasePropertyDeclarationSyntax syntax = (BasePropertyDeclarationSyntax)base.CSharpSyntaxNode;
|
|
return CreateAccessorSymbol(GetSetAccessorDeclaration(syntax), isAutoPropertyAccessor, diagnostics);
|
|
}
|
|
|
|
private SourcePropertyAccessorSymbol CreateAccessorSymbol(AccessorDeclarationSyntax syntax, bool isAutoPropertyAccessor, BindingDiagnosticBag diagnostics)
|
|
{
|
|
return SourcePropertyAccessorSymbol.CreateAccessorSymbol(ContainingType, this, _modifiers, syntax, isAutoPropertyAccessor, diagnostics);
|
|
}
|
|
|
|
private SourcePropertyAccessorSymbol CreateExpressionBodiedAccessor(ArrowExpressionClauseSyntax syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
return SourcePropertyAccessorSymbol.CreateAccessorSymbol(ContainingType, this, _modifiers, syntax, diagnostics);
|
|
}
|
|
|
|
private Binder CreateBinderForTypeAndParameters()
|
|
{
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpCompilation declaringCompilation = DeclaringCompilation;
|
|
SyntaxTree syntaxTree = base.SyntaxTree;
|
|
CSharpSyntaxNode cSharpSyntaxNode = base.CSharpSyntaxNode;
|
|
Binder binder = declaringCompilation.GetBinderFactory(syntaxTree).GetBinder((SyntaxNode)(object)cSharpSyntaxNode, cSharpSyntaxNode, this);
|
|
SyntaxTokenList modifierTokensSyntax = GetModifierTokensSyntax((SyntaxNode)(object)cSharpSyntaxNode);
|
|
return binder.WithUnsafeRegionIfNecessary(modifierTokensSyntax).WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.SuppressConstraintChecks, this);
|
|
}
|
|
|
|
protected override (TypeWithAnnotations Type, ImmutableArray<ParameterSymbol> Parameters) MakeParametersAndBindType(BindingDiagnosticBag diagnostics)
|
|
{
|
|
Binder binder = CreateBinderForTypeAndParameters();
|
|
CSharpSyntaxNode cSharpSyntaxNode = base.CSharpSyntaxNode;
|
|
return (Type: ComputeType(binder, (SyntaxNode)(object)cSharpSyntaxNode, diagnostics), Parameters: ComputeParameters(binder, cSharpSyntaxNode, diagnostics));
|
|
}
|
|
|
|
private TypeWithAnnotations ComputeType(Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_0023: 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)
|
|
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
TypeSyntax typeSyntax = GetTypeSyntax(syntax);
|
|
typeSyntax = typeSyntax.SkipScoped(out var _).SkipRef();
|
|
TypeWithAnnotations typeWithAnnotations = binder.BindType(typeSyntax, diagnostics);
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);
|
|
if (GetExplicitInterfaceSpecifier() == null && !this.IsNoMoreVisibleThan(typeWithAnnotations, ref useSiteInfo))
|
|
{
|
|
diagnostics.Add(IsIndexer ? ErrorCode.ERR_BadVisIndexerReturn : ErrorCode.ERR_BadVisPropertyType, base.Location, this, typeWithAnnotations.Type);
|
|
}
|
|
if (typeWithAnnotations.Type.HasFileLocalTypes() && !ContainingType.HasFileLocalTypes())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, base.Location, typeWithAnnotations.Type, ContainingType);
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(base.Location, useSiteInfo);
|
|
if (typeWithAnnotations.IsVoidType())
|
|
{
|
|
if (IsIndexer)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_IndexerCantHaveVoidType, base.Location);
|
|
}
|
|
else
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_PropertyCantHaveVoidType, base.Location, this);
|
|
}
|
|
}
|
|
return typeWithAnnotations;
|
|
}
|
|
|
|
private static ImmutableArray<ParameterSymbol> MakeParameters(Binder binder, SourcePropertySymbolBase owner, BaseParameterListSyntax? parameterSyntaxOpt, BindingDiagnosticBag diagnostics, bool addRefReadOnlyModifier)
|
|
{
|
|
//IL_000a: 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)
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: 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)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
|
|
if (parameterSyntaxOpt == null)
|
|
{
|
|
return ImmutableArray<ParameterSymbol>.Empty;
|
|
}
|
|
if (parameterSyntaxOpt.Parameters.Count < 1)
|
|
{
|
|
SyntaxToken lastToken = parameterSyntaxOpt.GetLastToken();
|
|
diagnostics.Add(ErrorCode.ERR_IndexerNeedsParam, ((SyntaxToken)(ref lastToken)).GetLocation());
|
|
}
|
|
bool addRefReadOnlyModifier2 = addRefReadOnlyModifier;
|
|
SyntaxToken arglistToken;
|
|
ImmutableArray<ParameterSymbol> result = ImmutableArrayExtensions.Cast<SourceParameterSymbol, ParameterSymbol>(ParameterHelpers.MakeParameters(binder, owner, parameterSyntaxOpt, out arglistToken, diagnostics, allowRefOrOut: false, allowThis: false, addRefReadOnlyModifier2));
|
|
if (arglistToken.Kind() != SyntaxKind.None)
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, ((SyntaxToken)(ref arglistToken)).GetLocation());
|
|
}
|
|
if (result.Length == 1 && !owner.IsExplicitInterfaceImplementation)
|
|
{
|
|
ParameterSyntax parameterSyntax = parameterSyntaxOpt.Parameters[0];
|
|
if (parameterSyntax.Default != null)
|
|
{
|
|
SyntaxToken identifier = parameterSyntax.Identifier;
|
|
diagnostics.Add(ErrorCode.WRN_DefaultValueForUnconsumedLocation, ((SyntaxToken)(ref identifier)).GetLocation(), ((SyntaxToken)(ref identifier)).ValueText);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private ImmutableArray<ParameterSymbol> ComputeParameters(Binder binder, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
|
|
{
|
|
BaseParameterListSyntax parameterListSyntax = GetParameterListSyntax(syntax);
|
|
return MakeParameters(binder, this, parameterListSyntax, diagnostics, IsVirtual || IsAbstract);
|
|
}
|
|
|
|
internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions, BindingDiagnosticBag diagnostics)
|
|
{
|
|
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
|
|
base.AfterAddingTypeMembersChecks(conversions, diagnostics);
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = default(CompoundUseSiteInfo<AssemblySymbol>);
|
|
useSiteInfo._002Ector((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics, ContainingAssembly);
|
|
ImmutableArray<ParameterSymbol>.Enumerator enumerator = Parameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
ParameterSymbol current = enumerator.Current;
|
|
if (!IsExplicitInterfaceImplementation && !this.IsNoMoreVisibleThan(current.Type, ref useSiteInfo))
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_BadVisIndexerParam, base.Location, this, current.Type);
|
|
}
|
|
else if (current.Type.HasFileLocalTypes() && !ContainingType.HasFileLocalTypes())
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_FileTypeDisallowedInSignature, base.Location, current.Type, ContainingType);
|
|
}
|
|
else if ((object)SetMethod != null && current.Name == "value")
|
|
{
|
|
diagnostics.Add(ErrorCode.ERR_DuplicateGeneratedName, current.TryGetFirstLocation() ?? base.Location, current.Name);
|
|
}
|
|
}
|
|
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).Add(base.Location, useSiteInfo);
|
|
}
|
|
|
|
private static BaseParameterListSyntax? GetParameterListSyntax(CSharpSyntaxNode syntax)
|
|
{
|
|
return (syntax as IndexerDeclarationSyntax)?.ParameterList;
|
|
}
|
|
}
|