Skip to content

Preserve alias corrections for executable commands in fallback DSC ASTs - #2284

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

Christoph Bergmeister (bergmeister) merged 2 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 configuration ASTs could misclassify executable commands as DSC resource declarations, suppressing expected Get- corrections.

  • Executable contexts: Treat subexpressions and array expressions as boundaries; reject redirected commands and candidates outside standalone statement blocks.
  • Regression coverage: Check these cases while preserving resource detection inside conditional bodies.
Write-Output $(Verb Argument {})
Verb Argument {} > $null
if (Verb Argument {}) {}
return Verb Argument {}

These executable commands retain their Get-Verb corrections; resource-shaped commands inside conditional bodies remain recognized.

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code issues as per review comments Preserve alias corrections for executable commands in fallback DSC ASTs 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

No active review issues are blocking approval.

No open issues 🎉

What changed in this PR

This PR refines the alias rule’s fallback DSC resource detection so executable commands retain their expected Get- corrections.

Changes:

  • Treat subexpressions and array expressions as executable-context boundaries.
  • Exclude redirected commands and commands outside standalone statement blocks from resource detection.
  • Add regression coverage while preserving resource recognition inside conditional bodies.
File Description
Tests/​Rules/​AvoidUsingAlias.tests.ps1 Tests executable-command corrections and conditional-body resource detection in fallback ASTs.
Rules/​AvoidAlias.cs Tightens checks that distinguish DSC resource declarations from executable commands.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 17:27
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 26f025c 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 18:20
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