Since Object.factory() is being deprecated https://github.com/dlang/dmd/pull/14681 a convenient replacement is necessary.
TraitsExpression:
__traits ( getModuleClasses [, TraitsArgument] )
The TraitsArgument is the name of the module or a fully qualified import.
If the TraitsArgument is not specified, it defaults to the current module.
It returns a Tuple of strings representing the fully qualified classes defined in the specified module.
For example:
module test;
import std.stdio;
class C { }
pragma(msg, __traits(getModuleClasses));
pragma(msg, __traits(getModuleClasses, std.stdio);
prints:
tuple("test.C")
tuple("std.stdio.Stdio.Exception")
".classinfo" can be appended to those strings to get the classinfo for those modules. See: https://dlang.org/spec/property.html#classinfo
Comment #1 by alphaglosined — 2022-12-15T06:53:40Z
Alternatively, return the types, and add a trait for getting the fully qualified name from a symbol (std.traits fullyQualifiedName is absolutely insane). This could also simplify handling of inner classes.
This will also take care of getting ClassInfo.