PowerShell module to declaratively expose non-public type members.
PSReflector greatly simplifies common reflection operations. This is done in two steps:
-
Instead of calling methods like
GetProperty(),GetField(), orGetMethod()and dealing withBindingFlagsand parameter types, you simply specify a type and a list of non-public members you want to access. In most cases, you have to provide only the member names. For overloads, adding the parameter count is usually sufficient. All this is done via the Reflector.Register() method. -
Instead of calling the
GetValue(),SetValue(), andInvoke()reflection methods, you pass the object whose type you've previously registered to the Reflector.Expose() method, which wraps it in a PSObject with the registered members added as public instance properties and methods. You then use the familiar dot-notation to access them, e.g.,$myObj.Foo. In the case of static classes, you can pass the type itself to Expose().
PSReflector can expose static and instance members, including instance constructors. If a registered member returns an object of a registered type, it will already have passed through Expose() and you can access its non-public members right away.
To learn more, see the Documentation.
You can install PSReflector from the PowerShell Gallery.
Install-PSResource -Name PSReflectorTo install the latest build from the CI feed:
Register-PSResourceRepository -Name 'mawosoft-nightly' -Uri 'https://pkgs.dev.azure.com/mawosoft-de/public/_packaging/public/nuget/v2/'
Install-PSResource -Name PSReflector -Repository 'mawosoft-nightly' -Prerelease