You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have never seen a valid use for TimeSpan.Milliseconds, but I have seen developers mistakenly use this where they really mean TimeSpan.TotalMilliseconds.
Can we add a rule against using TimesSpan.Days, TimeSpan.Hours, TimeSpan.Minutes, TimeSpan.Seconds, and TimeSpan.Milliseconds, suggesting instead to use the equivalent Total value?
We might also consider a rule against passing the result of TimeSpan.TotalMilliseconds into a method that has a TimeSpan parameter override.
The text was updated successfully, but these errors were encountered:
I have seen valid usages of TimeSpan.Milliseconds but always in conjunction with other "non-total" properties, not in isolation. Maybe we should warn when:
a) accessing a single non-total property without accessing other non-total properties,
b) accessing a mixture of total and non-total properties in the same method and
c) accessing multiple distinct "total" properties in the same method.
For the second rule, maybe it would be better to warn against using a method that takes an int if there is another overload that takes a TimeSpan for the same argument (and all other arguments are the same).
I have never seen a valid use for TimeSpan.Milliseconds, but I have seen developers mistakenly use this where they really mean TimeSpan.TotalMilliseconds.
Can we add a rule against using TimesSpan.Days, TimeSpan.Hours, TimeSpan.Minutes, TimeSpan.Seconds, and TimeSpan.Milliseconds, suggesting instead to use the equivalent Total value?
We might also consider a rule against passing the result of TimeSpan.TotalMilliseconds into a method that has a TimeSpan parameter override.
The text was updated successfully, but these errors were encountered: