public ImmediateShadowInterfaceInfo(TypeInfo type)
        {
            Type = type;
            ImplementedInterfaces = new(6);

            foreach (var implementedInterface in type.ImplementedInterfaces)
            {
                var interfaceInfo = implementedInterface.GetTypeInfo();

                // If there is no Vtbl attribute then this isn't a native interface.
                if (!VtblAttribute.Has(interfaceInfo))
                {
                    continue;
                }

                ImplementedInterfaces.Add(interfaceInfo);
            }
        }
Exemplo n.º 2
0
    private void InitializeCallableWrapperStorage()
    {
        var ccw = _ccw;

        Debug.Assert(ccw is not null);
        Debug.Assert(ccw.Count == 0);
        Debug.Assert(!_thisHandle.IsAllocated);

        // Associate all shadows with their interfaces.
        var interfaces = GetUninheritedShadowedInterfaces(GetType());

        if (interfaces.Count == 0)
        {
            return;
        }

        var thisHandle = _thisHandle = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);

        foreach (var item in interfaces)
        {
            Debug.Assert(VtblAttribute.Has(item.Type));

            GCHandle shadowHandle;
            if (ShadowAttribute.Get(item.Type) is { Type: { } shadowType })