Skip to content

Write-Output of class with hidden params regression in PS 7 #10554

@ili101

Description

@ili101

Steps to reproduce

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
#>

Expected behavior

If there are only hidden params show the ToString() like in PS6

Actual behavior

If there are only hidden params it shows blank lines like it tries to show the params but have noting to show.

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions