akamsteeg / AtleX.HaveIBeenPwned

A fully async .NET Standard client library for the API of HaveIBeenPwned.com
https://www.nuget.org/packages/AtleX.HaveIBeenPwned/
MIT License
5 stars 0 forks source link

Implement IEquatable<T> on Breach, Paste and SiteBreach #46

Closed akamsteeg closed 4 years ago

akamsteeg commented 4 years ago

The Breach, Paste and SiteBreach are sealed types, but they don't implement IEquatable<T>. That makes it hard to for example compare objects to eachother, e.g. when newly retrieved breaches are compared against cached objects to discover new breaches.

Suggestion: Implement IEquatable<T> (and override Equals(object)) on Breach, Paste and SiteBreach.

akamsteeg commented 4 years ago

I'd like to suggest introducing a .NET Standard 2.1 target so we can use System.HashCode on .NET Core 3.0+. That reduces the number of dependencies when used on newer frameworks. On .NET Standard 2.0 and NETFX targets, we can use the algorithm described here: https://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-overriding-gethashcode/263416#263416