diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 43254c22..6648a583 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -1163,7 +1163,7 @@ namespace DepotDownloader neededChunks = Util.ValidateSteam3FileChecksums(fs, file.Chunks.OrderBy(x => x.Offset).ToArray()); } - if (neededChunks.Count() == 0) + if (neededChunks.Count == 0) { lock (depotDownloadCounter) { diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index 483ee061..10380b40 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -211,9 +211,9 @@ namespace DepotDownloader }; var request = new SteamApps.PICSRequest(appId); - if (AppTokens.ContainsKey(appId)) + if (AppTokens.TryGetValue(appId, out var value)) { - request.AccessToken = AppTokens[appId]; + request.AccessToken = value; } WaitUntilCallback(() => @@ -656,7 +656,7 @@ namespace DepotDownloader { Console.Write("Please enter your 2 factor auth code from your authenticator app: "); logonDetails.TwoFactorCode = Console.ReadLine(); - } while (String.Empty == logonDetails.TwoFactorCode); + } while (string.Empty == logonDetails.TwoFactorCode); } else if (isAccessToken) { diff --git a/DepotDownloader/Util.cs b/DepotDownloader/Util.cs index f35a43bf..9dd954ce 100644 --- a/DepotDownloader/Util.cs +++ b/DepotDownloader/Util.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -115,12 +115,9 @@ namespace DepotDownloader public static byte[] SHAHash(byte[] input) { - using (var sha = SHA1.Create()) - { - var output = sha.ComputeHash(input); + var output = SHA1.HashData(input); - return output; - } + return output; } public static byte[] DecodeHexString(string hex) @@ -146,7 +143,7 @@ namespace DepotDownloader public static async Task InvokeAsync(IEnumerable> taskFactories, int maxDegreeOfParallelism) { - if (taskFactories == null) throw new ArgumentNullException(nameof(taskFactories)); + ArgumentNullException.ThrowIfNull(taskFactories); if (maxDegreeOfParallelism <= 0) throw new ArgumentException(nameof(maxDegreeOfParallelism)); var queue = taskFactories.ToArray();