From e926da7b49608b0416713d0695847556a8f82e25 Mon Sep 17 00:00:00 2001 From: Brett Miller Date: Mon, 18 Feb 2019 08:54:25 +0000 Subject: [PATCH 1/6] Added Calculated Property and ShouldProcess Snippets --- snippets/PowerShell.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 787d47801d..75c6548bf0 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -952,5 +952,21 @@ "#endregion" ], "description": "Region Block for organizing and folding of your code" + }, + "IfShouldProcess": { + "prefix": "IfShouldProcess", + "body": [ + "if ($$PSCmdlet.ShouldProcess(\"${1:The Item}\" , \"${2:The Change}\")) {", + "\t# Place Code here", + "}" + ], + "description": "Creates an if should process" + }, + "CalculatedProperty": { + "prefix": "Calculated-Property", + "body": [ + "@{name='${1:PropertyName}';expression={\\$_.${2:PropertyValue}}}$0" + ], + "description": "Creates a PSCustomObject" } } From 3dfc33ed5e5aed775b758f640467ab6955e460f8 Mon Sep 17 00:00:00 2001 From: Brett Miller Date: Mon, 18 Feb 2019 09:06:31 +0000 Subject: [PATCH 2/6] Added Pester Describe, Context & It Snippets --- snippets/PowerShell.json | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 75c6548bf0..5f6e7f6b70 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -968,5 +968,56 @@ "@{name='${1:PropertyName}';expression={\\$_.${2:PropertyValue}}}$0" ], "description": "Creates a PSCustomObject" + }, + "PesterDescribeContextIt": { + "prefix": "Describe-Context-It-Pester", + "body": [ + "Describe \"${1:DescribeName}\" {", + "\tContext \"${2:ContextName}\" {", + "\t\tIt \"${3:ItName}\" {", + "\t\t\t${4:Assertion}", + "\t\t}$0", + "\t}", + "}" + ], + "description": "Pester Describe block with nested Context & It blocks" + }, + "PesterDescribeBlock": { + "prefix": "Describe-Pester", + "body": [ + "Describe \"${1:DescribeName}\" {", + "\t$0", + "}" + ], + "description": "Pester Describe block" + }, + "PesterContextIt": { + "prefix": "Context-It-Pester", + "body": [ + "Context \"${1:ContextName}\" {", + "\tIt \"${2:ItName}\" {", + "\t\t${3:Assertion}", + "\t}$0", + "}" + ], + "description": "Pester - Context block with nested It block" + }, + "PesterContext": { + "prefix": "Context-Pester", + "body": [ + "Context \"${1:ContextName}\" {", + "\t$0", + "}" + ], + "description": "Pester - Context block" + }, + "PesterIt": { + "prefix": "It-Pester", + "body": [ + "It \"${1:ItName}\" {", + "\t${2:Assertion}", + "}$0" + ], + "description": "Pester - It block" } } From d817ec04c396050a8854f92be44d6cb505d99ada Mon Sep 17 00:00:00 2001 From: Brett Miller Date: Mon, 18 Feb 2019 09:34:05 +0000 Subject: [PATCH 3/6] Placeholder Rename for calc property snippet --- snippets/PowerShell.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 5f6e7f6b70..28734fa8ae 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -956,11 +956,11 @@ "IfShouldProcess": { "prefix": "IfShouldProcess", "body": [ - "if ($$PSCmdlet.ShouldProcess(\"${1:The Item}\" , \"${2:The Change}\")) {", - "\t# Place Code here", + "if (\\$PSCmdlet.ShouldProcess(\"${1:Target}\", \"${2:Operation}\")) {", + "\t$0", "}" ], - "description": "Creates an if should process" + "description": "Adds ShouldProcess block" }, "CalculatedProperty": { "prefix": "Calculated-Property", From 551f11d7e422cc428de3682e6a7e7520d39edaac Mon Sep 17 00:00:00 2001 From: Brett Miller Date: Mon, 18 Feb 2019 21:13:07 +0000 Subject: [PATCH 4/6] Fixed description for Calculated Property --- snippets/PowerShell.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 28734fa8ae..47aae204f2 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -960,14 +960,14 @@ "\t$0", "}" ], - "description": "Adds ShouldProcess block" + "description": "Creates ShouldProcess block" }, "CalculatedProperty": { "prefix": "Calculated-Property", "body": [ "@{name='${1:PropertyName}';expression={\\$_.${2:PropertyValue}}}$0" ], - "description": "Creates a PSCustomObject" + "description": "Creates a Calculated Property" }, "PesterDescribeContextIt": { "prefix": "Describe-Context-It-Pester", From ba6e53b1e9543b8c41bcb9eb61572a279fa6fd5b Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Thu, 21 Feb 2019 15:23:43 +0000 Subject: [PATCH 5/6] Calc Property Enhanced Description Co-Authored-By: brettmillerb --- snippets/PowerShell.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 47aae204f2..4ca8094158 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -967,7 +967,7 @@ "body": [ "@{name='${1:PropertyName}';expression={\\$_.${2:PropertyValue}}}$0" ], - "description": "Creates a Calculated Property" + "description": "Creates a Calculated Property typically used with Select-Object." }, "PesterDescribeContextIt": { "prefix": "Describe-Context-It-Pester", From e2fe871c33d86903cd40283b6db1fbf439d5c38e Mon Sep 17 00:00:00 2001 From: Brett Miller Date: Mon, 4 Mar 2019 10:58:31 +0000 Subject: [PATCH 6/6] Amended the tab stop for calc-property to include . --- snippets/PowerShell.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index 47aae204f2..67986c2839 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -965,7 +965,7 @@ "CalculatedProperty": { "prefix": "Calculated-Property", "body": [ - "@{name='${1:PropertyName}';expression={\\$_.${2:PropertyValue}}}$0" + "@{name='${1:PropertyName}';expression={${2:\\$_.PropertyValue}}}$0" ], "description": "Creates a Calculated Property" },