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
What language does this apply to?
If it's about generated code change, what programming language? C#
Describe the problem you are trying to solve.
I am trying to perform comparisons on the Duration type for data validation. I get a runtime exception when I run this code:
ComparativeValidation.LessThanOrEqual("x",Duration.FromTimeSpan(_timespanOf10),Duration.FromTimeSpan(_timespanOf20),Comparer<Duration>.Default);// At least one object must implement IComparable
Describe the solution you'd like
Can the Duration type implement the IComparable interface?
Describe alternatives you've considered
For our immediate need, we are pursuing a manual comparison method for the seconds and nano properties.
Additional context
This request is similar to the Timestamp request.
The text was updated successfully, but these errors were encountered:
Note that unlike Timestamp, this does *not* also overload comparison
operators. Adding a `==` overload now would be a breaking change (as
it would change the meaning of existing code from a reference
comparison to a value comparison), and implementing `<`, `<=`, `>=`
and `>` without implementing `==` would be odd.
Implementing `IComparable<T>` makes sorting much easier, however.
Fixesprotocolbuffers#7628
What language does this apply to?
If it's about generated code change, what programming language? C#
Describe the problem you are trying to solve.
I am trying to perform comparisons on the Duration type for data validation. I get a runtime exception when I run this code:
Describe the solution you'd like
Can the Duration type implement the IComparable interface?
Describe alternatives you've considered
For our immediate need, we are pursuing a manual comparison method for the seconds and nano properties.
Additional context
This request is similar to the Timestamp request.
The text was updated successfully, but these errors were encountered: