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

[C#] WellKnownTypes.Timestamp does not implement IComparable #4267

Closed
warrenfalk opened this issue Feb 1, 2018 · 0 comments · Fixed by #4318
Closed

[C#] WellKnownTypes.Timestamp does not implement IComparable #4267

warrenfalk opened this issue Feb 1, 2018 · 0 comments · Fixed by #4318

Comments

@warrenfalk
Copy link
Contributor

This is a runtime exception:

IEnumerable<MyMessage> myMessages = GetSome();
var inChronologicalOrder = myMessages.OrderBy(m => m.MyTimestampField).ToArray(); // At least one object must implement IComparable

I know that dealing with time in code is wrought with perilous traps and so I'm wondering if there's a reason that it is ill-advised to make this comparable. I couldn't think of one. If you convert a Timestamp to a DateTime, UTC is specified for you, and if you try to get a Timestamp from a DateTime structure that doesn't specify itself as UTC, it fails. So therefore we don't think Timestamp should be storing anything that is non-UTC. But if we think that Timestamp is UTC, then it should be safe to compare it to other Timestamps, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants