diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index 6ea619789..70b1b722b 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -41,13 +41,7 @@ namespace ArchiSteamFarm { internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue; - internal ArchiHandler(ArchiLogger archiLogger) { - if (archiLogger == null) { - throw new ArgumentNullException(nameof(archiLogger)); - } - - ArchiLogger = 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 fee75a116..66713d529 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -69,12 +69,7 @@ namespace ArchiSteamFarm { private ulong SteamID; internal ArchiWebHandler(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = bot; - + Bot = bot ?? throw new ArgumentNullException(nameof(bot)); WebBrowser = new WebBrowser(bot.ArchiLogger); } @@ -417,8 +412,7 @@ namespace ArchiSteamFarm { return null; } - uint steamID3; - if (!uint.TryParse(miniProfile, out steamID3) || (steamID3 == 0)) { + if (!uint.TryParse(miniProfile, out uint steamID3) || (steamID3 == 0)) { Bot.ArchiLogger.LogNullError(nameof(steamID3)); return null; } @@ -466,8 +460,7 @@ namespace ArchiSteamFarm { return null; } - uint appID; - if (!uint.TryParse(appNode.InnerText, out appID)) { + if (!uint.TryParse(appNode.InnerText, out uint appID)) { Bot.ArchiLogger.LogNullError(nameof(appID)); return null; } @@ -515,8 +508,7 @@ namespace ArchiSteamFarm { continue; } - ulong classID; - if (!ulong.TryParse(classIDString, out classID) || (classID == 0)) { + if (!ulong.TryParse(classIDString, out ulong classID) || (classID == 0)) { Bot.ArchiLogger.LogNullError(nameof(classID)); continue; } @@ -579,8 +571,7 @@ namespace ArchiSteamFarm { steamItem.AppID = Steam.Item.SteamAppID; steamItem.ContextID = Steam.Item.SteamCommunityContextID; - Tuple description; - if (descriptionMap.TryGetValue(steamItem.ClassID, out description)) { + if (descriptionMap.TryGetValue(steamItem.ClassID, out Tuple description)) { steamItem.RealAppID = description.Item1; steamItem.Type = description.Item2; } @@ -592,13 +583,11 @@ namespace ArchiSteamFarm { result.Add(steamItem); } - bool more; - if (!bool.TryParse(jObject["more"]?.ToString(), out more) || !more) { + if (!bool.TryParse(jObject["more"]?.ToString(), out bool more) || !more) { break; // OK, last page } - uint nextPage; - if (!uint.TryParse(jObject["more_start"]?.ToString(), out nextPage) || (nextPage <= currentPage)) { + if (!uint.TryParse(jObject["more_start"]?.ToString(), out uint nextPage) || (nextPage <= currentPage)) { Bot.ArchiLogger.LogNullError(nameof(nextPage)); return null; } @@ -738,8 +727,7 @@ namespace ArchiSteamFarm { text = text.Substring(0, index); - byte holdDuration; - if (byte.TryParse(text, out holdDuration)) { + if (byte.TryParse(text, out byte holdDuration)) { return holdDuration; } @@ -1193,8 +1181,7 @@ namespace ArchiSteamFarm { return 0; } - uint appID; - return uint.TryParse(hashName.Substring(0, index), out appID) ? appID : 0; + return uint.TryParse(hashName.Substring(0, index), out uint appID) ? appID : 0; } private static Steam.Item.EType GetItemType(string name) { @@ -1287,8 +1274,7 @@ namespace ArchiSteamFarm { uint realAppID = appID; Steam.Item.EType type = Steam.Item.EType.Unknown; - Tuple description; - if (descriptions.TryGetValue(classID, out description)) { + if (descriptions.TryGetValue(classID, out Tuple description)) { realAppID = description.Item1; type = description.Item2; } diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 2c2482ae5..575c34f38 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -347,8 +347,7 @@ namespace ArchiSteamFarm { } foreach (Dictionary productInfoApps in productInfoResultSet.Results.Select(result => result.Apps)) { - SteamApps.PICSProductInfoCallback.PICSProductInfo productInfoApp; - if (!productInfoApps.TryGetValue(appID, out productInfoApp)) { + if (!productInfoApps.TryGetValue(appID, out SteamApps.PICSProductInfoCallback.PICSProductInfo productInfoApp)) { continue; } @@ -418,8 +417,7 @@ namespace ArchiSteamFarm { string[] dlcAppIDsString = listOfDlc.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string dlcAppIDString in dlcAppIDsString) { - uint dlcAppID; - if (!uint.TryParse(dlcAppIDString, out dlcAppID) || (dlcAppID == 0)) { + if (!uint.TryParse(dlcAppIDString, out uint dlcAppID) || (dlcAppID == 0)) { ArchiLogger.LogNullError(nameof(dlcAppID)); break; } @@ -784,8 +782,7 @@ namespace ArchiSteamFarm { Task.Run(() => Stop()).Forget(); } - Bot ignored; - Bots.TryRemove(BotName, out ignored); + Bots.TryRemove(BotName, out Bot ignored); } private void Disconnect() { @@ -832,8 +829,7 @@ namespace ArchiSteamFarm { if (botName.Contains("..")) { string[] botRange = botName.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries); if (botRange.Length == 2) { - Bot firstBot, lastBot; - if (Bots.TryGetValue(botRange[0], out firstBot) && Bots.TryGetValue(botRange[1], out lastBot)) { + if (Bots.TryGetValue(botRange[0], out Bot firstBot) && Bots.TryGetValue(botRange[1], out Bot lastBot)) { bool inRange = false; foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value)) { @@ -855,8 +851,7 @@ namespace ArchiSteamFarm { } } - Bot targetBot; - if (!Bots.TryGetValue(botName, out targetBot)) { + if (!Bots.TryGetValue(botName, out Bot targetBot)) { continue; } @@ -1947,8 +1942,7 @@ namespace ArchiSteamFarm { HashSet gamesToRedeem = new HashSet(); foreach (string game in gameIDs) { - uint gameID; - if (!uint.TryParse(game, out gameID) || (gameID == 0)) { + if (!uint.TryParse(game, out uint gameID) || (gameID == 0)) { return FormatBotResponse(string.Format(Strings.ErrorParsingObject, nameof(gameID))); } @@ -2108,8 +2102,7 @@ namespace ArchiSteamFarm { return FormatBotResponse(Strings.ErrorFunctionOnlyInHeadlessMode); } - ASF.EUserInputType inputType; - if (!Enum.TryParse(propertyName, true, out inputType) || (inputType == ASF.EUserInputType.Unknown)) { + if (!Enum.TryParse(propertyName, true, out ASF.EUserInputType inputType) || (inputType == ASF.EUserInputType.Unknown)) { return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(inputType))); } @@ -2310,15 +2303,13 @@ namespace ArchiSteamFarm { foreach (string game in games) { // Check if this is gameID - uint gameID; - if (uint.TryParse(game, out gameID) && (gameID != 0)) { + if (uint.TryParse(game, out uint gameID) && (gameID != 0)) { if (OwnedPackageIDs.Contains(gameID)) { response.Append(FormatBotResponse(string.Format(Strings.BotOwnedAlready, gameID))); continue; } - string ownedName; - response.Append(FormatBotResponse(ownedGames.TryGetValue(gameID, out ownedName) ? string.Format(Strings.BotOwnedAlreadyWithName, gameID, ownedName) : string.Format(Strings.BotNotOwnedYet, gameID))); + response.Append(FormatBotResponse(ownedGames.TryGetValue(gameID, out string ownedName) ? string.Format(Strings.BotOwnedAlreadyWithName, gameID, ownedName) : string.Format(Strings.BotNotOwnedYet, gameID))); continue; } @@ -2509,8 +2500,7 @@ namespace ArchiSteamFarm { HashSet gamesToPlay = new HashSet(); foreach (string game in gameIDs) { - uint gameID; - if (!uint.TryParse(game, out gameID)) { + if (!uint.TryParse(game, out uint gameID)) { return FormatBotResponse(string.Format(Strings.ErrorParsingObject, nameof(gameID))); } diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs index 74d603b4c..fc2f5e21f 100644 --- a/ArchiSteamFarm/BotDatabase.cs +++ b/ArchiSteamFarm/BotDatabase.cs @@ -33,7 +33,7 @@ namespace ArchiSteamFarm { private readonly object FileLock = new object(); internal string LoginKey { - get { return _LoginKey; } + get => _LoginKey; set { if (_LoginKey == value) { @@ -46,7 +46,7 @@ namespace ArchiSteamFarm { } internal MobileAuthenticator MobileAuthenticator { - get { return _MobileAuthenticator; } + get => _MobileAuthenticator; set { if (_MobileAuthenticator == value) { diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 94b6b4522..b7a967f05 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -69,11 +69,7 @@ namespace ArchiSteamFarm { private bool StickyPause; internal CardsFarmer(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = bot; + Bot = bot ?? throw new ArgumentNullException(nameof(bot)); if (Program.GlobalConfig.IdleFarmingPeriod > 0) { IdleFarmingTimer = new Timer( @@ -340,8 +336,7 @@ namespace ArchiSteamFarm { appIDString = appIDSplitted[4]; - uint appID; - if (!uint.TryParse(appIDString, out appID) || (appID == 0)) { + if (!uint.TryParse(appIDString, out uint appID) || (appID == 0)) { Bot.ArchiLogger.LogNullError(nameof(appID)); continue; } @@ -351,8 +346,7 @@ namespace ArchiSteamFarm { continue; } - DateTime lastPICSReport; - if (IgnoredAppIDs.TryGetValue(appID, out lastPICSReport)) { + if (IgnoredAppIDs.TryGetValue(appID, out DateTime lastPICSReport)) { if (lastPICSReport.AddHours(HoursToIgnore) < DateTime.UtcNow) { // This game served its time as being ignored IgnoredAppIDs.TryRemove(appID, out lastPICSReport); @@ -409,8 +403,7 @@ namespace ArchiSteamFarm { continue; } - ushort cardsEarned; - if (!ushort.TryParse(cardsEarnedMatch.Value, out cardsEarned)) { + if (!ushort.TryParse(cardsEarnedMatch.Value, out ushort cardsEarned)) { Bot.ArchiLogger.LogNullError(nameof(cardsEarned)); continue; } @@ -681,8 +674,7 @@ namespace ArchiSteamFarm { return 0; } - ushort cardsRemaining; - if (ushort.TryParse(match.Value, out cardsRemaining) && (cardsRemaining != 0)) { + if (ushort.TryParse(match.Value, out ushort cardsRemaining) && (cardsRemaining != 0)) { return cardsRemaining; } diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index 9d0d250ab..936b4f1ea 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -46,7 +46,7 @@ namespace ArchiSteamFarm { private readonly object FileLock = new object(); internal uint CellID { - get { return _CellID; } + get => _CellID; set { if ((value == 0) || (_CellID == value)) { return; diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index 31020c66f..f00dc2633 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -178,7 +178,7 @@ namespace ArchiSteamFarm.JSON { } internal MobileAuthenticator.Confirmation Confirmation { - get { return _Confirmation; } + get => _Confirmation; set { if (value == null) { @@ -237,7 +237,7 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "amount", Required = Required.Always)] [SuppressMessage("ReSharper", "UnusedMember.Local")] private string AmountString { - get { return Amount.ToString(); } + get => Amount.ToString(); set { if (string.IsNullOrEmpty(value)) { @@ -245,8 +245,7 @@ namespace ArchiSteamFarm.JSON { return; } - uint amount; - if (!uint.TryParse(value, out amount) || (amount == 0)) { + if (!uint.TryParse(value, out uint amount) || (amount == 0)) { ASF.ArchiLogger.LogNullError(nameof(amount)); return; } @@ -258,7 +257,7 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "appid", Required = Required.DisallowNull)] [SuppressMessage("ReSharper", "UnusedMember.Local")] private string AppIDString { - get { return AppID.ToString(); } + get => AppID.ToString(); set { if (string.IsNullOrEmpty(value)) { @@ -266,8 +265,7 @@ namespace ArchiSteamFarm.JSON { return; } - uint appID; - if (!uint.TryParse(value, out appID) || (appID == 0)) { + if (!uint.TryParse(value, out uint appID) || (appID == 0)) { ASF.ArchiLogger.LogNullError(nameof(appID)); return; } @@ -278,7 +276,7 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "assetid", Required = Required.DisallowNull)] private string AssetIDString { - get { return AssetID.ToString(); } + get => AssetID.ToString(); set { if (string.IsNullOrEmpty(value)) { @@ -286,8 +284,7 @@ namespace ArchiSteamFarm.JSON { return; } - ulong assetID; - if (!ulong.TryParse(value, out assetID) || (assetID == 0)) { + if (!ulong.TryParse(value, out ulong assetID) || (assetID == 0)) { ASF.ArchiLogger.LogNullError(nameof(assetID)); return; } @@ -299,7 +296,7 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "classid", Required = Required.DisallowNull)] [SuppressMessage("ReSharper", "UnusedMember.Local")] private string ClassIDString { - get { return ClassID.ToString(); } + get => ClassID.ToString(); set { if (string.IsNullOrEmpty(value)) { @@ -307,8 +304,7 @@ namespace ArchiSteamFarm.JSON { return; } - ulong classID; - if (!ulong.TryParse(value, out classID) || (classID == 0)) { + if (!ulong.TryParse(value, out ulong classID) || (classID == 0)) { return; } @@ -319,7 +315,7 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "contextid", Required = Required.DisallowNull)] [SuppressMessage("ReSharper", "UnusedMember.Local")] private string ContextIDString { - get { return ContextID.ToString(); } + get => ContextID.ToString(); set { if (string.IsNullOrEmpty(value)) { @@ -327,8 +323,7 @@ namespace ArchiSteamFarm.JSON { return; } - ulong contextID; - if (!ulong.TryParse(value, out contextID) || (contextID == 0)) { + if (!ulong.TryParse(value, out ulong contextID) || (contextID == 0)) { ASF.ArchiLogger.LogNullError(nameof(contextID)); return; } @@ -340,8 +335,8 @@ namespace ArchiSteamFarm.JSON { [JsonProperty(PropertyName = "id", Required = Required.DisallowNull)] [SuppressMessage("ReSharper", "UnusedMember.Local")] private string ID { - get { return AssetIDString; } - set { AssetIDString = value; } + get => AssetIDString; + set => AssetIDString = value; } // Constructed from trades being received @@ -440,13 +435,11 @@ namespace ArchiSteamFarm.JSON { internal bool IsFairTypesExchange() { Dictionary> itemsToGivePerGame = new Dictionary>(); foreach (Item item in ItemsToGive) { - Dictionary itemsPerType; - if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out itemsPerType)) { + if (!itemsToGivePerGame.TryGetValue(item.RealAppID, out Dictionary itemsPerType)) { itemsPerType = new Dictionary { [item.Type] = item.Amount }; itemsToGivePerGame[item.RealAppID] = itemsPerType; } else { - uint amount; - if (itemsPerType.TryGetValue(item.Type, out amount)) { + if (itemsPerType.TryGetValue(item.Type, out uint amount)) { itemsPerType[item.Type] = amount + item.Amount; } else { itemsPerType[item.Type] = item.Amount; @@ -456,16 +449,14 @@ namespace ArchiSteamFarm.JSON { Dictionary> itemsToReceivePerGame = new Dictionary>(); foreach (Item item in ItemsToReceive) { - Dictionary itemsPerType; - if (!itemsToReceivePerGame.TryGetValue(item.RealAppID, out itemsPerType)) { + if (!itemsToReceivePerGame.TryGetValue(item.RealAppID, out Dictionary itemsPerType)) { itemsPerType = new Dictionary { { item.Type, item.Amount } }; itemsToReceivePerGame[item.RealAppID] = itemsPerType; } else { - uint amount; - if (itemsPerType.TryGetValue(item.Type, out amount)) { + if (itemsPerType.TryGetValue(item.Type, out uint amount)) { itemsPerType[item.Type] = amount + item.Amount; } else { itemsPerType[item.Type] = item.Amount; @@ -474,15 +465,13 @@ namespace ArchiSteamFarm.JSON { } // Ensure that amount of items to give is at least amount of items to receive (per game and per type) - foreach (KeyValuePair> itemsPerGame in itemsToGivePerGame) { - Dictionary otherItemsPerType; - if (!itemsToReceivePerGame.TryGetValue(itemsPerGame.Key, out otherItemsPerType)) { + foreach (KeyValuePair> itemsPerGame in itemsToGivePerGame) { + if (!itemsToReceivePerGame.TryGetValue(itemsPerGame.Key, out Dictionary otherItemsPerType)) { return false; } - foreach (KeyValuePair itemsPerType in itemsPerGame.Value) { - uint otherAmount; - if (!otherItemsPerType.TryGetValue(itemsPerType.Key, out otherAmount)) { + foreach (KeyValuePair itemsPerType in itemsPerGame.Value) { + if (!otherItemsPerType.TryGetValue(itemsPerType.Key, out uint otherAmount)) { return false; } diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index 041865ca7..4daf95202 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -154,8 +154,7 @@ namespace ArchiSteamFarm { return null; } - uint id; - if (!uint.TryParse(idString, out id) || (id == 0)) { + if (!uint.TryParse(idString, out uint id) || (id == 0)) { Bot.ArchiLogger.LogNullError(nameof(id)); return null; } @@ -166,8 +165,7 @@ namespace ArchiSteamFarm { return null; } - ulong key; - if (!ulong.TryParse(keyString, out key) || (key == 0)) { + if (!ulong.TryParse(keyString, out ulong key) || (key == 0)) { Bot.ArchiLogger.LogNullError(nameof(key)); return null; } @@ -248,13 +246,7 @@ namespace ArchiSteamFarm { } } - internal void Init(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = 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/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 7b61cdf26..91de301b2 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -48,13 +48,7 @@ namespace ArchiSteamFarm { private string LastNickname; private bool ShouldSendHeartBeats; - internal Statistics(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = bot; - } + internal Statistics(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); public void Dispose() => Semaphore.Dispose(); diff --git a/ArchiSteamFarm/Trading.cs b/ArchiSteamFarm/Trading.cs index 137261ca9..8082c681c 100644 --- a/ArchiSteamFarm/Trading.cs +++ b/ArchiSteamFarm/Trading.cs @@ -43,13 +43,7 @@ namespace ArchiSteamFarm { private bool ParsingScheduled; - internal Trading(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = bot; - } + internal Trading(Bot bot) => Bot = bot ?? throw new ArgumentNullException(nameof(bot)); public void Dispose() => TradesSemaphore.Dispose(); @@ -269,8 +263,7 @@ namespace ArchiSteamFarm { // Now let's create a map which maps items to their amount in our EQ Dictionary amountMap = new Dictionary(); foreach (Steam.Item item in inventory) { - uint amount; - if (amountMap.TryGetValue(item.ClassID, out amount)) { + if (amountMap.TryGetValue(item.ClassID, out uint amount)) { amountMap[item.ClassID] = amount + item.Amount; } else { amountMap[item.ClassID] = item.Amount; @@ -281,8 +274,7 @@ namespace ArchiSteamFarm { List amountsToGive = new List(tradeOffer.ItemsToGive.Count); Dictionary amountMapToGive = new Dictionary(amountMap); foreach (ulong key in tradeOffer.ItemsToGive.Select(item => item.ClassID)) { - uint amount; - if (!amountMapToGive.TryGetValue(key, out amount)) { + if (!amountMapToGive.TryGetValue(key, out uint amount)) { amountsToGive.Add(0); continue; } @@ -298,8 +290,7 @@ namespace ArchiSteamFarm { List amountsToReceive = new List(tradeOffer.ItemsToReceive.Count); Dictionary amountMapToReceive = new Dictionary(amountMap); foreach (ulong key in tradeOffer.ItemsToReceive.Select(item => item.ClassID)) { - uint amount; - if (!amountMapToReceive.TryGetValue(key, out amount)) { + if (!amountMapToReceive.TryGetValue(key, out uint amount)) { amountsToReceive.Add(0); continue; } diff --git a/ArchiSteamFarm/WebBrowser.cs b/ArchiSteamFarm/WebBrowser.cs index e02f1b5d7..96d2b35c7 100644 --- a/ArchiSteamFarm/WebBrowser.cs +++ b/ArchiSteamFarm/WebBrowser.cs @@ -46,11 +46,7 @@ namespace ArchiSteamFarm { private readonly HttpClient HttpClient; internal WebBrowser(ArchiLogger archiLogger) { - if (archiLogger == null) { - throw new ArgumentNullException(nameof(archiLogger)); - } - - ArchiLogger = archiLogger; + ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger)); HttpClientHandler httpClientHandler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, diff --git a/ConfigGenerator/ConfigPage.cs b/ConfigGenerator/ConfigPage.cs index 946827243..3171c186f 100644 --- a/ConfigGenerator/ConfigPage.cs +++ b/ConfigGenerator/ConfigPage.cs @@ -31,11 +31,7 @@ namespace ConfigGenerator { internal readonly ASFConfig ASFConfig; internal ConfigPage(ASFConfig config) { - if (config == null) { - throw new ArgumentNullException(nameof(config)); - } - - ASFConfig = config; + ASFConfig = config ?? throw new ArgumentNullException(nameof(config)); RefreshText(); diff --git a/ConfigGenerator/EnhancedPropertyGrid.cs b/ConfigGenerator/EnhancedPropertyGrid.cs index c0cdfdca1..9b6dfbb8d 100644 --- a/ConfigGenerator/EnhancedPropertyGrid.cs +++ b/ConfigGenerator/EnhancedPropertyGrid.cs @@ -30,11 +30,7 @@ namespace ConfigGenerator { private readonly ASFConfig ASFConfig; internal EnhancedPropertyGrid(ASFConfig config) { - if (config == null) { - throw new ArgumentNullException(nameof(config)); - } - - ASFConfig = config; + ASFConfig = config ?? throw new ArgumentNullException(nameof(config)); SelectedObject = config; Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; diff --git a/GUI/BotStatusForm.cs b/GUI/BotStatusForm.cs index a33fd1e79..60bf58641 100644 --- a/GUI/BotStatusForm.cs +++ b/GUI/BotStatusForm.cs @@ -11,11 +11,7 @@ namespace ArchiSteamFarm { private readonly Bot Bot; internal BotStatusForm(Bot bot) { - if (bot == null) { - throw new ArgumentNullException(nameof(bot)); - } - - Bot = bot; + Bot = bot ?? throw new ArgumentNullException(nameof(bot)); BotForms[bot.BotName] = this;