The .Arguments property on the System.Management.Automation.CallStackFrame instances output by Get-PSCallStack is a script property that - I presume - is meant to reflect the arguments passed.
The property isn't documented, but it seems to contain no useful information, seemingly containing $null in any non-global scope.
While you con obtain argument information via the type-native .InvocationInfo property, I assume there is a purpose to .Arguments that it currently doesn't fulfill.
& { (Get-PSCallStack)[0].Arguments } 'foo' | Should -match 'foo'
The test should pass.
The test fails, because .Arguments is $null:
Expected regular expression 'foo' to match $null, but it did not match.
PowerShell Core 7.0.0-preview.6
Looks like that script property got hit by the script that was replacing "" with string.Empty.
The line was (and is in Windows PowerShell):
foreach ($arg in $this.InvocationInfo.UnboundArguments.GetEnumerator())
{
if ($argumentsBuilder.Length -gt 1)
{
$argumentsBuilder.Append(", ")
}
# etc...
But is now
foreach ($arg in $this.InvocationInfo.UnboundArguments.GetEnumerator())
{
if ($argumentsBuilder.Length -gt 1)
{
$argumentsBuilder.Append(string.Empty, string.Empty)
}
# etc...
Which is a syntax error.
You can see it with (Get-PSCallStack)[0].psobject.Properties['Arguments'].GetterScript
@mklement0 Thanks! I pulled PR with fix.
:tada:This issue was addressed in #11210, which has now been successfully released as v7.0.0-rc.1.:tada:
Handy links:
Most helpful comment
@mklement0 Thanks! I pulled PR with fix.