Ejemplo n.º 1
0
 public EmbeddedType(EmbeddedTypesManager typeManager, NamedTypeSymbol underlyingNamedType) :
     base(typeManager, underlyingNamedType)
 {
     Debug.Assert(underlyingNamedType.IsDefinition);
     Debug.Assert(underlyingNamedType.IsTopLevelType());
     Debug.Assert(!underlyingNamedType.IsGenericType);
 }
Ejemplo n.º 2
0
 protected override ImmutableArray <EmbeddedParameter> GetParameters()
 {
     return(EmbeddedTypesManager.EmbedParameters(
                this,
                UnderlyingMethod.AdaptedMethodSymbol.Parameters
                ));
 }
Ejemplo n.º 3
0
        protected override void EmbedCorrespondingComEventInterfaceMethodInternal(SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, bool isUsedForComAwareEventBinding)
        {
            // If the event happens to belong to a class with a ComEventInterfaceAttribute, there will also be
            // a paired method living on its source interface. The ComAwareEventInfo class expects to find this
            // method through reflection. If we embed an event, therefore, we must ensure that the associated source
            // interface method is also included, even if it is not otherwise referenced in the embedding project.
            NamedTypeSymbol underlyingContainingType = ContainingType.UnderlyingNamedType;

            foreach (var attrData in underlyingContainingType.GetAttributes())
            {
                if (attrData.IsTargetAttribute(underlyingContainingType, AttributeDescription.ComEventInterfaceAttribute))
                {
                    bool            foundMatch      = false;
                    NamedTypeSymbol sourceInterface = null;

                    if (attrData.CommonConstructorArguments.Length == 2)
                    {
                        sourceInterface = attrData.CommonConstructorArguments[0].Value as NamedTypeSymbol;

                        if ((object)sourceInterface != null)
                        {
                            foundMatch = EmbedMatchingInterfaceMethods(sourceInterface, syntaxNodeOpt, diagnostics);

                            foreach (NamedTypeSymbol source in sourceInterface.AllInterfacesNoUseSiteDiagnostics)
                            {
                                if (EmbedMatchingInterfaceMethods(source, syntaxNodeOpt, diagnostics))
                                {
                                    foundMatch = true;
                                }
                            }
                        }
                    }

                    if (!foundMatch && isUsedForComAwareEventBinding)
                    {
                        if ((object)sourceInterface == null)
                        {
                            // ERRID_SourceInterfaceMustBeInterface/ERR_MissingSourceInterface
                            EmbeddedTypesManager.Error(diagnostics, ErrorCode.ERR_MissingSourceInterface, syntaxNodeOpt, underlyingContainingType, UnderlyingEvent);
                        }
                        else
                        {
                            HashSet <DiagnosticInfo> useSiteDiagnostics = null;
                            sourceInterface.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
                            diagnostics.Add(syntaxNodeOpt == null ? NoLocation.Singleton : syntaxNodeOpt.Location, useSiteDiagnostics);

                            // ERRID_EventNoPIANoBackingMember/ERR_MissingMethodOnSourceInterface
                            EmbeddedTypesManager.Error(diagnostics, ErrorCode.ERR_MissingMethodOnSourceInterface, syntaxNodeOpt, sourceInterface, UnderlyingEvent.MetadataName, UnderlyingEvent);
                        }
                    }

                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public EmbeddedType(EmbeddedTypesManager typeManager,
#if DEBUG
                            NamedTypeSymbolAdapter
#else
                            NamedTypeSymbol
#endif
                            underlyingNamedType) :
            base(typeManager, underlyingNamedType)
        {
            Debug.Assert(underlyingNamedType.AdaptedNamedTypeSymbol.IsDefinition);
            Debug.Assert(underlyingNamedType.AdaptedNamedTypeSymbol.IsTopLevelType());
            Debug.Assert(!underlyingNamedType.AdaptedNamedTypeSymbol.IsGenericType);
        }
Ejemplo n.º 5
0
 protected override void ReportMissingAttribute(
     AttributeDescription description,
     SyntaxNode syntaxNodeOpt,
     DiagnosticBag diagnostics
     )
 {
     EmbeddedTypesManager.Error(
         diagnostics,
         ErrorCode.ERR_InteropTypeMissingAttribute,
         syntaxNodeOpt,
         UnderlyingNamedType.AdaptedNamedTypeSymbol,
         description.FullName
         );
 }
Ejemplo n.º 6
0
 protected override ImmutableArray <EmbeddedParameter> GetParameters()
 {
     return(EmbeddedTypesManager.EmbedParameters(this, UnderlyingProperty.Parameters));
 }