In PS 6 and below if a class has only hidden params it will show the ToString() output like it do when there are no parameters. If there are non hiden params it shows them instead.
In PS 7 if a class has only hidden params it shows blank lines.
class Empty {
MyClass() { }
[String]ToString() { return 'MyString' }
}
[Empty]::new()
# Will Show "MyString"
class Hidden {
hidden $Param = 'Foo'
MyClass() { }
[String]ToString() { return 'MyString' }
}
[Hidden]::new()
# On PS < 7 Will Show "MyString"
# On PS 7 Will Show "2 blank lines"
class Params {
$Param = 'Foo'
MyClass() { }
[String]ToString() { return 'MyString' }
}
[Params]::new()
<# Will Show:
Param
-----
Foo
#>
If there are only hidden params show the ToString() like in PS6
If there are only hidden params it shows blank lines like it tries to show the params but have noting to show.
@daxian-dbw Could you please look the issue?
Is it possible to get a fix before PS7 go stable? as this was working in PS6 stable and it will be preferable not to lose functionality when upgrading to PS7.
Thank you
@daxian-dbw @iSazonov
I see the regression was already in 7.0 Preview1.
Write-Host works as expected.
I don't know that is a root of the regression. May be in formatting system. /cc @SteveL-MSFT
This is not in the formatter. In the formatter, the MyString output has Hidden as a typename so it's deliberately hidden. Not sure where that is being set. In the parser, I can see that only $Param has the hidden attribute. cc @rjmholt
We could try compiled artifacts to find a PR where the regression come but GitHub removes old ones.
This is a regression caused by the FirstOrDefault primitive added early in PS7 preview.
:tada:This issue was addressed in #11258, which has now been successfully released as v7.0.0-rc.1.:tada:
Handy links:
Most helpful comment
This is a regression caused by the
FirstOrDefaultprimitive added early in PS7 preview.