Beispiel #1
0
        void GetVirtualMethods(AssemblyCache cache, HashSet <MethodKey> methods, TypeDefinition type)
        {
            // check the interfaces
            foreach (var ifaceRef in type.Interfaces)
            {
                TypeDefinition iface = project.GetTypeDefinition(ifaceRef.InterfaceType);

                // if it's not in the project, try to get it via the cache
                if (iface == null)
                {
                    iface = cache.GetTypeDefinition(ifaceRef.InterfaceType);
                }

                // search interface
                if (iface != null)
                {
                    GetVirtualMethods(cache, methods, iface);
                }
            }

            // check the base type unless it isn't in the project, or we don't have one
            TypeDefinition baseType = project.GetTypeDefinition(type.BaseType);

            // if it's not in the project, try to get it via the cache
            if (baseType == null)
            {
                baseType = cache.GetTypeDefinition(type.BaseType);
            }

            // search base
            if (baseType != null)
            {
                GetVirtualMethods(cache, methods, baseType);
            }

            foreach (MethodDefinition method in type.Methods)
            {
                if (method.IsVirtual)
                {
                    methods.Add(new MethodKey(method));
                }
            }
        }
Beispiel #2
0
        public static void GetBaseTypes(Project project, HashSet <TypeKey> baseTypes, TypeDefinition type)
        {
            // check the interfaces
            foreach (var ifaceRef in type.Interfaces)
            {
                TypeDefinition iface = project.GetTypeDefinition(ifaceRef.InterfaceType);
                if (iface != null)
                {
                    GetBaseTypes(project, baseTypes, iface);
                    baseTypes.Add(new TypeKey(iface));
                }
            }

            // check the base type unless it isn't in the project, or we don't have one
            TypeDefinition baseType = project.GetTypeDefinition(type.BaseType);

            if (baseType != null && baseType.FullName != "System.Object")
            {
                GetBaseTypes(project, baseTypes, baseType);
                baseTypes.Add(new TypeKey(baseType));
            }
        }
Beispiel #3
0
        public static List <TypeKey> GetBaseTypes(Project project, TypeDefinition type)
        {
            var result = new List <TypeKey>();

            // check the interfaces
            foreach (var ifaceRef in type.Interfaces)
            {
                TypeDefinition iface = project.GetTypeDefinition(ifaceRef.InterfaceType);

                // if it's not in the project, try to get it via the cache
                if (iface == null)
                {
                    iface = project.Cache.GetTypeDefinition(ifaceRef.InterfaceType);
                }

                if (iface != null)
                {
                    result.Add(new TypeKey(iface));
                }
            }

            // check the base type unless it isn't in the project, or we don't have one
            TypeDefinition baseType = project.GetTypeDefinition(type.BaseType);

            // if it's not in the project, try to get it via the cache
            if (baseType == null)
            {
                baseType = project.Cache.GetTypeDefinition(type.BaseType);
            }

            if (baseType != null && baseType.FullName != "System.Object")
            {
                result.Add(new TypeKey(baseType));
            }

            return(result);
        }