Old code that was returning just a type from a clean runspace had a problem where local module functions were not visible to class's methods when called.
Returning an instance from a new clean runspace has a problem that PS streams (verbose/debug/etc) were not transferred to the calling runspace (a blocker for GC).
Per suggestion from Dongbo, changed code to returning an instance but creating it using [PowerShell]::Create('CurrentRunspace').
This also removes a need for an InitialSessionState-hack to transfer parent PSModulePath to a clean runspace.
Old code that was returning just a type from a clean runspace had a problem where local module functions were not visible to class's methods when called. Returning an instance from a new clean runspace has a problem that PS streams (verbose/debug/etc) were not transferred to the calling runspace (a blocker for GC). Per suggestion from Dongbo, changed code to returning an instance but creating it using
[PowerShell]::Create('CurrentRunspace')
. This also removes a need for an InitialSessionState-hack to transfer parent PSModulePath to a clean runspace.