public void EmbedAllMembersOfImplementedInterface(SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics) { Debug.Assert(UnderlyingNamedType.IsInterfaceType()); if (_embeddedAllMembersOfImplementedInterface) { return; } _embeddedAllMembersOfImplementedInterface = true; // Embed all members foreach (MethodSymbol m in UnderlyingNamedType.GetMethodsToEmit()) { if ((object)m != null) { TypeManager.EmbedMethod(this, m, syntaxNodeOpt, diagnostics); } } // We also should embed properties and events, but we don't need to do this explicitly here // because accessors embed them automatically. // Do the same for implemented interfaces. foreach (NamedTypeSymbol @interface in UnderlyingNamedType.GetInterfacesToEmit()) { TypeManager.ModuleBeingBuilt.Translate(@interface, syntaxNodeOpt, diagnostics, fromImplements: true); } }
protected override TypeLayout?GetTypeLayoutIfStruct() { if (UnderlyingNamedType.IsStructType()) { return(UnderlyingNamedType.Layout); } return(null); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (t2 is ExtendedNamedTypeSymbol t2Extended && UnderlyingNamedType.Equals(t2Extended.UnderlyingNamedType, comparison)) { return(_accessModifiers == t2Extended._accessModifiers); } return(false); }
protected override IEnumerable <Cci.ITypeReference> GetInterfaces(Microsoft.CodeAnalysis.Emit.Context context) { Debug.Assert((object)TypeManager.ModuleBeingBuilt == context.Module); PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)context.Module; foreach (NamedTypeSymbol @interface in UnderlyingNamedType.GetInterfacesToEmit()) { yield return(moduleBeingBuilt.Translate(@interface, (CSharpSyntaxNode)context.SyntaxNodeOpt, context.Diagnostics)); } }
protected override IEnumerable <Cci.TypeReferenceWithAttributes> GetInterfaces(EmitContext context) { Debug.Assert((object)TypeManager.ModuleBeingBuilt == context.Module); PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)context.Module; foreach (NamedTypeSymbol @interface in UnderlyingNamedType.GetInterfacesToEmit()) { var typeRef = moduleBeingBuilt.Translate( @interface, (CSharpSyntaxNode)context.SyntaxNodeOpt, context.Diagnostics); yield return(@interface.GetTypeRefWithAttributes( UnderlyingNamedType.DeclaringCompilation, typeRef)); } }
protected override void EmbedDefaultMembers(string defaultMember, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics) { foreach (Symbol s in UnderlyingNamedType.GetMembers(defaultMember)) { switch (s.Kind) { case SymbolKind.Field: TypeManager.EmbedField(this, (FieldSymbol)s, syntaxNodeOpt, diagnostics); break; case SymbolKind.Method: TypeManager.EmbedMethod(this, (MethodSymbol)s, syntaxNodeOpt, diagnostics); break; case SymbolKind.Property: TypeManager.EmbedProperty(this, (PropertySymbol)s, syntaxNodeOpt, diagnostics); break; case SymbolKind.Event: TypeManager.EmbedEvent(this, (EventSymbol)s, syntaxNodeOpt, diagnostics, isUsedForComAwareEventBinding: false); break; } } }
protected override IEnumerable <PropertySymbol> GetPropertiesToEmit() { return(UnderlyingNamedType.GetPropertiesToEmit()); }
protected override IEnumerable <EventSymbol> GetEventsToEmit() { return(UnderlyingNamedType.GetEventsToEmit()); }
protected override IEnumerable <MethodSymbol> GetMethodsToEmit() { return(UnderlyingNamedType.GetMethodsToEmit()); }
protected override CSharpAttributeData CreateTypeIdentifierAttribute(bool hasGuid, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics) { var member = hasGuid ? WellKnownMember.System_Runtime_InteropServices_TypeIdentifierAttribute__ctor : WellKnownMember.System_Runtime_InteropServices_TypeIdentifierAttribute__ctorStringString; var ctor = TypeManager.GetWellKnownMethod(member, syntaxNodeOpt, diagnostics); if ((object)ctor == null) { return(null); } if (hasGuid) { // This is an interface with a GuidAttribute, so we will generate the no-parameter TypeIdentifier. return(new SynthesizedAttributeData(ctor, ImmutableArray <TypedConstant> .Empty, ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty)); } else { // This is an interface with no GuidAttribute, or some other type, so we will generate the // TypeIdentifier with name and scope parameters. // Look for a GUID attribute attached to type's containing assembly. If we find one, we'll use it; // otherwise, we expect that we will have reported an error (ERRID_PIAHasNoAssemblyGuid1) about this assembly, since // you can't /link against an assembly which lacks a GuidAttribute. var stringType = TypeManager.GetSystemStringType(syntaxNodeOpt, diagnostics); if ((object)stringType != null) { string guidString = TypeManager.GetAssemblyGuidString(UnderlyingNamedType.ContainingAssembly); return(new SynthesizedAttributeData(ctor, ImmutableArray.Create(new TypedConstant(stringType, TypedConstantKind.Primitive, guidString), new TypedConstant(stringType, TypedConstantKind.Primitive, UnderlyingNamedType.ToDisplayString(SymbolDisplayFormat.QualifiedNameOnlyFormat))), ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty)); } } return(null); }
protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit(PEModuleBuilder moduleBuilder) { return(UnderlyingNamedType.GetCustomAttributesToEmit(moduleBuilder)); }
protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit() { return(UnderlyingNamedType.GetCustomAttributesToEmit()); }
protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState) { return(UnderlyingNamedType.GetCustomAttributesToEmit(compilationState)); }