From 8140ceecac3d122ff491cc8db5fcea1122747eaf Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Tue, 2 Jul 2019 14:27:58 -0500 Subject: [PATCH 1/4] Empty commit to reopen the accidentally-closed PR #1974 From b34ab49e7bae5a0e0e6ef679c68742fded70292d Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Wed, 3 Jul 2019 14:54:43 -0500 Subject: [PATCH 2/4] 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 --- snippets/PowerShell.json | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 2716e42b6d..1a1d3f2c11 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1082,5 +1082,65 @@ "}" ], "description": "IArgumentCompleter implementation class definition" + }, + "Requires Assembly": { + "prefix": "requires-assembly", + "body": "#Requires -Assembly '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'", + "description": "Requires an assembly (by name) in order to execute the containing script file." + }, + "Requires Assembly Path": { + "prefix": "requires-assembly-path", + "body": "#Requires -Assembly ${0:${TM_SELECTED_TEXT:path/to/assembly.dll}}", + "description": "Requires an assembly (by relative or absolute path) in order to execute the containing script file." + }, + "Requires Assembly Version": { + "prefix": "requires-assembly-version", + "body": "#Requires -Assembly '${1:${TM_SELECTED_TEXT:fully-qualified-name}}, Version=${2:1.0.0.0}'", + "description": "Requires an assembly (by name and minimum version) in order to execute the containing script file." + }, + "Requires Module": { + "prefix": "requires-module", + "body": "#Requires -Module ${0:${TM_SELECTED_TEXT:fully-qualified-name}}", + "description": "Requires a module (by name) in order to execute the containing script file." + }, + "Requires Module RequiredVersion": { + "prefix": "requires-module-required-version", + "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; ModuleVersion = '${2:minimum-acceptable-version}' }", + "description": "Requires a module (by name and minimum version) in order to execute the containing script file." + }, + "Requires Module Version": { + "prefix": "requires-module-version", + "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; RequiredVersion = '${2:exact-required-version}' }", + "description": "Requires a module (by name and exact version) in order to execute the containing script file." + }, + "Requires PSEdition": { + "prefix": "requires-ps-edition", + "body": "#Requires -PSEdition ${1|Core,Desktop|}", + "description": "Requires a specific edition of PowerShell in order to execute the containing script file." + }, + "Requires PSSnapin": { + "prefix": "requires-ps-snapin", + "body": "#Requires -PSSnapin ${0:${TM_SELECTED_TEXT:fully-qualified-name}}", + "description": "Requires a PowerShell snap-in (by name) in order to execute the containing script file." + }, + "Requires PSSnapin Version": { + "prefix": "requires-ps-snapin-version", + "body": "#Requires -PSSnapin ${1:${TM_SELECTED_TEXT:fully-qualified-name}} -Version ${2:minimum-acceptable-version}", + "description": "Requires a PowerShell snap-in (by name and minimum version) in order to execute the containing script file." + }, + "Requires RunAsAdministrator": { + "prefix": "requires-run-as-administrator", + "body": "#Requires -RunAsAdministrator", + "description": "Requires elevated user rights in order to execute the containing script file. Ignored on non-Windows systems. On Windows systems, it requires that the PowerShell session in which the containing script file is run must have been started with elevated user rights (\"Run as Administrator\")." + }, + "Requires ShellId": { + "prefix": "requires-shell-id", + "body": "#Requires -ShellId ${0:${TM_SELECTED_TEXT:shell-id}}", + "description": "Requires a specific shell id in order to execute the containing script file. The current shell id may be determined by querying the $ShellId automatic variable." + }, + "Requires Version": { + "prefix": "requires-version", + "body": "#Requires -Version ${0:${TM_SELECTED_TEXT:minimum-acceptable-version}}", + "description": "Requires a minimum version of PowerShell in order to execute the containing script file." } } From 7546e2a4924b875fafb534c4bd001b243047297d Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Thu, 4 Jul 2019 18:35:04 -0500 Subject: [PATCH 3/4] Correct mix-up between the snippets named "Required Module RequiredVersion" and "Requires Module Version" --- snippets/PowerShell.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 1a1d3f2c11..8c652c3746 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1105,13 +1105,13 @@ }, "Requires Module RequiredVersion": { "prefix": "requires-module-required-version", - "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; ModuleVersion = '${2:minimum-acceptable-version}' }", - "description": "Requires a module (by name and minimum version) in order to execute the containing script file." + "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; RequiredVersion = '${2:exact-required-version}' }", + "description": "Requires a module (by name and exact version) in order to execute the containing script file." }, "Requires Module Version": { "prefix": "requires-module-version", - "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; RequiredVersion = '${2:exact-required-version}' }", - "description": "Requires a module (by name and exact version) in order to execute the containing script file." + "body": "#Requires -Module @{ ModuleName = '${1:${TM_SELECTED_TEXT:fully-qualified-name}}'; ModuleVersion = '${2:minimum-acceptable-version}' }", + "description": "Requires a module (by name and minimum version) in order to execute the containing script file." }, "Requires PSEdition": { "prefix": "requires-ps-edition", From cd8d22a4b8f35f5d4a274a295b97e132823224f3 Mon Sep 17 00:00:00 2001 From: "Travis C. LaGrone" <22419287+travis-c-lagrone@users.noreply.github.com> Date: Thu, 4 Jul 2019 18:40:57 -0500 Subject: [PATCH 4/4] Comment to remove the "Requires *" snippets if-and-when the relevant intellisense is implemented --- snippets/PowerShell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 8c652c3746..1fdc437d70 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1,3 +1,4 @@ +// The "Requires *" snippets should be removed if-and-when intellisense is implemented for the script requirement directive syntax. { "ModuleManifest": { "prefix": "manifest",