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

Prevent ConvertTo-SmarterObject from flattening arrays #56

Merged
merged 6 commits into from
Nov 30, 2018

Conversation

HowardWolosky
Copy link
Member

  • Ensure that ConvertTo-SmarterObject does not cause any side-effects on InputObject
  • Ensure that ConvertTo-SmarterObject does not flatten any arrays
  • Switched all calls of ConvertTo-Json to not use pipelining in order to avoid PowerShell's
    array-flattening logic when piping the InputObject in, as opposed to when passing it as a parameter.
  • Ensured that we do best-effort Date conversion in ConvertTo-SmarterObject (a failed date conversion
    should never cause an exception/failure).
  • Used a workaround described in [Pester's Wiki](# https://github.com/pester/Pester/wiki/Testing-different-module-types)
    to force the module to be a Script Module instead of a Manifest Module so that Mock and
    InModuleScope (which lets you test private methods) work.
  • Added UT's for ConvertTo-SmarterObject core scenarios.

Resolves PowerShell#55: ConvertTo-SmarterObject is flattening arrays

Thanks to @danbelcher-MSFT for the assist on this one.

HowardWolosky and others added 6 commits November 29, 2018 03:20
* Ensure that `ConvertTo-SmarterObject` does not cause any side-effects on `InputObject`
* Ensure that `ConvertTo-SmarterObject` does not flatten any arrays
* Switched all calls to `ConvertTo-Json` to not use pipelining in order to avoid PowerShell's
  array-flattening logic when piping the InputObject in, as opposed to when passing it as a parameter.
* Ensured that we do best-effort Date conversion in `ConvertTo-SmarterObject` (a failed date conversion
  should never cause an exception/failure).
* Used a workaround described in [Pester's Wiki](# https://github.com/pester/Pester/wiki/Testing-different-module-types)
  to force the module to be a `Script Module` instead of a `Manifest Module` so that `Mock` and
  `InModuleScope` (which lets you test private methods) work.
* Added UT's for `ConvertTo-SmarterObject` core scenarios.

Resolves microsoft#55: ConvertTo-SmarterObject is flattening arrays

NOTE: Two tests still failing (legitimately).  Still a work in progress.
Consistently use System.Collections.IList in ConvertTo-SmarterObject
@HowardWolosky HowardWolosky merged commit 6cf344f into microsoft:master Nov 30, 2018
@HowardWolosky HowardWolosky deleted the smarterObjectFix branch November 30, 2018 19:26
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.

1 participant