Skip to content

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

Closed

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.

Activity

  1. added
    Issue-Question
    on Sep 16, 2019
  2. iSazonov commented on Sep 17, 2019

    @iSazonov
    Collaborator

    Dongbo Wang (@daxian-dbw) Could you please look the issue?

  3. added
    WG-Engine
    on Sep 17, 2019
  4. ili101 commented on Nov 27, 2019

    @ili101
    Author

    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
    Dongbo Wang (@daxian-dbw) Ilya (@iSazonov)

  5. iSazonov commented on Nov 28, 2019

    @iSazonov
    Collaborator

    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 Steve Lee (@SteveL-MSFT)

  6. SteveL-MSFT commented on Dec 2, 2019

    @SteveL-MSFT
    Member

    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 Rob Holt (@rjmholt)

  7. iSazonov commented on Dec 3, 2019

    @iSazonov
    Collaborator

    We could try compiled artifacts to find a PR where the regression come but GitHub removes old ones.

  8. daxian-dbw commented on Dec 3, 2019

    @daxian-dbw
    Member

    This is a regression caused by the FirstOrDefault primitive added early in PS7 preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-QuestionResolution-FixedWG-Engine

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions