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

Add #Requires snippets #1974

Merged

Conversation

travisclagrone
Copy link
Contributor

@travisclagrone travisclagrone commented May 22, 2019

PR Summary

Adds snippets for the various script requirement directive parameterizations. Also includes convenience snippets for some of the more specific common-but-verbose parameter sets.

Adds the following snippets (listed by name, not prefix):

  • "Requires Assembly"
  • "Requires Assembly Path"
  • "Requires Assembly Version"
  • "Requires Module"
  • "Requires Module RequiredVersion"
  • "Requires Module Version"
  • "Requires PSEdition"
  • "Requires PSSnapin"
  • "Requires PSSnapin Version"
  • "Requires RunAsAdministrator"
  • "Requires ShellId"
  • "Requires Version"

Notes:

  • The About Requires help documents the -Modules parameter only in the plural, but the ScriptRequirements Class API documentation demonstrates that that parameter can also be used in the singular (i.e. -Module), as these snippets use it.

  • The -Assembly parameter is not documented in the About Requires help, but is supported as demonstrated by the ScriptRequirements Class API documentation.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • NA PR has tests
  • This PR is ready to merge and is not work in progress

@SydneyhSmith
Copy link
Collaborator

These look good to be included in the extension!

@travisclagrone travisclagrone force-pushed the add-requires-directive-snippets branch from 572df38 to 8d8390f Compare July 2, 2019 01:19
@travisclagrone travisclagrone deleted the add-requires-directive-snippets branch July 2, 2019 01:37
@TylerLeonhardt
Copy link
Member

@travis-c-lagrone we'd still like to include these in the extension itself, if you're interested!

@travisclagrone travisclagrone restored the add-requires-directive-snippets branch July 2, 2019 19:20
travisclagrone added a commit to travisclagrone/vscode-powershell that referenced this pull request Jul 2, 2019
@travisclagrone
Copy link
Contributor Author

@TylerLeonhardt I am still interested! My apologies for the confusion. For some reason I thought it had already been merged, and so I was just cleaning up. It is restored and reopened now.

@travisclagrone travisclagrone reopened this Jul 2, 2019
@travisclagrone travisclagrone force-pushed the add-requires-directive-snippets branch 2 times, most recently from 35e763a to 244c902 Compare July 3, 2019 19:57
@travisclagrone
Copy link
Contributor Author

travisclagrone commented Jul 3, 2019

The force push from 35e763a to 244c902 amends corrupted formatting in the former commit message.

@rkeithhill
Copy link
Contributor

rkeithhill commented Jul 3, 2019

Seems like this would be better implemented via auto-completion? I know PowerShell doesn't support completion of #requires syntax but maybe it should. And if it doesn't there is nothing to say that this extension couldn't provide auto-completion for #requires.

@travisclagrone
Copy link
Contributor Author

@SydneyhSmith and @TylerLeonhardt, may I please have a new code review? I had to recreate the snippets after I had accidentally deleted my copy of the branch, but I did it slightly differently (I think better) this time around.

@travisclagrone
Copy link
Contributor Author

@rkeithhill

Seems like this would be better implemented via auto-completion? I know PowerShell doesn't support completion of #requires syntax but maybe it should. And if it doesn't there is nothing to say that this extension couldn't provide auto-completion.

I don't disagree with you there. However, unless you (or someone else) can implement PowerShell completion of the script requirement directive syntax anytime soon, I would argue that these snippets provide value in the indefinite meantime.

Adds the following snippets (listed by name, not prefix):
- Requires Assembly
- Requires Assembly Path
- Requires Assembly Version
- Requires Module
- Requires Module RequiredVersion
- Requires Module Version
- Requires PSEdition
- Requires PSSnapin
- Requires PSSnapin Version
- Requires RunAsAdministrator
- Requires ShellId
- Requires Version
@travisclagrone travisclagrone force-pushed the add-requires-directive-snippets branch from 244c902 to b34ab49 Compare July 4, 2019 23:30
@travisclagrone
Copy link
Contributor Author

The force push from 244c902 to b34ab49 is to correctly rebase recent changes from the master branch, particularly regarding associating the file "snippets/PowerShell.json" with the "JSON for Comments" language identifier.

@travisclagrone
Copy link
Contributor Author

@rkeithhill Now that "JSON with Comments" is supported for this snippets file, I added a comment noting that the "Requires *" snippets should be removed if-and-when the relevant intellisense is implemented.

@rjmholt rjmholt merged commit fbaf540 into PowerShell:master Jul 9, 2019
@travisclagrone travisclagrone deleted the add-requires-directive-snippets branch July 10, 2019 01:42
rjmholt pushed a commit to rjmholt/vscode-powershell that referenced this pull request Jul 24, 2019
* Add script requirement directive snippets

Adds the following snippets (listed by name, not prefix):
- Requires Assembly
- Requires Assembly Path
- Requires Assembly Version
- Requires Module
- Requires Module RequiredVersion
- Requires Module Version
- Requires PSEdition
- Requires PSSnapin
- Requires PSSnapin Version
- Requires RunAsAdministrator
- Requires ShellId
- Requires Version
rjmholt added a commit that referenced this pull request Jul 26, 2019
* Edit snippets to support $TM_SELECTED_TEXT (#1945)

Edit all-and-only applicable snippets to support $TM_SELECTED_TEXT,
where "applicable" is approximated by whether a snippet contains a
user-specified PowerShell expression, block, or body. Do not add,
remove, or otherwise change any placeholder number or name in order to
preserve backwards-compatibility.

Edit the following snippets (listed by name, not prefix):
- Class
- Constructor
- Method
- Enum
- Cmdlet
- Function-Advanced
- DSC Resource Provider (class-based)
- DSC Resource Provider (function-based)
- comment block
- do-until
- do-while
- while
- for
- for-reversed
- foreach
- function
- Function-Inline
- if
- elseif
- else
- switch
- try-catch
- try-catch-finally
- try-finally
- Workflow
- Workflow ForEachParallel
- Workflow InlineScript
- Workflow Parallel
- Workflow Sequence
- Region Block
- IfShouldProcess
- CalculatedProperty
- PesterDescribeContextIt
- PesterDescribeBlock
- PesterContextIt
- PesterContext
- PesterIt

* Add ArgumentCompleter snippets (#1946)

* Define snippet named 'ArgumentCompleterAttribute with ScriptBlock'

* Define snippet named 'IArgumentCompleter Class'

* Define snippet named 'ArgumentCompleterAttribute ScriptBlock'

* Add #Requires snippets (#1974)

* Add script requirement directive snippets

Adds the following snippets (listed by name, not prefix):
- Requires Assembly
- Requires Assembly Path
- Requires Assembly Version
- Requires Module
- Requires Module RequiredVersion
- Requires Module Version
- Requires PSEdition
- Requires PSSnapin
- Requires PSSnapin Version
- Requires RunAsAdministrator
- Requires ShellId
- Requires Version

* Fix node version detect logic to handle node v10 (#2025)

* #1019: Get format settings from document editor instead of global. (#2035)

* Update PSSA docs Url to point to master branch because master is now the default branch (#2037)

* add machine scope (#2039)

* add machine scope

* use a different setting for test and add user setting test

* remove isExecutable and remove powershell.developer.powerShellExePath

* Add param-block snippet (#2081)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants