|
49 | 49 | "}"
|
50 | 50 | ]
|
51 | 51 | },
|
| 52 | + "Class Method": { |
| 53 | + "prefix": "class-method", |
| 54 | + "description": "Defines the actions that a class can perform. Methods may take parameters that provide input data. Methods can return output. Data returned by a method can be any defined data type. More: Get-Help about_Classes", |
| 55 | + "body": [ |
| 56 | + "[${1:void}] ${2:MethodName}($${3:OptionalParameters}) {", |
| 57 | + "\t${0:${TM_SELECTED_TEXT:<# Action to perform. You can use $$this to reference the current instance of this class #>}}", |
| 58 | + "}" |
| 59 | + ] |
| 60 | + }, |
| 61 | + // Pester is no longer bundled with PowerShell Core, but is available as a NuGet package. |
| 62 | + // "PesterContext": { |
| 63 | + // "prefix": "Context-Pester", |
| 64 | + // "description": "Pester - Context block", |
| 65 | + // "body": [ |
| 66 | + // "Context \"${1:ContextName}\" {", |
| 67 | + // "\t${0:$TM_SELECTED_TEXT}", |
| 68 | + // "}" |
| 69 | + // ] |
| 70 | + // }, |
| 71 | + // "PesterContextIt": { |
| 72 | + // "prefix": "Context-It-Pester", |
| 73 | + // "description": "Pester - Context block with nested It block", |
| 74 | + // "body": [ |
| 75 | + // "Context \"${1:ContextName}\" {", |
| 76 | + // "\tIt \"${2:ItName}\" {", |
| 77 | + // "\t\t${3:${TM_SELECTED_TEXT:Assertion}}", |
| 78 | + // "\t}$0", |
| 79 | + // "}" |
| 80 | + // ] |
| 81 | + // }, |
| 82 | + // "PesterDescribeBlock": { |
| 83 | + // "prefix": "Describe-Pester", |
| 84 | + // "description": "Pester Describe block", |
| 85 | + // "body": [ |
| 86 | + // "Describe \"${1:DescribeName}\" {", |
| 87 | + // "\t${0:TM_SELECTED_TEXT}", |
| 88 | + // "}" |
| 89 | + // ] |
| 90 | + // }, |
| 91 | + // "PesterDescribeContextIt": { |
| 92 | + // "prefix": "Describe-Context-It-Pester", |
| 93 | + // "description": "Pester Describe block with nested Context & It blocks", |
| 94 | + // "body": [ |
| 95 | + // "Describe \"${1:DescribeName}\" {", |
| 96 | + // "\tContext \"${2:ContextName}\" {", |
| 97 | + // "\t\tIt \"${3:ItName}\" {", |
| 98 | + // "\t\t\t${4:${TM_SELECTED_TEXT:Assertion}}", |
| 99 | + // "\t\t}$0", |
| 100 | + // "\t}", |
| 101 | + // "}" |
| 102 | + // ] |
| 103 | + // }, |
| 104 | + // "PesterIt": { |
| 105 | + // "prefix": "It-Pester", |
| 106 | + // "description": "Pester - It block", |
| 107 | + // "body": [ |
| 108 | + // "It \"${1:ItName}\" {", |
| 109 | + // "\t${2:${TM_SELECTED_TEXT:Assertion}}", |
| 110 | + // "}$0" |
| 111 | + // ] |
| 112 | + // }, |
| 113 | + "Class Property": { |
| 114 | + "prefix": "class-property", |
| 115 | + "description": "Properties are variables declared at class scope. A property may be of any built-in type or an instance of another class. Classes have no restriction in the number of properties they have. More: Get-Help about_Classes", |
| 116 | + "body": [ |
| 117 | + "[${1:propertyType}] $${0:PropertyName}" |
| 118 | + ] |
| 119 | + }, |
52 | 120 | "Comment Block": {
|
53 | 121 | "prefix": [
|
54 | 122 | "block-comment"
|
|
610 | 678 | "}"
|
611 | 679 | ]
|
612 | 680 | },
|
| 681 | + "Function: Suppress PSScriptAnalyzer Rule": { |
| 682 | + "prefix": [ |
| 683 | + "suppress-message-rule-function", |
| 684 | + "[SuppressMessageAttribute]" |
| 685 | + ], |
| 686 | + "description": "Suppress a PSScriptAnalyzer rule for a function. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
| 687 | + "body": [ |
| 688 | + "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(", |
| 689 | + "\t<#Category#>'${1:PSProvideDefaultParameterValue}', <#CheckId>\\$null, Scope='Function',", |
| 690 | + "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
| 691 | + ")]" |
| 692 | + ] |
| 693 | + }, |
613 | 694 | "Hashtable": {
|
614 | 695 | "prefix": "Hashtable",
|
615 | 696 | "description": "A key/value store that are very effecient for finding and retrieving data. More: Get-Help about_Hash_Tables",
|
|
619 | 700 | "}"
|
620 | 701 | ]
|
621 | 702 | },
|
| 703 | + "Here-String": { |
| 704 | + "prefix": [ |
| 705 | + "hs", |
| 706 | + "here-string" |
| 707 | + ], |
| 708 | + "description": "Escape all text but evaluate variables. More: Get-Help about_Quoting_Rules", |
| 709 | + "body": [ |
| 710 | + "@\"", |
| 711 | + "${0:TM_SELECTED_TEXT}", |
| 712 | + "\"@", |
| 713 | + "" |
| 714 | + ] |
| 715 | + }, |
| 716 | + "Here-String (Literal)": { |
| 717 | + "prefix": [ |
| 718 | + "hsl", |
| 719 | + "literal-here-string" |
| 720 | + ], |
| 721 | + "description": "Escape all text regardless. More: Get-Help about_Quoting_Rules", |
| 722 | + "body": [ |
| 723 | + "@'", |
| 724 | + "${0:TM_SELECTED_TEXT}", |
| 725 | + "'@", |
| 726 | + "" |
| 727 | + ] |
| 728 | + }, |
622 | 729 | "Hidden Property": {
|
623 | 730 | "prefix": "class-proph-hidden",
|
624 |
| - "description": "Useful for creating properties and methods within a class that you do not necessarily want other users of the class to see, or readily be able to edit. More: about_Hidden", |
| 731 | + "description": "Useful for creating properties and methods within a class that you do not necessarily want other users of the class to see, or readily be able to edit. More: Get-Help about_Hidden", |
625 | 732 | "body": [
|
626 | 733 | "hidden [${1:string}] $${0:PropertyName}"
|
627 | 734 | ]
|
|
665 | 772 | "}"
|
666 | 773 | ]
|
667 | 774 | },
|
668 |
| - "Method": { |
669 |
| - "prefix": "method", |
670 |
| - "description": "Class method definition snippet", |
671 |
| - "body": [ |
672 |
| - "[${1:void}] ${2:MethodName}($${3:OptionalParameters}) {", |
673 |
| - "\t${0:$TM_SELECTED_TEXT}", |
674 |
| - "}" |
675 |
| - ] |
676 |
| - }, |
677 | 775 | "ModuleManifest": {
|
678 | 776 | "prefix": "manifest",
|
679 | 777 | "description": "Basic skeleton for a PowerShell module manifest, complete with PowerShell Gallery metadata.",
|
|
835 | 933 | "$${3:ParameterName}$0"
|
836 | 934 | ]
|
837 | 935 | },
|
| 936 | + "Parameter: Suppress PSScriptAnalyzer Rule": { |
| 937 | + "prefix": [ |
| 938 | + "suppress-message-rule-parameter", |
| 939 | + "[SuppressMessageAttribute]" |
| 940 | + ], |
| 941 | + "description": "Suppress a PSScriptAnalyzer rule on a parameter. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
| 942 | + "body": [ |
| 943 | + "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}',", |
| 944 | + "\t<#ParameterName#>'${0:${TM_SELECTED_TEXT:ParamName}}", |
| 945 | + "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
| 946 | + ")]" |
| 947 | + ] |
| 948 | + }, |
838 | 949 | "Pipeline Function": {
|
839 | 950 | "prefix": "function-pipeline",
|
840 |
| - "description": "Basic function that accepts pipeline input \nReference: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines?view=powershell-7.2", |
| 951 | + "description": "Basic function that accepts pipeline input. More: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines?view=powershell-7.2", |
841 | 952 | "body": [
|
842 | 953 | "function $1 {",
|
843 | 954 | " [CmdletBinding()]",
|
|
851 | 962 | "}"
|
852 | 963 | ]
|
853 | 964 | },
|
854 |
| - // Pester is no longer bundled with PowerShell Core, but is available as a NuGet package. |
855 |
| - // "PesterContext": { |
856 |
| - // "prefix": "Context-Pester", |
857 |
| - // "description": "Pester - Context block", |
858 |
| - // "body": [ |
859 |
| - // "Context \"${1:ContextName}\" {", |
860 |
| - // "\t${0:$TM_SELECTED_TEXT}", |
861 |
| - // "}" |
862 |
| - // ] |
863 |
| - // }, |
864 |
| - // "PesterContextIt": { |
865 |
| - // "prefix": "Context-It-Pester", |
866 |
| - // "description": "Pester - Context block with nested It block", |
867 |
| - // "body": [ |
868 |
| - // "Context \"${1:ContextName}\" {", |
869 |
| - // "\tIt \"${2:ItName}\" {", |
870 |
| - // "\t\t${3:${TM_SELECTED_TEXT:Assertion}}", |
871 |
| - // "\t}$0", |
872 |
| - // "}" |
873 |
| - // ] |
874 |
| - // }, |
875 |
| - // "PesterDescribeBlock": { |
876 |
| - // "prefix": "Describe-Pester", |
877 |
| - // "description": "Pester Describe block", |
878 |
| - // "body": [ |
879 |
| - // "Describe \"${1:DescribeName}\" {", |
880 |
| - // "\t${0:TM_SELECTED_TEXT}", |
881 |
| - // "}" |
882 |
| - // ] |
883 |
| - // }, |
884 |
| - // "PesterDescribeContextIt": { |
885 |
| - // "prefix": "Describe-Context-It-Pester", |
886 |
| - // "description": "Pester Describe block with nested Context & It blocks", |
887 |
| - // "body": [ |
888 |
| - // "Describe \"${1:DescribeName}\" {", |
889 |
| - // "\tContext \"${2:ContextName}\" {", |
890 |
| - // "\t\tIt \"${3:ItName}\" {", |
891 |
| - // "\t\t\t${4:${TM_SELECTED_TEXT:Assertion}}", |
892 |
| - // "\t\t}$0", |
893 |
| - // "\t}", |
894 |
| - // "}" |
895 |
| - // ] |
896 |
| - // }, |
897 |
| - // "PesterIt": { |
898 |
| - // "prefix": "It-Pester", |
899 |
| - // "description": "Pester - It block", |
900 |
| - // "body": [ |
901 |
| - // "It \"${1:ItName}\" {", |
902 |
| - // "\t${2:${TM_SELECTED_TEXT:Assertion}}", |
903 |
| - // "}$0" |
904 |
| - // ] |
905 |
| - // }, |
906 |
| - "Property": { |
907 |
| - "prefix": "prop", |
908 |
| - "description": "Class property definition snippet", |
909 |
| - "body": [ |
910 |
| - "[${1:string}] $${0:PropertyName}" |
911 |
| - ] |
912 |
| - }, |
913 | 965 | "PSCustomObject": {
|
914 |
| - "prefix": "[PSCustomObject]", |
915 |
| - "description": "Creates a PSCustomObject", |
| 966 | + "prefix": [ |
| 967 | + "pscustomobject", |
| 968 | + "[PSCustomObject]" |
| 969 | + ], |
| 970 | + "description": "Create a custom object from a hashtable of properties. More: Get-Help about_PSCustomObject", |
916 | 971 | "body": [
|
917 | 972 | "[PSCustomObject]@{",
|
918 | 973 | "\t${1:Name} = ${2:Value}",
|
|
928 | 983 | "#endregion"
|
929 | 984 | ]
|
930 | 985 | },
|
931 |
| - "Suppress PSScriptAnalyzer Rule": { |
932 |
| - "prefix": "suppress-message-rule", |
933 |
| - "description": "Suppress a PSScriptAnalyzer rule. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
934 |
| - "body": [ |
935 |
| - "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(", |
936 |
| - "\t<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}',<#CheckId#>\\$null,", |
937 |
| - "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
938 |
| - ")]" |
939 |
| - ] |
940 |
| - }, |
941 |
| - "Suppress PSScriptAnalyzer Rule in Function": { |
942 |
| - "prefix": "suppress-message-rule-function", |
943 |
| - "description": "Suppress a PSScriptAnalyzer rule for a function. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
| 986 | + "Scope: Suppress PSScriptAnalyzer Rule": { |
| 987 | + "prefix": "suppress-message-rule-scope", |
| 988 | + "description": "Suppress a PSScriptAnaylzer rule based on a function/parameter/class/variable/object's name by setting the SuppressMessageAttribute's Target property to a regular expression or a glob pattern. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
944 | 989 | "body": [
|
945 | 990 | "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(",
|
946 |
| - "\t<#Category#>'${1:PSProvideDefaultParameterValue}', <#CheckId>\\$null, Scope='Function',", |
947 |
| - "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
| 991 | + "\t<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}', <#CheckId#>\\$null, Scope='Function',", |
| 992 | + "\tTarget='${1:${TM_SELECTED_TEXT:RegexOrGlobPatternToMatchName}}'", |
| 993 | + "\tJustification = '${0:Reason for suppressing}}'", |
948 | 994 | ")]"
|
949 | 995 | ]
|
950 | 996 | },
|
951 |
| - "Suppress PSScriptAnalyzer Rule on Parameter": { |
952 |
| - "prefix": "suppress-message-rule-parameter", |
953 |
| - "description": "Suppress a PSScriptAnalyzer rule on a parameter. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
| 997 | + "splat": { |
| 998 | + "prefix": "splat", |
| 999 | + "description": "Use a hashtable to capture the parameters of a function and then pass them to a function in a concise way. More: about_Splatting", |
954 | 1000 | "body": [
|
955 |
| - "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}',", |
956 |
| - "\t<#ParameterName#>'${0:${TM_SELECTED_TEXT:ParamName}}", |
957 |
| - "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
958 |
| - ")]" |
| 1001 | + "$${1/[^\\w]/_/}Params = @{", |
| 1002 | + "\t${2:Parameter} = ${0:Value}", |
| 1003 | + "}", |
| 1004 | + "${1:${TM_SELECTED_TEXT}} @${1/[^\\w]/_/}Params" |
959 | 1005 | ]
|
960 | 1006 | },
|
961 |
| - "Suppress PSScriptAnalyzer Rule on a specific Scope": { |
962 |
| - "prefix": "suppress-message-rule-scope", |
963 |
| - "description": "Suppress a PSScriptAnaylzer rule based on a function/parameter/class/variable/object's name by setting the SuppressMessageAttribute's Target property to a regular expression or a glob pattern. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
| 1007 | + "Suppress PSScriptAnalyzer Rule": { |
| 1008 | + "prefix": [ |
| 1009 | + "suppress-message-rule", |
| 1010 | + "[SuppressMessageAttribute]" |
| 1011 | + ], |
| 1012 | + "description": "Suppress a PSScriptAnalyzer rule. More: https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#suppressing-rules", |
964 | 1013 | "body": [
|
965 | 1014 | "[Diagnostics.CodeAnalysis.SuppressMessageAttribute(",
|
966 |
| - "\t<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}', <#CheckId#>\\$null, Scope='Function',", |
967 |
| - "\tTarget='${1:${TM_SELECTED_TEXT:RegexOrGlobPatternToMatchName}}'", |
968 |
| - "\tJustification = '${0:Reason for suppressing}}'", |
| 1015 | + "\t<#Category#>'${1:PSUseDeclaredVarsMoreThanAssignments}',<#CheckId#>\\$null,", |
| 1016 | + "\tJustification = '${0:${TM_SELECTED_TEXT:Reason for suppressing}}'", |
969 | 1017 | ")]"
|
970 | 1018 | ]
|
971 | 1019 | },
|
|
1027 | 1075 | },
|
1028 | 1076 | "while": {
|
1029 | 1077 | "prefix": "while",
|
1030 |
| - "description": "Repeatedly perform an action after verifying a condition is true first.", |
| 1078 | + "description": "Repeatedly perform an action after verifying a condition is true first. More: Get-Help about_While", |
1031 | 1079 | "body": [
|
1032 | 1080 | "while (${1:condition}) {",
|
1033 | 1081 | "\t${0:$TM_SELECTED_TEXT}",
|
1034 | 1082 | "}"
|
1035 | 1083 | ]
|
1036 |
| - }, |
1037 |
| - "splat": { |
1038 |
| - "prefix": "splat", |
1039 |
| - "description": "Use a hashtable to capture the parameters of a function and then pass them to a function in a concise way. More: about_Splatting", |
1040 |
| - "body": [ |
1041 |
| - "$${1/[^\\w]/_/}Params = @{", |
1042 |
| - "\t${2:Parameter} = ${0:Value}", |
1043 |
| - "}", |
1044 |
| - "${1:${TM_SELECTED_TEXT}} @${1/[^\\w]/_/}Params" |
1045 |
| - ] |
1046 |
| - }, |
1047 |
| - "Here-String": { |
1048 |
| - "prefix": [ |
1049 |
| - "hs", |
1050 |
| - "here-string" |
1051 |
| - ], |
1052 |
| - "body": [ |
1053 |
| - "@\"", |
1054 |
| - "${0:TM_SELECTED_TEXT}", |
1055 |
| - "\"@", |
1056 |
| - "" |
1057 |
| - ], |
1058 |
| - "description": "Escape all text but evaluate variables. More: Get-Help about_Quoting_Rules" |
1059 |
| - }, |
1060 |
| - "Here-String (Literal)": { |
1061 |
| - "prefix": [ |
1062 |
| - "hsl", |
1063 |
| - "literal-here-string" |
1064 |
| - ], |
1065 |
| - "body": [ |
1066 |
| - "@'", |
1067 |
| - "${0:TM_SELECTED_TEXT}", |
1068 |
| - "'@", |
1069 |
| - "" |
1070 |
| - ], |
1071 |
| - "description": "Escape all text regardless. More: Get-Help about_Quoting_Rules" |
1072 | 1084 | }
|
1073 | 1085 | }
|
0 commit comments