Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 protected override TypeLayout?GetTypeLayoutIfStruct()
 {
     if (UnderlyingNamedType.IsStructType())
     {
         return(UnderlyingNamedType.Layout);
     }
     return(null);
 }
Exemplo n.º 3
0
        internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison)
        {
            if (t2 is ExtendedNamedTypeSymbol t2Extended && UnderlyingNamedType.Equals(t2Extended.UnderlyingNamedType, comparison))
            {
                return(_accessModifiers == t2Extended._accessModifiers);
            }

            return(false);
        }
Exemplo n.º 4
0
        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));
            }
        }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
 protected override IEnumerable <PropertySymbol> GetPropertiesToEmit()
 {
     return(UnderlyingNamedType.GetPropertiesToEmit());
 }
Exemplo n.º 8
0
 protected override IEnumerable <EventSymbol> GetEventsToEmit()
 {
     return(UnderlyingNamedType.GetEventsToEmit());
 }
Exemplo n.º 9
0
 protected override IEnumerable <MethodSymbol> GetMethodsToEmit()
 {
     return(UnderlyingNamedType.GetMethodsToEmit());
 }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit(PEModuleBuilder moduleBuilder)
 {
     return(UnderlyingNamedType.GetCustomAttributesToEmit(moduleBuilder));
 }
Exemplo n.º 12
0
 protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit()
 {
     return(UnderlyingNamedType.GetCustomAttributesToEmit());
 }
Exemplo n.º 13
0
 protected override IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit(ModuleCompilationState compilationState)
 {
     return(UnderlyingNamedType.GetCustomAttributesToEmit(compilationState));
 }