R# cleanup

This commit is contained in:
JustArchi
2019-10-13 17:21:40 +02:00
parent 0a6392cd2b
commit a0dfb28e59
15 changed files with 84 additions and 71 deletions

View File

@@ -20,6 +20,7 @@
// limitations under the License. // limitations under the License.
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -32,7 +33,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
private const string URL = "https://aws.random.cat"; private const string URL = "https://aws.random.cat";
[ItemCanBeNull] [ItemCanBeNull]
internal static async Task<string> GetRandomCatURL([NotNull] WebBrowser webBrowser) { internal static async Task<string> GetRandomCatURL([JetBrains.Annotations.NotNull] WebBrowser webBrowser) {
const string request = URL + "/meow"; const string request = URL + "/meow";
WebBrowser.ObjectResponse<MeowResponse> response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false); WebBrowser.ObjectResponse<MeowResponse> response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false);
@@ -50,7 +51,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
return Uri.EscapeUriString(response.Content.Link); return Uri.EscapeUriString(response.Content.Link);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
private sealed class MeowResponse { private sealed class MeowResponse {
#pragma warning disable 649 #pragma warning disable 649
[JsonProperty(PropertyName = "file", Required = Required.Always)] [JsonProperty(PropertyName = "file", Required = Required.Always)]

View File

@@ -21,6 +21,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -44,7 +45,7 @@ namespace ArchiSteamFarm {
private bool ProcessingGiftsScheduled; private bool ProcessingGiftsScheduled;
private bool TradingScheduled; private bool TradingScheduled;
internal Actions([NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); internal Actions([JetBrains.Annotations.NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
public void Dispose() { public void Dispose() {
// Those are objects that are always being created if constructor doesn't throw exception // Those are objects that are always being created if constructor doesn't throw exception
@@ -232,7 +233,7 @@ namespace ArchiSteamFarm {
} }
[PublicAPI] [PublicAPI]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
public async Task<(bool Success, string Message)> SendTradeOffer(uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, ulong targetSteamID = 0, string tradeToken = null, IReadOnlyCollection<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> wantedTypes = null) { public async Task<(bool Success, string Message)> SendTradeOffer(uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, ulong targetSteamID = 0, string tradeToken = null, IReadOnlyCollection<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> wantedTypes = null) {
if ((appID == 0) || (contextID == 0)) { if ((appID == 0) || (contextID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID));

View File

@@ -21,6 +21,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@@ -46,7 +47,7 @@ namespace ArchiSteamFarm {
internal DateTime LastPacketReceived { get; private set; } internal DateTime LastPacketReceived { get; private set; }
internal ArchiHandler([NotNull] ArchiLogger archiLogger, [NotNull] SteamUnifiedMessages steamUnifiedMessages) { internal ArchiHandler([JetBrains.Annotations.NotNull] ArchiLogger archiLogger, [JetBrains.Annotations.NotNull] SteamUnifiedMessages steamUnifiedMessages) {
if ((archiLogger == null) || (steamUnifiedMessages == null)) { if ((archiLogger == null) || (steamUnifiedMessages == null)) {
throw new ArgumentNullException(nameof(archiLogger) + " || " + nameof(steamUnifiedMessages)); throw new ArgumentNullException(nameof(archiLogger) + " || " + nameof(steamUnifiedMessages));
} }
@@ -705,7 +706,7 @@ namespace ArchiSteamFarm {
Client.PostCallback(new VanityURLChangedCallback(packetMsg.TargetJobID, response.Body)); Client.PostCallback(new VanityURLChangedCallback(packetMsg.TargetJobID, response.Body));
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBeInternal")]
public sealed class PurchaseResponseCallback : CallbackMsg { public sealed class PurchaseResponseCallback : CallbackMsg {
public readonly Dictionary<uint, string> Items; public readonly Dictionary<uint, string> Items;
@@ -721,7 +722,7 @@ namespace ArchiSteamFarm {
PurchaseResultDetail = purchaseResult; PurchaseResultDetail = purchaseResult;
} }
internal PurchaseResponseCallback([NotNull] JobID jobID, [NotNull] CMsgClientPurchaseResponse msg) { internal PurchaseResponseCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientPurchaseResponse msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -787,7 +788,7 @@ namespace ArchiSteamFarm {
internal sealed class PlayingSessionStateCallback : CallbackMsg { internal sealed class PlayingSessionStateCallback : CallbackMsg {
internal readonly bool PlayingBlocked; internal readonly bool PlayingBlocked;
internal PlayingSessionStateCallback([NotNull] JobID jobID, [NotNull] CMsgClientPlayingSessionState msg) { internal PlayingSessionStateCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientPlayingSessionState msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -800,7 +801,7 @@ namespace ArchiSteamFarm {
internal sealed class RedeemGuestPassResponseCallback : CallbackMsg { internal sealed class RedeemGuestPassResponseCallback : CallbackMsg {
internal readonly EResult Result; internal readonly EResult Result;
internal RedeemGuestPassResponseCallback([NotNull] JobID jobID, [NotNull] CMsgClientRedeemGuestPassResponse msg) { internal RedeemGuestPassResponseCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientRedeemGuestPassResponse msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -813,7 +814,7 @@ namespace ArchiSteamFarm {
internal sealed class SharedLibraryLockStatusCallback : CallbackMsg { internal sealed class SharedLibraryLockStatusCallback : CallbackMsg {
internal readonly ulong LibraryLockedBySteamID; internal readonly ulong LibraryLockedBySteamID;
internal SharedLibraryLockStatusCallback([NotNull] JobID jobID, [NotNull] CMsgClientSharedLibraryLockStatus msg) { internal SharedLibraryLockStatusCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientSharedLibraryLockStatus msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -831,7 +832,7 @@ namespace ArchiSteamFarm {
internal sealed class UserNotificationsCallback : CallbackMsg { internal sealed class UserNotificationsCallback : CallbackMsg {
internal readonly Dictionary<EUserNotification, uint> Notifications; internal readonly Dictionary<EUserNotification, uint> Notifications;
internal UserNotificationsCallback([NotNull] JobID jobID, [NotNull] CMsgClientUserNotifications msg) { internal UserNotificationsCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientUserNotifications msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -870,7 +871,7 @@ namespace ArchiSteamFarm {
} }
} }
internal UserNotificationsCallback([NotNull] JobID jobID, [NotNull] CMsgClientItemAnnouncements msg) { internal UserNotificationsCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientItemAnnouncements msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }
@@ -899,7 +900,7 @@ namespace ArchiSteamFarm {
internal sealed class VanityURLChangedCallback : CallbackMsg { internal sealed class VanityURLChangedCallback : CallbackMsg {
internal readonly string VanityURL; internal readonly string VanityURL;
internal VanityURLChangedCallback([NotNull] JobID jobID, [NotNull] CMsgClientVanityURLChangedNotification msg) { internal VanityURLChangedCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientVanityURLChangedNotification msg) {
if ((jobID == null) || (msg == null)) { if ((jobID == null) || (msg == null)) {
throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
} }

View File

@@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
@@ -87,7 +88,7 @@ namespace ArchiSteamFarm {
private bool MarkingInventoryScheduled; private bool MarkingInventoryScheduled;
private string VanityURL; private string VanityURL;
internal ArchiWebHandler([NotNull] Bot bot) { internal ArchiWebHandler([JetBrains.Annotations.NotNull] Bot bot) {
Bot = bot ?? throw new ArgumentNullException(nameof(bot)); Bot = bot ?? throw new ArgumentNullException(nameof(bot));
CachedApiKey = new ArchiCacheable<string>(ResolveApiKey); CachedApiKey = new ArchiCacheable<string>(ResolveApiKey);
@@ -122,7 +123,7 @@ namespace ArchiSteamFarm {
[ItemCanBeNull] [ItemCanBeNull]
[PublicAPI] [PublicAPI]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
public async Task<HashSet<Steam.Asset>> GetInventory(ulong steamID = 0, uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, bool? marketable = null, bool? tradable = null, IReadOnlyCollection<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> wantedTypes = null, IReadOnlyCollection<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> wantedSets = null) { public async Task<HashSet<Steam.Asset>> GetInventory(ulong steamID = 0, uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, bool? marketable = null, bool? tradable = null, IReadOnlyCollection<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> wantedTypes = null, IReadOnlyCollection<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> wantedSets = null) {
if ((appID == 0) || (contextID == 0)) { if ((appID == 0) || (contextID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID));
@@ -1388,7 +1389,7 @@ namespace ArchiSteamFarm {
return true; return true;
} }
[NotNull] [JetBrains.Annotations.NotNull]
internal HttpClient GenerateDisposableHttpClient() => WebBrowser.GenerateDisposableHttpClient(); internal HttpClient GenerateDisposableHttpClient() => WebBrowser.GenerateDisposableHttpClient();
[ItemCanBeNull] [ItemCanBeNull]

View File

@@ -24,6 +24,7 @@ using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
@@ -142,7 +143,7 @@ namespace ArchiSteamFarm {
#pragma warning disable IDE0051 #pragma warning disable IDE0051
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamID))] [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamID))]
[NotNull] [JetBrains.Annotations.NotNull]
private string SSteamID => SteamID.ToString(); private string SSteamID => SteamID.ToString();
#pragma warning restore IDE0051 #pragma warning restore IDE0051
@@ -197,7 +198,7 @@ namespace ArchiSteamFarm {
private string TwoFactorCode; private string TwoFactorCode;
private byte TwoFactorCodeFailures; private byte TwoFactorCodeFailures;
private Bot([NotNull] string botName, [NotNull] BotConfig botConfig, [NotNull] BotDatabase botDatabase) { private Bot([JetBrains.Annotations.NotNull] string botName, [JetBrains.Annotations.NotNull] BotConfig botConfig, [JetBrains.Annotations.NotNull] BotDatabase botDatabase) {
if (string.IsNullOrEmpty(botName) || (botConfig == null) || (botDatabase == null)) { if (string.IsNullOrEmpty(botName) || (botConfig == null) || (botDatabase == null)) {
throw new ArgumentNullException(nameof(botName) + " || " + nameof(botConfig) + " || " + nameof(botDatabase)); throw new ArgumentNullException(nameof(botName) + " || " + nameof(botConfig) + " || " + nameof(botDatabase));
} }
@@ -2771,7 +2772,7 @@ namespace ArchiSteamFarm {
WalletCurrency = callback.Currency; WalletCurrency = callback.Currency;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
private async Task RedeemGamesInBackground() { private async Task RedeemGamesInBackground() {
if (!await GamesRedeemerInBackgroundSemaphore.WaitAsync(0).ConfigureAwait(false)) { if (!await GamesRedeemerInBackgroundSemaphore.WaitAsync(0).ConfigureAwait(false)) {
return; return;

View File

@@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@@ -34,7 +35,7 @@ using Newtonsoft.Json.Linq;
using SteamKit2; using SteamKit2;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public sealed class BotConfig { public sealed class BotConfig {
internal const byte SteamParentalCodeLength = 4; internal const byte SteamParentalCodeLength = 4;
@@ -224,7 +225,7 @@ namespace ArchiSteamFarm {
private bool ShouldSerializeSensitiveDetails = true; private bool ShouldSerializeSensitiveDetails = true;
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamMasterClanID), Required = Required.DisallowNull)] [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamMasterClanID), Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string SSteamMasterClanID { private string SSteamMasterClanID {
get => SteamMasterClanID.ToString(); get => SteamMasterClanID.ToString();

View File

@@ -23,6 +23,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -35,7 +36,7 @@ namespace ArchiSteamFarm.Collections {
public ConcurrentHashSet() => BackingCollection = new ConcurrentDictionary<T, bool>(); public ConcurrentHashSet() => BackingCollection = new ConcurrentDictionary<T, bool>();
public ConcurrentHashSet([NotNull] IEqualityComparer<T> comparer) { public ConcurrentHashSet([JetBrains.Annotations.NotNull] IEqualityComparer<T> comparer) {
if (comparer == null) { if (comparer == null) {
throw new ArgumentNullException(nameof(comparer)); throw new ArgumentNullException(nameof(comparer));
} }
@@ -46,7 +47,7 @@ namespace ArchiSteamFarm.Collections {
public bool Add(T item) => BackingCollection.TryAdd(item, true); public bool Add(T item) => BackingCollection.TryAdd(item, true);
public void Clear() => BackingCollection.Clear(); public void Clear() => BackingCollection.Clear();
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
public bool Contains(T item) => BackingCollection.ContainsKey(item); public bool Contains(T item) => BackingCollection.ContainsKey(item);
public void CopyTo(T[] array, int arrayIndex) => BackingCollection.Keys.CopyTo(array, arrayIndex); public void CopyTo(T[] array, int arrayIndex) => BackingCollection.Keys.CopyTo(array, arrayIndex);
@@ -97,7 +98,7 @@ namespace ArchiSteamFarm.Collections {
return otherSet.Any(Contains); return otherSet.Any(Contains);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
public bool Remove(T item) => BackingCollection.TryRemove(item, out _); public bool Remove(T item) => BackingCollection.TryRemove(item, out _);
public bool SetEquals(IEnumerable<T> other) { public bool SetEquals(IEnumerable<T> other) {
@@ -126,22 +127,22 @@ namespace ArchiSteamFarm.Collections {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationConflictInHierarchy")] [SuppressMessage("ReSharper", "AnnotationConflictInHierarchy")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
void ICollection<T>.Add([NotNull] T item) => Add(item); void ICollection<T>.Add([JetBrains.Annotations.NotNull] T item) => Add(item);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
// We use Count() and not Any() because we must ensure full loop pass // We use Count() and not Any() because we must ensure full loop pass
[PublicAPI] [PublicAPI]
public bool AddRange([NotNull] IEnumerable<T> items) => items.Count(Add) > 0; public bool AddRange([JetBrains.Annotations.NotNull] IEnumerable<T> items) => items.Count(Add) > 0;
// We use Count() and not Any() because we must ensure full loop pass // We use Count() and not Any() because we must ensure full loop pass
[PublicAPI] [PublicAPI]
public bool RemoveRange([NotNull] IEnumerable<T> items) => items.Count(Remove) > 0; public bool RemoveRange([JetBrains.Annotations.NotNull] IEnumerable<T> items) => items.Count(Remove) > 0;
[PublicAPI] [PublicAPI]
public bool ReplaceIfNeededWith([NotNull] IReadOnlyCollection<T> other) { public bool ReplaceIfNeededWith([JetBrains.Annotations.NotNull] IReadOnlyCollection<T> other) {
if (SetEquals(other)) { if (SetEquals(other)) {
return false; return false;
} }
@@ -152,7 +153,7 @@ namespace ArchiSteamFarm.Collections {
} }
[PublicAPI] [PublicAPI]
public void ReplaceWith([NotNull] IEnumerable<T> other) { public void ReplaceWith([JetBrains.Annotations.NotNull] IEnumerable<T> other) {
BackingCollection.Clear(); BackingCollection.Clear();
foreach (T item in other) { foreach (T item in other) {

View File

@@ -21,7 +21,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using System.Diagnostics.CodeAnalysis;
using Nito.AsyncEx; using Nito.AsyncEx;
namespace ArchiSteamFarm.Collections { namespace ArchiSteamFarm.Collections {
@@ -80,8 +80,8 @@ namespace ArchiSteamFarm.Collections {
} }
} }
[NotNull] [JetBrains.Annotations.NotNull]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")]
public IEnumerator<T> GetEnumerator() => new ConcurrentEnumerator<T>(BackingCollection, Lock.ReaderLock()); public IEnumerator<T> GetEnumerator() => new ConcurrentEnumerator<T>(BackingCollection, Lock.ReaderLock());
public int IndexOf(T item) { public int IndexOf(T item) {
@@ -108,11 +108,11 @@ namespace ArchiSteamFarm.Collections {
} }
} }
[NotNull] [JetBrains.Annotations.NotNull]
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")]
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
internal void ReplaceWith([NotNull] IEnumerable<T> collection) { internal void ReplaceWith([JetBrains.Annotations.NotNull] IEnumerable<T> collection) {
using (Lock.WriterLock()) { using (Lock.WriterLock()) {
BackingCollection.Clear(); BackingCollection.Clear();
BackingCollection.AddRange(collection); BackingCollection.AddRange(collection);

View File

@@ -21,6 +21,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -38,7 +39,7 @@ namespace ArchiSteamFarm {
private readonly Bot Bot; private readonly Bot Bot;
private readonly Dictionary<uint, string> CachedGamesOwned = new Dictionary<uint, string>(); private readonly Dictionary<uint, string> CachedGamesOwned = new Dictionary<uint, string>();
internal Commands([NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); internal Commands([JetBrains.Annotations.NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
[PublicAPI] [PublicAPI]
public static string FormatBotResponse(string response, string botName) { public static string FormatBotResponse(string response, string botName) {
@@ -1622,7 +1623,7 @@ namespace ArchiSteamFarm {
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
private async Task<(string Response, Dictionary<string, string> OwnedGames)> ResponseOwns(ulong steamID, string query) { private async Task<(string Response, Dictionary<string, string> OwnedGames)> ResponseOwns(ulong steamID, string query) {
if ((steamID == 0) || string.IsNullOrEmpty(query)) { if ((steamID == 0) || string.IsNullOrEmpty(query)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(query)); Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(query));
@@ -2141,7 +2142,7 @@ namespace ArchiSteamFarm {
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
private async Task<string> ResponseRedeem(ulong steamID, string keysText, ERedeemFlags redeemFlags = ERedeemFlags.None) { private async Task<string> ResponseRedeem(ulong steamID, string keysText, ERedeemFlags redeemFlags = ERedeemFlags.None) {
if ((steamID == 0) || string.IsNullOrEmpty(keysText)) { if ((steamID == 0) || string.IsNullOrEmpty(keysText)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(keysText)); Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(keysText));

View File

@@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
@@ -33,7 +34,7 @@ using Newtonsoft.Json.Linq;
using SteamKit2; using SteamKit2;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public sealed class GlobalConfig { public sealed class GlobalConfig {
internal const byte DefaultConnectionTimeout = 90; internal const byte DefaultConnectionTimeout = 90;
internal const byte DefaultLoginLimiterDelay = 10; internal const byte DefaultLoginLimiterDelay = 10;
@@ -217,7 +218,7 @@ namespace ArchiSteamFarm {
private bool ShouldSerializeSensitiveDetails = true; private bool ShouldSerializeSensitiveDetails = true;
[JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamOwnerID), Required = Required.DisallowNull)] [JsonProperty(PropertyName = SharedInfo.UlongCompatibilityStringPrefix + nameof(SteamOwnerID), Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string SSteamOwnerID { private string SSteamOwnerID {
get => SteamOwnerID.ToString(); get => SteamOwnerID.ToString();
@@ -267,7 +268,7 @@ namespace ArchiSteamFarm {
return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel)); return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel));
} }
[NotNull] [JetBrains.Annotations.NotNull]
internal static GlobalConfig Create() => internal static GlobalConfig Create() =>
new GlobalConfig { new GlobalConfig {
ShouldSerializeEverything = false, ShouldSerializeEverything = false,

View File

@@ -21,6 +21,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
@@ -30,7 +31,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
namespace ArchiSteamFarm.IPC.Integration { namespace ArchiSteamFarm.IPC.Integration {
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
internal sealed class ApiAuthenticationMiddleware { internal sealed class ApiAuthenticationMiddleware {
internal const string HeadersField = "Authentication"; internal const string HeadersField = "Authentication";
@@ -44,7 +45,7 @@ namespace ArchiSteamFarm.IPC.Integration {
private readonly RequestDelegate Next; private readonly RequestDelegate Next;
public ApiAuthenticationMiddleware([NotNull] RequestDelegate next) { public ApiAuthenticationMiddleware([JetBrains.Annotations.NotNull] RequestDelegate next) {
Next = next ?? throw new ArgumentNullException(nameof(next)); Next = next ?? throw new ArgumentNullException(nameof(next));
lock (FailedAuthorizations) { lock (FailedAuthorizations) {

View File

@@ -21,11 +21,11 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using JetBrains.Annotations; using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace ArchiSteamFarm.IPC.Requests { namespace ArchiSteamFarm.IPC.Requests {
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public sealed class CommandRequest { public sealed class CommandRequest {
/// <summary> /// <summary>
/// Specifies the command that will be executed by ASF. /// Specifies the command that will be executed by ASF.
@@ -34,7 +34,7 @@ namespace ArchiSteamFarm.IPC.Requests {
[Required] [Required]
public readonly string Command; public readonly string Command;
internal CommandRequest([NotNull] string command) { internal CommandRequest([JetBrains.Annotations.NotNull] string command) {
if (string.IsNullOrEmpty(command)) { if (string.IsNullOrEmpty(command)) {
throw new ArgumentNullException(nameof(command)); throw new ArgumentNullException(nameof(command));
} }

View File

@@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using ArchiSteamFarm.Localization; using ArchiSteamFarm.Localization;
using HtmlAgilityPack; using HtmlAgilityPack;
@@ -71,7 +72,7 @@ namespace ArchiSteamFarm.Json {
#pragma warning disable IDE0051 #pragma warning disable IDE0051
[JsonProperty(PropertyName = "amount", Required = Required.Always)] [JsonProperty(PropertyName = "amount", Required = Required.Always)]
[NotNull] [JetBrains.Annotations.NotNull]
private string AmountText { private string AmountText {
get => Amount.ToString(); get => Amount.ToString();
@@ -94,7 +95,7 @@ namespace ArchiSteamFarm.Json {
#pragma warning restore IDE0051 #pragma warning restore IDE0051
[JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string AssetIDText { private string AssetIDText {
get => AssetID.ToString(); get => AssetID.ToString();
@@ -117,7 +118,7 @@ namespace ArchiSteamFarm.Json {
#pragma warning disable IDE0051 #pragma warning disable IDE0051
[JsonProperty(PropertyName = "classid", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "classid", Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string ClassIDText { private string ClassIDText {
get => ClassID.ToString(); get => ClassID.ToString();
@@ -139,7 +140,7 @@ namespace ArchiSteamFarm.Json {
#pragma warning disable IDE0051 #pragma warning disable IDE0051
[JsonProperty(PropertyName = "contextid", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "contextid", Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string ContextIDText { private string ContextIDText {
get => ContextID.ToString(); get => ContextID.ToString();
@@ -163,7 +164,7 @@ namespace ArchiSteamFarm.Json {
#pragma warning disable IDE0051 #pragma warning disable IDE0051
[JsonProperty(PropertyName = "id", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "id", Required = Required.DisallowNull)]
[NotNull] [JetBrains.Annotations.NotNull]
private string IDText { private string IDText {
get => AssetIDText; get => AssetIDText;
set => AssetIDText = value; set => AssetIDText = value;
@@ -189,7 +190,7 @@ namespace ArchiSteamFarm.Json {
[JsonConstructor] [JsonConstructor]
private Asset() { } private Asset() { }
[NotNull] [JetBrains.Annotations.NotNull]
internal Asset CreateShallowCopy() => (Asset) MemberwiseClone(); internal Asset CreateShallowCopy() => (Asset) MemberwiseClone();
public enum ERarity : byte { public enum ERarity : byte {
@@ -213,7 +214,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public class BooleanResponse { public class BooleanResponse {
[JsonProperty(PropertyName = "success", Required = Required.Always)] [JsonProperty(PropertyName = "success", Required = Required.Always)]
public readonly bool Success; public readonly bool Success;
@@ -222,7 +223,7 @@ namespace ArchiSteamFarm.Json {
protected BooleanResponse() { } protected BooleanResponse() { }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public sealed class ConfirmationDetails : BooleanResponse { public sealed class ConfirmationDetails : BooleanResponse {
internal MobileAuthenticator.Confirmation Confirmation { get; set; } internal MobileAuthenticator.Confirmation Confirmation { get; set; }
internal ulong TradeOfferID { get; private set; } internal ulong TradeOfferID { get; private set; }
@@ -316,7 +317,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public class EResultResponse { public class EResultResponse {
[JsonProperty(PropertyName = "success", Required = Required.Always)] [JsonProperty(PropertyName = "success", Required = Required.Always)]
public readonly EResult Result; public readonly EResult Result;
@@ -325,7 +326,7 @@ namespace ArchiSteamFarm.Json {
protected EResultResponse() { } protected EResultResponse() { }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
public class NumberResponse { public class NumberResponse {
[PublicAPI] [PublicAPI]
public bool Success { get; private set; } public bool Success { get; private set; }
@@ -415,7 +416,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class InventoryResponse : NumberResponse { internal sealed class InventoryResponse : NumberResponse {
[JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)]
internal readonly ImmutableHashSet<Asset> Assets; internal readonly ImmutableHashSet<Asset> Assets;
@@ -653,7 +654,7 @@ namespace ArchiSteamFarm.Json {
[JsonProperty(PropertyName = "internal_name", Required = Required.Always)] [JsonProperty(PropertyName = "internal_name", Required = Required.Always)]
internal readonly string Value; internal readonly string Value;
internal Tag([NotNull] string identifier, [NotNull] string value) { internal Tag([JetBrains.Annotations.NotNull] string identifier, [JetBrains.Annotations.NotNull] string value) {
if (string.IsNullOrEmpty(identifier) || string.IsNullOrEmpty(value)) { if (string.IsNullOrEmpty(identifier) || string.IsNullOrEmpty(value)) {
throw new ArgumentNullException(nameof(identifier) + " || " + nameof(value)); throw new ArgumentNullException(nameof(identifier) + " || " + nameof(value));
} }
@@ -668,7 +669,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class NewDiscoveryQueueResponse { internal sealed class NewDiscoveryQueueResponse {
[JsonProperty(PropertyName = "queue", Required = Required.Always)] [JsonProperty(PropertyName = "queue", Required = Required.Always)]
internal readonly ImmutableHashSet<uint> Queue; internal readonly ImmutableHashSet<uint> Queue;
@@ -677,7 +678,7 @@ namespace ArchiSteamFarm.Json {
private NewDiscoveryQueueResponse() { } private NewDiscoveryQueueResponse() { }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class RedeemWalletResponse : EResultResponse { internal sealed class RedeemWalletResponse : EResultResponse {
[JsonProperty(PropertyName = "wallet", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "wallet", Required = Required.DisallowNull)]
internal readonly InternalKeyDetails KeyDetails; internal readonly InternalKeyDetails KeyDetails;
@@ -700,7 +701,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class TradeOfferAcceptResponse { internal sealed class TradeOfferAcceptResponse {
[JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)]
internal readonly bool RequiresMobileConfirmation; internal readonly bool RequiresMobileConfirmation;
@@ -722,7 +723,7 @@ namespace ArchiSteamFarm.Json {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class TradeOfferSendResponse { internal sealed class TradeOfferSendResponse {
[JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)] [JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)]
internal readonly bool RequiresMobileConfirmation; internal readonly bool RequiresMobileConfirmation;
@@ -754,7 +755,7 @@ namespace ArchiSteamFarm.Json {
private TradeOfferSendResponse() { } private TradeOfferSendResponse() { }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class UserPrivacy { internal sealed class UserPrivacy {
[JsonProperty(PropertyName = "eCommentPermission", Required = Required.Always)] [JsonProperty(PropertyName = "eCommentPermission", Required = Required.Always)]
internal readonly ECommentPermission CommentPermission; internal readonly ECommentPermission CommentPermission;
@@ -763,7 +764,7 @@ namespace ArchiSteamFarm.Json {
internal readonly PrivacySettings Settings; internal readonly PrivacySettings Settings;
// Constructed from privacy change request // Constructed from privacy change request
internal UserPrivacy([NotNull] PrivacySettings settings, ECommentPermission commentPermission) { internal UserPrivacy([JetBrains.Annotations.NotNull] PrivacySettings settings, ECommentPermission commentPermission) {
Settings = settings ?? throw new ArgumentNullException(nameof(settings)); Settings = settings ?? throw new ArgumentNullException(nameof(settings));
CommentPermission = commentPermission; CommentPermission = commentPermission;
} }

View File

@@ -21,6 +21,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@@ -32,7 +33,7 @@ using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
internal sealed class MobileAuthenticator { internal sealed class MobileAuthenticator {
private const byte CodeDigits = 5; private const byte CodeDigits = 5;
private const byte CodeInterval = 30; private const byte CodeInterval = 30;
@@ -278,7 +279,7 @@ namespace ArchiSteamFarm {
return true; return true;
} }
internal void Init([NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); internal void Init([JetBrains.Annotations.NotNull] Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot));
internal static bool IsValidDeviceID(string deviceID) { internal static bool IsValidDeviceID(string deviceID) {
if (string.IsNullOrEmpty(deviceID)) { if (string.IsNullOrEmpty(deviceID)) {

View File

@@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -58,7 +59,7 @@ namespace ArchiSteamFarm {
private DateTime LastPersonaStateRequest; private DateTime LastPersonaStateRequest;
private bool ShouldSendHeartBeats; private bool ShouldSendHeartBeats;
internal Statistics([NotNull] Bot bot) { internal Statistics([JetBrains.Annotations.NotNull] Bot bot) {
Bot = bot ?? throw new ArgumentNullException(nameof(bot)); Bot = bot ?? throw new ArgumentNullException(nameof(bot));
MatchActivelyTimer = new Timer( MatchActivelyTimer = new Timer(
@@ -340,7 +341,7 @@ namespace ArchiSteamFarm {
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
private async Task<bool> MatchActivelyRound(IReadOnlyCollection<Steam.Asset.EType> acceptedMatchableTypes, IDictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs)> triedSteamIDs) { private async Task<bool> MatchActivelyRound(IReadOnlyCollection<Steam.Asset.EType> acceptedMatchableTypes, IDictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> ReceivedAssetIDs)> triedSteamIDs) {
if ((acceptedMatchableTypes == null) || (acceptedMatchableTypes.Count == 0) || (triedSteamIDs == null)) { if ((acceptedMatchableTypes == null) || (acceptedMatchableTypes.Count == 0) || (triedSteamIDs == null)) {
Bot.ArchiLogger.LogNullError(nameof(acceptedMatchableTypes) + " || " + nameof(triedSteamIDs)); Bot.ArchiLogger.LogNullError(nameof(acceptedMatchableTypes) + " || " + nameof(triedSteamIDs));
@@ -663,7 +664,7 @@ namespace ArchiSteamFarm {
return skippedSetsThisRound.Count > 0; return skippedSetsThisRound.Count > 0;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
private sealed class ListedUser { private sealed class ListedUser {
internal readonly HashSet<Steam.Asset.EType> MatchableTypes = new HashSet<Steam.Asset.EType>(); internal readonly HashSet<Steam.Asset.EType> MatchableTypes = new HashSet<Steam.Asset.EType>();