Skip to content

Reject invalid DSC resource-body pairings - #2286

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

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

Conversation

Copilot AI commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fallback DSC AST detection could pair executable commands with following blocks, suppressing expected Get- corrections when the block had redirections or a semicolon separated the statements.

  • Detection: Reject candidate blocks with redirections and sibling statements separated by a statement terminator.
  • Regression coverage: Verify both commands below retain their Get-ChildItem corrections.
{
    gci .
    {} > $null
    gci .; {}
}

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code according to review comments Reject invalid DSC resource-body pairings 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Updates DSC resource-body detection to avoid incorrectly pairing commands with subsequent script blocks when redirections or semicolon-separated statements are present, ensuring alias corrections still occur as expected.

Changes:

  • Reject candidate DSC “resource body” blocks when the candidate scriptblock expression has redirections.
  • Reject candidate DSC “resource body” blocks when a semicolon statement separator exists between the command and the following block.
  • Add regression test ensuring gci is still flagged/corrected in the reported edge cases.
File Description
Tests/​Rules/​AvoidUsingAlias.tests.ps1 Adds regression coverage for alias correction when adjacent blocks include redirections or are separated by semicolons.
Rules/​AvoidAlias.cs Tightens DSC AST fallback pairing logic by rejecting redirection-bearing blocks and semicolon-separated statements.

Review effort: Lite

Comment thread Rules/AvoidAlias.cs
Comment thread Rules/AvoidAlias.cs Outdated
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 remain for the fallback DSC resource-body detection changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

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