GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||
GeezerVison is showing github.com — Fix `Get-Help` `PSTypeName` issue with `-Parameter` when only one parameter is declared by pougetat · Pull Request #8754 · PowerShell/PowerShell Conversation
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You could probably condense much of this into the ternary statement, if I'm reading this right...
| paramAsPSObjArray != null ? paramAsPSObjArray : param, | |
| paramPSObjArray == null ? paramPSObjArray : new[] { (PSObject)prmts.Properties["parameter"].Value }, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The problem is that param is not necessarily PSObject or PSObject[]. It can also be object which makes the cast failure prone.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can do PSObject.AsPSObject(obj) to safely convert object -> PSObject, but I'm not sure whether that would completely resolve the issue.
That method will also no-op if the input object is already a PSObject.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think it resolves the issue since that method will attempt to create a PSObject from object. What I'm doing here is essentially trying to use the object as is in the form of a PSObject and if it doesn't work then I will just pass the object along to ConvertTo as was done previously. ConvertTo itself knows what to do with a plain object in regards to transforming it into a PSObject.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure, but I think that's more or less just what ConvertTo would do itself... I'd have to chase down the convoluted code paths in there, though. I'm sure it's OK to use ConvertTo, though. 🙂
Sorry, something went wrong.
There was an error while loading. Please reload this page.
40bca28 to
0c67a87
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
0c67a87 to
de39c19
Compare
Get-Help PSTypeName issue with -Parameter when only one parameter is declared
|
pougetat (@pougetat) Thank you for your contribution! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ameter is declared (PowerShell#8754)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Get-Help -Parameter does not correctly set PSTypeName when one parameter is declared
There was an error while loading. Please reload this page.