/// <summary> /// Determines whether an <see cref="ISymbol"/> must be visited. /// </summary> /// <param name="symbol">The symbol to visit.</param> /// <returns>A value indicating whether the <see cref="ISymbol"/> must be visited.</returns> private bool CanSymbolBeVisited(ISymbol symbol) { // Do not visit compiler generated symbols. if (symbol.IsCompilerGenerated()) { return(false); } bool result = true; VisitorDepth depth = options.GetVisitorDepth(); switch (symbol) { case INamespaceSymbol _: result = depth >= VisitorDepth.Namespace; break; case INamedTypeSymbol namedTypeSymbol when namedTypeSymbol.TypeKind == TypeKind.Class: result = depth >= VisitorDepth.NamedType && classFilter?.Invoke(namedTypeSymbol) != false; break; case INamedTypeSymbol namedTypeSymbol when namedTypeSymbol.TypeKind == TypeKind.Struct: result = depth >= VisitorDepth.NamedType && structFilter?.Invoke(namedTypeSymbol) != false; break; case INamedTypeSymbol namedTypeSymbol when namedTypeSymbol.TypeKind == TypeKind.Enum: result = depth >= VisitorDepth.NamedType && enumFilter?.Invoke(namedTypeSymbol) != false; break; case INamedTypeSymbol namedTypeSymbol when namedTypeSymbol.TypeKind == TypeKind.Interface: result = depth >= VisitorDepth.NamedType && interfaceFilter?.Invoke(namedTypeSymbol) != false; break; case IMethodSymbol methodSymbol: result = depth >= VisitorDepth.Members && methodFilter?.Invoke(methodSymbol) != false; break; case IPropertySymbol propertySymbol: result = depth >= VisitorDepth.Members && propertyFilter?.Invoke(propertySymbol) != false; break; case IFieldSymbol fieldSymbol: result = depth >= VisitorDepth.Members && fieldFilter?.Invoke(fieldSymbol) != false; break; case IParameterSymbol parameterSymbol: result = depth >= VisitorDepth.Parameters && parameterFilter?.Invoke(parameterSymbol) != false; break; case ITypeParameterSymbol typeParameterSymbol: result = typeParameterFilter(typeParameterSymbol); break; } return(result); }
internal VisitorDepth GetVisitorDepth() { VisitorDepth depth = VisitorDepth.None; depth = GetNamespaces ? VisitorDepth.Namespace : depth; depth = GetInterfaces || GetClasses || GetStructs || GetEnums ? VisitorDepth.NamedType : depth; depth = GetMethods || GetProperties || GetFields ? VisitorDepth.Members : depth; depth = GetParameters ? VisitorDepth.Parameters : depth; return(depth); }