private static void GetNameAndExplicitInterfaceImplementations( PropertySymbol explicitlyImplementedPropertyOpt, string propertyName, bool isWinMd, string aliasQualifierOpt, bool isGetMethod, out string name, out ImmutableArray <MethodSymbol> explicitInterfaceImplementations) { if ((object)explicitlyImplementedPropertyOpt == null) { name = GetAccessorName(propertyName, isGetMethod, isWinMd); explicitInterfaceImplementations = ImmutableArray <MethodSymbol> .Empty; } else { MethodSymbol implementedAccessor = isGetMethod ? explicitlyImplementedPropertyOpt.GetMethod : explicitlyImplementedPropertyOpt.SetMethod; string accessorName = (object)implementedAccessor != null ? implementedAccessor.Name : GetAccessorName(explicitlyImplementedPropertyOpt.MetadataName, isGetMethod, isWinMd); //Not name - could be indexer placeholder name = ExplicitInterfaceHelpers.GetMemberName(accessorName, explicitlyImplementedPropertyOpt.ContainingType, aliasQualifierOpt); explicitInterfaceImplementations = (object)implementedAccessor == null ? ImmutableArray <MethodSymbol> .Empty : ImmutableArray.Create <MethodSymbol>(implementedAccessor); } }
public SynthesizedImplementationMethod( MethodSymbol interfaceMethod, NamedTypeSymbol implementingType, string name = null, bool generateDebugInfo = true, PropertySymbol associatedProperty = null ) { //it does not make sense to add methods to substituted types Debug.Assert(implementingType.IsDefinition); _name = name ?? ExplicitInterfaceHelpers.GetMemberName( interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null ); _implementingType = implementingType; _generateDebugInfo = generateDebugInfo; _associatedProperty = associatedProperty; _explicitInterfaceImplementations = ImmutableArray.Create <MethodSymbol>( interfaceMethod ); // alpha-rename to get the implementation's type parameters var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty; typeMap.WithAlphaRename(interfaceMethod, this, out _typeParameters); _interfaceMethod = interfaceMethod.ConstructIfGeneric(TypeArgumentsWithAnnotations); _parameters = SynthesizedParameterSymbol.DeriveParameters(_interfaceMethod, this); }
public SynthesizedImplementationMethod( MethodSymbol interfaceMethod, NamedTypeSymbol implementingType, string name = null, bool debuggerHidden = false, bool generateDebugInfo = true, PropertySymbol associatedProperty = null, MethodSymbol asyncKickoffMethod = null) { //it does not make sense to add methods to substituted types Debug.Assert(implementingType.IsDefinition); this.name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null); this.interfaceMethod = interfaceMethod; this.implementingType = implementingType; this.debuggerHidden = debuggerHidden; this.generateDebugInfo = generateDebugInfo; this.associatedProperty = associatedProperty; this.explicitInterfaceImplementations = ImmutableArray.Create <MethodSymbol>(interfaceMethod); this.asyncKickoffMethod = asyncKickoffMethod; // alpha-rename to get the implementation's type parameters var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty; typeMap.WithAlphaRename(interfaceMethod, this, out this.typeParameters); var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(this.typeParameters.Cast <TypeParameterSymbol, TypeSymbol>()); this.returnType = substitutedInterfaceMethod.ReturnType; this.parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this); }
public SourceEventAccessorSymbol( SourceEventSymbol @event, SyntaxReference syntaxReference, ImmutableArray <Location> locations, EventSymbol explicitlyImplementedEventOpt, string aliasQualifierOpt, bool isAdder, bool isIterator, bool isNullableAnalysisEnabled ) : base(@event.containingType, syntaxReference, locations, isIterator) { _event = @event; string name; ImmutableArray <MethodSymbol> explicitInterfaceImplementations; if ((object)explicitlyImplementedEventOpt == null) { name = SourceEventSymbol.GetAccessorName(@event.Name, isAdder); explicitInterfaceImplementations = ImmutableArray <MethodSymbol> .Empty; } else { MethodSymbol implementedAccessor = isAdder ? explicitlyImplementedEventOpt.AddMethod : explicitlyImplementedEventOpt.RemoveMethod; string accessorName = (object)implementedAccessor != null ? implementedAccessor.Name : SourceEventSymbol.GetAccessorName( explicitlyImplementedEventOpt.Name, isAdder ); name = ExplicitInterfaceHelpers.GetMemberName( accessorName, explicitlyImplementedEventOpt.ContainingType, aliasQualifierOpt ); explicitInterfaceImplementations = (object)implementedAccessor == null ? ImmutableArray <MethodSymbol> .Empty : ImmutableArray.Create <MethodSymbol>(implementedAccessor); } _explicitInterfaceImplementations = explicitInterfaceImplementations; this.MakeFlags( isAdder ? MethodKind.EventAdd : MethodKind.EventRemove, @event.Modifiers, returnsVoid: false, // until we learn otherwise (in LazyMethodChecks). isExtensionMethod: false, isNullableAnalysisEnabled: isNullableAnalysisEnabled, isMetadataVirtualIgnoringModifiers: @event.IsExplicitInterfaceImplementation ); _name = GetOverriddenAccessorName(@event, isAdder) ?? name; }
internal SynthesizedStateMachineProperty( MethodSymbol interfacePropertyGetter, StateMachineTypeSymbol stateMachineType) { _name = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.AssociatedSymbol.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); var getterName = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); _getter = new SynthesizedStateMachineDebuggerHiddenMethod( getterName, interfacePropertyGetter, stateMachineType, associatedProperty: this, hasMethodBodyDependency: false); }
public static SourcePropertyAccessorSymbol CreateAccessorSymbol( NamedTypeSymbol containingType, SourcePropertySymbol property, DeclarationModifiers propertyModifiers, string propertyName, AccessorDeclarationSyntax syntax, PropertySymbol explicitlyImplementedPropertyOpt, string aliasQualifierOpt, bool isAutoPropertyAccessor, DiagnosticBag diagnostics) { Debug.Assert(syntax.Kind == SyntaxKind.GetAccessorDeclaration || syntax.Kind == SyntaxKind.SetAccessorDeclaration); bool isGetMethod = (syntax.Kind == SyntaxKind.GetAccessorDeclaration); bool isWinMd = property.IsCompilationOutputWinMdObj(); string name; ImmutableArray <MethodSymbol> explicitInterfaceImplementations; if ((object)explicitlyImplementedPropertyOpt == null) { name = GetAccessorName(propertyName, isGetMethod, isWinMd); explicitInterfaceImplementations = ImmutableArray <MethodSymbol> .Empty; } else { MethodSymbol implementedAccessor = isGetMethod ? explicitlyImplementedPropertyOpt.GetMethod : explicitlyImplementedPropertyOpt.SetMethod; string accessorName = (object)implementedAccessor != null ? implementedAccessor.Name : GetAccessorName(explicitlyImplementedPropertyOpt.MetadataName, isGetMethod, isWinMd); //Not name - could be indexer placeholder name = ExplicitInterfaceHelpers.GetMemberName(accessorName, explicitlyImplementedPropertyOpt.ContainingType, aliasQualifierOpt); explicitInterfaceImplementations = (object)implementedAccessor == null ? ImmutableArray <MethodSymbol> .Empty : ImmutableArray.Create <MethodSymbol>(implementedAccessor); } var methodKind = isGetMethod ? MethodKind.PropertyGet : MethodKind.PropertySet; return(new SourcePropertyAccessorSymbol( containingType, name, property, propertyModifiers, explicitInterfaceImplementations, syntax.Keyword.GetLocation(), syntax, methodKind, isAutoPropertyAccessor, diagnostics)); }
internal SynthesizedImplementationReadOnlyProperty( MethodSymbol interfaceMethod, NamedTypeSymbol implementingType, bool debuggerHidden = false) { this.propName = ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.AssociatedSymbol.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null); var getterName = ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null); getter = new SynthesizedImplementationMethod(interfaceMethod, implementingType, getterName, debuggerHidden, associatedProperty: this); }
internal SynthesizedStateMachineProperty( MethodSymbol interfacePropertyGetter, NamedTypeSymbol implementingType, bool debuggerHidden, bool hasMethodBodyDependency) { this.name = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.AssociatedSymbol.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); var getterName = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); getter = new SynthesizedStateMachineMethod( getterName, interfacePropertyGetter, implementingType, asyncKickoffMethod: null, associatedProperty: this, debuggerHidden: debuggerHidden, hasMethodBodyDependency: hasMethodBodyDependency); }
internal SynthesizedStateMachineProperty( MethodSymbol interfacePropertyGetter, StateMachineTypeSymbol stateMachineType, bool debuggerHidden, bool hasMethodBodyDependency) { this.name = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.AssociatedSymbol.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); var getterName = ExplicitInterfaceHelpers.GetMemberName(interfacePropertyGetter.Name, interfacePropertyGetter.ContainingType, aliasQualifierOpt: null); this.getter = new SynthesizedStateMachineMethod( getterName, interfacePropertyGetter, stateMachineType, associatedProperty: this, debuggerHidden: debuggerHidden, generateDebugInfo: !debuggerHidden, hasMethodBodyDependency: hasMethodBodyDependency); }
internal SourceCustomEventAccessorSymbol( SourceEventSymbol @event, AccessorDeclarationSyntax syntax, EventSymbol explicitlyImplementedEventOpt, string aliasQualifierOpt, DiagnosticBag diagnostics) : base(@event, syntax.GetReference(), syntax.Body.GetReferenceOrNull(), ImmutableArray.Create(syntax.Keyword.GetLocation())) { Debug.Assert(syntax != null); Debug.Assert(syntax.Kind == SyntaxKind.AddAccessorDeclaration || syntax.Kind == SyntaxKind.RemoveAccessorDeclaration); bool isAdder = syntax.Kind == SyntaxKind.AddAccessorDeclaration; string name; ImmutableArray <MethodSymbol> explicitInterfaceImplementations; if ((object)explicitlyImplementedEventOpt == null) { name = SourceEventSymbol.GetAccessorName(@event.Name, isAdder); explicitInterfaceImplementations = ImmutableArray <MethodSymbol> .Empty; } else { MethodSymbol implementedAccessor = isAdder ? explicitlyImplementedEventOpt.AddMethod : explicitlyImplementedEventOpt.RemoveMethod; string accessorName = (object)implementedAccessor != null ? implementedAccessor.Name : SourceEventSymbol.GetAccessorName(explicitlyImplementedEventOpt.Name, isAdder); name = ExplicitInterfaceHelpers.GetMemberName(accessorName, explicitlyImplementedEventOpt.ContainingType, aliasQualifierOpt); explicitInterfaceImplementations = (object)implementedAccessor == null ? ImmutableArray <MethodSymbol> .Empty : ImmutableArray.Create <MethodSymbol>(implementedAccessor); } this.explicitInterfaceImplementations = explicitInterfaceImplementations; this.name = name; this.flags = MakeFlags( isAdder ? MethodKind.EventAdd : MethodKind.EventRemove, @event.Modifiers, returnsVoid: false, // until we learn otherwise (in LazyMethodChecks). isExtensionMethod: false, isMetadataVirtualIgnoringModifiers: explicitInterfaceImplementations.Any()); if (@event.ContainingType.IsInterface) { diagnostics.Add(ErrorCode.ERR_EventPropertyInInterface, this.Location); } else { var bodyOpt = syntax.Body; if (bodyOpt != null) { if (IsExtern && !IsAbstract) { diagnostics.Add(ErrorCode.ERR_ExternHasBody, this.Location, this); } else if (IsAbstract && !IsExtern) { diagnostics.Add(ErrorCode.ERR_AbstractHasBody, this.Location, this); } // Do not report error for IsAbstract && IsExtern. Dev10 reports CS0180 only // in that case ("member cannot be both extern and abstract"). } } this.name = GetOverriddenAccessorName(@event, isAdder) ?? this.name; }