Ejemplo n.º 1
0
		/// <summary>
		/// Gets all non-interface base types.
		/// </summary>
		/// <remarks>
		/// When <paramref name="type"/> is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetNonInterfaceBaseTypes(this IType type)
		{
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.SkipImplementedInterfaces = true;
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Gets all base types.
        /// </summary>
        /// <remarks>This is the reflexive and transitive closure of <see cref="IType.GetBaseTypes"/>.
        /// Note that this method does not return all supertypes - doing so is impossible due to contravariance
        /// (and undesirable for covariance as the list could become very large).
        ///
        /// The output is ordered so that base types occur in before derived types.
        /// </remarks>
        public static IEnumerable <IType> GetAllBaseTypes(this IType type, ITypeResolveContext context)
        {
            BaseTypeCollector collector = new BaseTypeCollector(context);

            collector.CollectBaseTypes(type);
            return(collector);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all base types.
        /// </summary>
        /// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
        /// Note that this method does not return all supertypes - doing so is impossible due to contravariance
        /// (and undesirable for covariance as the list could become very large).
        ///
        /// The output is ordered so that base types occur before derived types.
        /// </remarks>
        public static IEnumerable <IType> GetAllBaseTypes(this IType type)
        {
            BaseTypeCollector collector = new BaseTypeCollector();

            collector.CollectBaseTypes(type);
            return(collector);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets all non-interface base types.
        /// </summary>
        /// <remarks>
        /// When <paramref name="type"/> is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()).
        ///
        /// The output is ordered so that base types occur before derived types.
        /// </remarks>
        public static IEnumerable <IType> GetNonInterfaceBaseTypes(this IType type)
        {
            BaseTypeCollector collector = new BaseTypeCollector();

            collector.SkipImplementedInterfaces = true;
            collector.CollectBaseTypes(type);
            return(collector);
        }
Ejemplo n.º 6
0
		/// <summary>
		/// Gets all base types.
		/// </summary>
		/// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
		/// Note that this method does not return all supertypes - doing so is impossible due to contravariance
		/// (and undesirable for covariance as the list could become very large).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetAllBaseTypes(this IType type)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Gets all base types.
		/// </summary>
		/// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
		/// Note that this method does not return all supertypes - doing so is impossible due to contravariance
		/// (and undesirable for covariance as the list could become very large).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetAllBaseTypes(this IType type)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Gets all non-interface base types.
		/// </summary>
		/// <remarks>
		/// When <paramref name="type"/> is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetNonInterfaceBaseTypes(this IType type)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.SkipImplementedInterfaces = true;
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Gets all non-interface base types.
		/// </summary>
		/// <remarks>
		/// When <paramref name="type"/> is an interface, this method will also return base interfaces (return same output as GetAllBaseTypes()).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetNonInterfaceBaseTypes(this IType type)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.SkipImplementedInterfaces = true;
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 10
0
        /// <summary>
        /// Gets all base types.
        /// </summary>
        /// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
        /// Note that this method does not return all supertypes - doing so is impossible due to contravariance
        /// (and undesirable for covariance as the list could become very large).
        ///
        /// The output is ordered so that base types occur before derived types.
        /// </remarks>
        public static IEnumerable <IType> GetAllBaseTypes(this IType type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            BaseTypeCollector collector = new BaseTypeCollector();

            collector.CollectBaseTypes(type);
            return(collector);
        }
Ejemplo n.º 11
0
		/// <summary>
		/// Gets all base types.
		/// </summary>
		/// <remarks>This is the reflexive and transitive closure of <see cref="IType.DirectBaseTypes"/>.
		/// Note that this method does not return all supertypes - doing so is impossible due to contravariance
		/// (and undesirable for covariance as the list could become very large).
		/// 
		/// The output is ordered so that base types occur before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetAllBaseTypes(this IType type)
		{
			BaseTypeCollector collector = new BaseTypeCollector();
			collector.CollectBaseTypes(type);
			return collector;
		}
Ejemplo n.º 12
0
		/// <summary>
		/// Gets all base types.
		/// </summary>
		/// <remarks>This is the reflexive and transitive closure of <see cref="IType.GetBaseTypes"/>.
		/// Note that this method does not return all supertypes - doing so is impossible due to contravariance
		/// (and undesirable for covariance as the list could become very large).
		/// 
		/// The output is ordered so that base types occur in before derived types.
		/// </remarks>
		public static IEnumerable<IType> GetAllBaseTypes(this IType type, ITypeResolveContext context)
		{
			BaseTypeCollector collector = new BaseTypeCollector(context);
			collector.CollectBaseTypes(type);
			return collector;
		}