-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add Duration property to HistoryInfo #5208
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
Conversation
vors
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.
sweet! any tests?
|
Not really sure what to test. Testing public TimeSpan Duration => EndExecutionTime - StartExecutionTime; will hardly give a lot. |
|
|
@powercode Please resolve merge conflicts. |
a4e8808 to
f0674cc
Compare
|
@vors You were so right. Added tests and fixed bugs |
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.
Looks solid, but not a big fan of reflection in the tests. This is very fragile.
I guess it should not be a blocker, but maybe we can just do some unit testing from C#? Don't we have such tests?
iSazonov
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.
Leave 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.
@SteveL-MSFT @PaulHigin Does this not break remoting?
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.
There's a specific list of types and HistoryInfo isn't in that list
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.
These tests are very similar. Please use -TestCases.
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.
good point
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.
Minor comment - should we follow ToString() and use ToDurationString() for public?
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.
Yes, or Tostring(string). Thought about that a bit also, but never reach any real conclusion.
iSazonov
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.
Leave 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.
Should we remove the test?
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.
TimeSeparator can be culture sensitive. Could you please use TimeSpan constructor for duration?
Also in C# $@"{duration:d\.hh\:mm\:ss}"; should we be culture sensitive too?
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 Excellent catch!
I will fix!
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 keep the implementation as it is.
Closed.
|
We're not holding the RC for this PR, if it makes it in soon, great! If not, it'll catch the next release. |
|
@SteveL-MSFT will it merge this time? |
|
We have only one open comment about |
|
I have looked a bit on how PowerShell treats timespans in other cases, and it seems to use the default formatting, which is not culture sensitive. |
|
@powercode please resolve conflicts. |
601c66c to
89ca944
Compare
|
@SteveL-MSFT @daxian-dbw Have you any thoughts about the PR? |
SteveL-MSFT
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.
Regarding GetDurationString() vs ToDurationString(), looking in PS code, it seems Get*String() is used (although internal methods). I'm fine keeping GetDurationString() unless someone can point to some guidance otherwise.
|
@TravisEz13 @daxian-dbw Have you any thoughts about |
This adds the property ExecutionTime to the table view
Renaming GetExecutionTimeString() -> GetDurationString()
|
These build errors are not related to my changes. Can anyone restart the build here? |
|
Reopen the PR to restart CIs. |
Changes were recommended after approval
|
@powercode Is the PR ready for review? |
|
Yes |
|
@daxian-dbw @SteveL-MSFT @BrucePay Please review the PR. |
TravisEz13
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.
Reviewed 1 of 1 files at r4, 1 of 2 files at r5.
Reviewable status:complete! all files reviewed
| } | ||
|
|
||
| It "HistoryInfo calculates Duration" { | ||
| $ctor = [Microsoft.PowerShell.Commands.HistoryInfo].GetConstructors([Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Instance).Where{$_.GetParameters().Length -eq 5} |
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.
Seems like this test should just get the first item from item from Get-History and validate that Duration = End - Start?
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.
@SteveL-MSFT Am I guaranteed to have something in the history at that moment?
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.
@powercode I think it's ok to use Add-History
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.
Fixed
SteveL-MSFT
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
| } | ||
| $history | Add-History | ||
| $h = Get-History -count 1 | ||
| $h.Duration | Should Be $duration |
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.
@powercode Sorry I lost the PR. Please fix Be -> -Be and we ready to merge.
|
@powercode Thank you for the contribution! Sorry for delay. |
Fixes #4181
Adding a property Duration to HistoryInfo to end the
{$_.EndExecutionTime - $_.StartExecutionTime}madness :)This change is