Add EscapeHandling parameter in ConvertTo-Json cmdlet#7775
Add EscapeHandling parameter in ConvertTo-Json cmdlet#7775iSazonov merged 5 commits intoPowerShell:masterfrom
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.
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.
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.
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.
@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.
I added verbose in BeginProcessing(). (Previously it was in ProcessRecord())
There was a problem hiding this comment.
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.
I think we could discuss this in #7819 and perhaps remove the tests at all.
There was a problem hiding this comment.
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.
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.
Surprised this test passed if you remove -verbose as line 35 is waiting on verbose output?
There was a problem hiding this comment.
The waiting take 10 seconds until timeout.
There was a problem hiding this comment.
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.
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.
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? |
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