Code review

This commit is contained in:
JustArchi
2018-12-14 22:27:50 +01:00
parent c95653e72b
commit 39fb21cc83
3 changed files with 11 additions and 8 deletions

View File

@@ -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);
}
}
}

View File

@@ -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<T>.Add(T item) => Add(item);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
internal void ReplaceWith(IEnumerable<T> other) {

View File

@@ -83,6 +83,15 @@ namespace ArchiSteamFarm {
}
#pragma warning restore 1998
internal static class HashCode {
internal static int Combine<T1, T2, T3>(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