Repository navigation
Add regression tests for attribute scriptblock indentation ([Attr({ … })]) - #2263
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Conversation
2 tasks done
….. })]) Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix double indent issue for attribute bodies in scripting
Add regression tests for attribute scriptblock indentation (Oct 27, 2026
[Attr({ … })])
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the added attribute scriptblock indentation regression tests.
No open issues 🎉
What changed in this PR
Adds regression coverage for attribute scriptblock indentation reported in #2216, protecting the existing fix from #2173 without changing rule behavior.
Changes:
- Tests correction of double-indented bodies and closing delimiters in top-level
[ArgumentCompleter({ … })]. - Tests the same correction for
[ValidateScript({ … })]nested inside a function’sparam()block.
| File | Description |
|---|---|
| Tests/Rules/UseConsistentIndentation.tests.ps1 | Adds two attribute scriptblock cases to the multiple-openers indentation tests. |
Review effort: Balanced
Christoph Bergmeister (bergmeister)
marked this pull request as ready for review
October 28, 2026 11:36
Christoph Bergmeister (bergmeister)
requested a review
from a team
as a code owner
October 28, 2026 11:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In 1.25.0,
PSUseConsistentIndentationdouble-indents the body of an attribute that opens a scriptblock, such as[ArgumentCompleter({ … })]or[ValidateScript({ … })]. The body gets two levels and the closing})]gets one.Root cause / status
(and the{on the opener line each add an indentation level.main, though no release includes it yet. When a(is followed on the same line by an opener that stays unclosed, the(skips its increment and its matching)skips the decrement. The check doesn't care what comes before the(, so[Attr({is covered too.Changes
Tests only, no rule changes. Two cases are added to the "When multiple openers appear on the same line" context in
Tests/Rules/UseConsistentIndentation.tests.ps1:[ArgumentCompleter({ … })], using the issue's example[ValidateScript({ … })]nested inside a function'sparam()blockBoth start from double-indented input and check that it is corrected. They fail against 1.25.0, so a regression would be caught.
[Attr({ … })]) #2216