Skip to content

Commit 1bb539d

Browse files
committed
Update PowerShell guidelines to prefer New-Exception and New-ErrorRecord commands over direct .NET object instantiation
1 parent 6a595c8 commit 1bb539d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

.github/instructions/dsc-community-style-guidelines-powershell.instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ function Get-Something
201201
- Return a single, consistent object type per function
202202
- return `$null` for no objects/non-terminating errors
203203
- Use `::new()` static method instead of `New-Object` for .NET types, e.g `[System.Management.Automation.ErrorRecord]::new()`
204+
- Instead of `[System.Exception]::new(...)`, use `New-Exception` command
205+
- Instead of `[System.Management.Automation.ErrorRecord]::new(...)`, use `New-ErrorRecord` command
204206

205207
### Security & Safety
206208

0 commit comments

Comments
 (0)