← 输入框|github.com|刷新
Skip to content

Reject ampersand-separated DSC resource bodies - #2288

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

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

Conversation

Copilot AI commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

In fallback configuration ASTs, a command followed by & and a standalone block could be mistaken for a DSC resource declaration, suppressing the command’s alias diagnostic.

  • Detection: Treat & as a statement separator alongside ; when checking adjacent command and block statements.
  • Regression: Cover the background-job terminator case:
{
    gci . &
    {}
}

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code based on review comments Reject ampersand-separated DSC resource bodies Oct 28, 2026

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

The alias-rule separator change has no active review issues blocking approval.

No open issues 🎉

What changed in this PR

This PR updates AvoidUsingAlias so commands separated from a following script block by & are not incorrectly treated as DSC resource declarations.

Changes:

  • Extends the statement-separator check to recognize both ; and &.
  • Adds regression coverage for gci . & followed by {}, expecting an alias diagnostic.
File Description
Tests/​Rules/​AvoidUsingAlias.tests.ps1 Adds the ampersand-separated case and updates the expected diagnostic count.
Rules/​AvoidAlias.cs Renames the separator helper and adds ampersand detection.

Review effort: Balanced

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

No active review issues are identified for the fallback DSC resource detection change.

No open issues 🎉

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 21:59
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 6dcd4a4 into copilot/fix-auto-correct-aliases Oct 28, 2026
8 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-comments-in-review-thread branch October 28, 2026 22:15
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