GeezerVison is showing github.com — Preserve alias diagnostics for two-element DSC-shaped commands by Copilot · Pull Request #2295 · PowerShell/PSScriptAnalyzer
Conversation
Copilot
AI
commented
Oct 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
A two-element command followed by a next-line block could be mistaken for a DSC resource declaration, suppressing its alias diagnostic. This made the gci correction depend on brace placement.
- Rule behavior: Remove the two-element exception so explicit aliases still receive diagnostics.
- Regression coverage: Verify the next-line block case recommends
Get-ChildItem.
gci ResourceAliasExample
{
Name = "Example"
}
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
changed the title
[WIP] Fix the code for review comments in pull request 2270
Preserve alias diagnostics for two-element DSC-shaped commands
Oct 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
There are no active review issues for the change that makes alias diagnostics consistent across brace placement.
No open issues 🎉
What changed in this PR
This PR makes alias diagnostics consistent across brace placement by preserving warnings for two-element commands that resemble DSC resource declarations.
Changes:
- Remove the two-element exception when the command name resolves to an alias.
- Update regression assertions to expect the
gci diagnostic and its Get-ChildItem correction, with consistent counts across PowerShell versions.
| File |
Description |
| Tests/Rules/AvoidUsingAlias.tests.ps1 |
Update diagnostic counts and verify the gci correction. |
| Rules/AvoidAlias.cs |
Preserve diagnostics for explicit aliases in DSC-shaped commands. |
Review effort: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.