Format-Checklist does not accept parameter input
Format-Checklist fails when passing a RequirementEvent[] object as a parameter. It should format the objects as it does when they are passed in from the pipeline.
Error:
Format-Checklist : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type
"System.DateTime"."
At line:25 char:1
+ Format-Checklist -RequirementEvent $output # fails
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Format-Checklist], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Format-Checklist
Code to reproduce:
$mySystem = [collections.generic.list[int]]::new()
$requirements = @(
@{
Name = "Resource 1"
Describe = "Resource 1 is present in the system"
Test = { $mySystem -contains 1 }
Set = { $mySystem.Add(1) | Out-Null; Start-Sleep 1 }
},
@{
Name = "Resource 2"
Describe = "Resource 2 is present in the system"
Test = { $mySystem -contains 2 }
Set = { $mySystem.Add(2) | Out-Null; Start-Sleep 1 }
}
)
$output = $requirements | Invoke-Requirement
$output | Format-Table | Out-Host # works
Format-Table -InputObject $output | Out-Host # works
$output | Format-Checklist | Out-Host # works
Format-Checklist -RequirementEvent $output # fails
Seems like
- the parameter attribute should be changed from
ValueFromPipelinetoValueFromPipelineByPropertyName - the
processblock should wrap aforeachloop around the currentprocessblock content - update the iterated value from
$_to$eventor something similar
I should probably add that I'm not sure why anyone would do this. Format-Checklist is meant for real-time updating of the host. If you want non-realtime, you're probably better off using the other Format-* cmdlets that support stream redirection.
Users' wants and developers' expectations are rarely in sync. :-)
Well, my attempted solution seemed to stop the formatters from accepting pipeline input. Not sure if anyone has any ideas here...