Enable Write-Information to accept $null#8774
Conversation
|
The codefactor issue is in existing code that wasn't changed and also complaining about Hungarian notation which it isn't. |
| } | ||
|
|
||
| It "Write-Information accespts `$Null" { | ||
| $null | Write-Information | Should -BeNullOrEmpty |
There was a problem hiding this comment.
Rather than "NullOrEmpty", we should probably be specific about what this case does, and test it by checking the information stream for the result if possible.
There was a problem hiding this comment.
Not sure what you're proposing to check here. Previously it was returning a non-terminating error. I can change it to stop on error which would cause the test to fail without this change. The OrEmpty of the assertion only applies if the input is a string anyways.
There was a problem hiding this comment.
Write-Information doesn't write to pipeline so the test is misleading. It is more clear to check Information stream contains $null or check -NotThrow.
There was a problem hiding this comment.
Ok, I see what you guys are saying now. Will make a change.
test/powershell/Modules/Microsoft.PowerShell.Utility/Write-Stream.Tests.ps1
Outdated
Show resolved
Hide resolved
|
The codefactor issue is wrong |
PR Summary
Write-Informationcurrently errors if $null is passed.PR Context
There's no benefit to having it error out if $null is passed. If a pipeline is sending objects to
Write-Information, it would make sense for the cmdlet to handle $null which in this case is a no-op.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.[feature]to your commit messages if the change is significant or affects feature tests