platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

PlatyPS cmdlets don't work with PSReadLine focused parameter help (ShowParameterHelp)

Open pewill opened this issue 4 months ago • 1 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest version
  • [x] Search the existing issues.

Steps to reproduce

When I try to get help for PlatyPS cmdlet parameters (like New-CommandInfo -CommandInfo and press ALT+h) it throws and error. Repro:

Update-Help -Module Microsoft.PowerShell.PlatyPS # make sure not to use the autogenerated help
New-CommandHelp -CommandInfo # press ALT+h when cursor is at the end of -CommandInfo parameter to trigger ShowParameterHelp function

I think it can be related to https://github.com/PowerShell/platyPS/issues/801 (if the PlatyPS help is generated with PlatyPS itself) since PSReadline expects a default value and it is typically set to None if it is not provided. https://github.com/PowerShell/PSReadLine/blob/ceaad10f3d49df1b62957cf282f15b5a2fb2017f/PSReadLine/DynamicHelp.cs#L238C14-L238C226

Expected behavior

The focused parameter help should be shown for the parameter

Actual behavior

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
PowerShell: 7.5.2
OS: Microsoft Windows 10.0.26100
BufferWidth: 120
BufferHeight: 30

Last 145 Keys:

 h e l p Spacebar n e w - c o m m a n d h Tab Enter
 n e w - c o m m a n d h e Tab Spacebar - Tab Spacebar Backspace Alt+h Escape Escape U p d a t e - H e l - Backspace p Spacebar - p l Tab Backspace Backspace Backspace - m o Tab Spacebar M i c r o s o f t . P o w e r S h e l l . P l a t Tab Enter
 h e l p RightArrow Enter
 n e w - c o m m a n d Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace n e w p Backspace - c o m m a n Tab Spacebar - Tab Alt+h

### Exception

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
   at CallSite.Target(Closure, CallSite, Object)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at Microsoft.PowerShell.PSConsoleReadLine.WriteParameterHelp(Object helpContent)
   at Microsoft.PowerShell.PSConsoleReadLine.WriteDynamicHelpContent(String commandName, String parameterName, Boolean isFullHelp)
   at Microsoft.PowerShell.PSConsoleReadLine.DynamicHelpImpl(Boolean isFullHelp)
   at Microsoft.PowerShell.PSConsoleReadLine.ShowParameterHelp(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Error details


Environment data

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.0.1

Visuals

No response

pewill avatar Aug 14 '25 06:08 pewill

This is partially a bug in PlatyPS and partially a bug in PSReadLine.

The PlatyPS issue needs further investigation.

@adityapatwardhan Compare the maml files in the attached ZIP. They were produced by the old and new versions of PlatyPS.

sdwheeler avatar Aug 19 '25 14:08 sdwheeler