Skip to content

Commit 67a57aa

Browse files
committed
Refine documentation structure and enhance clarity in copilot instructions
1 parent 4a69457 commit 67a57aa

File tree

1 file changed

+61
-22
lines changed

1 file changed

+61
-22
lines changed

.github/copilot-instructions.md

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,50 @@ Assume that the word "command" references to a public command, the word
44
"function" references to a private function, and the word "resource"
55
references a Desired State Configuration (DSC) class-based resource.
66

7+
## Public commands
8+
79
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,
911
these files shall always be placed in the folder source/Public.
1012

1113
Public commands may use private functions to move out logic that can be
1214
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
1521
shall always be placed in the folder source/Private.
1622

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
2451

2552
All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning
2653
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
3461
the variable $script:localizedData.
3562

3663
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
4373

4474
All tests should use the Pester framework and use Pester v5.0 syntax.
4575

4676
Never test, mock or use `Should -Invoke` for `Write-Verbose` and `Write-Debug`
4777
regardless of other instructions.
4878

79+
Parameter validation should not be tested in unit tests.
80+
4981
Test code should never be added outside of the `Describe` block.
5082

5183
Unit tests should be added for all public commands and private functions.
@@ -143,20 +175,21 @@ AfterAll {
143175
}
144176
```
145177

178+
## Integration tests
179+
146180
Integration tests should be added for all public commands. Integration must
147181
never mock any command but run the command in a real environment. The integration
148182
tests should be placed in the folder tests/Integration/Commands and the
149183
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
152186
edge cases and common use cases are tested. The integration tests should
153187
also be written to test the command in a real environment, using real
154188
resources and dependencies.
155189

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
160193

161194
```powershell
162195
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
@@ -183,4 +216,10 @@ BeforeDiscovery {
183216
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
184217
}
185218
}
219+
220+
BeforeAll {
221+
$script:dscModuleName = 'SqlServerDsc'
222+
223+
Import-Module -Name $script:dscModuleName
224+
}
186225
```

0 commit comments

Comments
 (0)