-
Notifications
You must be signed in to change notification settings - Fork 8.1k
MeasureInfo: Only display properties with values #6214
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
MeasureInfo: Only display properties with values #6214
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a correct letter case in all lines.
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a DisplayEntry for the given scriptblock |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where we use the method?
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 don't.
But CreatePropertyEntry is used now, so I added the scriptblock one for completeness.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the change binary backward compatible? We shouldn't break public API.
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 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) |
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 same.
| .AddItemProperty(@"Maximum") | ||
| .AddItemProperty(@"Minimum") | ||
| .AddItemProperty(@"Property") | ||
| .AddItemProperty(@"Average", itemSelectionContition: DisplayEntry.CreatePropertyEntry("Average")) |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.