-
Notifications
You must be signed in to change notification settings - Fork 2.7k
TimeSpan.FromMilliseconds(TimeSpan.MaxValue.TotalMilliseconds) #10352
Conversation
…ion fix The problem is discussed here: https://connect.microsoft.com/VisualStudio/feedback/details/542235/timespan-structure-incorrectly-handles-values-close-to-min-and-max-value The existing overflow checks are ignorant and superfluous.
Thanks for the contribution @ezverev we'll take a look. |
@danmosemsft OK, noted. |
@joshfree the proposed change looks good to me as it will do the rounding to the ticks instead of the milliseconds which would be more precise. I am seeing your comment on https://connect.microsoft.com/VisualStudio/feedback/details/542235/timespan-structure-incorrectly-handles-values-close-to-min-and-max-value Do you still have a concern? I already checked manually the changes with values around TimeSpan.MaxValue and TimeSpan.MinValue and not seeing any problem.
@ezverev could you please resolve the merge conflict? |
@ezverev please resolve the merge conflict. Thanks. |
@ezverev did you have a chance to resolve the conflict? |
Sorry for the delay. Resolved. |
Thanks @ezverev for submitting this fix |
@tarekgh Do we need a regression test in corefx? |
I will look into appending a test in order to assure there is no longer unneeded precision loss when constructing TimeSpan from a double of different scales. Thanks for the constructive approach. I am sorry to rush the thing and passing over the expected "issue discussion". |
This appears to be breaking a bunch a bunch of corefx tests: |
…) exception fix (dotnet#10352)" This reverts commit 7951bc9.
@ezverev that's totally fine and it takes time to get used to get used to the "ways" of any OSS project. We're glad for your contribution and hopefully you will be interested to make more in future. https://github.com/dotnet/corefx/issues/17619 may be interesting. |
fixes dotnet#3137 There is a committed pull request in coreclr: dotnet/coreclr#10352.
…ion (#3144) fixes #3137 There is a committed pull request in coreclr: dotnet/coreclr#10352.
Working on the unit tests for modified TimeSpan I found a huge flaw in my fix. I got into the kid's trap with the overflow check. Existing unit tests do not cover it: With my fix the TimeSpan.FromMilliseconds(922337203685477.62) gives incorrect result. Please do revert the change that I've made. I will have to work on the issue further and enhance the unit tests before I resubmit the PR. |
TimeSpan.FromMilliseconds(TimeSpan.MaxValue.TotalMilliseconds) gives exception. I suggest the fix.
The problem is discussed here: https://connect.microsoft.com/VisualStudio/feedback/details/542235/timespan-structure-incorrectly-handles-values-close-to-min-and-max-value
The existing overflow checks are ignorant and superfluous.