-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Apply the TimeProvider design feedback #84501
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-datetime |
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
I know that #84274 decided to go with methods for the "now" properties.... but it feels Java-y and was quite weird to look at upon review. Maybe it's because it's not consistent with a simple Leaving it as a Just my 2cp |
I agree with leaving the properties as properties and not changing it to methods on this new abstraction. Feels weird to try and “fix things” here. |
Why is it weird? This is a new abstraction. Why shouldn't we get it "right", especially when overrides can do even more than the erroneous-as-a-property UtcNow? I think the arguments made in the issue where this was discussed at length are pretty compelling. We shouldn't be relitigating it here. (That said, I continue to be fine with it either way, but I do prefer the methods.) |
I think I favor consistency over being “technically correct”. I also think about the future blog posts that continue to explain why there are differences and try to get the readers to really appreciate that mistakes were fixed. I won’t die on this hill, but I feel like these would have made a huge difference earlier and now it won’t have the same positive impact on user code (but it’ll make the design cleaner) |
From a consistency perspective, I think consistency with itself is more important. There are similar explanation challenges as to why it's appropriate for UtcNow/LocalNow to be properties but GetTimestamp() to be a method. |
There are convincing strong reasons mentioned in the following comments to have them as methods. #36617 (comment) Additionally, users keep complaining having |
Sure, like I said, I wouldn’t die on this hill 😅 |
public TimeSpan GetElapsedTime(long startingTimestamp, long endingTimestamp) { throw null; } | ||
public abstract System.Threading.ITimer CreateTimer(System.Threading.TimerCallback callback, object? state, System.TimeSpan dueTime, System.TimeSpan period); | ||
public virtual System.Threading.ITimer CreateTimer(System.Threading.TimerCallback callback, object? state, System.TimeSpan dueTime, System.TimeSpan period) { throw 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.
Question: Why would you want to throw null here? I'd expect NotImplementedException / abstract implementation.
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.
This is the reference assembly. It should never be used at runtime, and the goal is to define just the signatures while keeping the size as small as possible. throw null is what we do in the ref assemblies everywhere.
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.
Thanks, that makes sense!
Fixes #36617
Fixes #84274
This is the third and last part of the changes to TimeProvider.