Skip to content

fix: normalize object properties in ConvertTo-ClikaeJsonArray for PS … - #32

Open
chodaict wants to merge 1 commit into
mainfrom
fix/powershell-5.1-json-serialization
Open

fix: normalize object properties in ConvertTo-ClikaeJsonArray for PS …#32
chodaict wants to merge 1 commit into
mainfrom
fix/powershell-5.1-json-serialization

Conversation

@chodaict

Copy link
Copy Markdown
Contributor

…5.1 compatibility

Fixes PowerShell 5.1 Pester test failures in Get-ClikaeProfile -Json.

PS 5.1's ConvertTo-Json exhibits inconsistent behavior when serializing objects created from ordered hashtables, particularly when those objects have multiple properties. Under .NET Framework, property enumeration can become incomplete or reordered.

Solution: Use Select-Object * to normalize the PSCustomObject before serialization. This forces re-enumeration of all properties consistently across PS 5.1 (.NET Framework) and PS 7+ (.NET Core).

Resolves #31: "PowerShell module: Get-ClikaeProfile -Json fails Pester on Windows PowerShell 5.1 (passes on pwsh 7)"

What & why

Checklist

  • Ran the repo's checks locally (see the README's Development section — e.g. scripts/test.sh, an npm/make target) and they're green
  • Matched the surrounding code style; ran the formatter/linter if the repo has one
  • No documentation of features that aren't shipped and verified
  • One focused concern — split unrelated changes into separate PRs

…5.1 compatibility

Fixes PowerShell 5.1 Pester test failures in Get-ClikaeProfile -Json.

PS 5.1's ConvertTo-Json exhibits inconsistent behavior when serializing
objects created from ordered hashtables, particularly when those objects
have multiple properties. Under .NET Framework, property enumeration can
become incomplete or reordered.

Solution: Use Select-Object * to normalize the PSCustomObject before
serialization. This forces re-enumeration of all properties consistently
across PS 5.1 (.NET Framework) and PS 7+ (.NET Core).

Resolves #31: "PowerShell module: Get-ClikaeProfile -Json fails Pester 
on Windows PowerShell 5.1 (passes on pwsh 7)"
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.

PowerShell module: Get-ClikaeProfile -Json fails Pester on Windows PowerShell 5.1 (passes on pwsh 7)

1 participant