diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 606345db5..cc96765cc 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Net; @@ -1075,11 +1074,9 @@ namespace ArchiSteamFarm { PlayableAppID = appID; } - [SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")] - public bool Equals(Game other) => (other != null) && ((other == this) || (AppID == other.AppID)); - + public bool Equals(Game other) => (other != null) && (ReferenceEquals(other, this) || ((AppID == other.AppID) && (BadgeLevel == other.BadgeLevel) && (GameName == other.GameName))); public override bool Equals(object obj) => (obj != null) && ((obj == this) || (obj is Game game && Equals(game))); - public override int GetHashCode() => (int) (AppID - 1 - int.MaxValue); + public override int GetHashCode() => RuntimeCompatibility.HashCode.Combine(AppID, BadgeLevel, GameName); } } } diff --git a/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs b/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs index c192c0c56..e41588758 100644 --- a/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs +++ b/ArchiSteamFarm/Collections/ConcurrentSortedHashSet.cs @@ -22,7 +22,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Threading; namespace ArchiSteamFarm.Collections { @@ -198,9 +197,7 @@ namespace ArchiSteamFarm.Collections { } } - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] void ICollection.Add(T item) => Add(item); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); internal void ReplaceWith(IEnumerable other) { diff --git a/ArchiSteamFarm/RuntimeCompatibility.cs b/ArchiSteamFarm/RuntimeCompatibility.cs index ecdaf0a12..f8f72ab23 100644 --- a/ArchiSteamFarm/RuntimeCompatibility.cs +++ b/ArchiSteamFarm/RuntimeCompatibility.cs @@ -83,6 +83,15 @@ namespace ArchiSteamFarm { } #pragma warning restore 1998 + internal static class HashCode { + internal static int Combine(T1 value1, T2 value2, T3 value3) => +#if NETFRAMEWORK + (value1, value2, value3).GetHashCode(); +#else + System.HashCode.Combine(value1, value2, value3); +#endif + } + internal static class Path { internal static string GetRelativePath(string relativeTo, string path) { #if NETFRAMEWORK