Skip to content

Preserve alias diagnostics after executable commands in DSC ASTs - #2293

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

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

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The fallback DSC AST heuristic could mistake a known executable command followed by a standalone block for a resource declaration, suppressing alias diagnostics inside the block.

  • Detection: Apply the existing alias and command-resolution checks to following-line resource candidates, while retaining the Node exception.
  • Example: In this layout, Verb should still receive the Get-Verb correction:
    {
        Write-Output value
        {
            Verb Argument {}
        }
    }

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code based on review comments Preserve alias diagnostics after executable commands in DSC ASTs Oct 29, 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

There are no active review issues for the DSC fallback heuristic update and its alias-diagnostic regression test.

No open issues 🎉

What changed in this PR

This PR refines the DSC AST fallback heuristic so executable commands followed by standalone blocks do not suppress alias diagnostics inside those blocks.

Changes:

  • Apply alias and command-resolution checks to following-line resource candidates while preserving the Node exception.
  • Add a regression test verifying that Verb still receives the Get-Verb correction after Write-Output.
File Description
Tests/​Rules/​AvoidUsingAlias.tests.ps1 Tests alias diagnostics inside a standalone block following an executable command.
Rules/​AvoidAlias.cs Filters following-line DSC resource candidates using alias and command resolution.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 29, 2026 11:23
@bergmeister
Christoph Bergmeister (bergmeister) merged commit e51412d into copilot/fix-auto-correct-aliases Oct 29, 2026
8 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-comments-review-thread-2270 branch October 29, 2026 11:23
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