Skip to content

Conversation

HowardWolosky
Copy link
Contributor

Description

ConvertFrom-Json defaults numbers to different types depending on the PowerShell version.

PS5 defaults numbers to [Int32] while PS7 defaults numbers to [Int64], but both versions default to [Int32] in a [PSCustomObject].

Due to this, if you had a number config value saved, on PS7 it would be ignored and the default value would be used because the expected and actual types wouldn't match.

I've updated Resolve-PropertyValue to have equivalence logic for number types to avoid this issue.

Issues Fixed

n/a

References

n/a

Checklist

  • You actually ran the code that you just wrote, especially if you did just "one last quick change".
  • Comment-based help added/updated, including examples.
  • Static analysis is reporting back clean.
  • New/changed code adheres to our coding guidelines.
  • New/changed code continues to support the pipeline.
  • Changes to the manifest file follow the manifest guidance.
  • Unit tests were added/updated and are all passing. See testing guidelines. This includes making sure that all pipeline input variations have been covered.
  • Relevant usage examples have been added/updated in USAGE.md.
  • If desired, ensure your name is added to our Contributors list

ConvertFrom-Json defaults numbers to different types depending on
the PowerShell version.

PS5 defaults numbers to [Int32] while PS7 defaults numbers to [int64],
but both versions default to [Int32] in [PSCustomObjects].

Due to this, if you had a number config value saved, on PS7 it would be
ignored and the default value would be used because the expected and
actual types wouldn't match.

I've updated `Resolve-PropertyValue` to have equivalence logic for
number types to avoid this issue.
@HowardWolosky HowardWolosky added the bug This relates to a bug in the existing module. label Jul 9, 2020
@HowardWolosky
Copy link
Contributor Author

/azp run PowerShellForGitHub-CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@HowardWolosky HowardWolosky merged commit 683187a into microsoft:master Jul 10, 2020
@HowardWolosky HowardWolosky deleted the configNumbers branch July 10, 2020 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This relates to a bug in the existing module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant