Skip to content
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

[Feature] Use TimeSpan for duration not Int32 #3220

Open
iancooper opened this issue Jul 21, 2024 · 2 comments
Open

[Feature] Use TimeSpan for duration not Int32 #3220

iancooper opened this issue Jul 21, 2024 · 2 comments
Assignees
Labels
3 - Done feature request .NET Pull requests that update .net code v10 Allocal to a v10 release

Comments

@iancooper
Copy link
Member

Is your feature request related to a problem? Please describe.
Our API predates TimeSpan and uses int in many places to represent a duration, such as a timeout or retry. The problem is that the units of time only exist within either the name, or the Documentation Comments. This causes errors when people assume the wrong unit, based on units in use elsewhere. This is an example of primitive obsession, which is unnecessary in a strongly typed language.

Describe the solution you'd like
We should use a TimeSpan to represent a duration throughout our system to remove the class of errors that come from dealing with units of time.

Describe alternatives you've considered
The alternative here would be to use a standard such that the unit is always milliseconds. This was our previous approach but has broken down in places

@iancooper iancooper added 0 - Backlog feature request v10 Allocal to a v10 release .NET Pull requests that update .net code labels Jul 21, 2024
@SteveBush
Copy link
Contributor

As you consider changing to TimeSpan instead of an integer duration, you might also consider moving from a DateTime to DateTimeOffset. The advantage of DateTimeOffset is that it facilitates moving between UTC internally and local time for display to a user.

@iancooper
Copy link
Member Author

@SteveBush Thanks, that is a really good suggestion.

@preardon preardon self-assigned this Sep 2, 2024
preardon added a commit that referenced this issue Sep 2, 2024
preardon added a commit that referenced this issue Sep 3, 2024
* Use TimeSpan instead of milisecond int

Feature #3220

* Fix Extensions

* Fix SQL Timestamp mapping

* Address Comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Done feature request .NET Pull requests that update .net code v10 Allocal to a v10 release
Projects
None yet
Development

No branches or pull requests

3 participants