8000 ConvertFrom-Json: Unwrap Collections by default by danstur · Pull Request #10861 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@danstur
Copy link
Contributor
@danstur danstur commented Oct 21, 2019

PR Summary

Changes the default behavior of ConvertFrom-Json to follow the usual collection-unwrapping behavior. With this change ('[1,2]' | ConvertFrom-Json | Measure-Object).Count returns 2, instead of 1.

Provides a NoEnumerate switch similar to the Write-Output command to revert to the old behavior.

See issue #3424.

PR Context

Improves the user experience for the majority of people by changing ConvertFrom-Json's behavior to match the default behavior when dealing with collections. See for example this or this stackoverflow question for examples of people falling into this trap.

PR Checklist

@msftclas
Copy link
msftclas commented Oct 21, 2019

CLA assistant check
All CLA requirements met.

@rjmholt rjmholt added Breaking-Change breaking change that may affect users Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Oct 21, 2019
@iSazonov
Copy link
Collaborator

/cc @mklement0 Could you please review?

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Oct 22, 2019
@danstur
Copy link
Contributor Author
danstur commented Oct 24, 2019

Looked at the failing checks.

I'm not sure what mandatory parameter I'm supposed to be passing to ConvertFrom-Json in my tests.

I can change the documentation for the new parameter, I pretty much just copied it from the Write-Output cmdlet. Starting the sentence with "Get or sets" strikes me as awkward - any proposals for the text?

@mklement0
Copy link
Contributor

Everything now looks good to me - I'm also baffled by the two Codacy failures:

Cmdlet 'ConvertFrom-Json' may be used incorrectly. Please check that all mandatory parameters are supplied.

@SteveL-MSFT, since you seem to have set up Codacy, any ideas?

danstur pushed a commit to danstur/PowerShell-Docs that referenced this pull request Oct 24, 2019
Adds documentation for new parameter added with PowerShell/PowerShell#10861
@vexx32
Copy link
Collaborator
vexx32 commented Oct 24, 2019

Codacy is probably using existing stable versions of PS as reference. Since we're adding a parameter here, we can expect it to complain.

@mklement0
Copy link
Contributor

Thanks, @vexx32.

It's curious that instead of complaining about an unrecognized parameter it admonishes checking for mandatory ones - but perhaps it's a catch-all message for any unrecognized syntax (can this be customized?).

I haven't participated much in code reviews, so I'm asking innocently:

  • Will this not keep happening?

  • What's the protocol when it does happen? Can it be ignored and overridden by those with merge privileges?

@vexx32
Copy link
Collaborator
vexx32 commented Oct 24, 2019

This particular warning seems to be a new thing, I think? I haven't seen it much until now, at least.

Codacy issues have always been considered fairly low-priority and not blocking, though -- we have Codacy completely ignoring C# at the moment as its linter isn't entirely up to speed and the newer C# features confuse it a lot.

Its PS linting is fairly good, but it's not mandatory to fix all issues -- some of them, like this one, we simply can't, after all! :slight_smile:

It's generally up to the folks reviewing whether we ask authors to fix Codacy issues, from what I've seen. 🙂

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 30, 2019
@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Breaking-Change breaking change that may affect users Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Oct 30, 2019
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 9, 2019
Changes the default behavior of ConvertFrom-Json to follow the usual
collection-unwrapping behavior.
With this change `('[1,2]' | ConvertFrom-Json | Measure-Object).Count`
returns 2, instead of 1.

Provides a NoEnumerate switch similar to the Write-Output command to
revert to the old behavior.

See issue PowerShell#3424.
@SteveL-MSFT SteveL-MSFT added the Breaking-Change breaking change that may affect users label Nov 15, 2019
@anmenaga
8000
Copy link

@anmenaga anmenaga merged commit 9e02343 into PowerShell:master Nov 15, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.6 milestone Nov 15, 2019
@iSazonov
Copy link
Collaborator

@danstur Thanks for your contribution.

sdwheeler pushed a commit to MicrosoftDocs/PowerShell-Docs that referenced this pull request Nov 18, 2019
@ghost
Copy link
ghost commented Nov 21, 2019

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

0