Ejemplo n.º 1
0
        public ISet <CSharpType> GetDerivedTypes(CSharpTypeIdentifier typeId)
        {
            ISet <CSharpType> result = new HashSet <CSharpType>();

            foreach (Compilation compilation in AllProjects)
            {
                CSharpType baseType = compilation.ResolveTypeIdentifier(typeId);
                if (baseType == null)
                {
                    continue;
                }

                BaseTypeCollector collector = baseType.IsInterface ? GetBaseInterfaceCollector() : GetBaseClassCollector();
                foreach (CSharpType type in compilation.MainAssembly.Types)
                {
                    // an interface can't be derived from a class
                    if (type.IsInterface && !baseType.IsInterface)
                    {
                        continue;
                    }

                    var baseTypes = collector.GetBaseTypes(type);
                    if (baseTypes.Contains(baseType))
                    {
                        result.Add(type);
                    }
                }
            }

            return(result);
        }