GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@pougetat

@pougetat pougetat (pougetat) commented Jan 26, 2019 •
edited by adityapatwardhan
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

Fix #8697 'Get-Help -Parameter does not correctly set PSTypeName when one parameter is declared'.

PR Context

This issue occurs for the following reason :

  • For a single parameter the FullHelp object contains a PSObject representing the parameter
  • For multiple parameters the FullHelp object conrains a PSObject[] with each element representing a parameter.
    My fix is to manipulate a PSObject[] instead of a PSObject even in the event that it only contains one parameter.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] to your commit messages if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pougetat
pougetat (pougetat) requested review from Francisco Gamino (Francisco-Gamino) and Aditya Patwardhan (adityapatwardhan) as code owners January 26, 2019 21:51
@pougetat
pougetat (pougetat) force-pushed the fix-gethelp branch 4 times, most recently from 0e64b17 to 1d42ef2 Compare January 26, 2019 23:10
vexx32
Rain Sallow (/u/ta11ow) (vexx32) reviewed Jan 26, 2019
View reviewed changes
Comment thread src/System.Management.Automation/help/BaseCommandHelpInfo.cs Outdated

@vexx32 Rain Sallow (/u/ta11ow) (vexx32) Jan 26, 2019

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for 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...

Suggested change
paramAsPSObjArray != null ? paramAsPSObjArray : param,
paramPSObjArray == null ? paramPSObjArray : new[] { (PSObject)prmts.Properties["parameter"].Value },

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pougetat pougetat (pougetat) Jan 26, 2019

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vexx32 Rain Sallow (/u/ta11ow) (vexx32) Jan 27, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pougetat pougetat (pougetat) Jan 27, 2019

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

vexx32 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@vexx32 Rain Sallow (/u/ta11ow) (vexx32) Jan 27, 2019

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pougetat
pougetat (pougetat) force-pushed the fix-gethelp branch 4 times, most recently from 40bca28 to 0c67a87 Compare January 27, 2019 10:49
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) requested changes Jan 28, 2019
View reviewed changes
Comment thread src/System.Management.Automation/help/BaseCommandHelpInfo.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/engine/Help/HelpSystem.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/engine/Help/HelpSystem.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/engine/Help/HelpSystem.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/engine/Help/HelpSystem.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) self-assigned this Jan 28, 2019
@throwaway774
Fix Get-Help issue wih -Parameter option PowerShell#8697
de39c19
@pougetat
pougetat (pougetat) force-pushed the fix-gethelp branch from 0c67a87 to de39c19 Compare January 29, 2019 08:08
adityapatwardhan
Aditya Patwardhan (adityapatwardhan) approved these changes Jan 29, 2019
View reviewed changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) changed the title Fix Get-Help issue wih -Parameter option #8697 Fix Get-Help PSTypeName issue with -Parameter when only one parameter is declared Jan 30, 2019
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit 1d7651f into PowerShell:master Jan 30, 2019
@adityapatwardhan

Aditya Patwardhan (adityapatwardhan) commented Jan 30, 2019

Copy link
Copy Markdown
Member

pougetat (@pougetat) Thank you for your contribution!

pougetat reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 30, 2019
@pougetat
pougetat (pougetat) deleted the fix-gethelp branch April 8, 2019 06:23
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
pougetat @adityapatwardhan
Fix Get-Help PSTypeName issue with -Parameter when only one par…
e39f009
…ameter is declared (PowerShell#8754)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adityapatwardhan Aditya Patwardhan (adityapatwardhan) adityapatwardhan approved these changes
@Francisco-Gamino Francisco Gamino (Francisco-Gamino) Awaiting requested review from Francisco-Gamino
+1 more reviewer
@vexx32 Rain Sallow (/u/ta11ow) (vexx32) vexx32 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adityapatwardhan Aditya Patwardhan (adityapatwardhan)

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Get-Help -Parameter does not correctly set PSTypeName when one parameter is declared

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@pougetat @adityapatwardhan @vexx32 @iSazonov @throwaway774
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.