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

[release/v7.6.7] Allow user to force the default implicit formatting to use AutoSize - #28096

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:release/v7.6.7from
daxian-dbw:backport/release/v7.6.7/28018-2179219c8
Sep 24, 2026
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:release/v7.6.7from
daxian-dbw:backport/release/v7.6.7/28018-2179219c8

Conversation

@daxian-dbw

Copy link
Copy Markdown
Member

Backport of #28018 to release/v7.6.7

Triggered by Dongbo Wang (@daxian-dbw) on behalf of Dongbo Wang (@daxian-dbw)

Original CL Label: CL-General

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

Adds a new $PSStyle.AutoSizeDefaultFormatting setting. When set to $true, PowerShell's default implicit formatting (via Out-Default) will enforce AutoSize for table/wide views, matching Format-Table -AutoSize/Format-Wide -AutoSize behavior. This lets users get less verbose, better-fitting output in small terminal windows or when consumed by an agent, without needing to explicitly pipe to Format-Table/Format-Wide.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Original PR added a test verifying that List and Complex view formatting remain streamed (not buffered) even with AutoSizeDefaultFormatting enabled. Backport verified by confirming the cherry-pick applied cleanly with no conflicts on release/v7.6.7.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk: adds new opt-in formatting behavior gated behind a new $PSStyle property that defaults to off, so existing behavior is unchanged unless a user explicitly opts in. List and Complex views remain streamed (unbuffered), limiting the scope of the change.

…PowerShell#28018)

When `$PSStyle.AutoSizeDefaultFormatting = $true`, the default implicit formatting applied by PowerShell (via `Out-Default`) will enforce `AutoSize` when the chosen formatting view is `table` or `wide`, similar to running `Format-Table -AutoSize` and `Format-Wide -AutoSize` explicitly. The `List` and `Complex` views formatting won't be buffered though -- they will continue to be streamed.

This allows PowerShell to generate less verbose output when used by an agent. It also makes PowerShell works better with small-window terminal.
Copilot AI lite review requested due to automatic review settings September 24, 2026 21:28
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Copilot review overview

🟡 Changes recommended

The fallback path drops formatting parameters, preventing AutoSize for objects without registered format views.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Backports opt-in $PSStyle.AutoSizeDefaultFormatting support for implicit table and wide formatting while preserving streaming for list and complex views.

Changes:

  • Adds the new PSStyle setting and default display property.
  • Applies AutoSize during default formatting.
  • Adds formatting and streaming tests.
File Summary
test/​powershell/​engine/​Formatting/​PSStyle.Tests.ps1 Tests the new setting and formatting behavior.
src/​System.Management.Automation/​FormatAndOutput/​format-default/​format-default.cs Applies the AutoSize override; the fallback path requires correction.
src/​System.Management.Automation/​FormatAndOutput/​DefaultFormatters/​PowerShellCore_format_ps1xml.cs Displays the new PSStyle property.
src/​System.Management.Automation/​FormatAndOutput/​common/​PSStyle.cs Defines the new setting.
src/​System.Management.Automation/​FormatAndOutput/​common/​FormatViewGenerator.cs Restricts AutoSize to table and wide views.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 4bb1dc6 into PowerShell:release/v7.6.7 Sep 24, 2026
36 checks passed
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the backport/release/v7.6.7/28018-2179219c8 branch September 24, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants