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

Clarify that not providing a -ParameterName argument implies the -Native switch #11248

Closed
mklement0 opened this issue Jul 10, 2024 · 1 comment · Fixed by #11249
Closed

Clarify that not providing a -ParameterName argument implies the -Native switch #11248

mklement0 opened this issue Jul 10, 2024 · 1 comment · Fixed by #11249
Assignees
Labels
area-core Area - Microsoft.PowerShell.Core module issue-doc-bug Issue - error in documentation

Comments

@mklement0
Copy link
Contributor

Type of issue

Missing information

Feedback

Register-ArgumentCompleter's parameter design is unusual in that a switch (-Native) is situationally implied (whereas switch parameters normally require opt-in).

It's worth mentioning that when a -ParameterName argument is (possibly accidentally) not supplied, -Native is implied, which fundamentally changes the arguments passed to the -ScriptBlock argument and can therefore cause confusion; see:

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Core/Register-ArgumentCompleter.md

Author

@sdwheeler

Document Id

e471c27f-aa83-321f-541f-878442638e1b

@ar-std
Copy link

ar-std commented Jul 10, 2024

I would additionally consider to remove the switch -Native entirely as

Register-ArgumentCompleter
        -CommandName <String[]>
        -ScriptBlock <ScriptBlock>
        [<CommonParameters>]

... , nonetheless, already leads to the script block parameters as described for -Native. And if providing $ParameterName in

Register-ArgumentCompleter
        [-CommandName <String[]>]
        -ParameterName <String>
        -ScriptBlock <ScriptBlock>
        [<CommonParameters>]

..., -Native is not allowed.

@michaeltlombardi michaeltlombardi added area-core Area - Microsoft.PowerShell.Core module issue-doc-bug Issue - error in documentation and removed needs-triage Waiting - Needs triage labels Jul 10, 2024
michaeltlombardi added a commit to michaeltlombardi/PowerShell-Docs that referenced this issue Jul 10, 2024
…ter` parameters

Prior to this change, the `Register-ArgumentCompleter` reference didn't indicate that
specifying the **CommandName** parameter without the **ParameterName** or **Native**
parameters causes the command to behave as if the user specified the `-Native` switch.

This change:

- Clarifies that users should always specify the **ParameterName** parameter when
  registering an argument completer for a PowerShell command.
- Resolves MicrosoftDocs#11248
- Fixes AB#281953
michaeltlombardi added a commit to michaeltlombardi/PowerShell-Docs that referenced this issue Jul 10, 2024
…ter` parameters

Prior to this change, the `Register-ArgumentCompleter` reference didn't indicate that
specifying the **CommandName** parameter without the **ParameterName** or **Native**
parameters causes the command to behave as if the user specified the `-Native` switch.

This change:

- Clarifies that users should always specify the **ParameterName** parameter when
  registering an argument completer for a PowerShell command.
- Resolves MicrosoftDocs#11248
- Fixes AB#281953
@Taojunshen Taojunshen mentioned this issue Jul 10, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core Area - Microsoft.PowerShell.Core module issue-doc-bug Issue - error in documentation
Projects
None yet
3 participants