New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write-Output $null -NoEnumerate produces different Collection<PSObject> in 5.1 vs 6.0 #6451
Comments
Oi. That's a messy broken business, indeed. |
It looks like this change to Write-Output is the culprit. Copying the command from the revision prior and renaming to Add-Type '
using System.Management.Automation;
[Cmdlet(VerbsCommunications.Write, "Output2")]
public class WriteOutput2Command : PSCmdlet
{
private PSObject[] _inputObjects = null;
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromRemainingArguments = true)]
[AllowNull]
[AllowEmptyCollection]
public PSObject[] InputObject
{
get { return _inputObjects; }
set { _inputObjects = value; }
}
[Parameter()]
public SwitchParameter NoEnumerate
{
get;
set;
}
protected override void ProcessRecord()
{
if (null == _inputObjects)
{
WriteObject(_inputObjects);
return;
}
bool enumerate = true;
if (NoEnumerate.IsPresent)
{
enumerate = false;
}
foreach (PSObject inputObject in _inputObjects)
{
WriteObject(inputObject, enumerate);
}
}//processrecord
}' -PassThru | % Assembly | Import-Module
$r = [System.Collections.ObjectModel.Collection[psobject]]{Write-Output2 $Null -NoEnumerate}.Invoke()
$r.Item(0).GetType() outputs
|
when -NoEnumerate is used. Fix PowerShell#5122
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
1 similar comment
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
I'm not sure which behavior is better, but I expected 5.1 and 6.0 to behave the same in this respect. If this change is deliberate I would like to understand why.
Steps to reproduce
Behavior in PowerShell 5.1
Behavior in PowerShell 6.0
The text was updated successfully, but these errors were encountered: