diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings index 560e5be30..391d1b97a 100644 --- a/ArchiSteamFarm.sln.DotSettings +++ b/ArchiSteamFarm.sln.DotSettings @@ -106,7 +106,6 @@ True END_OF_LINE 1 - 0 END_OF_LINE TOGETHER_SAME_LINE END_OF_LINE diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index fb314046d..f5a60c440 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -41,9 +41,7 @@ namespace ArchiSteamFarm { internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue; - internal ArchiHandler(ArchiLogger archiLogger) { - ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger)); - } + internal ArchiHandler(ArchiLogger archiLogger) => ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger)); public override void HandleMsg(IPacketMsg packetMsg) { if (packetMsg == null) { diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index c2d6dcca0..10f8e41c3 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -175,21 +175,20 @@ namespace ArchiSteamFarm { KeyValue response = null; for (byte i = 0; (i < WebBrowser.MaxRetries) && (response == null); i++) { await Task.Run(() => { - using (dynamic iEconService = WebAPI.GetInterface(IEconService, steamApiKey)) { - iEconService.Timeout = Timeout; + using (dynamic iEconService = WebAPI.GetInterface(IEconService, steamApiKey)) { + iEconService.Timeout = Timeout; - try { - response = iEconService.DeclineTradeOffer( - tradeofferid: tradeID.ToString(), - method: WebRequestMethods.Http.Post, - secure: true - ); - } catch (Exception e) { - Bot.ArchiLogger.LogGenericWarningException(e); - } + try { + response = iEconService.DeclineTradeOffer( + tradeofferid: tradeID.ToString(), + method: WebRequestMethods.Http.Post, + secure: true + ); + } catch (Exception e) { + Bot.ArchiLogger.LogGenericWarningException(e); } - }) - .ConfigureAwait(false); + } + }).ConfigureAwait(false); } if (response == null) { @@ -229,22 +228,21 @@ namespace ArchiSteamFarm { KeyValue response = null; for (byte i = 0; (i < WebBrowser.MaxRetries) && (response == null); i++) { await Task.Run(() => { - using (dynamic iEconService = WebAPI.GetInterface(IEconService, steamApiKey)) { - iEconService.Timeout = Timeout; + using (dynamic iEconService = WebAPI.GetInterface(IEconService, steamApiKey)) { + iEconService.Timeout = Timeout; - try { - response = iEconService.GetTradeOffers( - get_received_offers: 1, - active_only: 1, - get_descriptions: 1, - secure: true - ); - } catch (Exception e) { - Bot.ArchiLogger.LogGenericWarningException(e); - } + try { + response = iEconService.GetTradeOffers( + get_received_offers: 1, + active_only: 1, + get_descriptions: 1, + secure: true + ); + } catch (Exception e) { + Bot.ArchiLogger.LogGenericWarningException(e); } - }) - .ConfigureAwait(false); + } + }).ConfigureAwait(false); } if (response == null) { @@ -614,21 +612,20 @@ namespace ArchiSteamFarm { KeyValue response = null; for (byte i = 0; (i < WebBrowser.MaxRetries) && (response == null); i++) { await Task.Run(() => { - using (dynamic iPlayerService = WebAPI.GetInterface(IPlayerService, steamApiKey)) { - iPlayerService.Timeout = Timeout; + using (dynamic iPlayerService = WebAPI.GetInterface(IPlayerService, steamApiKey)) { + iPlayerService.Timeout = Timeout; - try { - response = iPlayerService.GetOwnedGames( - steamid: steamID, - include_appinfo: 1, - secure: true - ); - } catch (Exception e) { - Bot.ArchiLogger.LogGenericWarningException(e); - } + try { + response = iPlayerService.GetOwnedGames( + steamid: steamID, + include_appinfo: 1, + secure: true + ); + } catch (Exception e) { + Bot.ArchiLogger.LogGenericWarningException(e); } - }) - .ConfigureAwait(false); + } + }).ConfigureAwait(false); } if (response == null) { @@ -654,20 +651,19 @@ namespace ArchiSteamFarm { KeyValue response = null; for (byte i = 0; (i < WebBrowser.MaxRetries) && (response == null); i++) { await Task.Run(() => { - using (dynamic iTwoFactorService = WebAPI.GetInterface(ITwoFactorService)) { - iTwoFactorService.Timeout = Timeout; + using (dynamic iTwoFactorService = WebAPI.GetInterface(ITwoFactorService)) { + iTwoFactorService.Timeout = Timeout; - try { - response = iTwoFactorService.QueryTime( - method: WebRequestMethods.Http.Post, - secure: true - ); - } catch (Exception e) { - Bot.ArchiLogger.LogGenericWarningException(e); - } + try { + response = iTwoFactorService.QueryTime( + method: WebRequestMethods.Http.Post, + secure: true + ); + } catch (Exception e) { + Bot.ArchiLogger.LogGenericWarningException(e); } - }) - .ConfigureAwait(false); + } + }).ConfigureAwait(false); } if (response != null) { @@ -810,13 +806,9 @@ namespace ArchiSteamFarm { } } - internal async Task HasValidApiKey() { - return !string.IsNullOrEmpty(await GetApiKey().ConfigureAwait(false)); - } + internal async Task HasValidApiKey() => !string.IsNullOrEmpty(await GetApiKey().ConfigureAwait(false)); - internal static void Init() { - Timeout = Program.GlobalConfig.ConnectionTimeout * 1000; - } + internal static void Init() => Timeout = Program.GlobalConfig.ConnectionTimeout * 1000; internal async Task Init(ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalPin) { if ((steamID == 0) || (universe == EUniverse.Invalid) || string.IsNullOrEmpty(webAPIUserNonce) || string.IsNullOrEmpty(parentalPin)) { @@ -847,23 +839,22 @@ namespace ArchiSteamFarm { KeyValue authResult = null; await Task.Run(() => { - using (dynamic iSteamUserAuth = WebAPI.GetInterface(ISteamUserAuth)) { - iSteamUserAuth.Timeout = Timeout; + using (dynamic iSteamUserAuth = WebAPI.GetInterface(ISteamUserAuth)) { + iSteamUserAuth.Timeout = Timeout; - try { - authResult = iSteamUserAuth.AuthenticateUser( - steamid: steamID, - sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)), - encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)), - method: WebRequestMethods.Http.Post, - secure: true - ); - } catch (Exception e) { - Bot.ArchiLogger.LogGenericWarningException(e); - } + try { + authResult = iSteamUserAuth.AuthenticateUser( + steamid: steamID, + sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)), + encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)), + method: WebRequestMethods.Http.Post, + secure: true + ); + } catch (Exception e) { + Bot.ArchiLogger.LogGenericWarningException(e); } - }) - .ConfigureAwait(false); + } + }).ConfigureAwait(false); if (authResult == null) { return false; diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index d21ed1ed6..211e15009 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -56,7 +56,6 @@ namespace ArchiSteamFarm { private static readonly SemaphoreSlim GiftsSemaphore = new SemaphoreSlim(1); private static readonly SemaphoreSlim LoginSemaphore = new SemaphoreSlim(1); - internal readonly ArchiLogger ArchiLogger; internal readonly ArchiWebHandler ArchiWebHandler; internal readonly string BotName; @@ -81,6 +80,7 @@ namespace ArchiSteamFarm { private readonly Timer HeartBeatTimer; private readonly SemaphoreSlim InitializationSemaphore = new SemaphoreSlim(1); private readonly ConcurrentHashSet OwnedPackageIDs = new ConcurrentHashSet(); + private readonly Statistics Statistics; private readonly SteamApps SteamApps; private readonly SteamClient SteamClient; @@ -510,9 +510,7 @@ namespace ArchiSteamFarm { } } - internal void OnFarmingStopped() { - ResetGamesPlayed(); - } + internal void OnFarmingStopped() => ResetGamesPlayed(); internal async Task OnNewConfigLoaded(ASF.BotConfigEventArgs args) { if (args == null) { @@ -546,9 +544,7 @@ namespace ArchiSteamFarm { } } - internal void PlayGame(uint gameID, string gameName = null) { - PlayGames(gameID.ToEnumerable(), gameName); - } + internal void PlayGame(uint gameID, string gameName = null) => PlayGames(gameID.ToEnumerable(), gameName); internal void PlayGames(IEnumerable gameIDs, string gameName = null) { if (gameIDs == null) { @@ -846,7 +842,7 @@ namespace ArchiSteamFarm { Task.Run(() => Stop()).Forget(); } - Bots.TryRemove(BotName, out _); + Bots.TryRemove(BotName, out Bot _); } private void Disconnect() { @@ -925,9 +921,7 @@ namespace ArchiSteamFarm { return result; } - private ulong GetFirstSteamMasterID() { - return BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Key != SteamID) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderBy(steamID => steamID).FirstOrDefault(); - } + private ulong GetFirstSteamMasterID() => BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Key != SteamID) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderBy(steamID => steamID).FirstOrDefault(); private BotConfig.EPermission GetSteamUserPermission(ulong steamID) { if (steamID != 0) { @@ -1202,19 +1196,17 @@ namespace ArchiSteamFarm { private static async Task LimitGiftsRequestsAsync() { await GiftsSemaphore.WaitAsync().ConfigureAwait(false); Task.Run(async () => { - await Task.Delay(Program.GlobalConfig.GiftsLimiterDelay * 1000).ConfigureAwait(false); - GiftsSemaphore.Release(); - }) - .Forget(); + await Task.Delay(Program.GlobalConfig.GiftsLimiterDelay * 1000).ConfigureAwait(false); + GiftsSemaphore.Release(); + }).Forget(); } private static async Task LimitLoginRequestsAsync() { await LoginSemaphore.WaitAsync().ConfigureAwait(false); Task.Run(async () => { - await Task.Delay(Program.GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false); - LoginSemaphore.Release(); - }) - .Forget(); + await Task.Delay(Program.GlobalConfig.LoginLimiterDelay * 1000).ConfigureAwait(false); + LoginSemaphore.Release(); + }).Forget(); } private async Task MarkInventoryIfNeeded() { @@ -1682,10 +1674,9 @@ namespace ArchiSteamFarm { if (BotConfig.SteamMasterClanID != 0) { Task.Run(async () => { - await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false); - JoinMasterChat(); - }) - .Forget(); + await ArchiWebHandler.JoinGroup(BotConfig.SteamMasterClanID).ConfigureAwait(false); + JoinMasterChat(); + }).Forget(); } Statistics?.OnLoggedOn().Forget(); @@ -2308,10 +2299,9 @@ namespace ArchiSteamFarm { // Schedule the task after some time so user can receive response Task.Run(async () => { - await Task.Delay(1000).ConfigureAwait(false); - await Program.Exit().ConfigureAwait(false); - }) - .Forget(); + await Task.Delay(1000).ConfigureAwait(false); + await Program.Exit().ConfigureAwait(false); + }).Forget(); return FormatStaticResponse(Strings.Done); } @@ -3171,10 +3161,9 @@ namespace ArchiSteamFarm { // Schedule the task after some time so user can receive response Task.Run(async () => { - await Task.Delay(1000).ConfigureAwait(false); - await Program.Restart().ConfigureAwait(false); - }) - .Forget(); + await Task.Delay(1000).ConfigureAwait(false); + await Program.Restart().ConfigureAwait(false); + }).Forget(); return FormatStaticResponse(Strings.Done); } diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs index 2ab7c68d2..025343f10 100644 --- a/ArchiSteamFarm/BotDatabase.cs +++ b/ArchiSteamFarm/BotDatabase.cs @@ -95,9 +95,7 @@ namespace ArchiSteamFarm { } } - internal IEnumerable GetBlacklistedFromTradesSteamIDs() { - return BlacklistedFromTradesSteamIDs; - } + internal IEnumerable GetBlacklistedFromTradesSteamIDs() => BlacklistedFromTradesSteamIDs; internal bool IsBlacklistedFromTrades(ulong steamID) { if (steamID != 0) { diff --git a/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs b/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs index f57c0f1a9..0d341c27e 100644 --- a/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs +++ b/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs @@ -42,9 +42,7 @@ namespace ArchiSteamFarm.CMsgs { AcceptInvite = binaryReader.ReadBoolean(); } - EMsg ISteamSerializableMessage.GetEMsg() { - return EMsg.ClientAcknowledgeClanInvite; - } + EMsg ISteamSerializableMessage.GetEMsg() => EMsg.ClientAcknowledgeClanInvite; void ISteamSerializable.Serialize(Stream stream) { if (stream == null) { diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index c02c71f55..b7a967f05 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -90,9 +90,7 @@ namespace ArchiSteamFarm { IdleFarmingTimer?.Dispose(); } - internal void OnDisconnected() { - StopFarming().Forget(); - } + internal void OnDisconnected() => StopFarming().Forget(); internal async Task OnNewGameAdded() { // If we're not farming yet, obviously it's worth it to make a check @@ -148,9 +146,7 @@ namespace ArchiSteamFarm { } } - internal void SetInitialState(bool paused) { - StickyPause = Paused = paused; - } + internal void SetInitialState(bool paused) => StickyPause = Paused = paused; internal async Task StartFarming() { if (NowFarming || Paused || !Bot.IsPlayingPossible) { @@ -848,13 +844,9 @@ namespace ArchiSteamFarm { return (game != null) && Equals(game); } - public override int GetHashCode() { - return (int) AppID; - } + public override int GetHashCode() => (int) AppID; - private bool Equals(Game other) { - return AppID == other.AppID; - } + private bool Equals(Game other) => AppID == other.AppID; } } } \ No newline at end of file diff --git a/ArchiSteamFarm/ConcurrentEnumerator.cs b/ArchiSteamFarm/ConcurrentEnumerator.cs index be3325995..034baade2 100644 --- a/ArchiSteamFarm/ConcurrentEnumerator.cs +++ b/ArchiSteamFarm/ConcurrentEnumerator.cs @@ -45,16 +45,8 @@ namespace ArchiSteamFarm { Enumerator = collection.GetEnumerator(); } - public void Dispose() { - Lock.Dispose(); - } - - public bool MoveNext() { - return Enumerator.MoveNext(); - } - - public void Reset() { - Enumerator.Reset(); - } + public void Dispose() => Lock.Dispose(); + public bool MoveNext() => Enumerator.MoveNext(); + public void Reset() => Enumerator.Reset(); } } \ No newline at end of file diff --git a/ArchiSteamFarm/ConcurrentHashSet.cs b/ArchiSteamFarm/ConcurrentHashSet.cs index 981b20429..e451b27c3 100644 --- a/ArchiSteamFarm/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/ConcurrentHashSet.cs @@ -72,9 +72,7 @@ namespace ArchiSteamFarm { } } - public IEnumerator GetEnumerator() { - return new ConcurrentEnumerator(HashSet, Lock); - } + public IEnumerator GetEnumerator() => new ConcurrentEnumerator(HashSet, Lock); public void IntersectWith(IEnumerable other) { using (Lock.WriterLock()) { @@ -136,13 +134,9 @@ namespace ArchiSteamFarm { } } - void ICollection.Add(T item) { - Add(item); - } + void ICollection.Add(T item) => Add(item); - IEnumerator IEnumerable.GetEnumerator() { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); internal bool AddRange(IEnumerable items) { using (Lock.WriterLock()) { diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index e31b5844b..7ce85d382 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -77,9 +77,7 @@ namespace ArchiSteamFarm { ServerListProvider.ServerListUpdated += OnServerListUpdated; } - public void Dispose() { - ServerListProvider.ServerListUpdated -= OnServerListUpdated; - } + public void Dispose() => ServerListProvider.ServerListUpdated -= OnServerListUpdated; internal static GlobalDatabase Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { @@ -109,9 +107,7 @@ namespace ArchiSteamFarm { return globalDatabase; } - private void OnServerListUpdated(object sender, EventArgs e) { - Save(); - } + private void OnServerListUpdated(object sender, EventArgs e) => Save(); private void Save() { string json = JsonConvert.SerializeObject(this, CustomSerializerSettings); diff --git a/ArchiSteamFarm/IPAddressConverter.cs b/ArchiSteamFarm/IPAddressConverter.cs index 4669e76e8..f6ab83fe0 100644 --- a/ArchiSteamFarm/IPAddressConverter.cs +++ b/ArchiSteamFarm/IPAddressConverter.cs @@ -29,9 +29,7 @@ using Newtonsoft.Json.Linq; namespace ArchiSteamFarm { internal sealed class IPAddressConverter : JsonConverter { - public override bool CanConvert(Type objectType) { - return objectType == typeof(IPAddress); - } + public override bool CanConvert(Type objectType) => objectType == typeof(IPAddress); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JToken token = JToken.Load(reader); diff --git a/ArchiSteamFarm/IPEndPointConverter.cs b/ArchiSteamFarm/IPEndPointConverter.cs index 890586762..8f89d2e28 100644 --- a/ArchiSteamFarm/IPEndPointConverter.cs +++ b/ArchiSteamFarm/IPEndPointConverter.cs @@ -29,9 +29,7 @@ using Newtonsoft.Json.Linq; namespace ArchiSteamFarm { internal sealed class IPEndPointConverter : JsonConverter { - public override bool CanConvert(Type objectType) { - return objectType == typeof(IPEndPoint); - } + public override bool CanConvert(Type objectType) => objectType == typeof(IPEndPoint); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); diff --git a/ArchiSteamFarm/InMemoryServerListProvider.cs b/ArchiSteamFarm/InMemoryServerListProvider.cs index a0858f406..9eecb58b5 100644 --- a/ArchiSteamFarm/InMemoryServerListProvider.cs +++ b/ArchiSteamFarm/InMemoryServerListProvider.cs @@ -34,9 +34,7 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] private readonly ConcurrentHashSet Servers = new ConcurrentHashSet(); - public Task> FetchServerListAsync() { - return Task.FromResult>(Servers); - } + public Task> FetchServerListAsync() => Task.FromResult>(Servers); public Task UpdateServerListAsync(IEnumerable endPoints) { if (endPoints == null) { diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index c11188659..a41a840de 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -440,7 +440,7 @@ namespace ArchiSteamFarm.JSON { internal bool IsFairTypesExchange() { Dictionary> itemsToGivePerGame = new Dictionary>(); foreach (Item item in ItemsToGive) { - if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out Dictionary itemsPerType)) { + if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out Dictionary itemsPerType)) { itemsPerType = new Dictionary { [item.Type] = item.Amount }; itemsToGivePerGame[item.RealAppID] = itemsPerType; } else { @@ -489,9 +489,7 @@ namespace ArchiSteamFarm.JSON { return true; } - internal bool IsSteamCardsRequest() { - return ItemsToGive.All(item => (item.AppID == Item.SteamAppID) && (item.ContextID == Item.SteamCommunityContextID) && (item.Type == Item.EType.TradingCard)); - } + internal bool IsSteamCardsRequest() => ItemsToGive.All(item => (item.AppID == Item.SteamAppID) && (item.ContextID == Item.SteamCommunityContextID) && (item.Type == Item.EType.TradingCard)); [SuppressMessage("ReSharper", "UnusedMember.Global")] internal enum ETradeOfferState : byte { diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index 76c769210..4daf95202 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -68,9 +68,7 @@ namespace ArchiSteamFarm { private MobileAuthenticator() { } - public void Dispose() { - ConfirmationsSemaphore.Dispose(); - } + public void Dispose() => ConfirmationsSemaphore.Dispose(); internal void CorrectDeviceID(string deviceID) { if (string.IsNullOrEmpty(deviceID)) { @@ -248,9 +246,7 @@ namespace ArchiSteamFarm { } } - internal void Init(Bot bot) { - Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - } + internal void Init(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); internal static async Task OnTimeChanged() { await TimeSemaphore.WaitAsync().ConfigureAwait(false); diff --git a/ArchiSteamFarm/OS.cs b/ArchiSteamFarm/OS.cs index 94d01e682..f429570fc 100644 --- a/ArchiSteamFarm/OS.cs +++ b/ArchiSteamFarm/OS.cs @@ -77,9 +77,7 @@ namespace ArchiSteamFarm { } } - private static async void OnTimeChanged(object sender, EventArgs e) { - await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false); - } + private static async void OnTimeChanged(object sender, EventArgs e) => await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false); private static class NativeMethods { internal const uint EnableQuickEditMode = 0x0040; diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 5bcdf2c18..599b36bf8 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -446,22 +446,18 @@ namespace ArchiSteamFarm { ServiceName = SharedInfo.ServiceName; } - protected override void OnStart(string[] args) { - Task.Run(async () => { - // Normally it'd make sense to use already provided string[] args parameter above - // However, that one doesn't seem to work when ASF is started as a service, it's always null - // Therefore, we will use Environment args in such case - string[] envArgs = Environment.GetCommandLineArgs(); - await Init(envArgs).ConfigureAwait(false); + protected override void OnStart(string[] args) => Task.Run(async () => { + // Normally it'd make sense to use already provided string[] args parameter above + // However, that one doesn't seem to work when ASF is started as a service, it's always null + // Therefore, we will use Environment args in such case + string[] envArgs = Environment.GetCommandLineArgs(); + await Init(envArgs).ConfigureAwait(false); - ShutdownResetEvent.Wait(); - Stop(); - }); - } + ShutdownResetEvent.Wait(); + Stop(); + }); - protected override async void OnStop() { - await Shutdown().ConfigureAwait(false); - } + protected override async void OnStop() => await Shutdown().ConfigureAwait(false); } } } \ No newline at end of file diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 3784bc5e3..ecf71af06 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -48,13 +48,9 @@ namespace ArchiSteamFarm { private DateTime LastPersonaStateRequest = DateTime.MinValue; private bool ShouldSendHeartBeats; - internal Statistics(Bot bot) { - Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - } + internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - public void Dispose() { - Semaphore.Dispose(); - } + public void Dispose() => Semaphore.Dispose(); internal async Task OnHeartBeat() { // Request persona update if needed @@ -89,9 +85,7 @@ namespace ArchiSteamFarm { } } - internal async Task OnLoggedOn() { - await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false); - } + internal async Task OnLoggedOn() => await Bot.ArchiWebHandler.JoinGroup(SharedInfo.ASFGroupSteamID).ConfigureAwait(false); internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) { if (callback == null) { diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index de4e0a738..91e84269c 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -43,13 +43,9 @@ namespace ArchiSteamFarm { private bool ParsingScheduled; - internal Trading(Bot bot) { - Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - } + internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - public void Dispose() { - TradesSemaphore.Dispose(); - } + public void Dispose() => TradesSemaphore.Dispose(); internal async Task CheckTrades() { // We aim to have a maximum of 2 tasks, one already parsing, and one waiting in the queue @@ -78,15 +74,12 @@ namespace ArchiSteamFarm { internal static async Task LimitInventoryRequestsAsync() { await InventorySemaphore.WaitAsync().ConfigureAwait(false); Task.Run(async () => { - await Task.Delay(Program.GlobalConfig.InventoryLimiterDelay * 1000).ConfigureAwait(false); - InventorySemaphore.Release(); - }) - .Forget(); + await Task.Delay(Program.GlobalConfig.InventoryLimiterDelay * 1000).ConfigureAwait(false); + InventorySemaphore.Release(); + }).Forget(); } - internal void OnDisconnected() { - IgnoredTrades.ClearAndTrim(); - } + internal void OnDisconnected() => IgnoredTrades.ClearAndTrim(); private async Task ParseActiveTrades() { HashSet tradeOffers = await Bot.ArchiWebHandler.GetActiveTradeOffers().ConfigureAwait(false); diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index bef3ff795..83c39bf3f 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -68,9 +68,7 @@ namespace ArchiSteamFarm { return cookies.Count != 0 ? (from Cookie cookie in cookies where cookie.Name.Equals(name) select cookie.Value).FirstOrDefault() : null; } - internal static uint GetUnixTime() { - return (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - } + internal static uint GetUnixTime() => (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds(); /* internal static int RandomNext(int maxWithout) { @@ -99,7 +97,7 @@ namespace ArchiSteamFarm { for (byte i = 0; i < text.Length; i += split) { string textPart = string.Join("", text.Skip(i).Take(split)); - if (!ulong.TryParse(textPart, NumberStyles.HexNumber, null, out _)) { + if (!ulong.TryParse(textPart, NumberStyles.HexNumber, null, out ulong _)) { return false; } } diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index d23c78f32..68bde4deb 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -50,9 +50,7 @@ namespace ArchiSteamFarm { StopServer(); } - public string GetStatus() { - return Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots); - } + public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots); public string HandleCommand(string input) { if (string.IsNullOrEmpty(input)) { diff --git a/ArchiSteamFarm/WebBrowser.cs b/ArchiSteamFarm/WebBrowser.cs index 49d46bf37..d44c45d7c 100644 --- a/ArchiSteamFarm/WebBrowser.cs +++ b/ArchiSteamFarm/WebBrowser.cs @@ -305,11 +305,7 @@ namespace ArchiSteamFarm { } #if !__MonoCS__ - - private static void InitNonMonoBehaviour() { - ServicePointManager.ReusePort = true; - } - + private static void InitNonMonoBehaviour() => ServicePointManager.ReusePort = true; #endif private async Task UrlGetToBytes(string request, string referer = null) { diff --git a/ArchiSteamFarm/config/ASF.json b/ArchiSteamFarm/config/ASF.json index 9cdd15b21..0f797679c 100644 --- a/ArchiSteamFarm/config/ASF.json +++ b/ArchiSteamFarm/config/ASF.json @@ -1,24 +1,24 @@ { - "AutoRestart": true, - "AutoUpdates": true, - "Blacklist": [], - "ConnectionTimeout": 60, - "CurrentCulture": null, - "Debug": false, - "FarmingDelay": 15, - "GiftsLimiterDelay": 1, - "Headless": false, - "IdleFarmingPeriod": 3, - "InventoryLimiterDelay": 3, - "LoginLimiterDelay": 10, - "MaxFarmingTime": 10, - "MaxTradeHoldDuration": 15, - "OptimizationMode": 0, - "Statistics": true, - "SteamOwnerID": 0, - "SteamProtocol": 6, - "UpdateChannel": 1, - "WCFBinding": 0, - "WCFHost": "127.0.0.1", - "WCFPort": 1242 + "AutoRestart": true, + "AutoUpdates": true, + "Blacklist": [], + "ConnectionTimeout": 60, + "CurrentCulture": null, + "Debug": false, + "FarmingDelay": 15, + "GiftsLimiterDelay": 1, + "Headless": false, + "IdleFarmingPeriod": 3, + "InventoryLimiterDelay": 3, + "LoginLimiterDelay": 10, + "MaxFarmingTime": 10, + "MaxTradeHoldDuration": 15, + "OptimizationMode": 0, + "Statistics": true, + "SteamOwnerID": 0, + "SteamProtocol": 6, + "UpdateChannel": 1, + "WCFBinding": 0, + "WCFHost": "127.0.0.1", + "WCFPort": 1242 } \ No newline at end of file diff --git a/ArchiSteamFarm/config/example.json b/ArchiSteamFarm/config/example.json index baaf8d778..6ea3822a2 100644 --- a/ArchiSteamFarm/config/example.json +++ b/ArchiSteamFarm/config/example.json @@ -1,31 +1,31 @@ { - "AcceptGifts": false, - "CardDropsRestricted": true, - "CustomGamePlayedWhileFarming": null, - "CustomGamePlayedWhileIdle": null, - "DismissInventoryNotifications": false, - "Enabled": false, - "FarmingOrder": 0, - "FarmOffline": false, - "GamesPlayedWhileIdle": [], - "HandleOfflineMessages": false, - "IsBotAccount": false, - "LootableTypes": [ - 1, - 3, - 5 - ], - "PasswordFormat": 0, - "Paused": false, - "RedeemingPreferences": 0, - "SendOnFarmingFinished": false, - "SendTradePeriod": 0, - "ShutdownOnFarmingFinished": false, - "SteamLogin": null, - "SteamMasterClanID": 0, - "SteamParentalPIN": "0", - "SteamPassword": null, - "SteamTradeToken": null, - "SteamUserPermissions": {}, - "TradingPreferences": 0 -} \ No newline at end of file + "AcceptGifts": false, + "CardDropsRestricted": true, + "CustomGamePlayedWhileFarming": null, + "CustomGamePlayedWhileIdle": null, + "DismissInventoryNotifications": false, + "Enabled": false, + "FarmingOrder": 0, + "FarmOffline": false, + "GamesPlayedWhileIdle": [], + "HandleOfflineMessages": false, + "IsBotAccount": false, + "LootableTypes": [ + 1, + 3, + 5 + ], + "PasswordFormat": 0, + "Paused": false, + "RedeemingPreferences": 0, + "SendOnFarmingFinished": false, + "SendTradePeriod": 0, + "ShutdownOnFarmingFinished": false, + "SteamLogin": null, + "SteamMasterClanID": 0, + "SteamParentalPIN": "0", + "SteamPassword": null, + "SteamTradeToken": null, + "SteamUserPermissions": {}, + "TradingPreferences": 0 +} diff --git a/ArchiSteamFarm/config/minimal.json b/ArchiSteamFarm/config/minimal.json index 22e780aca..9699bdba5 100644 --- a/ArchiSteamFarm/config/minimal.json +++ b/ArchiSteamFarm/config/minimal.json @@ -1,5 +1,5 @@ { - "Enabled": false, - "SteamLogin": null, - "SteamPassword": null -} \ No newline at end of file + "Enabled": false, + "SteamLogin": null, + "SteamPassword": null +} diff --git a/ArchiSteamFarm/packages.config b/ArchiSteamFarm/packages.config index 4249e77fe..bda25b0dc 100644 --- a/ArchiSteamFarm/packages.config +++ b/ArchiSteamFarm/packages.config @@ -1,16 +1,15 @@  - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/ConfigGenerator/ConfigPage.cs b/ConfigGenerator/ConfigPage.cs index cb8f42407..3171c186f 100644 --- a/ConfigGenerator/ConfigPage.cs +++ b/ConfigGenerator/ConfigPage.cs @@ -39,8 +39,6 @@ namespace ConfigGenerator { Controls.Add(enhancedPropertyGrid); } - internal void RefreshText() { - Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath); - } + internal void RefreshText() => Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath); } } \ No newline at end of file diff --git a/ConfigGenerator/FlagEnumEditor.cs b/ConfigGenerator/FlagEnumEditor.cs index d026565e6..93a8ddd75 100644 --- a/ConfigGenerator/FlagEnumEditor.cs +++ b/ConfigGenerator/FlagEnumEditor.cs @@ -68,9 +68,7 @@ namespace ConfigGenerator { } // Gets the current bit value corresponding to all checked items - private int GetCurrentValue() { - return (from object t in Items select t as FlagCheckedListBoxItem).Where((item, i) => (item != null) && GetItemChecked(i)).Aggregate(0, (current, item) => current | item.Value); - } + private int GetCurrentValue() => (from object t in Items select t as FlagCheckedListBoxItem).Where((item, i) => (item != null) && GetItemChecked(i)).Aggregate(0, (current, item) => current | item.Value); #region Component Designer generated code @@ -148,9 +146,7 @@ namespace ConfigGenerator { Caption = c; } - public override string ToString() { - return Caption; - } + public override string ToString() => Caption; } // UITypeEditor for flag enums @@ -179,8 +175,6 @@ namespace ConfigGenerator { return FlagEnumCb.EnumValue; } - public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { - return UITypeEditorEditStyle.DropDown; - } + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.DropDown; } } \ No newline at end of file diff --git a/ConfigGenerator/packages.config b/ConfigGenerator/packages.config index 4982963b5..2897ef632 100644 --- a/ConfigGenerator/packages.config +++ b/ConfigGenerator/packages.config @@ -1,9 +1,8 @@  - - - - - - + + + + + \ No newline at end of file diff --git a/GUI/BotStatusForm.cs b/GUI/BotStatusForm.cs index ad422a2a7..60bf58641 100644 --- a/GUI/BotStatusForm.cs +++ b/GUI/BotStatusForm.cs @@ -40,8 +40,6 @@ namespace ArchiSteamFarm { AvatarPictureBox.LoadAsync(); } - private void AvatarPictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e) { - MainForm.UpdateBotAvatar(Bot.BotName, AvatarPictureBox.Image); - } + private void AvatarPictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e) => MainForm.UpdateBotAvatar(Bot.BotName, AvatarPictureBox.Image); } } \ No newline at end of file diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 5cef4b172..52ab8a940 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -57,9 +57,7 @@ namespace ArchiSteamFarm { BotStatusForm.BotForms[PreviouslySelectedBotName].Visible = true; } - private async void MainForm_FormClosed(object sender, FormClosedEventArgs e) { - await Program.InitShutdownSequence().ConfigureAwait(false); - } + private async void MainForm_FormClosed(object sender, FormClosedEventArgs e) => await Program.InitShutdownSequence().ConfigureAwait(false); private async void MainForm_Load(object sender, EventArgs e) { BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList; diff --git a/GUI/Program.cs b/GUI/Program.cs index 980b0f987..79c5fe342 100644 --- a/GUI/Program.cs +++ b/GUI/Program.cs @@ -29,9 +29,7 @@ namespace ArchiSteamFarm { Application.Exit(); } - internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) { - return null; - } + internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) => null; // TODO internal static async Task InitASF() { ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version); diff --git a/GUI/packages.config b/GUI/packages.config index 4f7360db2..95f0f49d6 100644 --- a/GUI/packages.config +++ b/GUI/packages.config @@ -1,17 +1,16 @@  - - - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file