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
Comparers #929
Comparers #929
Conversation
public static IEqualityComparer<IGuild> GuildComparer => _guildComparer ?? (_guildComparer = new EntityEqualityComparer<IGuild, ulong>()); | ||
public static IEqualityComparer<IChannel> ChannelComparer => _channelComparer ?? (_channelComparer = new EntityEqualityComparer<IChannel, ulong>()); | ||
public static IEqualityComparer<IRole> RoleComparer => _roleComparer ?? (_roleComparer = new EntityEqualityComparer<IRole, ulong>()); | ||
|
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.
IMessage comparer as well?
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.
Good call.
EDIT: Wait, wasn't there something that it's not guaranteed message IDs will remain globally unique?
Decided to make a specialized implementation just to be safe.
if (xNull ^ yNull) | ||
return false; | ||
|
||
return x.Channel.Id.Equals(y.Channel.Id) && x.Id.Equals(y.Id); |
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.
I'm not sure we really need to check channel IDs as well as message IDs, snowflakes in messages should be unique globally.
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.
Yeah, we definitely don't. All snowflakes generated by Discord are guaranteed to be unique, unless they are explicitly duplicated (e.g. default general channel, everyone role)
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.
I vaguely recall a Discord dev saying that message IDs being globally unique can't be guaranteed indefinitely.
* Add entity equality comparers * Fix namespace #whoops * Add Message comparer. * Add comment explaining the specialized implementation * Remove specialized implementation, as per feedback
As suggested in #912.
Also, if there are other suggestions for the containing class name, make them before this gets merged.