Add Duration property to HistoryInfo - #5208
Conversation
sergei (vors)
left a comment
There was a problem hiding this comment.
sweet! any tests?
|
Not really sure what to test. Testing public TimeSpan Duration => EndExecutionTime - StartExecutionTime; will hardly give a lot. |
|
|
Staffan Gustafsson (@powercode) Please resolve merge conflicts. |
a4e8808 to
f0674cc
Compare
|
sergei (@vors) You were so right. Added tests and fixed bugs |
Ilya (iSazonov)
left a comment
There was a problem hiding this comment.
Leave a comment
There was a problem hiding this comment.
Steve Lee (@SteveL-MSFT) Paul Higinbotham (@PaulHigin) Does this not break remoting?
There was a problem hiding this comment.
There's a specific list of types and HistoryInfo isn't in that list
There was a problem hiding this comment.
These tests are very similar. Please use -TestCases.
There was a problem hiding this comment.
good point
There was a problem hiding this comment.
Minor comment - should we follow ToString() and use ToDurationString() for public?
There was a problem hiding this comment.
Yes, or Tostring(string). Thought about that a bit also, but never reach any real conclusion.
Ilya (iSazonov)
left a comment
There was a problem hiding this comment.
Leave a comment
There was a problem hiding this comment.
Should we remove the test?
There was a problem hiding this comment.
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.
Ilya (@iSazonov) Excellent catch!
I will fix!
There was a problem hiding this comment.
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. |
|
Steve Lee (@SteveL-MSFT) will it merge this time? |
|
mi-hol if the maintainer Ilya (@iSazonov) believes there has been sufficient review, he can merge this, but we're limiting code changes we're taking for GA to avoid risk of regression. This will show up in 6.1.0 preview release which should happen early next year. |
|
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. |
|
Staffan Gustafsson (@powercode) please resolve conflicts. |
601c66c to
89ca944
Compare
|
Steve Lee (@SteveL-MSFT) Dongbo Wang (@daxian-dbw) Have you any thoughts about the PR? |
Steve Lee (SteveL-MSFT)
left a comment
There was a problem hiding this comment.
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.
|
Travis Plunk (@TravisEz13) Dongbo Wang (@daxian-dbw) Have you any thoughts about |
This adds the property ExecutionTime to the table view
Renaming GetExecutionTimeString() -> GetDurationString()
7720c1c to
84f6949
Compare
|
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
|
Staffan Gustafsson (@powercode) Is the PR ready for review? |
|
Yes |
|
Dongbo Wang (@daxian-dbw) Steve Lee (@SteveL-MSFT) Bruce Payette (@BrucePay) Please review the PR. |
Travis Plunk (TravisEz13)
left a comment
There was a problem hiding this comment.
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.
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.
Steve Lee (@SteveL-MSFT) Am I guaranteed to have something in the history at that moment?
There was a problem hiding this comment.
Staffan Gustafsson (@powercode) I think it's ok to use Add-History
There was a problem hiding this comment.
Fixed
| } | ||
| $history | Add-History | ||
| $h = Get-History -count 1 | ||
| $h.Duration | Should Be $duration |
There was a problem hiding this comment.
Staffan Gustafsson (@powercode) Sorry I lost the PR. Please fix Be -> -Be and we ready to merge.
c2a1537 to
5e5af80
Compare
|
Staffan Gustafsson (@powercode) Thank you for the contribution! Sorry for delay. |
* Remove regions in HistoryInfo class * Auto properties refactoring in HistoryInfo * Adding Duration property to HistoryInfo * Rename ExecutionTime => Duration
Fixes #4181
Adding a property Duration to HistoryInfo to end the
{$_.EndExecutionTime - $_.StartExecutionTime}madness :)This change is