MeasureInfo: Only display properties with values #6214
MeasureInfo: Only display properties with values #6214powercode wants to merge 5 commits intoPowerShell:masterfrom
Conversation
|
|
||
| $text = 1, 2, 3 | Measure-Object -Minimum -Maximum | format-list | out-string | ||
| $text -match "min|max" | should -BeTrue | ||
| } |
There was a problem hiding this comment.
Please use a correct letter case in all lines.
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a DisplayEntry for the given scriptblock |
There was a problem hiding this comment.
Please add final dot in public comments.
| /// Creates a DisplayEntry for the given scriptblock | ||
| /// </summary> | ||
| /// <param name="scriptblock">The content of the scriptblock</param> | ||
| public static DisplayEntry CreateScriptBlockEntry(string scriptblock) |
There was a problem hiding this comment.
Where we use the method?
There was a problem hiding this comment.
We don't.
But CreatePropertyEntry is used now, so I added the scriptblock one for completeness.
There was a problem hiding this comment.
Clear.
We should add tests for the public method.
|
|
||
| /// <summary></summary> | ||
| public ListEntryBuilder AddItemScriptBlock(string scriptBlock, string label = null, string format = null) | ||
| public ListEntryBuilder AddItemScriptBlock(string scriptBlock, string label = null, string format = null, DisplayEntry itemSelectionContition = null ) |
There was a problem hiding this comment.
Is the change binary backward compatible? We shouldn't break public API.
There was a problem hiding this comment.
The change is not binary compatible.
That said, it is unlikely anyone uses this api yet, people still rely on a ps1xml file because there isn't a good way for a module author to use this api in a useful way yet.
|
|
||
| /// <summary></summary> | ||
| public ListEntryBuilder AddItemProperty(string property, string label = null, string format = null) | ||
| public ListEntryBuilder AddItemProperty(string property, string label = null, string format = null, DisplayEntry itemSelectionContition = null) |
| .AddItemProperty(@"Maximum") | ||
| .AddItemProperty(@"Minimum") | ||
| .AddItemProperty(@"Property") | ||
| .AddItemProperty(@"Average", itemSelectionContition: DisplayEntry.CreatePropertyEntry("Average")) |
There was a problem hiding this comment.
We could add AddItemPropertyByCondition.
|
@SteveL-MSFT The PR contains a public API change - PowerShell Committee conclusion needed. |
| It 'should only display fields that are set' { | ||
| $text = 1, 2, 3 | Measure-Object -sum -Average | format-list | out-string | ||
| $text -match "min|max" | should -BeFalse | ||
| $text = 1, 2, 3 | Measure-Object -sum -Average | Format-List | Out-String |
There was a problem hiding this comment.
Please replace sum with Sum.
|
@powercode Thanks! We are waiting PowerShell Committee. |
|
|
||
| It 'should only display fields that are set' { | ||
| $text = 1, 2, 3 | Measure-Object -Sum -Average | Format-List | Out-String | ||
| $text -match "min|max" | Should -BeFalse |
There was a problem hiding this comment.
would it be better if this was a positive test? What should this actually look like? or both positive/negative?
|
@PowerShell/powershell-committee reviewed this and is ok with the public apis |
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
|
This PR has be automatically close because it is stale. If you wish to continue working on the PR, please first update the PR, then reopen it. |
|
Updating |
PR Summary
Adding Item selection conditions to the list formatting info for
MeasureInfoso that only the properties with values gets displayedPR Checklist
Note: Please mark anything not applicable to this PR
NA.[feature]if the change is significant or affects feature testsWIP:to the beginning of the title and remove the prefix when the PR is ready.