GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow user to force the default implicit formatting to use `AutoSize` by daxian-dbw · Pull Request #28018 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

Allow user to force the default implicit formatting to use AutoSize.

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. A test was added to make the formatting for those 2 views are streamed.

This allows PowerShell to generate less verbose output when used by an agent. It also makes PowerShell works better with small-window terminal.

image

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed: The property $PSStyle.AutoSizeDefaultFormatting is added to allow user to force the default implicit formatting to use AutoSize for Table and Wide views MicrosoftDocs/PowerShell-Docs#13289
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kborowinski reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Dongbo Wang (daxian-dbw) added 2 commits September 15, 2026 15:51
@daxian-dbw
Allow user to force the default implicit formatting to use 'AutoSize'
c314ba5
@daxian-dbw
Add tests
be1b097
Copilot AI lite review requested due to automatic review settings September 16, 2026 01:06
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from a team as a code owner September 16, 2026 01:06
@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 16, 2026
@azure-pipelines

azure-pipelines Bot commented Sep 16, 2026

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Dongbo Wang (daxian-dbw) September 16, 2026 01:07
View session
Copilot AI reviewed Sep 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical formatting defects and missing regression coverage must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds $PSStyle.AutoSizeDefaultFormatting to enable AutoSize for implicit table and wide formatting.

Changes:

  • Adds the new $PSStyle setting.
  • Applies it during default formatting.
  • Adds formatting tests.
File summaries
File Review findings
test/powershell/engine/Formatting/PSStyle.Tests.ps1 Moderate (3 votes): Add coverage for implicit wide views and untyped objects. Moderate (1 vote): Restore the original process-wide setting in cleanup rather than hard-coding $false.
src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs Critical (3 votes): Preserve null parameters during shape inference for objects without default views. Critical (3 votes): Apply the override only to selected Table or Wide views to avoid buffering List and Complex output.
src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs Nit (1 vote): Include AutoSizeDefaultFormatting in the default $PSStyle formatter view.
Review details

Suppressed comments (2)

src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs:647

  • The default PSStyle view is an explicit ListControl that enumerates the top-level settings (PowerShellCore_format_ps1xml.cs:2139-2212), but it has no entry for AutoSizeDefaultFormatting. As a result, $PSStyle and $PSStyle | Format-List hide this new user-facing setting; add it to the generated default formatter view.
        public bool AutoSizeDefaultFormatting { get; set; }

test/powershell/engine/Formatting/PSStyle.Tests.ps1:624

  • The cleanup hard-codes $false instead of restoring the value present when the test started. Because PSStyle.Instance is process-wide and the surrounding tests save and restore settings (for example, lines 143-153), this can leak state to later tests and makes the test depend on an initially disabled feature. Save the original value, establish a false baseline before capturing $defaultOutput, and restore the original in finally.
            $PSStyle.AutoSizeDefaultFormatting = $false
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/powershell/engine/Formatting/PSStyle.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Dongbo Wang (daxian-dbw) added 2 commits September 16, 2026 09:24
@daxian-dbw
Fix the test
05af986
@daxian-dbw
Keep the streaming rendering behavior for List and Complex views
4ace497
@daxian-dbw
Dongbo Wang (daxian-dbw) requested a lite review from Copilot September 16, 2026 19:15
Copilot started reviewing on behalf of Dongbo Wang (daxian-dbw) September 16, 2026 19:16
View session
Copilot AI reviewed Sep 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Fix autosizing for inferred views and update the user-facing documentation/checklist.

Review details

Suppressed comments (2)

src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs:647

  • This adds a new public $PSStyle setting that users must discover and configure, while the PR checklist marks “User-facing changes” as Not Applicable. Please update the user-facing PSStyle documentation (or file the required documentation issue) and correct the checklist before merging.
        public bool AutoSizeDefaultFormatting { get; set; }

src/System.Management.Automation/FormatAndOutput/format-default/format-default.cs:33

  • The no-default-view branch in FormatViewManager.Initialize() still calls SelectViewGeneratorFromProperties(..., null), so this parameters object is discarded for inferred views. As a result, $PSStyle.AutoSizeDefaultFormatting = $true has no effect for an untyped object that is inferred as a table (for example, a [pscustomobject] with four or fewer properties), even though the feature promises to autosize the chosen table/wide view. Preserve null for shape inference, then apply the autosize flag to the resulting Table/Wide generator, and add a regression case for this path.
                var parameters = new FormattingCommandLineParameters { autosize = true };
                ((InnerFormatShapeCommand)this.implementation).SetCommandLineParameters(parameters);
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw Dongbo Wang (daxian-dbw) added the Backport-7.6.x-Consider label Sep 16, 2026
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Mark this PR 7.6-consider because this could be potentially required by agent to reduce the output verbosity from shell invocation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SeeminglyScience
Patrick Meinecke (SeeminglyScience) approved these changes Sep 17, 2026
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 2179219 into PowerShell:master Sep 17, 2026
53 of 58 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the auto-size-format branch September 17, 2026 21:27
@daxian-dbw Dongbo Wang (daxian-dbw) mentioned this pull request Sep 17, 2026
The property $PSStyle.AutoSizeDefaultFormatting is added to allow user to force the default implicit formatting to use AutoSize for Table and Wide views MicrosoftDocs/PowerShell-Docs#13289
Closed
2 tasks done
@daxian-dbw Dongbo Wang (daxian-dbw) added Backport-7.6.x-Approved and removed Backport-7.6.x-Consider labels Sep 24, 2026
@daxian-dbw Dongbo Wang (daxian-dbw) mentioned this pull request Sep 24, 2026
[release/v7.6.7] Allow user to force the default implicit formatting to use AutoSize #28096
Merged
3 of 9 tasks
@daxian-dbw Dongbo Wang (daxian-dbw) added Backport-7.6.x-Migrated Backport-7.6.x-Done and removed Backport-7.6.x-Approved Backport-7.6.x-Migrated labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@SeeminglyScience Patrick Meinecke (SeeminglyScience) SeeminglyScience approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Backport-7.6.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@daxian-dbw @SeeminglyScience
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.