Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format single item arrays as an array #2330

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Mar 28, 2023

PR Summary

Single item arrays are currently printed as single item without type-specific formatting because Is-Value expands them. Arrays with a single string or bool (more types?) will not be properly formatted.

# Current
> Format-Nicely @('a')
a

# After
> Format-Nicely @('a')                
@('a')

Related #2329

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@fflaten
Copy link
Collaborator Author

fflaten commented Mar 28, 2023

Submitting as a draft because I'm not sure if this might format items in an unexpected array somewhere because Pester wraps input internally. The broken test is fixed by #2329

Alternative: Do extra checks inside if(Is-Value ...) { } to call Format-Bool, Format-String etc.

Thoughts @nohwnd ?

@fflaten fflaten force-pushed the format-singlevaluecollection branch from d6b32b2 to e177a7d Compare May 12, 2023 22:11
@nohwnd
Copy link
Member

nohwnd commented Apr 12, 2024

I will have a look will need to touch the formatting code for assert as well.

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.

None yet

2 participants