Commit 4fe1d90
authored
🩹 [Docs]: Add suppressing output guidance to PowerShell style guidelines (#225)
The PowerShell style guidelines now include comprehensive guidance on
suppressing unwanted output from commands and methods. This addition
helps developers choose the most performant approach when they need to
discard function or method return values.
- Fixes #224
## Suppressing Output Section
A new section has been added to the PowerShell style guidelines
(`pwsh.instructions.md`) that provides clear guidance on:
- **Using `$null =` for best performance** - The recommended approach
for suppressing output from both cmdlets and .NET method calls
- **Using `[void]` as an alternative** - Another valid option
specifically for method calls that return values
- **Avoiding `| Out-Null`** - Explicitly noting that this approach has
significantly slower performance and should be avoided
The section includes practical examples showing both correct and
incorrect usage patterns, making it easy for developers to follow the
best practices.
## Performance Impact
This guidance is especially important in performance-critical code and
loops, where the overhead of `| Out-Null` can accumulate and cause
noticeable slowdowns. By using `$null =` or `[void]`, developers can
ensure their scripts run efficiently.1 parent 23e6f84 commit 4fe1d90
1 file changed
+30
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
518 | 548 | | |
519 | 549 | | |
520 | 550 | | |
| |||
0 commit comments