Skip to content

v2.4.0

Latest

Choose a tag to compare

@SeeminglyScience SeeminglyScience released this 22 Dec 22:58
9bd78a3

2.4.0 - 2025-12-22

Invoke-Member (aka ivm) (#55)

Quality of life command that makes interactive invocation of reflection info easier.

Tracks source instance

No need to save instances to an intermediate variable, Find-Member will attach a hidden ETS property to its output.

[WildcardPattern]'c*' | Find-Member -Force PatternConvertedToRegex | Invoke-Member
# returns:
# ^c

The source object will remain tracked between chained Find-Member commands, but not subsequent invocations (for the engine nerds, the PSObject does not register itself to the member resurrection table).

Handles normal conversions, out parameters, and pointers

using namespace System.Runtime.InteropServices

# very contrived example
$message = 'testing'
$chars = [Marshal]::AllocHGlobal($message.Length * 2)
[Marshal]::Copy($message.ToCharArray(), 0, $chars, $message.Length)
$encoder = [System.Text.Encoding]::UTF8.GetEncoder()
$bytes = [Marshal]::AllocHGlobal(0x200)

# arbitrarily make it a string to show conversion
$charLength = [string]$message.Length
$encoder | Find-Member Convert -ParameterType { [char+] } | % DisplayString

# returns:
# public override void Convert(char* chars, int charCount, byte* bytes, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed);

$encoder |
    Find-Member Convert -ParameterType { [char+] } |
    Invoke-Member $chars $charLength $bytes 0x200 $true

# charsUsed bytesUsed completed
# --------- --------- ---------
#         7         7      True

demoing the same thing as the code block above

Get-AssemblyLoadContext (aka galc) (#55)

A way to interact with and explore ALCs via ClassExplorer.

Get-AssemblyLoadContext

# Definition      ImplementingType                              Assemblies
# ----------      ----------------                              ----------
# Default         System.Runtime.Loader.DefaultAssemblyLoadCon… 152 assemblies (System.Private.CoreLib, pwsh, …
# <Unnamed>       PowerShellRun.CustomAssemblyLoadContext       0 assemblies
# Yayaml          Yayaml.LoadContext                            2 assemblies (Yayaml.Module, YamlDotNet)

[ref] | Get-AssemblyLoadContext

# Definition      ImplementingType                              Assemblies
# ----------      ----------------                              ----------
# Default         System.Runtime.Loader.DefaultAssemblyLoadCon… 152 assemblies (System.Private.CoreLib, pwsh, …

Get-AssemblyLoadContext Yayaml | Find-Type | select -First 5

#    Namespace: Yayaml.Module
#
# Access        Modifiers           Name
# ------        ---------           ----
# public        sealed class        AddYamlFormatCommand : PSCmdlet
# public        sealed class        ConvertFromYamlCommand : PSCmdlet
# public        sealed class        ConvertToYamlCommand : PSCmdlet
# public        sealed class        NewYamlSchemaCommand : PSCmdlet
# public        class               YamlSchemaCompletionsAttribute : ArgumentCompletionsAttribute

again just demoing the same thing as above