From 847c78b6504f4f19994857aff93ee1deb3a4c57c Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 5 Mar 2020 21:05:40 +0100 Subject: [PATCH] R# cleanup --- ArchiSteamFarm.sln.DotSettings | 1 + ArchiSteamFarm/Actions.cs | 36 +++++++++++++++++----------------- ArchiSteamFarm/Bot.cs | 2 +- ArchiSteamFarm/CardsFarmer.cs | 6 ++++-- ArchiSteamFarm/IPC/Startup.cs | 2 ++ ArchiSteamFarm/Json/Steam.cs | 15 +++++++------- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings index 819d988c5..f1751c32c 100644 --- a/ArchiSteamFarm.sln.DotSettings +++ b/ArchiSteamFarm.sln.DotSettings @@ -537,6 +537,7 @@ limitations under the License. <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + False False LIVE_MONITOR LIVE_MONITOR diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index fdc6aef42..c92d46eeb 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -233,24 +233,6 @@ namespace ArchiSteamFarm { return (true, Strings.BotAutomaticIdlingNowResumed); } - [Obsolete] - [PublicAPI] - 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 wantedRealAppIDs = null, IReadOnlyCollection unwantedRealAppIDs = null, IReadOnlyCollection wantedTypes = null) { - if ((appID == 0) || (contextID == 0)) { - Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); - - return (false, string.Format(Strings.ErrorObjectIsNull, nameof(appID) + " || " + nameof(contextID))); - } - - if ((wantedRealAppIDs?.Count == 0) || (unwantedRealAppIDs?.Count == 0) || (wantedTypes?.Count == 0)) { - Bot.ArchiLogger.LogNullError(nameof(wantedRealAppIDs) + " || " + nameof(unwantedRealAppIDs) + " || " + nameof(wantedTypes)); - - return (false, string.Format(Strings.ErrorObjectIsNull, nameof(wantedRealAppIDs) + " || " + nameof(unwantedRealAppIDs) + " || " + nameof(wantedTypes))); - } - - return await SendInventory(appID, contextID, targetSteamID, tradeToken, item => (wantedRealAppIDs?.Contains(item.RealAppID) != false) && (unwantedRealAppIDs?.Contains(item.RealAppID) != true) && (wantedTypes?.Contains(item.Type) != false)).ConfigureAwait(false); - } - [PublicAPI] [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] public async Task<(bool Success, string Message)> SendInventory(uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, ulong targetSteamID = 0, string tradeToken = null, Func filterFunction = null) { @@ -344,6 +326,24 @@ namespace ArchiSteamFarm { return (true, Strings.BotLootingSuccess); } + [Obsolete] + [PublicAPI] + 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 wantedRealAppIDs = null, IReadOnlyCollection unwantedRealAppIDs = null, IReadOnlyCollection wantedTypes = null) { + if ((appID == 0) || (contextID == 0)) { + Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); + + return (false, string.Format(Strings.ErrorObjectIsNull, nameof(appID) + " || " + nameof(contextID))); + } + + if ((wantedRealAppIDs?.Count == 0) || (unwantedRealAppIDs?.Count == 0) || (wantedTypes?.Count == 0)) { + Bot.ArchiLogger.LogNullError(nameof(wantedRealAppIDs) + " || " + nameof(unwantedRealAppIDs) + " || " + nameof(wantedTypes)); + + return (false, string.Format(Strings.ErrorObjectIsNull, nameof(wantedRealAppIDs) + " || " + nameof(unwantedRealAppIDs) + " || " + nameof(wantedTypes))); + } + + return await SendInventory(appID, contextID, targetSteamID, tradeToken, item => (wantedRealAppIDs?.Contains(item.RealAppID) != false) && (unwantedRealAppIDs?.Contains(item.RealAppID) != true) && (wantedTypes?.Contains(item.Type) != false)).ConfigureAwait(false); + } + [PublicAPI] public (bool Success, string Message) Start() { if (Bot.KeepRunning) { diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 2dc6eab92..d3fb3306f 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -454,7 +454,7 @@ namespace ArchiSteamFarm { return permission switch { BotConfig.EPermission.FamilySharing when SteamFamilySharingIDs.Contains(steamID) => true, - _ => BotConfig.SteamUserPermissions.TryGetValue(steamID, out BotConfig.EPermission realPermission) && (realPermission >= permission), + _ => BotConfig.SteamUserPermissions.TryGetValue(steamID, out BotConfig.EPermission realPermission) && (realPermission >= permission) }; } diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 97d2e6b77..4705bfa07 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -23,6 +23,7 @@ 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; @@ -97,7 +98,7 @@ namespace ArchiSteamFarm { private bool PermanentlyPaused; private bool ShouldResumeFarming = true; - internal CardsFarmer([NotNull] Bot bot) { + internal CardsFarmer([JetBrains.Annotations.NotNull] Bot bot) { Bot = bot ?? throw new ArgumentNullException(nameof(bot)); if (ASF.GlobalConfig.IdleFarmingPeriod > 0) { @@ -370,6 +371,7 @@ namespace ArchiSteamFarm { await StartFarming().ConfigureAwait(false); } + [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] private async Task CheckPage(HtmlDocument htmlDocument, ISet parsedAppIDs) { if ((htmlDocument == null) || (parsedAppIDs == null)) { Bot.ArchiLogger.LogNullError(nameof(htmlDocument) + " || " + nameof(parsedAppIDs)); @@ -1240,7 +1242,7 @@ namespace ArchiSteamFarm { internal uint PlayableAppID { get; set; } - internal Game(uint appID, [NotNull] string gameName, float hoursPlayed, ushort cardsRemaining, byte badgeLevel) { + internal Game(uint appID, [JetBrains.Annotations.NotNull] string gameName, float hoursPlayed, ushort cardsRemaining, byte badgeLevel) { if ((appID == 0) || string.IsNullOrEmpty(gameName) || (hoursPlayed < 0) || (cardsRemaining == 0)) { throw new ArgumentOutOfRangeException(nameof(appID) + " || " + nameof(gameName) + " || " + nameof(hoursPlayed) + " || " + nameof(cardsRemaining)); } diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index 0b92eb904..c97d86a01 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -44,8 +44,10 @@ namespace ArchiSteamFarm.IPC { public Startup([NotNull] IConfiguration configuration) => Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); #if NETFRAMEWORK + [UsedImplicitly] public void Configure(IApplicationBuilder app, IHostingEnvironment env) { #else + [UsedImplicitly] public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { #endif if ((app == null) || (env == null)) { diff --git a/ArchiSteamFarm/Json/Steam.cs b/ArchiSteamFarm/Json/Steam.cs index 43bd03225..2b5bfe5d3 100644 --- a/ArchiSteamFarm/Json/Steam.cs +++ b/ArchiSteamFarm/Json/Steam.cs @@ -488,9 +488,8 @@ namespace ArchiSteamFarm.Json { [JsonProperty(PropertyName = "appid", Required = Required.Always)] internal readonly uint AppID; - internal ulong ClassID { get; private set; } - internal ulong InstanceID { get; private set; } - internal bool Marketable { get; private set; } + [JsonProperty(PropertyName = "tags", Required = Required.DisallowNull)] + internal readonly ImmutableHashSet Tags; internal Asset.ERarity Rarity { get { @@ -545,11 +544,6 @@ namespace ArchiSteamFarm.Json { } } - [JsonProperty(PropertyName = "tags", Required = Required.DisallowNull)] - internal readonly ImmutableHashSet Tags; - - internal bool Tradable { get; private set; } - internal Asset.EType Type { get { Asset.EType type = Asset.EType.Unknown; @@ -612,6 +606,11 @@ namespace ArchiSteamFarm.Json { } } + internal ulong ClassID { get; private set; } + internal ulong InstanceID { get; private set; } + internal bool Marketable { get; private set; } + internal bool Tradable { get; private set; } + #pragma warning disable IDE0051 [JsonProperty(PropertyName = "classid", Required = Required.Always)] private string ClassIDText {