Skip to content

MeasureInfo: Only display properties with values - #6214

Closed
Staffan Gustafsson (powercode) wants to merge 5 commits into
PowerShell:masterfrom
powercode:formatting_ItemSelectionConditions
Closed

Staffan Gustafsson (powercode) wants to merge 5 commits into
PowerShell:masterfrom
powercode:formatting_ItemSelectionConditions

Conversation

@powercode

@powercode Staffan Gustafsson (powercode) commented Feb 21, 2018 •

Copy link
Copy Markdown
Collaborator

PR Summary

Adding Item selection conditions to the list formatting info for MeasureInfo so that only the properties with values gets displayed

PR Checklist

Note: Please mark anything not applicable to this PR NA.


$text = 1, 2, 3 | Measure-Object -Minimum -Maximum | format-list | out-string
$text -match "min|max" | should -BeTrue
}

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

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)

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Collaborator Author

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.

Copy link
Copy Markdown
Collaborator

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 )

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Collaborator

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"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add AddItemPropertyByCondition.

@iSazonov

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) The PR contains a public API change - PowerShell Committee conclusion needed.

@SteveL-MSFT Steve Lee (SteveL-MSFT) added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Feb 22, 2018
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

Copy link
Copy Markdown
Collaborator

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.

@iSazonov

Copy link
Copy Markdown
Collaborator

Staffan Gustafsson (@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

@JamesWTruher James Truher (JamesWTruher) Feb 28, 2018 •

Copy link
Copy Markdown
Collaborator

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?

@SteveL-MSFT

Copy link
Copy Markdown
Member

@PowerShell/powershell-committee reviewed this and is ok with the public apis

@iSazonov Ilya (iSazonov) added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Mar 1, 2018
@stale

stale Bot commented Apr 20, 2018

Copy link
Copy Markdown

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.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale Bot added the Stale label Apr 20, 2018
@stale

stale Bot commented Apr 30, 2018

Copy link
Copy Markdown

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.
Thanks again for your contribution.
Community members are welcome to grab these works.

@stale stale Bot closed this Apr 30, 2018
@powercode Staffan Gustafsson (powercode) changed the title MeasureInfo: Only display properties with values WIP MeasureInfo: Only display properties with values Jun 18, 2018
@powercode

Copy link
Copy Markdown
Collaborator Author

Updating

@powercode Staffan Gustafsson (powercode) changed the title WIP MeasureInfo: Only display properties with values MeasureInfo: Only display properties with values Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Committee-Reviewed PS-Committee has reviewed this and made a decision Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants