diff --git a/Clients/AppveyorClient/Client.cs b/Clients/AppveyorClient/Client.cs index b5ee2af6..3a6bd869 100644 --- a/Clients/AppveyorClient/Client.cs +++ b/Clients/AppveyorClient/Client.cs @@ -245,7 +245,7 @@ namespace AppveyorClient try { - mergeDate = mergeDate ?? (DateTime.UtcNow - JobIdSearchThreshold); + mergeDate ??= (DateTime.UtcNow - JobIdSearchThreshold); result = await FindBuildAsync( h => h.Builds.Last().Created?.ToUniversalTime() > mergeDate, b => b.CommitId.StartsWith(commit, StringComparison.InvariantCultureIgnoreCase) && b.Status == "success", diff --git a/Clients/IrdLibraryClient/IrdClient.cs b/Clients/IrdLibraryClient/IrdClient.cs index 33c6b52f..ada1731f 100644 --- a/Clients/IrdLibraryClient/IrdClient.cs +++ b/Clients/IrdLibraryClient/IrdClient.cs @@ -82,7 +82,7 @@ namespace IrdLibraryClient { await response.Content.LoadIntoBufferAsync().ConfigureAwait(false); var result = await response.Content.ReadAsAsync(underscoreFormatters, cancellationToken).ConfigureAwait(false); - result.Data = result.Data ?? new List(0); + result.Data ??= new List(0); foreach (var item in result.Data) { item.Filename = GetIrdFilename(item.Filename); diff --git a/Clients/PsnClient/PsnClient.cs b/Clients/PsnClient/PsnClient.cs index c56eb27b..6aec36f4 100644 --- a/Clients/PsnClient/PsnClient.cs +++ b/Clients/PsnClient/PsnClient.cs @@ -181,7 +181,7 @@ namespace PsnClient { var loc = locale.AsLocaleData(); var url = new Uri($"https://store.playstation.com/valkyrie-api/{loc.language}/{loc.country}/999/container/{containerId}"); - filters = filters ?? new Dictionary(); + filters ??= new Dictionary(); filters["start"] = start.ToString(); filters["size"] = take.ToString(); filters["bucket"] = "games"; diff --git a/CompatBot/EventHandlers/GithubLinksHandler.cs b/CompatBot/EventHandlers/GithubLinksHandler.cs index 377d1ccd..15402f67 100644 --- a/CompatBot/EventHandlers/GithubLinksHandler.cs +++ b/CompatBot/EventHandlers/GithubLinksHandler.cs @@ -33,7 +33,7 @@ namespace CompatBot.EventHandlers { if (msg.Author.IsCurrent) { - previousRepliesBuilder = previousRepliesBuilder ?? new StringBuilder(); + previousRepliesBuilder ??= new StringBuilder(); previousRepliesBuilder.AppendLine(msg.Content); var embeds = msg.Embeds; if (embeds?.Count > 0) diff --git a/CompatBot/EventHandlers/ProductCodeLookup.cs b/CompatBot/EventHandlers/ProductCodeLookup.cs index 147d12d3..3074a0db 100644 --- a/CompatBot/EventHandlers/ProductCodeLookup.cs +++ b/CompatBot/EventHandlers/ProductCodeLookup.cs @@ -37,7 +37,7 @@ namespace CompatBot.EventHandlers { if (msg.Author.IsCurrent) { - previousRepliesBuilder = previousRepliesBuilder ?? new StringBuilder(); + previousRepliesBuilder ??= new StringBuilder(); previousRepliesBuilder.AppendLine(msg.Content); var embeds = msg.Embeds; if (embeds?.Count > 0) diff --git a/CompatBot/Utils/EmbedPager.cs b/CompatBot/Utils/EmbedPager.cs index 9aae282f..4c41b5de 100644 --- a/CompatBot/Utils/EmbedPager.cs +++ b/CompatBot/Utils/EmbedPager.cs @@ -36,7 +36,7 @@ namespace CompatBot.Utils if (maxLinesPerField < 1) throw new ArgumentException("Expected a number greater than 0, but was " + maxLinesPerField, nameof(maxLinesPerField)); - makeTitle = makeTitle ?? MakeTitle; + makeTitle ??= MakeTitle; var buffer = new StringBuilder(); var lineCount = 0; diff --git a/CompatBot/Utils/Extensions/AutosplitResponseHelper.cs b/CompatBot/Utils/Extensions/AutosplitResponseHelper.cs index 35e42125..802969f5 100644 --- a/CompatBot/Utils/Extensions/AutosplitResponseHelper.cs +++ b/CompatBot/Utils/Extensions/AutosplitResponseHelper.cs @@ -36,8 +36,8 @@ namespace CompatBot.Utils if (string.IsNullOrEmpty(message)) return; - blockEnd = blockEnd ?? ""; - blockStart = blockStart ?? ""; + blockEnd ??= ""; + blockStart ??= ""; var maxContentSize = blockSize - blockEnd.Length - blockStart.Length; await channel.TriggerTypingAsync().ConfigureAwait(false); var buffer = new StringBuilder(); diff --git a/CompatBot/Utils/Extensions/DiscordClientExtensions.cs b/CompatBot/Utils/Extensions/DiscordClientExtensions.cs index 6be2cc7f..489d807d 100644 --- a/CompatBot/Utils/Extensions/DiscordClientExtensions.cs +++ b/CompatBot/Utils/Extensions/DiscordClientExtensions.cs @@ -70,7 +70,7 @@ namespace CompatBot.Utils { try { - showBoth = showBoth ?? message.Channel.IsPrivate; + showBoth ??= message.Channel.IsPrivate; var canReact = message.Channel.IsPrivate || message.Channel.PermissionsFor(message.Channel.Guild.CurrentMember).HasPermission(Permissions.AddReactions); if (canReact) await message.CreateReactionAsync(emoji).ConfigureAwait(false); diff --git a/CompatBot/Utils/Extensions/StringUtils.cs b/CompatBot/Utils/Extensions/StringUtils.cs index bbaae199..82934f57 100644 --- a/CompatBot/Utils/Extensions/StringUtils.cs +++ b/CompatBot/Utils/Extensions/StringUtils.cs @@ -101,7 +101,7 @@ namespace CompatBot.Utils public static string AsString(this ReadOnlySequence buffer, Encoding encoding = null) { - encoding = encoding ?? Latin8BitEncoding; + encoding ??= Latin8BitEncoding; if (buffer.IsSingleSegment) return encoding.GetString(buffer.First.Span); @@ -186,7 +186,7 @@ namespace CompatBot.Utils public static string PadLeftVisible(this string s, int totalWidth, char padding = ' ') { - s = s ?? ""; + s ??= ""; var valueWidth = s.GetVisibleLength(); var diff = s.Length - valueWidth; totalWidth += diff; @@ -195,7 +195,7 @@ namespace CompatBot.Utils public static string PadRightVisible(this string s, int totalWidth, char padding = ' ') { - s = s ?? ""; + s ??= ""; var valueWidth = s.GetVisibleLength(); var diff = s.Length - valueWidth; totalWidth += diff; diff --git a/CompatBot/Utils/ResultFormatters/UpdateInfoFormatter.cs b/CompatBot/Utils/ResultFormatters/UpdateInfoFormatter.cs index 28271bdd..9dafe607 100644 --- a/CompatBot/Utils/ResultFormatters/UpdateInfoFormatter.cs +++ b/CompatBot/Utils/ResultFormatters/UpdateInfoFormatter.cs @@ -62,7 +62,7 @@ namespace CompatBot.Utils.ResultFormatters } } } - builder = builder ?? new DiscordEmbedBuilder {Title = prDesc, Url = url, Description = desc, Color = Config.Colors.DownloadLinks}; + builder ??= new DiscordEmbedBuilder {Title = prDesc, Url = url, Description = desc, Color = Config.Colors.DownloadLinks}; var currentCommit = currentPrInfo?.MergeCommitSha; var latestCommit = latestPrInfo?.MergeCommitSha; var currentAppveyorBuild = await appveyorClient.GetMasterBuildAsync(currentCommit, currentPrInfo?.MergedAt, Config.Cts.Token).ConfigureAwait(false);