示例#1
0
        /// <inheritdoc cref="FindDerivedClassesAsync(INamedTypeSymbol, Solution, bool, IImmutableSet{Project}, CancellationToken)"/>
        internal static async Task <ImmutableArray <INamedTypeSymbol> > FindDerivedClassesArrayAsync(
            INamedTypeSymbol type, Solution solution, bool transitive, IImmutableSet <Project> projects = null, CancellationToken cancellationToken = default)
        {
            var types = await DependentTypeFinder.FindDerivedClassesAsync(
                type, solution, projects, transitive, cancellationToken).ConfigureAwait(false);

            return(types.WhereAsArray(t => IsAccessible(t)));
        }
        /// <summary>
        /// Finds the derived classes of the given type. Implementations of an interface are not considered "derived", but can be found
        /// with <see cref="FindImplementationsAsync"/>.
        /// </summary>
        /// <param name="type">The symbol to find derived types of.</param>
        /// <param name="solution">The solution to search in.</param>
        /// <param name="projects">The projects to search. Can be null to search the entire solution.</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The derived types of the symbol. The symbol passed in is not included in this list.</returns>
        public static Task <IEnumerable <INamedTypeSymbol> > FindDerivedClassesAsync(
            INamedTypeSymbol type, Solution solution, IImmutableSet <Project> projects = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (solution == null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            return(DependentTypeFinder.FindDerivedClassesAsync(type, solution, projects, cancellationToken));
        }