Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to support dynamic parameters #483

Open
jdhitsolutions opened this issue May 13, 2020 · 6 comments
Open

Need to support dynamic parameters #483

jdhitsolutions opened this issue May 13, 2020 · 6 comments
Labels
Issue-Enhancement Issue is more of a feature request than a bug

Comments

@jdhitsolutions
Copy link

jdhitsolutions commented May 13, 2020

I found an old issue from 2017 that is related to this and from what I can tell nothing has happened since. Platyps doesn't appear to detect dynamic parameters that are defined in a PowerShell function. Which on one hand I can understand. If I have a function that can work in both Windows PowerShell and PowerShell 7, but define a dynamic parameter that only works in PS7, I won't see the dynamic parameter when I create the markdown in Windows PowerShell.

What's the best way to display help or create provider aware help for that matter. To reference the old issue, if I define a dynamic parameter that relies on the CERT provider, how should I create help?

@JustinGrote
Copy link

JustinGrote commented Jun 16, 2020

Just came across this with the MSTerminalSettings 2.0. Is there a workaround perhaps, or am I going to have to develop my own?

EDIT: I think this is blocked on PowerShell/PowerShell#6694 and more specifically PowerShell/PowerShell#3006 because if you just run get-help against a module, the same problem happens.

@jdhitsolutions did you try removing all comment based help and see if the dynamic parameters show up?

@JustinGrote
Copy link

If I have time I can attempt a sufficient workaround that I POC'd:

  1. Use AST to strip all the comments (I have ready-to-go code for this from my module compiler) and run PlatyPS against that module to get the dynamic information
  2. Run it again against the "regular" module with comment based help
  3. Merge the two into a new PSObject (this will probably take some work for edge cases especially modifying existing documentation)
  4. Continue as normal to convert to MAML

@jdhitsolutions
Copy link
Author

@JustinGrote I rarely write comment-based help anymore. I'm running Platyps against clean code. I think a big part of the challenge how the dynamic parameter(s) are being detected.

@JustinGrote
Copy link

@jdhitsolutions It literally does this:

  1. Gets the module
  2. Pulls the commands from the module
  3. loops through and runs get-help on each module command
  4. Converts the resultant object to MAML

So if it doesn't show up in Get-Help it won't show up in PlatyPS.

@asears
Copy link

asears commented Aug 18, 2020

Is this related to the issue we arehaving with the following syntax?

In the synopsis header

.PARAMETER 
  None

fails with following unhandled error:

Get-Command : The term 'Remove-LegacySupportHybridWorker.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\andrew.sears\Documents\WindowsPowerShell\Modules\platyPS\0.14.0\platyPS.psm1:2360 char:17
+         return (Get-Command $help.Name -Syntax) -eq ($help.Synopsis)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Remove-LegacySupportHybridWorker.ps1:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
.PARAMETER None

succeeds.

If not I will open another issue.

Get-Help returns a minimal result rather than the full synopsis for this syntax, so this trivial issue with parameter name being on a different line probably needs to be bubbled up to Powershell team too.

@theJasonHelmick
Copy link
Collaborator

@jdhitsolutions - thank you for this issue. The nature of dynamic parameters with PlatyPS requires that the provider be loaded or that PlatyPS check the providers. This is outside the design of PlatyPS and we will need to further investigate. I've added to our future backlog for post 2.0 release review.

@sdwheeler sdwheeler added Feature Request Issue-Enhancement Issue is more of a feature request than a bug and removed Feature Request labels Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement Issue is more of a feature request than a bug
Projects
None yet
Development

No branches or pull requests

5 participants