示例#1
0
        public static bool ExcludeTypeParameterForDefinition(IMember member)
        {
            if (member.ImplementedInterfaceMembers.Count == 0)
            {
                return(false);
            }

            if (member.ImplementedInterfaceMembers.Any(im =>
            {
                var typeDef = im.DeclaringTypeDefinition;
                var type = im.DeclaringType;

                return(typeDef != null && !Helpers.IsIgnoreGeneric(typeDef) && type != null &&
                       type.TypeArguments.Count > 0 && Helpers.IsTypeParameterType(type));
            }))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public static bool NeedCreateAlias(MemberResolveResult rr)
        {
            if (rr == null || rr.Member.ImplementedInterfaceMembers.Count == 0)
            {
                return(false);
            }

            if (rr.Member.ImplementedInterfaceMembers.Count > 0 &&
                rr.Member.ImplementedInterfaceMembers.Any(im => im.DeclaringTypeDefinition.TypeParameters.Any(tp => tp.Variance != VarianceModifier.Invariant)))
            {
                return(true);
            }

            if (rr.Member.IsExplicitInterfaceImplementation)
            {
                var explicitInterfaceMember = rr.Member.ImplementedInterfaceMembers.First();
                var typeDef = explicitInterfaceMember.DeclaringTypeDefinition;
                var type    = explicitInterfaceMember.DeclaringType;

                return(typeDef != null && !Helpers.IsIgnoreGeneric(typeDef) && type != null && type.TypeArguments.Count > 0 && Helpers.IsTypeParameterType(type));
            }

            return(true);
        }