Optimize formatting for template strings and numbers#2866
Draft
fflaten wants to merge 8 commits into
Draft
Conversation
fflaten
commented
Jul 13, 2026
Comment on lines
+180
to
+181
| # Limit recursion to simple arrays and hashtable to avoid hangs and complex test names/paths. | ||
| Format-Nicely2 -Value $Value -MaxDepth 1 |
Collaborator
Author
There was a problem hiding this comment.
This will still print a massive multi-line name for something like (Get-Command Invoke-Pester), but at least it doesn't hang. Questions:
- Should we special case
CommandInfoto just return the name like v5? Or let it be so the author will identify a bad practice (not referencing the name property) and fix it. - Should tests names expand arrays/dictionaries etc in general?
- Should tests names allow multi-line at all? Messy console output. Trim or run through
[Pester.Formatter]::EscapeControlChars()?
fflaten
commented
Jul 14, 2026
|
|
||
| function Is-IntegralNumber ($Value) { | ||
| # Note: Using int16/uint16 as short/ushort names doesn't exist in PS 5.1 | ||
| $Value -is [int] -or $Value -is [long] -or $Value -is [int16] -or $Value -is [sbyte] -or $Value -is [uint] -or $Value -is [ulong] -or $Value -is [uint16] -or $Value -is [byte] |
Collaborator
Author
There was a problem hiding this comment.
Use .NET names. Some C# names are missing in 5.1. PowerShell/PowerShell@8f4b66a
8e5120e to
b224e8e
Compare
fflaten
commented
Jul 14, 2026
|
|
||
| function Is-DecimalNumber ($Value) { | ||
| $Value -is [float] -or $Value -is [single] -or $Value -is [double] -or $Value -is [decimal] | ||
| $Value -is [Single] -or $Value -is [Double] -or $Value -is [Decimal] |
Collaborator
Author
There was a problem hiding this comment.
Just cosmetic to get consistent naming in code and tests <Type.Name> for both PS 5.1 and 7+
b224e8e to
a510080
Compare
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.
PR Summary
Restricts template strings to one level of object recursion in formatting to avoid hangs on large complex objects.
To address the issue above, this PR also:
-MaxDepthinstead of increasing-Depthwith hard limit. Easier to restrict something a max 1 level than start at depth 9.Format-Numbers*for integers and not just decimals. Integers was formatted as ValueType, requring-MaxDepth 2for formatting simple arrays.[char]vs[string]etc, but not fixed for now.Fix #2865
PR Checklist
Create Pull Requestto mark it as a draft. PR can be markedReady for reviewwhen it's ready.