-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add EscapeHandling parameter in ConvertTo-Json cmdlet #7775
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
Add EscapeHandling parameter in ConvertTo-Json cmdlet #7775
Conversation
|
Great solution - thanks @iSazonov - really appreciate it. 🏆 |
d2e6719 to
1af310d
Compare
|
@TravisEz13 Should CI Travis be removed? |
|
@iSazonov Yes, it is now replaced with the |
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.
Turn this into -TestCases? Benefit is if first assert fails, the whole thing doesn't fail.
3ff21c6 to
4cf4378
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.
Is there a reason for this change from using the verbose channel to know that the cmdlet has started to a sleep? On a particularly slow container/VM, it might take longer than 300ms.
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.
We removed the verbose message in #7487 and currently the test take 10 seconds until timeout.
We could consider adding debug message instead of the verbose message.
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.
@iSazonov ok, got it. Seems like the right thing to do would be to have some test hook so that we can make this predictable as anything with small timeouts are more likely to fail in CI especially when it's under load.
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.
I added verbose in BeginProcessing(). (Previously it was in ProcessRecord())
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.
Per comment on line 33, Stop() is synchronous and in the chance it blocks, Pester is blocked. Perhaps we can change the sleep on line 34 to Wait-UntilTrue where State changes?
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.
I think we could discuss this in #7819 and perhaps remove the tests at all.
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.
If you can revert changes to this test in this PR, I think we can move forward with this PR and resolve this test in the other PR.
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.
Reverted in the PR and moved to #7819.
24ffde6 to
7ef9f10
Compare
6df405a to
7ef9f10
Compare
|
Reopen to restart PowerShell-CI-Linux. |
| $obj = [PSCustomObject]@{P1 = ''; P2 = ''; P3 = ''; P4 = ''; P5 = ''; P6 = ''} | ||
| $obj.P1 = $obj.P2 = $obj.P3 = $obj.P4 = $obj.P5 = $obj.P6 = $obj | ||
| 1..100 | Foreach-Object { $obj } | ConvertTo-Json -Depth 10 -Verbose | ||
| 1..100 | Foreach-Object { $obj } | ConvertTo-Json -Depth 10 |
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.
Surprised this test passed if you remove -verbose as line 35 is waiting on verbose output?
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.
The waiting take 10 seconds until timeout.
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.
You are removing -Verbose because another PR removed the verbose message (which you added back with the test hook in the other PR), right? If so, I suppose this is ok, but it seems this change doesn't have any impact to this test so wondering why have this change in this PR at all?
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.
Reverted the change.
| $obj = [PSCustomObject]@{P1 = ''; P2 = ''; P3 = ''; P4 = ''; P5 = ''; P6 = ''} | ||
| $obj.P1 = $obj.P2 = $obj.P3 = $obj.P4 = $obj.P5 = $obj.P6 = $obj | ||
| 1..100 | Foreach-Object { $obj } | ConvertTo-Json -Depth 10 -Verbose | ||
| 1..100 | Foreach-Object { $obj } | ConvertTo-Json -Depth 10 |
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.
You are removing -Verbose because another PR removed the verbose message (which you added back with the test hook in the other PR), right? If so, I suppose this is ok, but it seems this change doesn't have any impact to this test so wondering why have this change in this PR at all?
|
@daxian-dbw @dantraMSFT Could you please do (fast) review before we merge? |
markekraus
left a comment
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
Add EscapeHandling parameter in ConvertTo-Json cmdlet to allow escape the HTML (<, >, &, ', ") and control characters (e.g. newline).
PR Summary
Fix #7693.
Add EscapeHandling parameter in ConvertTo-Json cmdlet to allow escape the HTML (<, >, &, ', ") and control characters (e.g. newline).
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests