using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace StellaOps.Plugin.Internal;

internal static class ReflectionExtensions
{
    public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
    {
        try
        {
            return assembly.GetTypes();
        }
        catch (ReflectionTypeLoadException ex)
        {
            return ex.Types.Where(static t => t is not null)!;
        }
    }
}