Skip to content

Add default formatting for System.Text.Rune - #1

Open
Ankith-B wants to merge 2 commits into
masterfrom
rune-formatting
Open

Ankith-B wants to merge 2 commits into
masterfrom
rune-formatting

Conversation

@Ankith-B

@Ankith-B Ankith-B commented Sep 6, 2026

Copy link
Copy Markdown
Owner

PR Summary

Adds a default table view for System.Text.Rune so it displays the character
alongside its Unicode code point, instead of a property dump.

Before:

PS> [Text.Rune]65

IsAscii             : True
IsBmp               : True
Plane               : 0
Utf16SequenceLength : 1
Utf8SequenceLength  : 1
Value               : 65

After:

PS> [Text.Rune]65

Rune
----
A (U+0041)

PR Context

Fixes PowerShell#27595.

Rune has no default view, so it falls back to listing its properties. None
of them show the character itself, which makes the output unhelpful for the
type's main purpose — you cannot tell that 65 is A or that 128512 is an
emoji without decoding by hand. [char]65 already displays as A, so this
brings Rune in line.

Implemented as a TableControl view in DotNetTypes_format_ps1xml.cs,
following the existing pattern used for other simple value types such as
System.Guid. Uses a script-block column because the display string is
computed from ToString() and Value rather than read from a single
property.

Note this changes rendered output for Rune, so anything parsing the current
property-list rendering would see different text.

Tests added in test/powershell/engine/Formatting/Rune.Tests.ps1 covering an
ASCII rune and a non-BMP rune.

Note

AI assistance was used in preparing this change.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge.
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • Make sure you've added a new test if existing tests do not effectively test the code changed

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.

Prettily display System.Text.Rune instance

1 participant