Skip to content

Preserve alias diagnostics for two-element DSC-shaped commands - #2295

Merged
Christoph Bergmeister (bergmeister) merged 3 commits into
copilot/fix-auto-correct-aliasesfrom
copilot/fix-code-for-review-comments
Oct 29, 2026
Merged

Christoph Bergmeister (bergmeister) merged 3 commits into
copilot/fix-auto-correct-aliasesfrom
copilot/fix-code-for-review-comments

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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"
}

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
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
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 29, 2026 14:53
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 9914f20 into copilot/fix-auto-correct-aliases Oct 29, 2026
8 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-for-review-comments branch October 29, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants