You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+61-22Lines changed: 61 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,23 +4,50 @@ Assume that the word "command" references to a public command, the word
4
4
"function" references to a private function, and the word "resource"
5
5
references a Desired State Configuration (DSC) class-based resource.
6
6
7
+
## Public commands
8
+
7
9
PowerShell commands that should be public should always have its separate
8
-
script file and the the command name as the file name with the .ps1 extension,
10
+
script file and the command name as the file name with the .ps1 extension,
9
11
these files shall always be placed in the folder source/Public.
10
12
11
13
Public commands may use private functions to move out logic that can be
12
14
reused by other public commands, so move out any logic that can be deemed
13
-
reusable. Private functions should always have its separate script file and
14
-
the the function name as the file name with the .ps1 extension, these files
15
+
reusable.
16
+
17
+
## Private functions
18
+
19
+
Private functions should always have its separate script file and
20
+
the function name as the file name with the .ps1 extension, these files
15
21
shall always be placed in the folder source/Private.
16
22
17
-
Comment-based help should be added to each public command and private functions.
18
-
The comment-based help should always be before the function-statement. Each
19
-
comment-based help keyword should be indented with 4 spaces and each keywords
20
-
text should be indented 8 spaces. The text for keyword .DESCRIPTION should
21
-
be descriptive and must have a length greater than 40 characters. A comment-based
22
-
help must have at least one example, but preferably more examples to showcase
23
-
all possible parameter sets and different parameter combinations.
23
+
## Desired State Configuration (DSC) class-based resource
24
+
25
+
Desired State Configuration (DSC) class-based resource should always have
26
+
its separate script file and the resource class name as the file name with
27
+
the .ps1 extension, these files shall always be placed in the folder
28
+
source/Classes.
29
+
30
+
## Comment-based help
31
+
32
+
Comment-based help should always be before the function-statement for each
33
+
public command and private function, and before the class-statement for each
34
+
class-based resource. Comment-based help should always be in the format of
35
+
a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION,
36
+
.PARAMETER, .EXAMPLE, and .NOTES.
37
+
38
+
Each comment-based help keyword should be indented with 4 spaces and each
39
+
keyword's text should be indented 8 spaces.
40
+
41
+
The text for keyword .DESCRIPTION should be descriptive and must have a
42
+
length greater than 40 characters. The .SYNOPSIS keyword text should be
43
+
a short description of the public command, private function, or class-based
44
+
resource.
45
+
46
+
A comment-based help must have at least one example, but preferably more
47
+
examples to showcase all possible parameter sets and different parameter
48
+
combinations.
49
+
50
+
## Localization
24
51
25
52
All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning
26
53
and other error messages in public commands and private functions should be
@@ -34,18 +61,23 @@ Always assume that all localized string keys have already been assigned to
34
61
the variable $script:localizedData.
35
62
36
63
For class-based resource you should always add a localized strings in a
37
-
separate file the folder source\en-US. The strings file for For class-based
38
-
resource should be named using the resource's name and suffixed with `.strings.psd1`.
39
-
Localized string key names should always never be prefixed with anything but
40
-
use underscore as word separator. Always assume that all localized string
41
-
keys for a class-based resource already have been assigned to the variable
42
-
`$this.localizedData`.
64
+
separate file the folder source\en-US. The strings file for a class-based
65
+
resource should be named to exactly match the resource class name with the
66
+
suffix `.strings.psd1`.
67
+
Localized string key names should never be prefixed with anything but
68
+
use underscore as word separator if key name has more than one word. Always
69
+
assume that all localized string keys for a class-based resource already
70
+
have been assigned to the variable `$this.localizedData`.
71
+
72
+
## Unit tests
43
73
44
74
All tests should use the Pester framework and use Pester v5.0 syntax.
45
75
46
76
Never test, mock or use `Should -Invoke` for `Write-Verbose` and `Write-Debug`
47
77
regardless of other instructions.
48
78
79
+
Parameter validation should not be tested in unit tests.
80
+
49
81
Test code should never be added outside of the `Describe` block.
50
82
51
83
Unit tests should be added for all public commands and private functions.
@@ -143,20 +175,21 @@ AfterAll {
143
175
}
144
176
```
145
177
178
+
## Integration tests
179
+
146
180
Integration tests should be added for all public commands. Integration must
147
181
never mock any command but run the command in a real environment. The integration
148
182
tests should be placed in the folder tests/Integration/Commands and the
149
183
integration tests should be named after the public command they are testing,
150
-
but should have the suffix .Integration.Tests.ps1. The integration tests should be
151
-
written to cover all possible scenarios and code paths, ensuring that both
184
+
but should have the suffix .Integration.Tests.ps1. The integration tests should
185
+
be written to cover all possible scenarios and code paths, ensuring that both
152
186
edge cases and common use cases are tested. The integration tests should
153
187
also be written to test the command in a real environment, using real
154
188
resources and dependencies.
155
189
156
-
The module being tested should not be imported in the integration tests.
157
-
All integration tests should should use this code block prior to the `Describe`
158
-
block which will set up the test environment and will make sure the correct
159
-
module is available for testing:
190
+
All integration tests must use the below code block prior to the first
191
+
`Describe`-block. The following code will set up the integration test
192
+
environment and it will make sure the module being tested is available
160
193
161
194
```powershell
162
195
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
@@ -183,4 +216,10 @@ BeforeDiscovery {
183
216
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
0 commit comments