-
Notifications
You must be signed in to change notification settings - Fork 8k
ConvertFrom-Json: Ignore comments inside array literals (#14553) #26050
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
Conversation
e0f3c79 to
637295e
Compare
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertFrom-Json.Tests.ps1
Outdated
Show resolved
Hide resolved
637295e to
49175d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
@MatejKafka |
|
/azp run PowerShell-CI-linux-packaging, PowerShell-Windows-Packaging-CI |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one style comment.
| It 'Ignores comments in arrays' -TestCase $testCasesWithAndWithoutAsHashtableSwitch { | ||
| param($AsHashtable) | ||
|
|
||
| # https://github.com/powerShell/powerShell/issues/14553 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatejKafka Please remove. We never use references to GitHub in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think there is no harm to have this reference in test :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful if it were a tracking issue for a disabled test. In this form, it's just garbage.
I think there is no harm to have the reference to the GitHub issue in test code. Also, we are going to create the preview release branch today, so I will merge the PR with that reference.
|
📣 Hey @@MatejKafka, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
| // This function is a clone of PopulateFromList using JArray as input. | ||
| private static ICollection<object> PopulateFromJArray(JArray list, out ErrorRecord error) | ||
| { | ||
| error = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daxian-dbw Just curious, why move error initialization up here? Imo initializing it at the beginning can potentially hide issues where you forget to set error before return, while if it was only assigned directly before the return, compiler would throw an error about a potentially uninitialized variable.
PR Summary
Fixes #14553.
PR Context
Previously,
ConvertFrom-Jsonturned comments inside JSON arrays into strings, so callingresulted in
@(" comment", 100). This PR fixes the issue by correctly ignoring comments.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header