-
Notifications
You must be signed in to change notification settings - Fork 510
Add param block snippet #2080
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
Comments
Should probably have something like this... [CmdletBinding(DefaultParameterSetName = 'Default', SupportsShouldProcess = $false)]
param(
[Parameter(
Position = 0,
Mandatory = $false,
ValueFromPipeline = $false,
ValueFromPipelineByPropertyName = $false,
ParameterSetName = 'Default'
)]
[object]
$Parameter
) Maybe with some inline comments that properties not needed / set to $false can be omitted if not used. |
I think there's a difference between a "teaching" style snippet and a "productivity" snippet. The above, as a productivity snippet, wouldn't work for me because I'd end up deleting more stuff than I would have typed in the first place. For me, this would be a productivity snippet:
|
Hm, that's a very good point! Yeah definitely err on the side of productivity. |
FWIW I do think there is value in having "teaching" style snippets. They just need to be easily distinguished somehow between normal productivity snippets. That's why we have snippets that are prefixed with |
It might be nice to give the user the CHOICE of a comma, or maybe we should just leave the cursor at the right end of the variable name? |
Something like this: Note where the
|
I’d approve that PR 😄 |
Well, let's see how I did... |
Hi team, might I suggest, that by presenting me with potential options of what I can populate, I can learn how to use the snippet and what it represents. Otherwise I get confused as to why i can't tab/shift tab between the fillable parts? Would certainly like a url to a man page to "teach the snippet" in the description somewhere. I just ended up deleting and typing more than I would have typed if I memorized the param block? On the other hand, we don't create param blocks often. Still I would really love a fillable snippet (great for teaching new comers to Powershell) |
@malcolmardalon are you referring to snippets in general or this specific snippet? |
This snippet exists now, so I'll close this. However, feel free to continue the discussion. |
I'm not sure how much of this the PowerShell extension is responsible for, vs VSCode itself, but if we can work out which is which we can see what can be done where |
Summary of the new feature
On my stream with Scott Hanselman, he wasn't sure on how to write a param block because we have snippets for individual parameters, not param blocks.
I'd be nice to have a snippet of a param block, with a parameter inside.
Proposed technical implementation details (optional)
Take the current
parameter
snippet, and wrap it in a param block and call it theparam-block
snippet.The text was updated successfully, but these errors were encountered: