// Not sure which of the two versions of this method give better performance -- you might want to test yourself.
    public static IEnumerable <Type> DerivedTypesFromAllAssemblies(this Type baseType)
    {
        // TODO: Optimization: check if baseType is private or internal.
        var assemblies = AssemblyExtensions.GetAllAssemblies();

        Debug.Assert(assemblies.Count() == assemblies.Distinct().Count());
        return(assemblies
               .SelectMany(a => a.GetTypes())
               .Where(t => baseType.IsAssignableFrom(t)));
    }