See #3641. Types needed in PowerShell classes must be available at parse-time (i.e. not loaded with Import-Module or Add-Type) to be able to compile classes to IL.
To be able to resolve these types, we want to support the using assembly statement. However, the most available way to do this involves loading a DLL and possibly executing some of its code, presenting a vector for arbitrary code execution.
Instead, we should analyse a DLL's metadata to discover the types it exports, using a System.Reflection.Metadata.MetadataReader. Example code for this is in PR #3169. The entry point for this analysis would be the PowerShellModuleAssemblyAnalyzer class.
The right way to do this is now to use a MetadataLoadContext