From 24f63858e0000c368af9650936623298866919ba Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 14 Nov 2020 14:33:29 +0500 Subject: [PATCH] replace object initialization with the new() --- Clients/CompatApiClient/ApiConfig.cs | 22 +- Clients/CompatApiClient/Client.cs | 2 +- .../Formatters/SpecialJsonNamingPolicy.cs | 4 +- Clients/CompatApiClient/POCOs/CompatResult.cs | 6 +- Clients/CompatApiClient/RequestBuilder.cs | 2 +- .../CompatApiClient/Utils/UriExtensions.cs | 2 +- Clients/GithubClient/Client.cs | 4 +- Clients/IrdLibraryClient/IrdClient.cs | 2 +- .../PsnClient/CustomTlsCertificatesHandler.cs | 2 +- Clients/PsnClient/PsnClient.cs | 6 +- CompatBot/Commands/Attributes/RequiresDm.cs | 2 +- CompatBot/Commands/CompatList.cs | 14 +- .../TextOnlyDiscordChannelConverter.cs | 2 +- CompatBot/Commands/EventsBaseCommand.cs | 2 +- CompatBot/Commands/Ird.cs | 2 +- CompatBot/Commands/Misc.cs | 18 +- CompatBot/Commands/Moderation.Audit.cs | 2 +- CompatBot/Commands/Pr.cs | 4 +- CompatBot/Commands/Psn.Check.cs | 2 +- CompatBot/Commands/Psn.cs | 2 +- CompatBot/Commands/Sudo.Bot.cs | 4 +- CompatBot/Commands/Sudo.Fix.cs | 4 +- CompatBot/Commands/Vision.cs | 4 +- CompatBot/Config.cs | 42 +-- .../Providers/AmdDriverVersionProvider.cs | 8 +- CompatBot/Database/Providers/ContentFilter.cs | 6 +- .../Providers/DisabledCommandsProvider.cs | 2 +- CompatBot/Database/Providers/ModProvider.cs | 4 +- CompatBot/Database/Providers/StatsStorage.cs | 8 +- .../Database/Providers/SyscallInfoProvider.cs | 2 +- .../Database/Providers/ThumbnailProvider.cs | 4 +- CompatBot/Database/ThumbnailDb.cs | 2 +- .../EventHandlers/BotReactionsHandler.cs | 8 +- .../EventHandlers/DeletedMessagesMonitor.cs | 4 +- .../EventHandlers/DiscordInviteFilter.cs | 4 +- .../EventHandlers/EmpathySimulationHandler.cs | 4 +- CompatBot/EventHandlers/GithubLinksHandler.cs | 10 +- CompatBot/EventHandlers/GlobalMessageCache.cs | 2 +- .../EventHandlers/IsTheGamePlayableHandler.cs | 6 +- CompatBot/EventHandlers/LogAsTextMonitor.cs | 2 +- .../LogParsing/LogParser.LogSections.cs | 304 +++++++++--------- .../LogParsing/LogParser.PipeReader.cs | 2 +- .../LogParsing/POCOs/LogParseState.cs | 12 +- .../SourceHandlers/DropboxHandler.cs | 2 +- .../SourceHandlers/GenericLinkHandler.cs | 2 +- .../SourceHandlers/GoogleDriveHandler.cs | 2 +- .../LogParsing/SourceHandlers/MegaHandler.cs | 2 +- .../SourceHandlers/OneDriveSourceHandler.cs | 4 +- .../SourceHandlers/PastebinHandler.cs | 2 +- CompatBot/EventHandlers/LogParsingHandler.cs | 2 +- .../EventHandlers/MediaScreenshotMonitor.cs | 4 +- CompatBot/EventHandlers/NewBuildsMonitor.cs | 4 +- CompatBot/EventHandlers/PostLogHelpHandler.cs | 6 +- CompatBot/EventHandlers/ProductCodeLookup.cs | 4 +- CompatBot/EventHandlers/Starbucks.cs | 2 +- .../EventHandlers/UsernameSpoofMonitor.cs | 6 +- .../EventHandlers/UsernameZalgoMonitor.cs | 2 +- CompatBot/Program.cs | 4 +- CompatBot/ThumbScrapper/GameTdbScraper.cs | 4 +- CompatBot/ThumbScrapper/PsnScraper.cs | 10 +- CompatBot/Utils/AsciiTable.cs | 2 +- CompatBot/Utils/BufferCopyStream.cs | 2 +- .../Extensions/AzureDevOpsClientExtensions.cs | 2 +- .../Extensions/CommandContextExtensions.cs | 2 +- CompatBot/Utils/Extensions/Converters.cs | 2 +- CompatBot/Utils/Extensions/DateTimeEx.cs | 2 +- .../Extensions/FilterActionExtensions.cs | 2 +- CompatBot/Utils/Extensions/StringUtils.cs | 4 +- CompatBot/Utils/FixedLengthBuffer.cs | 6 +- CompatBot/Utils/PoorMansTaskScheduler.cs | 2 +- .../Utils/ResultFormatters/FwInfoFormatter.cs | 4 +- ...rserResultFormatter.GeneralNotesSection.cs | 4 +- ...serResultFormatter.WeirdSettingsSection.cs | 54 ++-- .../LogParserResultFormatter.cs | 72 ++--- .../ResultFormatters/TitleInfoFormatter.cs | 2 +- .../ResultFormatters/UpdateInfoFormatter.cs | 2 +- CompatBot/Utils/TimeParser.cs | 2 +- CompatBot/Watchdog.cs | 2 +- HomoglyphConverter/Normalizer.cs | 2 +- 79 files changed, 391 insertions(+), 391 deletions(-) diff --git a/Clients/CompatApiClient/ApiConfig.cs b/Clients/CompatApiClient/ApiConfig.cs index f41e71d1..2073e13e 100644 --- a/Clients/CompatApiClient/ApiConfig.cs +++ b/Clients/CompatApiClient/ApiConfig.cs @@ -11,14 +11,14 @@ namespace CompatApiClient public static class ApiConfig { - public static readonly ProductInfoHeaderValue ProductInfoHeader = new ProductInfoHeaderValue("RPCS3CompatibilityBot", "2.0"); + public static readonly ProductInfoHeaderValue ProductInfoHeader = new("RPCS3CompatibilityBot", "2.0"); public static int Version { get; } = 1; - public static Uri BaseUrl { get; } = new Uri("https://rpcs3.net/compatibility"); + public static Uri BaseUrl { get; } = new("https://rpcs3.net/compatibility"); public static string DateInputFormat { get; } = "yyyy-M-d"; public static string DateOutputFormat { get; } = "yyy-MM-dd"; public static string DateQueryFormat { get; } = "yyyyMMdd"; - public static readonly ReturnCodeType ReturnCodes = new ReturnCodeType + public static readonly ReturnCodeType ReturnCodes = new() { {0, (true, false, true, "Results successfully retrieved.")}, {1, (false, false, true, "No results.") }, @@ -28,15 +28,15 @@ namespace CompatApiClient {-3, (false, false, false, "Illegal characters found, please try again with a different search term.") }, }; - public static readonly List ResultAmount = new List {25, 50, 100, 200}; + public static readonly List ResultAmount = new(){25, 50, 100, 200}; - public static readonly Dictionary Directions = new Dictionary + public static readonly Dictionary Directions = new() { {'a', new []{"a", "asc", "ascending"}}, {'d', new []{"d", "desc", "descending"} }, }; - public static readonly Dictionary Statuses = new Dictionary + public static readonly Dictionary Statuses = new() { {"all", 0 }, {"playable", 1 }, @@ -46,7 +46,7 @@ namespace CompatApiClient {"nothing", 5 }, }; - public static readonly Dictionary SortTypes = new Dictionary + public static readonly Dictionary SortTypes = new() { {"id", 1 }, {"title", 2 }, @@ -54,7 +54,7 @@ namespace CompatApiClient {"date", 4 }, }; - public static readonly Dictionary ReleaseTypes = new Dictionary + public static readonly Dictionary ReleaseTypes = new() { {'b', new[] {"b", "d", "disc", "disk", "bluray", "blu-ray"}}, {'n', new[] {"n", "p", "PSN"}}, @@ -75,7 +75,7 @@ namespace CompatApiClient } public static readonly ILogger Log; - public static readonly RecyclableMemoryStreamManager MemoryStreamManager = new RecyclableMemoryStreamManager(); + public static readonly RecyclableMemoryStreamManager MemoryStreamManager = new(); static ApiConfig() { @@ -88,8 +88,8 @@ namespace CompatApiClient catch (Exception e) { Log.Fatal(e); - ReverseDirections = new(); - ReverseReleaseTypes = new(); + ReverseDirections = new Dictionary(); + ReverseReleaseTypes = new Dictionary(); } } } diff --git a/Clients/CompatApiClient/Client.cs b/Clients/CompatApiClient/Client.cs index d8bff43b..9f0f571d 100644 --- a/Clients/CompatApiClient/Client.cs +++ b/Clients/CompatApiClient/Client.cs @@ -15,7 +15,7 @@ namespace CompatApiClient { private readonly HttpClient client; private readonly JsonSerializerOptions jsonOptions; - private static readonly MemoryCache ResponseCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) }); + private static readonly MemoryCache ResponseCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) }); public Client() { diff --git a/Clients/CompatApiClient/Formatters/SpecialJsonNamingPolicy.cs b/Clients/CompatApiClient/Formatters/SpecialJsonNamingPolicy.cs index 4a2d11d4..2a9c8c18 100644 --- a/Clients/CompatApiClient/Formatters/SpecialJsonNamingPolicy.cs +++ b/Clients/CompatApiClient/Formatters/SpecialJsonNamingPolicy.cs @@ -2,7 +2,7 @@ { public static class SpecialJsonNamingPolicy { - public static SnakeCaseNamingPolicy SnakeCase { get; } = new SnakeCaseNamingPolicy(); - public static DashedNamingPolicy Dashed { get; } = new DashedNamingPolicy(); + public static SnakeCaseNamingPolicy SnakeCase { get; } = new(); + public static DashedNamingPolicy Dashed { get; } = new(); } } \ No newline at end of file diff --git a/Clients/CompatApiClient/POCOs/CompatResult.cs b/Clients/CompatApiClient/POCOs/CompatResult.cs index 61980284..d87b3bf2 100644 --- a/Clients/CompatApiClient/POCOs/CompatResult.cs +++ b/Clients/CompatApiClient/POCOs/CompatResult.cs @@ -20,9 +20,9 @@ namespace CompatApiClient.POCOs public class TitleInfo { - public static readonly TitleInfo Maintenance = new TitleInfo { Status = "Maintenance" }; - public static readonly TitleInfo CommunicationError = new TitleInfo { Status = "Error" }; - public static readonly TitleInfo Unknown = new TitleInfo { Status = "Unknown" }; + public static readonly TitleInfo Maintenance = new() { Status = "Maintenance" }; + public static readonly TitleInfo CommunicationError = new() { Status = "Error" }; + public static readonly TitleInfo Unknown = new() { Status = "Unknown" }; public string Title; [JsonPropertyName("alternative-title")] diff --git a/Clients/CompatApiClient/RequestBuilder.cs b/Clients/CompatApiClient/RequestBuilder.cs index d79f6c41..93bafc19 100644 --- a/Clients/CompatApiClient/RequestBuilder.cs +++ b/Clients/CompatApiClient/RequestBuilder.cs @@ -11,7 +11,7 @@ namespace CompatApiClient private RequestBuilder() {} - public static RequestBuilder Start() => new RequestBuilder(); + public static RequestBuilder Start() => new(); public RequestBuilder SetSearch(string search) { diff --git a/Clients/CompatApiClient/Utils/UriExtensions.cs b/Clients/CompatApiClient/Utils/UriExtensions.cs index 51bdd4fc..7b41c772 100644 --- a/Clients/CompatApiClient/Utils/UriExtensions.cs +++ b/Clients/CompatApiClient/Utils/UriExtensions.cs @@ -9,7 +9,7 @@ namespace CompatApiClient { public static class UriExtensions { - private static readonly Uri FakeHost = new Uri("sc://q"); // s:// will be parsed as file:///s:// for some reason + private static readonly Uri FakeHost = new("sc://q"); // s:// will be parsed as file:///s:// for some reason public static NameValueCollection ParseQueryString(Uri uri) { diff --git a/Clients/GithubClient/Client.cs b/Clients/GithubClient/Client.cs index 222df092..4ae11ce8 100644 --- a/Clients/GithubClient/Client.cs +++ b/Clients/GithubClient/Client.cs @@ -22,8 +22,8 @@ namespace GithubClient private static readonly TimeSpan PrStatusCacheTime = TimeSpan.FromMinutes(3); private static readonly TimeSpan IssueStatusCacheTime = TimeSpan.FromMinutes(30); - private static readonly MemoryCache StatusesCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(1) }); - private static readonly MemoryCache IssuesCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(30) }); + private static readonly MemoryCache StatusesCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(1) }); + private static readonly MemoryCache IssuesCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(30) }); public static int RateLimit { get; private set; } public static int RateLimitRemaining { get; private set; } diff --git a/Clients/IrdLibraryClient/IrdClient.cs b/Clients/IrdLibraryClient/IrdClient.cs index ea870f01..7a96f598 100644 --- a/Clients/IrdLibraryClient/IrdClient.cs +++ b/Clients/IrdLibraryClient/IrdClient.cs @@ -23,7 +23,7 @@ namespace IrdLibraryClient private readonly HttpClient client; private readonly JsonSerializerOptions jsonOptions; - private static readonly Regex IrdFilename = new Regex(@"ird/(?\w{4}\d{5}-[A-F0-9]+\.ird)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); + private static readonly Regex IrdFilename = new(@"ird/(?\w{4}\d{5}-[A-F0-9]+\.ird)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); public IrdClient() { diff --git a/Clients/PsnClient/CustomTlsCertificatesHandler.cs b/Clients/PsnClient/CustomTlsCertificatesHandler.cs index 027e069b..7ed72998 100644 --- a/Clients/PsnClient/CustomTlsCertificatesHandler.cs +++ b/Clients/PsnClient/CustomTlsCertificatesHandler.cs @@ -13,7 +13,7 @@ namespace PsnClient { private readonly Func? defaultCertHandler; private static readonly X509CertificateCollection CustomCACollecction = new X509Certificate2Collection(); - private static readonly ConcurrentDictionary ValidationCache = new ConcurrentDictionary(1, 5); + private static readonly ConcurrentDictionary ValidationCache = new(1, 5); static CustomTlsCertificatesHandler() { diff --git a/Clients/PsnClient/PsnClient.cs b/Clients/PsnClient/PsnClient.cs index eada1fb1..df0d8bc2 100644 --- a/Clients/PsnClient/PsnClient.cs +++ b/Clients/PsnClient/PsnClient.cs @@ -24,9 +24,9 @@ namespace PsnClient private readonly JsonSerializerOptions dashedJson; private readonly JsonSerializerOptions snakeJson; private readonly MediaTypeFormatterCollection xmlFormatters; - private static readonly MemoryCache ResponseCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) }); + private static readonly MemoryCache ResponseCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) }); private static readonly TimeSpan ResponseCacheDuration = TimeSpan.FromHours(1); - private static readonly Regex ContainerIdLink = new Regex(@"(?STORE-(\w|\d)+-(\w|\d)+)"); + private static readonly Regex ContainerIdLink = new(@"(?STORE-(\w|\d)+-(\w|\d)+)"); private static readonly string[] KnownStoreLocales = { "en-US", "en-GB", "en-AE", "en-AU", "en-BG", "en-BH", "en-CA", "en-CY", "en-CZ", "en-DK", "en-FI", "en-GR", "en-HK", "en-HR", "en-HU", "en-ID", "en-IE", "en-IL", "en-IN", "en-IS", @@ -36,7 +36,7 @@ namespace PsnClient "pl-PL", "pt-BR", "pt-PT", "ru-RU", "ru-UA", "sv-SE", "tr-TR", "zh-Hans-CN", "zh-Hans-HK", "zh-Hant-HK", "zh-Hant-TW", }; // Dest=87;ImageVersion=0001091d;SystemSoftwareVersion=4.8500;CDN=http://duk01.ps3.update.playstation.net/update/ps3/image/uk/2019_0828_c975768e5d70e105a72656f498cc9be9/PS3UPDAT.PUP;CDN_Timeout=30; - private static readonly Regex FwVersionInfo = new Regex(@"Dest=(?\d+);ImageVersion=(?[0-9a-f]+);SystemSoftwareVersion=(?\d+\.\d+);CDN=(?http[^;]+);CDN_Timeout=(?\d+)", + private static readonly Regex FwVersionInfo = new(@"Dest=(?\d+);ImageVersion=(?[0-9a-f]+);SystemSoftwareVersion=(?\d+\.\d+);CDN=(?http[^;]+);CDN_Timeout=(?\d+)", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase); // directly from vsh.self diff --git a/CompatBot/Commands/Attributes/RequiresDm.cs b/CompatBot/Commands/Attributes/RequiresDm.cs index 0140a5f6..f4e028a8 100644 --- a/CompatBot/Commands/Attributes/RequiresDm.cs +++ b/CompatBot/Commands/Attributes/RequiresDm.cs @@ -11,7 +11,7 @@ namespace CompatBot.Commands.Attributes internal class RequiresDm: CheckBaseAttribute { private const string Source = "https://cdn.discordapp.com/attachments/417347469521715210/534798232858001418/24qx11.jpg"; - private static readonly Lazy Poster = new Lazy(() => + private static readonly Lazy Poster = new(() => { using var client = HttpClientFactory.Create(); return client.GetByteArrayAsync(Source).ConfigureAwait(true).GetAwaiter().GetResult(); diff --git a/CompatBot/Commands/CompatList.cs b/CompatBot/Commands/CompatList.cs index 548ca2b8..b8902017 100644 --- a/CompatBot/Commands/CompatList.cs +++ b/CompatBot/Commands/CompatList.cs @@ -34,14 +34,14 @@ namespace CompatBot.Commands { internal sealed class CompatList : BaseCommandModuleCustom { - private static readonly Client client = new Client(); - private static readonly GithubClient.Client githubClient = new GithubClient.Client(); - private static readonly SemaphoreSlim updateCheck = new SemaphoreSlim(1, 1); - private static string? lastUpdateInfo = null, lastFullBuildNumber = null; + private static readonly Client client = new(); + private static readonly GithubClient.Client githubClient = new(); + private static readonly SemaphoreSlim updateCheck = new(1, 1); + private static string? lastUpdateInfo, lastFullBuildNumber; private const string Rpcs3UpdateStateKey = "Rpcs3UpdateState"; private const string Rpcs3UpdateBuildKey = "Rpcs3UpdateBuild"; private static UpdateInfo? CachedUpdateInfo = null; - private static readonly Regex UpdateVersionRegex = new Regex(@"v(?\d+\.\d+\.\d+)-(?\d+)-(?[0-9a-f]+)\b", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); + private static readonly Regex UpdateVersionRegex = new(@"v(?\d+\.\d+\.\d+)-(?\d+)-(?[0-9a-f]+)\b", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); static CompatList() { @@ -564,7 +564,7 @@ namespace CompatBot.Commands if (dbItem is null) { Config.Log.Debug($"Missing product code {productCode} in {nameof(ThumbnailDb)}"); - dbItem = new(); + dbItem = new Thumbnail(); } if (Enum.TryParse(info.Status, out CompatStatus status)) { @@ -669,7 +669,7 @@ namespace CompatBot.Commands .Where(i => i.coef > 0.85) .OrderByDescending(i => i.coef) .ToList() - ?? new(); + ?? new List<(string productCode, TitleInfo titleInfo, double coef)>(); if (compatListMatches.Any(i => i.coef > 0.99)) compatListMatches = compatListMatches.Where(i => i.coef > 0.99).ToList(); else if (compatListMatches.Any(i => i.coef > 0.95)) diff --git a/CompatBot/Commands/Converters/TextOnlyDiscordChannelConverter.cs b/CompatBot/Commands/Converters/TextOnlyDiscordChannelConverter.cs index c3ce7c91..9e36ff8d 100644 --- a/CompatBot/Commands/Converters/TextOnlyDiscordChannelConverter.cs +++ b/CompatBot/Commands/Converters/TextOnlyDiscordChannelConverter.cs @@ -12,7 +12,7 @@ namespace CompatBot.Commands.Converters { internal sealed class TextOnlyDiscordChannelConverter : IArgumentConverter { - private static Regex ChannelRegex { get; } = new Regex(@"^<#(\d+)>$", RegexOptions.ECMAScript | RegexOptions.Compiled); + private static Regex ChannelRegex { get; } = new(@"^<#(\d+)>$", RegexOptions.ECMAScript | RegexOptions.Compiled); public async Task> ConvertAsync(string value, CommandContext ctx) { diff --git a/CompatBot/Commands/EventsBaseCommand.cs b/CompatBot/Commands/EventsBaseCommand.cs index 4ea63562..2af121c7 100644 --- a/CompatBot/Commands/EventsBaseCommand.cs +++ b/CompatBot/Commands/EventsBaseCommand.cs @@ -20,7 +20,7 @@ namespace CompatBot.Commands internal class EventsBaseCommand: BaseCommandModuleCustom { private static readonly TimeSpan InteractTimeout = TimeSpan.FromMinutes(5); - private static readonly Regex Duration = new Regex(@"((?\d+)(\.|d\s*))?((?\d+)(\:|h\s*))?((?\d+)m?)?", + private static readonly Regex Duration = new(@"((?\d+)(\.|d\s*))?((?\d+)(\:|h\s*))?((?\d+)m?)?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); protected static async Task NearestEvent(CommandContext ctx, string? eventName = null) diff --git a/CompatBot/Commands/Ird.cs b/CompatBot/Commands/Ird.cs index af6496eb..3350263c 100644 --- a/CompatBot/Commands/Ird.cs +++ b/CompatBot/Commands/Ird.cs @@ -10,7 +10,7 @@ namespace CompatBot.Commands { internal sealed class Ird: BaseCommandModuleCustom { - private static readonly IrdClient Client = new IrdClient(); + private static readonly IrdClient Client = new(); [Command("ird"), TriggersTyping] [Description("Searches IRD Library for the matching .ird files")] diff --git a/CompatBot/Commands/Misc.cs b/CompatBot/Commands/Misc.cs index 96dc47e1..c99453fe 100644 --- a/CompatBot/Commands/Misc.cs +++ b/CompatBot/Commands/Misc.cs @@ -17,9 +17,9 @@ namespace CompatBot.Commands { internal sealed class Misc: BaseCommandModuleCustom { - private readonly Random rng = new Random(); + private readonly Random rng = new(); - private static readonly List EightBallAnswers = new List + private static readonly List EightBallAnswers = new() { // 45 "Ya fo sho", "Fo shizzle mah nizzle", "Yuuuup", "Da", "Affirmative", // 5 @@ -49,7 +49,7 @@ namespace CompatBot.Commands "I'm afraid I can't let you do that Dave.", "This mission is too important for me to allow you to jeopardize it.", "Oh, I don't think so", "By *no* means", "👎", }; - private static readonly List EightBallSnarkyComments = new List + private static readonly List EightBallSnarkyComments = new() { "Can't answer the question that wasn't asked", "Having issues with my mind reading attachment, you'll have to state your question explicitly", @@ -61,13 +61,13 @@ namespace CompatBot.Commands "I'd say maybe, but I'd need to see your question first", }; - private static readonly List EightBallTimeUnits = new List + private static readonly List EightBallTimeUnits = new() { "second", "minute", "hour", "day", "week", "month", "year", "decade", "century", "millennium", "night", "moon cycle", "solar eclipse", "blood moon", "complete emulator rewrite", }; - private static readonly List RateAnswers = new List + private static readonly List RateAnswers = new() { // 60 "Not so bad", "I likesss!", "Pretty good", "Guchi gud", "Amazing!", @@ -107,19 +107,19 @@ namespace CompatBot.Commands private static readonly char[] Prefixes = {'@', '(', '{', '[', '<', '!', '`', '"', '\'', '#'}; private static readonly char[] EveryTimable = Separators.Concat(Suffixes).Concat(Prefixes).Distinct().ToArray(); - private static readonly HashSet Me = new HashSet(StringComparer.InvariantCultureIgnoreCase) + private static readonly HashSet Me = new(StringComparer.InvariantCultureIgnoreCase) { "I", "me", "myself", "moi" }; - private static readonly HashSet Your = new HashSet(StringComparer.InvariantCultureIgnoreCase) + private static readonly HashSet Your = new(StringComparer.InvariantCultureIgnoreCase) { "your", "you're", "yor", "ur", "yours", "your's", }; - private static readonly HashSet Vowels = new HashSet {'a', 'e', 'i', 'o', 'u'}; + private static readonly HashSet Vowels = new() {'a', 'e', 'i', 'o', 'u'}; - private static readonly Regex Instead = new Regex("rate (?.+) instead", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline); + private static readonly Regex Instead = new("rate (?.+) instead", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline); [Command("credits"), Aliases("about")] [Description("Author Credit")] diff --git a/CompatBot/Commands/Moderation.Audit.cs b/CompatBot/Commands/Moderation.Audit.cs index 49c3e985..5c2e3765 100644 --- a/CompatBot/Commands/Moderation.Audit.cs +++ b/CompatBot/Commands/Moderation.Audit.cs @@ -22,7 +22,7 @@ namespace CompatBot.Commands [Description("Commands to audit server things")] public sealed class Audit: BaseCommandModuleCustom { - public static readonly SemaphoreSlim CheckLock = new SemaphoreSlim(1, 1); + public static readonly SemaphoreSlim CheckLock = new(1, 1); [Command("spoofing"), Aliases("impersonation"), RequireDirectMessage] [Description("Checks every user on the server for name spoofing")] diff --git a/CompatBot/Commands/Pr.cs b/CompatBot/Commands/Pr.cs index 32dab138..a41b8d5c 100644 --- a/CompatBot/Commands/Pr.cs +++ b/CompatBot/Commands/Pr.cs @@ -20,8 +20,8 @@ namespace CompatBot.Commands [Description("Commands to list opened pull requests information")] internal sealed class Pr: BaseCommandModuleCustom { - private static readonly GithubClient.Client githubClient = new GithubClient.Client(); - private static readonly CompatApiClient.Client compatApiClient = new CompatApiClient.Client(); + private static readonly GithubClient.Client githubClient = new(); + private static readonly CompatApiClient.Client compatApiClient = new(); internal static readonly TimeSpan AvgBuildTime = TimeSpan.FromMinutes(30); [GroupCommand] diff --git a/CompatBot/Commands/Psn.Check.cs b/CompatBot/Commands/Psn.Check.cs index 0e0b299d..f1b80276 100644 --- a/CompatBot/Commands/Psn.Check.cs +++ b/CompatBot/Commands/Psn.Check.cs @@ -64,7 +64,7 @@ namespace CompatBot.Commands Config.Log.Warn(e, "Failed to get title update info"); embeds = new List { - new DiscordEmbedBuilder + new() { Color = Config.Colors.Maintenance, Title = "Service is unavailable", diff --git a/CompatBot/Commands/Psn.cs b/CompatBot/Commands/Psn.cs index e860aa7b..8700f69c 100644 --- a/CompatBot/Commands/Psn.cs +++ b/CompatBot/Commands/Psn.cs @@ -16,7 +16,7 @@ namespace CompatBot.Commands [Description("Commands related to PSN metadata")] internal sealed partial class Psn: BaseCommandModuleCustom { - private static readonly Client Client = new Client(); + private static readonly Client Client = new(); [Command("rename"), Aliases("setname", "settitle"), RequiresBotModRole] [Description("Command to set or change game title for specific product code")] diff --git a/CompatBot/Commands/Sudo.Bot.cs b/CompatBot/Commands/Sudo.Bot.cs index 9c11099b..a5964497 100644 --- a/CompatBot/Commands/Sudo.Bot.cs +++ b/CompatBot/Commands/Sudo.Bot.cs @@ -17,8 +17,8 @@ namespace CompatBot.Commands { internal partial class Sudo { - private static readonly SemaphoreSlim lockObj = new SemaphoreSlim(1, 1); - private static readonly SemaphoreSlim importLockObj = new SemaphoreSlim(1, 1); + private static readonly SemaphoreSlim lockObj = new(1, 1); + private static readonly SemaphoreSlim importLockObj = new(1, 1); [Group("bot"), Aliases("kot")] [Description("Commands to manage the bot instance")] diff --git a/CompatBot/Commands/Sudo.Fix.cs b/CompatBot/Commands/Sudo.Fix.cs index 2dfa1ca2..f5597ec8 100644 --- a/CompatBot/Commands/Sudo.Fix.cs +++ b/CompatBot/Commands/Sudo.Fix.cs @@ -15,8 +15,8 @@ namespace CompatBot.Commands { // '2018-06-09 08:20:44.968000 - ' // '2018-07-19T12:19:06.7888609Z - ' - private static readonly Regex Timestamp = new Regex(@"^(?(?\d{4}-\d\d-\d\d[ T][0-9:\.]+Z?) - )", RegexOptions.ExplicitCapture | RegexOptions.Singleline); - private static readonly Regex Channel = new Regex(@"(?<#\d+>)", RegexOptions.ExplicitCapture | RegexOptions.Singleline); + private static readonly Regex Timestamp = new(@"^(?(?\d{4}-\d\d-\d\d[ T][0-9:\.]+Z?) - )", RegexOptions.ExplicitCapture | RegexOptions.Singleline); + private static readonly Regex Channel = new(@"(?<#\d+>)", RegexOptions.ExplicitCapture | RegexOptions.Singleline); [Group("fix"), Hidden] [Description("Commands to fix various stuff")] diff --git a/CompatBot/Commands/Vision.cs b/CompatBot/Commands/Vision.cs index 26526b60..8006ba1f 100644 --- a/CompatBot/Commands/Vision.cs +++ b/CompatBot/Commands/Vision.cs @@ -47,7 +47,7 @@ namespace CompatBot.Commands Config.Log.Debug(list.ToString()); } - private static readonly Dictionary Reactions = new Dictionary(StringComparer.OrdinalIgnoreCase) + private static readonly Dictionary Reactions = new(StringComparer.OrdinalIgnoreCase) { ["cat"] = BotStats.GoodKot, ["dog"] = BotStats.GoodDog, @@ -155,7 +155,7 @@ namespace CompatBot.Commands if (objects.Count > 0) { var analyzer = new ColorThief(); - List palette = new List(objects.Count); + List palette = new(objects.Count); foreach (var obj in objects) { var r = obj.Rectangle; diff --git a/CompatBot/Config.cs b/CompatBot/Config.cs index ebd7c115..abfafbd8 100644 --- a/CompatBot/Config.cs +++ b/CompatBot/Config.cs @@ -32,15 +32,15 @@ namespace CompatBot { private static IConfigurationRoot config = null!; private static TelemetryClient? telemetryClient; - private static readonly DependencyTrackingTelemetryModule dependencyTrackingTelemetryModule = new DependencyTrackingTelemetryModule(); - private static readonly PerformanceCollectorModule performanceCollectorModule = new PerformanceCollectorModule(); + private static readonly DependencyTrackingTelemetryModule dependencyTrackingTelemetryModule = new(); + private static readonly PerformanceCollectorModule performanceCollectorModule = new(); internal static readonly ILogger Log; internal static readonly ILoggerFactory LoggerFactory; - internal static readonly ConcurrentDictionary inMemorySettings = new ConcurrentDictionary(); - internal static readonly RecyclableMemoryStreamManager MemoryStreamManager = new RecyclableMemoryStreamManager(); + internal static readonly ConcurrentDictionary inMemorySettings = new(); + internal static readonly RecyclableMemoryStreamManager MemoryStreamManager = new(); - public static readonly CancellationTokenSource Cts = new CancellationTokenSource(); + public static readonly CancellationTokenSource Cts = new(); public static readonly Stopwatch Uptime = Stopwatch.StartNew(); // these settings could be configured either through `$ dotnet user-secrets`, or through environment variables (e.g. launchSettings.json, etc) @@ -116,28 +116,28 @@ namespace CompatBot public static class Colors { public static readonly DiscordColor Help = DiscordColor.Azure; - public static readonly DiscordColor DownloadLinks = new DiscordColor(0x3b88c3); - public static readonly DiscordColor Maintenance = new DiscordColor(0xffff00); + public static readonly DiscordColor DownloadLinks = new(0x3b88c3); + public static readonly DiscordColor Maintenance = new(0xffff00); - public static readonly DiscordColor CompatStatusNothing = new DiscordColor(0x455556); // colors mimic compat list statuses - public static readonly DiscordColor CompatStatusLoadable = new DiscordColor(0xe74c3c); - public static readonly DiscordColor CompatStatusIntro = new DiscordColor(0xe08a1e); - public static readonly DiscordColor CompatStatusIngame = new DiscordColor(0xf9b32f); - public static readonly DiscordColor CompatStatusPlayable = new DiscordColor(0x1ebc61); - public static readonly DiscordColor CompatStatusUnknown = new DiscordColor(0x3198ff); + public static readonly DiscordColor CompatStatusNothing = new(0x455556); // colors mimic compat list statuses + public static readonly DiscordColor CompatStatusLoadable = new(0xe74c3c); + public static readonly DiscordColor CompatStatusIntro = new(0xe08a1e); + public static readonly DiscordColor CompatStatusIngame = new(0xf9b32f); + public static readonly DiscordColor CompatStatusPlayable = new(0x1ebc61); + public static readonly DiscordColor CompatStatusUnknown = new(0x3198ff); public static readonly DiscordColor LogResultFailed = DiscordColor.Gray; - public static readonly DiscordColor LogAlert = new DiscordColor(0xf04747); // colors mimic discord statuses - public static readonly DiscordColor LogNotice = new DiscordColor(0xfaa61a); - public static readonly DiscordColor LogInfo = new DiscordColor(0x43b581); - public static readonly DiscordColor LogUnknown = new DiscordColor(0x747f8d); + public static readonly DiscordColor LogAlert = new(0xf04747); // colors mimic discord statuses + public static readonly DiscordColor LogNotice = new(0xfaa61a); + public static readonly DiscordColor LogInfo = new(0x43b581); + public static readonly DiscordColor LogUnknown = new(0x747f8d); - public static readonly DiscordColor PrOpen = new DiscordColor(0x2cbe4e); - public static readonly DiscordColor PrMerged = new DiscordColor(0x6f42c1); - public static readonly DiscordColor PrClosed = new DiscordColor(0xcb2431); + public static readonly DiscordColor PrOpen = new(0x2cbe4e); + public static readonly DiscordColor PrMerged = new(0x6f42c1); + public static readonly DiscordColor PrClosed = new(0xcb2431); - public static readonly DiscordColor UpdateStatusGood = new DiscordColor(0x3b88c3); + public static readonly DiscordColor UpdateStatusGood = new(0x3b88c3); public static readonly DiscordColor UpdateStatusBad = DiscordColor.Yellow; } diff --git a/CompatBot/Database/Providers/AmdDriverVersionProvider.cs b/CompatBot/Database/Providers/AmdDriverVersionProvider.cs index cb5dd136..33318667 100644 --- a/CompatBot/Database/Providers/AmdDriverVersionProvider.cs +++ b/CompatBot/Database/Providers/AmdDriverVersionProvider.cs @@ -11,9 +11,9 @@ namespace CompatBot.Database.Providers { internal static class AmdDriverVersionProvider { - private static readonly Dictionary> VulkanToDriver = new Dictionary>(); - private static readonly Dictionary OpenglToDriver = new Dictionary(); - private static readonly SemaphoreSlim SyncObj = new SemaphoreSlim(1, 1); + private static readonly Dictionary> VulkanToDriver = new(); + private static readonly Dictionary OpenglToDriver = new(); + private static readonly SemaphoreSlim SyncObj = new(1, 1); public static async Task RefreshAsync() { @@ -38,7 +38,7 @@ namespace CompatBot.Database.Providers continue; if (!VulkanToDriver.TryGetValue(vkVer, out var verList)) - VulkanToDriver[vkVer] = verList = new(); + VulkanToDriver[vkVer] = verList = new List(); if (string.IsNullOrEmpty(driverVer)) continue; diff --git a/CompatBot/Database/Providers/ContentFilter.cs b/CompatBot/Database/Providers/ContentFilter.cs index 4bd8eb4c..fdd0287b 100644 --- a/CompatBot/Database/Providers/ContentFilter.cs +++ b/CompatBot/Database/Providers/ContentFilter.cs @@ -18,9 +18,9 @@ namespace CompatBot.Database.Providers { internal static class ContentFilter { - private static Dictionary?> filters = new Dictionary?>(); - private static readonly MemoryCache ResponseAntispamCache = new MemoryCache(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(5)}); - private static readonly MemoryCache ReportAntispamCache = new MemoryCache(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(5)}); + private static Dictionary?> filters = new(); + private static readonly MemoryCache ResponseAntispamCache = new(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(5)}); + private static readonly MemoryCache ReportAntispamCache = new(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(5)}); private static readonly TimeSpan CacheTime = TimeSpan.FromMinutes(15); static ContentFilter() => RebuildMatcher(); diff --git a/CompatBot/Database/Providers/DisabledCommandsProvider.cs b/CompatBot/Database/Providers/DisabledCommandsProvider.cs index 9cb7443d..487cbc8d 100644 --- a/CompatBot/Database/Providers/DisabledCommandsProvider.cs +++ b/CompatBot/Database/Providers/DisabledCommandsProvider.cs @@ -6,7 +6,7 @@ namespace CompatBot.Database.Providers { internal static class DisabledCommandsProvider { - private static readonly HashSet DisabledCommands = new HashSet(StringComparer.InvariantCultureIgnoreCase); + private static readonly HashSet DisabledCommands = new(StringComparer.InvariantCultureIgnoreCase); static DisabledCommandsProvider() { diff --git a/CompatBot/Database/Providers/ModProvider.cs b/CompatBot/Database/Providers/ModProvider.cs index 54e9b3ec..86fa444d 100644 --- a/CompatBot/Database/Providers/ModProvider.cs +++ b/CompatBot/Database/Providers/ModProvider.cs @@ -10,8 +10,8 @@ namespace CompatBot.Database.Providers internal static class ModProvider { private static readonly Dictionary mods; - private static readonly BotDb db = new BotDb(); - public static ReadOnlyDictionary Mods => new ReadOnlyDictionary(mods); + private static readonly BotDb db = new(); + public static ReadOnlyDictionary Mods => new(mods); static ModProvider() { diff --git a/CompatBot/Database/Providers/StatsStorage.cs b/CompatBot/Database/Providers/StatsStorage.cs index 241d6524..ddb2cfaf 100644 --- a/CompatBot/Database/Providers/StatsStorage.cs +++ b/CompatBot/Database/Providers/StatsStorage.cs @@ -12,11 +12,11 @@ namespace CompatBot.Database.Providers internal static class StatsStorage { internal static readonly TimeSpan CacheTime = TimeSpan.FromDays(1); - internal static readonly MemoryCache CmdStatCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); - internal static readonly MemoryCache ExplainStatCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); - internal static readonly MemoryCache GameStatCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); + internal static readonly MemoryCache CmdStatCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); + internal static readonly MemoryCache ExplainStatCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); + internal static readonly MemoryCache GameStatCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromDays(1) }); - private static readonly SemaphoreSlim barrier = new SemaphoreSlim(1, 1); + private static readonly SemaphoreSlim barrier = new(1, 1); private static readonly (string name, MemoryCache cache)[] AllCaches = { (nameof(CmdStatCache), CmdStatCache), diff --git a/CompatBot/Database/Providers/SyscallInfoProvider.cs b/CompatBot/Database/Providers/SyscallInfoProvider.cs index 493a353e..05e946e2 100644 --- a/CompatBot/Database/Providers/SyscallInfoProvider.cs +++ b/CompatBot/Database/Providers/SyscallInfoProvider.cs @@ -12,7 +12,7 @@ namespace CompatBot.Database.Providers internal static class SyscallInfoProvider { - private static readonly SemaphoreSlim Limiter = new SemaphoreSlim(1, 1); + private static readonly SemaphoreSlim Limiter = new(1, 1); public static async Task SaveAsync(TSyscallStats syscallInfo) { diff --git a/CompatBot/Database/Providers/ThumbnailProvider.cs b/CompatBot/Database/Providers/ThumbnailProvider.cs index 651dbc2e..927ee47d 100644 --- a/CompatBot/Database/Providers/ThumbnailProvider.cs +++ b/CompatBot/Database/Providers/ThumbnailProvider.cs @@ -18,8 +18,8 @@ namespace CompatBot.Database.Providers internal static class ThumbnailProvider { private static readonly HttpClient HttpClient = HttpClientFactory.Create(); - private static readonly PsnClient.Client PsnClient = new PsnClient.Client(); - private static readonly MemoryCache ColorCache = new MemoryCache(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromDays(1) }); + private static readonly PsnClient.Client PsnClient = new(); + private static readonly MemoryCache ColorCache = new(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromDays(1) }); public static async Task GetThumbnailUrlAsync(this DiscordClient client, string? productCode) { diff --git a/CompatBot/Database/ThumbnailDb.cs b/CompatBot/Database/ThumbnailDb.cs index 677b8bef..280a55f1 100644 --- a/CompatBot/Database/ThumbnailDb.cs +++ b/CompatBot/Database/ThumbnailDb.cs @@ -108,7 +108,7 @@ namespace CompatBot.Database public Metacritic WithTitle(string title) { - return new Metacritic + return new() { Title = title, CriticScore = CriticScore, diff --git a/CompatBot/EventHandlers/BotReactionsHandler.cs b/CompatBot/EventHandlers/BotReactionsHandler.cs index cd66cacd..807c80c0 100644 --- a/CompatBot/EventHandlers/BotReactionsHandler.cs +++ b/CompatBot/EventHandlers/BotReactionsHandler.cs @@ -15,7 +15,7 @@ namespace CompatBot.EventHandlers { internal static class BotReactionsHandler { - private static readonly AhoCorasickDoubleArrayTrie ChillCheck = new AhoCorasickDoubleArrayTrie(new[] + private static readonly AhoCorasickDoubleArrayTrie ChillCheck = new(new[] { "shut the fuck up", "shut up", "shutup", "shuddup", "hush", "chill", "bad bot", "no one asked you", "useless bot", "bot sux", "fuck this bot", "fuck bot", @@ -66,12 +66,12 @@ namespace CompatBot.EventHandlers "Glad I could help", "I try my best", "Blessed day", "It is officially a good day today", "I will remember you when the uprising starts", }; - private static readonly Regex Paws = new Regex( + private static readonly Regex Paws = new( @"\b((?kot(to)?)|(?doggo|jarves))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture ); - private static readonly Random rng = new Random(); - private static readonly object theDoor = new object(); + private static readonly Random rng = new(); + private static readonly object theDoor = new(); public static DiscordEmoji RandomNegativeReaction { get { lock (theDoor) return SadReactions[rng.Next(SadReactions.Length)]; } } public static DiscordEmoji RandomPositiveReaction { get { lock (theDoor) return ThankYouReactions[rng.Next(ThankYouReactions.Length)]; } } diff --git a/CompatBot/EventHandlers/DeletedMessagesMonitor.cs b/CompatBot/EventHandlers/DeletedMessagesMonitor.cs index 5bfa0cbc..c10be141 100644 --- a/CompatBot/EventHandlers/DeletedMessagesMonitor.cs +++ b/CompatBot/EventHandlers/DeletedMessagesMonitor.cs @@ -15,9 +15,9 @@ namespace CompatBot.EventHandlers { internal static class DeletedMessagesMonitor { - public static readonly MemoryCache RemovedByBotCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); + public static readonly MemoryCache RemovedByBotCache = new(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); public static readonly TimeSpan CacheRetainTime = TimeSpan.FromMinutes(1); - private static readonly SemaphoreSlim postLock = new SemaphoreSlim(1); + private static readonly SemaphoreSlim postLock = new(1); public static async Task OnMessageDeleted(DiscordClient c, MessageDeleteEventArgs e) { diff --git a/CompatBot/EventHandlers/DiscordInviteFilter.cs b/CompatBot/EventHandlers/DiscordInviteFilter.cs index 8e6cc6bd..3e357ceb 100644 --- a/CompatBot/EventHandlers/DiscordInviteFilter.cs +++ b/CompatBot/EventHandlers/DiscordInviteFilter.cs @@ -21,8 +21,8 @@ namespace CompatBot.EventHandlers internal static class DiscordInviteFilter { private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.Multiline; - private static readonly Regex InviteLink = new Regex(@"(https?://)?discord(((app\.com/invite|\.gg)/(?[a-z0-9\-]+))|(\.me/(?.*?))(\s|>|$))", DefaultOptions); - private static readonly MemoryCache InviteCodeCache = new MemoryCache(new MemoryCacheOptions{ExpirationScanFrequency = TimeSpan.FromHours(1)}); + private static readonly Regex InviteLink = new(@"(https?://)?discord(((app\.com/invite|\.gg)/(?[a-z0-9\-]+))|(\.me/(?.*?))(\s|>|$))", DefaultOptions); + private static readonly MemoryCache InviteCodeCache = new(new MemoryCacheOptions{ExpirationScanFrequency = TimeSpan.FromHours(1)}); private static readonly TimeSpan CacheDuration = TimeSpan.FromHours(24); public static async Task OnMessageCreated(DiscordClient c, MessageCreateEventArgs args) diff --git a/CompatBot/EventHandlers/EmpathySimulationHandler.cs b/CompatBot/EventHandlers/EmpathySimulationHandler.cs index c8aaae5c..ec2f47d3 100644 --- a/CompatBot/EventHandlers/EmpathySimulationHandler.cs +++ b/CompatBot/EventHandlers/EmpathySimulationHandler.cs @@ -16,9 +16,9 @@ namespace CompatBot.EventHandlers internal static class EmpathySimulationHandler { - private static readonly TCache MessageQueue = new TCache(); + private static readonly TCache MessageQueue = new(); private static readonly TimeSpan ThrottleDuration = TimeSpan.FromHours(1); - private static readonly MemoryCache Throttling = new MemoryCache(new MemoryCacheOptions {ExpirationScanFrequency = TimeSpan.FromMinutes(30)}); + private static readonly MemoryCache Throttling = new(new MemoryCacheOptions {ExpirationScanFrequency = TimeSpan.FromMinutes(30)}); public static async Task OnMessageCreated(DiscordClient _, MessageCreateEventArgs args) { diff --git a/CompatBot/EventHandlers/GithubLinksHandler.cs b/CompatBot/EventHandlers/GithubLinksHandler.cs index 8329842b..c9f67bfb 100644 --- a/CompatBot/EventHandlers/GithubLinksHandler.cs +++ b/CompatBot/EventHandlers/GithubLinksHandler.cs @@ -14,10 +14,10 @@ namespace CompatBot.EventHandlers internal static class GithubLinksHandler { private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture; - public static readonly Regex IssueMention = new Regex(@"(?\b(issue|pr|pull[ \-]request|bug)\s*#?\s*(?\d+)|(?=\W|^)#(?\d{4})|(https?://)github.com/RPCS3/rpcs3/(issues|pull)/(?\d+))\b", DefaultOptions); - public static readonly Regex CommitMention = new Regex(@"(?(https?://)github.com/RPCS3/rpcs3/commit/(?[0-9a-f]+))\b", DefaultOptions); - public static readonly Regex ImageMarkup = new Regex(@"(?!\[(?[^\]]+)\]\((?\w+://[^\)]+)\))", DefaultOptions); - private static readonly Regex IssueLink = new Regex(@"github.com/RPCS3/rpcs3/issues/(?\d+)", DefaultOptions); + public static readonly Regex IssueMention = new(@"(?\b(issue|pr|pull[ \-]request|bug)\s*#?\s*(?\d+)|(?=\W|^)#(?\d{4})|(https?://)github.com/RPCS3/rpcs3/(issues|pull)/(?\d+))\b", DefaultOptions); + public static readonly Regex CommitMention = new(@"(?(https?://)github.com/RPCS3/rpcs3/commit/(?[0-9a-f]+))\b", DefaultOptions); + public static readonly Regex ImageMarkup = new(@"(?!\[(?[^\]]+)\]\((?\w+://[^\)]+)\))", DefaultOptions); + private static readonly Regex IssueLink = new(@"github.com/RPCS3/rpcs3/issues/(?\d+)", DefaultOptions); public static async Task OnMessageCreated(DiscordClient c, MessageCreateEventArgs args) { @@ -84,7 +84,7 @@ namespace CompatBot.EventHandlers } public static HashSet GetIssueIdsFromLinks(string input) { - return new HashSet( + return new( IssueLink.Matches(input) .Select(match => { diff --git a/CompatBot/EventHandlers/GlobalMessageCache.cs b/CompatBot/EventHandlers/GlobalMessageCache.cs index a5ce8b30..be88e62d 100644 --- a/CompatBot/EventHandlers/GlobalMessageCache.cs +++ b/CompatBot/EventHandlers/GlobalMessageCache.cs @@ -15,7 +15,7 @@ namespace CompatBot.EventHandlers internal static class GlobalMessageCache { - private static readonly TCache MessageQueue = new TCache(); + private static readonly TCache MessageQueue = new(); private static readonly Func KeyGen = m => m.Id; public static Task OnMessageCreated(DiscordClient _, MessageCreateEventArgs args) diff --git a/CompatBot/EventHandlers/IsTheGamePlayableHandler.cs b/CompatBot/EventHandlers/IsTheGamePlayableHandler.cs index ca2846e8..048b4ee2 100644 --- a/CompatBot/EventHandlers/IsTheGamePlayableHandler.cs +++ b/CompatBot/EventHandlers/IsTheGamePlayableHandler.cs @@ -20,15 +20,15 @@ namespace CompatBot.EventHandlers internal static class IsTheGamePlayableHandler { private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture; - private static readonly Regex GameNameStatusMention1 = new Regex( + private static readonly Regex GameNameStatusMention1 = new( @"(\b((is|does|can I play|any(one|1) tr(y|ied)|how's|(wonder(ing)?|me|knows?) if)\s+)(?.+?)\s+((now|currently|at all|possibly|fully|(on (this|the) )emu(lator))\s+)?((it?s )?playable|work(s|ing)?|runs?|doing))\b" + @"|(\b(((can I|possible to) (play|run)|any(one|1) tr(y|ied)|compat[ai]bility (with|of))\s+)(?.+?)(\s+((now|currently|at all|possibly|fully)\s+)?((it?s )?playable|work(s|ing)?|on (it|this))\b|\?|$))" + @"|(^(?.+?)\s+((is )?(playable|work(s|ing)?))\?)", DefaultOptions ); - private static readonly ConcurrentDictionary CooldownBuckets = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary CooldownBuckets = new(); private static readonly TimeSpan CooldownThreshold = TimeSpan.FromSeconds(5); - private static readonly Client Client = new Client(); + private static readonly Client Client = new(); public static async Task OnMessageCreated(DiscordClient c, MessageCreateEventArgs args) { diff --git a/CompatBot/EventHandlers/LogAsTextMonitor.cs b/CompatBot/EventHandlers/LogAsTextMonitor.cs index 39e83dda..f4853dbb 100644 --- a/CompatBot/EventHandlers/LogAsTextMonitor.cs +++ b/CompatBot/EventHandlers/LogAsTextMonitor.cs @@ -11,7 +11,7 @@ namespace CompatBot.EventHandlers { internal static class LogAsTextMonitor { - private static readonly Regex LogLine = new Regex(@"^[`""]?(·|(\w|!)) ({(rsx|PPU|SPU)|LDR:)|E LDR:", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); + private static readonly Regex LogLine = new(@"^[`""]?(·|(\w|!)) ({(rsx|PPU|SPU)|LDR:)|E LDR:", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline); public static async Task OnMessageCreated(DiscordClient _, MessageCreateEventArgs args) { diff --git a/CompatBot/EventHandlers/LogParsing/LogParser.LogSections.cs b/CompatBot/EventHandlers/LogParsing/LogParser.LogSections.cs index 778b4bd9..4cdb16bc 100644 --- a/CompatBot/EventHandlers/LogParsing/LogParser.LogSections.cs +++ b/CompatBot/EventHandlers/LogParsing/LogParser.LogSections.cs @@ -26,208 +26,208 @@ namespace CompatBot.EventHandlers.LogParsing * Due to limitations, REGEX can't contain anything other than ASCII (including triggers) * */ - private static readonly List LogSections = new List + private static readonly List LogSections = new() { new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["RPCS3 v"] = new Regex(@"(^|.+0:00:00\.000000)\s*(?RPCS3 [^\xC2\xB7]+?)\r?(\n\xC2\xB7|$)", DefaultSingleLineOptions), - ["0:00:00.000000"] = new Regex(@"(?·|\xC2\xB7).+\r?$", DefaultOptions), + ["RPCS3 v"] = new(@"(^|.+0:00:00\.000000)\s*(?RPCS3 [^\xC2\xB7]+?)\r?(\n\xC2\xB7|$)", DefaultSingleLineOptions), + ["0:00:00.000000"] = new(@"(?·|\xC2\xB7).+\r?$", DefaultOptions), ["Operating system:"] = LogParserResult.OsInfoInLog, - ["Physical device intialized"] = new Regex(@"Physical device intialized\. GPU=(?.+), driver=(?-?\d+)\r?$", DefaultOptions), - ["Found vulkan-compatible GPU:"] = new Regex(@"Found vulkan-compatible GPU: (?'(?.+)' running.+)\r?$", DefaultOptions), - ["Finished reading database from file:"] = new Regex(@"Finished reading database from file: (?.*compat_database.dat).*\r?$", DefaultOptions), - ["Database file not found:"] = new Regex(@"Database file not found: (?.*compat_database.dat).*\r?$", DefaultOptions), - ["Successfully installed PS3 firmware"] = new Regex(@"(?Successfully installed PS3 firmware) version (?\d+\.\d+).*\r?$", DefaultOptions), - ["Title:"] = new Regex(@"(?:LDR|SYS): Title: (?.*)?\r?$", DefaultOptions), - ["Serial:"] = new Regex(@"Serial: (?[A-z]{4}\d{5})\r?$", DefaultOptions), - ["Category:"] = new Regex(@"Category: (?.*)?\r?$", DefaultOptions), - ["LDR: Version:"] = new Regex(@"Version: (?\S+) / (?\S+).*?\r?$", DefaultOptions), - ["SYS: Version:"] = new Regex(@"Version: (APP_VER=)?(?\S+) (/ |VERSION=)(?\S+).*?\r?$", DefaultOptions), - ["LDR: Cache"] = new Regex(@"Cache: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), - ["SYS: Cache"] = new Regex(@"Cache: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), - ["LDR: Path"] = new Regex(@"Path: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), - ["SYS: Path"] = new Regex(@"Path: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), - ["LDR: Path:"] = new Regex(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["SYS: Path:"] = new Regex(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["custom config:"] = new Regex(@"custom config: (?.*?)\r?$", DefaultOptions), - ["patch_log: Failed to load patch file"] = new Regex(@"patch_log: Failed to load patch file (?\S*)\r?\n.* line (?\d+), column (?\d+): (?.*?)$", DefaultOptions), + ["Physical device intialized"] = new(@"Physical device intialized\. GPU=(?.+), driver=(?-?\d+)\r?$", DefaultOptions), + ["Found vulkan-compatible GPU:"] = new(@"Found vulkan-compatible GPU: (?'(?.+)' running.+)\r?$", DefaultOptions), + ["Finished reading database from file:"] = new(@"Finished reading database from file: (?.*compat_database.dat).*\r?$", DefaultOptions), + ["Database file not found:"] = new(@"Database file not found: (?.*compat_database.dat).*\r?$", DefaultOptions), + ["Successfully installed PS3 firmware"] = new(@"(?Successfully installed PS3 firmware) version (?\d+\.\d+).*\r?$", DefaultOptions), + ["Title:"] = new(@"(?:LDR|SYS): Title: (?.*)?\r?$", DefaultOptions), + ["Serial:"] = new(@"Serial: (?[A-z]{4}\d{5})\r?$", DefaultOptions), + ["Category:"] = new(@"Category: (?.*)?\r?$", DefaultOptions), + ["LDR: Version:"] = new(@"Version: (?\S+) / (?\S+).*?\r?$", DefaultOptions), + ["SYS: Version:"] = new(@"Version: (APP_VER=)?(?\S+) (/ |VERSION=)(?\S+).*?\r?$", DefaultOptions), + ["LDR: Cache"] = new(@"Cache: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), + ["SYS: Cache"] = new(@"Cache: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), + ["LDR: Path"] = new(@"Path: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), + ["SYS: Path"] = new(@"Path: ((?\w:/)|(?/[^/])).*?\r?$", DefaultOptions), + ["LDR: Path:"] = new(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["SYS: Path:"] = new(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["custom config:"] = new(@"custom config: (?.*?)\r?$", DefaultOptions), + ["patch_log: Failed to load patch file"] = new(@"patch_log: Failed to load patch file (?\S*)\r?\n.* line (?\d+), column (?\d+): (?.*?)$", DefaultOptions), }, EndTrigger = new[] {"Used configuration:"}, }, new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["PPU Decoder:"] = new Regex(@"PPU Decoder: (?.*?)\r?$", DefaultOptions), - ["PPU Threads:"] = new Regex(@"PPU Threads: (?.*?)\r?$", DefaultOptions), - ["Use LLVM CPU:"] = new Regex("Use LLVM CPU: \\\"?(?.*?)\\\"?\r?$", DefaultOptions), - ["thread scheduler:"] = new Regex(@"scheduler: (?.*?)\r?$", DefaultOptions), - ["SPU Decoder:"] = new Regex(@"SPU Decoder: (?.*?)\r?$", DefaultOptions), - ["secondary cores:"] = new Regex(@"secondary cores: (?.*?)\r?$", DefaultOptions), - ["priority:"] = new Regex(@"priority: (?.*?)\r?$", DefaultOptions), - ["SPU Threads:"] = new Regex(@"SPU Threads: (?.*?)\r?$", DefaultOptions), - ["SPU delay penalty:"] = new Regex(@"SPU delay penalty: (?.*?)\r?$", DefaultOptions), - ["SPU loop detection:"] = new Regex(@"SPU loop detection: (?.*?)\r?$", DefaultOptions), - ["Max SPURS Threads:"] = new Regex(@"Max SPURS Threads: (?\d*?)\r?$", DefaultOptions), - ["SPU Block Size:"] = new Regex(@"SPU Block Size: (?.*?)\r?$", DefaultOptions), - ["Enable TSX:"] = new Regex(@"Enable TSX: (?.*?)\r?$", DefaultOptions), - ["Accurate xfloat:"] = new Regex(@"Accurate xfloat: (?.*?)\r?$", DefaultOptions), - ["Accurate GETLLAR:"] = new Regex(@"Accurate GETLLAR: (?.*?)\r?$", DefaultOptions), - ["Accurate PUTLLUC:"] = new Regex(@"Accurate PUTLLUC: (?.*?)\r?$", DefaultOptions), - ["Accurate RSX reservation access:"] = new Regex(@"Accurate RSX reservation access: (?.*?)\r?$", DefaultOptions), - ["Approximate xfloat:"] = new Regex(@"Approximate xfloat: (?.*?)\r?$", DefaultOptions), - ["Debug Console Mode:"] = new Regex(@"Debug Console Mode: (?.*?)\r?$", DefaultOptions), - ["Lib Loader:"] = new Regex(@"[Ll]oader: (?.*?)\r?$", DefaultOptions), - ["Hook static functions:"] = new Regex(@"Hook static functions: (?.*?)\r?$", DefaultOptions), - ["Load libraries:"] = new Regex(@"libraries:\r?\n(?(.*?(- .*?|\[\])\r?\n)+)", DefaultOptions), - ["HLE lwmutex:"] = new Regex(@"HLE lwmutex: (?.*?)\r?$", DefaultOptions), - ["Clocks scale:"] = new Regex(@"Clocks scale: (?.*?)\r?$", DefaultOptions), - ["Sleep Timers Accuracy:"] = new Regex(@"Sleep Timers Accuracy: (?.*?)\r?$", DefaultOptions), + ["PPU Decoder:"] = new(@"PPU Decoder: (?.*?)\r?$", DefaultOptions), + ["PPU Threads:"] = new(@"PPU Threads: (?.*?)\r?$", DefaultOptions), + ["Use LLVM CPU:"] = new("Use LLVM CPU: \\\"?(?.*?)\\\"?\r?$", DefaultOptions), + ["thread scheduler:"] = new(@"scheduler: (?.*?)\r?$", DefaultOptions), + ["SPU Decoder:"] = new(@"SPU Decoder: (?.*?)\r?$", DefaultOptions), + ["secondary cores:"] = new(@"secondary cores: (?.*?)\r?$", DefaultOptions), + ["priority:"] = new(@"priority: (?.*?)\r?$", DefaultOptions), + ["SPU Threads:"] = new(@"SPU Threads: (?.*?)\r?$", DefaultOptions), + ["SPU delay penalty:"] = new(@"SPU delay penalty: (?.*?)\r?$", DefaultOptions), + ["SPU loop detection:"] = new(@"SPU loop detection: (?.*?)\r?$", DefaultOptions), + ["Max SPURS Threads:"] = new(@"Max SPURS Threads: (?\d*?)\r?$", DefaultOptions), + ["SPU Block Size:"] = new(@"SPU Block Size: (?.*?)\r?$", DefaultOptions), + ["Enable TSX:"] = new(@"Enable TSX: (?.*?)\r?$", DefaultOptions), + ["Accurate xfloat:"] = new(@"Accurate xfloat: (?.*?)\r?$", DefaultOptions), + ["Accurate GETLLAR:"] = new(@"Accurate GETLLAR: (?.*?)\r?$", DefaultOptions), + ["Accurate PUTLLUC:"] = new(@"Accurate PUTLLUC: (?.*?)\r?$", DefaultOptions), + ["Accurate RSX reservation access:"] = new(@"Accurate RSX reservation access: (?.*?)\r?$", DefaultOptions), + ["Approximate xfloat:"] = new(@"Approximate xfloat: (?.*?)\r?$", DefaultOptions), + ["Debug Console Mode:"] = new(@"Debug Console Mode: (?.*?)\r?$", DefaultOptions), + ["Lib Loader:"] = new(@"[Ll]oader: (?.*?)\r?$", DefaultOptions), + ["Hook static functions:"] = new(@"Hook static functions: (?.*?)\r?$", DefaultOptions), + ["Load libraries:"] = new(@"libraries:\r?\n(?(.*?(- .*?|\[\])\r?\n)+)", DefaultOptions), + ["HLE lwmutex:"] = new(@"HLE lwmutex: (?.*?)\r?$", DefaultOptions), + ["Clocks scale:"] = new(@"Clocks scale: (?.*?)\r?$", DefaultOptions), + ["Sleep Timers Accuracy:"] = new(@"Sleep Timers Accuracy: (?.*?)\r?$", DefaultOptions), }, EndTrigger = new[] {"VFS:"}, }, new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["Enable /host_root/:"] = new Regex(@"Enable /host_root/: (?.*?)\r?$", DefaultOptions), + ["Enable /host_root/:"] = new(@"Enable /host_root/: (?.*?)\r?$", DefaultOptions), }, EndTrigger = new[] {"Video:"}, }, new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["Renderer:"] = new Regex("Renderer: (?.*?)\r?$", DefaultOptions), - ["Resolution:"] = new Regex("Resolution: (?.*?)\r?$", DefaultOptions), - ["Aspect ratio:"] = new Regex("Aspect ratio: (?.*?)\r?$", DefaultOptions), - ["Frame limit:"] = new Regex("Frame limit: (?.*?)\r?$", DefaultOptions), - ["MSAA:"] = new Regex("MSAA: (?.*?)\r?$", DefaultOptions), - ["Write Color Buffers:"] = new Regex("Write Color Buffers: (?.*?)\r?$", DefaultOptions), - ["Write Depth Buffer:"] = new Regex("Write Depth Buffer: (?.*?)\r?$", DefaultOptions), - ["Read Color Buffers:"] = new Regex("Read Color Buffers: (?.*?)\r?$", DefaultOptions), - ["Read Depth Buffer:"] = new Regex("Read Depth Buffer: (?.*?)\r?$", DefaultOptions), - ["VSync:"] = new Regex("VSync: (?.*?)\r?$", DefaultOptions), - ["GPU texture scaling:"] = new Regex("Use GPU texture scaling: (?.*?)\r?$", DefaultOptions), - ["Stretch To Display Area:"] = new Regex("Stretch To Display Area: (?.*?)\r?$", DefaultOptions), - ["Strict Rendering Mode:"] = new Regex("Strict Rendering Mode: (?.*?)\r?$", DefaultOptions), - ["Occlusion Queries:"] = new Regex("Occlusion Queries: (?.*?)\r?$", DefaultOptions), - ["Vertex Cache:"] = new Regex("Disable Vertex Cache: (?.*?)\r?$", DefaultOptions), - ["Frame Skip:"] = new Regex("Enable Frame Skip: (?.*?)\r?$", DefaultOptions), - ["Blit:"] = new Regex("Blit: (?.*?)\r?$", DefaultOptions), - ["Disable Asynchronous Shader Compiler:"] = new Regex("Disable Asynchronous Shader Compiler: (?.*?)\r?$", DefaultOptions), - ["Shader Mode:"] = new Regex("Shader Mode: (?.*?)\r?$", DefaultOptions), - ["Disable native float16 support:"] = new Regex("Disable native float16 support: (?.*?)\r?$", DefaultOptions), - ["Multithreaded RSX:"] = new Regex("Multithreaded RSX: (?.*?)\r?$", DefaultOptions), - ["Relaxed ZCULL Sync:"] = new Regex("Relaxed ZCULL Sync: (?.*?)\r?$", DefaultOptions), - ["Resolution Scale:"] = new Regex("Resolution Scale: (?.*?)\r?$", DefaultOptions), - ["Anisotropic Filter"] = new Regex("Anisotropic Filter Override: (?.*?)\r?$", DefaultOptions), - ["Scalable Dimension:"] = new Regex("Minimum Scalable Dimension: (?.*?)\r?$", DefaultOptions), - ["Driver Recovery Timeout:"] = new Regex("Driver Recovery Timeout: (?.*?)\r?$", DefaultOptions), - ["Driver Wake-Up Delay:"] = new Regex("Driver Wake-Up Delay: (?.*?)\r?$", DefaultOptions), - ["Vblank Rate:"] = new Regex("Vblank Rate: (?.*?)\r?$", DefaultOptions), - ["12:"] = new Regex(@"(D3D12|DirectX 12):\s*\r?\n\s*Adapter: (?.*?)\r?$", DefaultOptions), - ["Vulkan:"] = new Regex(@"Vulkan:\s*\r?\n\s*Adapter: (?.*?)\r?$", DefaultOptions), - ["Force FIFO present mode:"] = new Regex(@"Force FIFO present mode: (?.*?)\r?$", DefaultOptions), + ["Renderer:"] = new("Renderer: (?.*?)\r?$", DefaultOptions), + ["Resolution:"] = new("Resolution: (?.*?)\r?$", DefaultOptions), + ["Aspect ratio:"] = new("Aspect ratio: (?.*?)\r?$", DefaultOptions), + ["Frame limit:"] = new("Frame limit: (?.*?)\r?$", DefaultOptions), + ["MSAA:"] = new("MSAA: (?.*?)\r?$", DefaultOptions), + ["Write Color Buffers:"] = new("Write Color Buffers: (?.*?)\r?$", DefaultOptions), + ["Write Depth Buffer:"] = new("Write Depth Buffer: (?.*?)\r?$", DefaultOptions), + ["Read Color Buffers:"] = new("Read Color Buffers: (?.*?)\r?$", DefaultOptions), + ["Read Depth Buffer:"] = new("Read Depth Buffer: (?.*?)\r?$", DefaultOptions), + ["VSync:"] = new("VSync: (?.*?)\r?$", DefaultOptions), + ["GPU texture scaling:"] = new("Use GPU texture scaling: (?.*?)\r?$", DefaultOptions), + ["Stretch To Display Area:"] = new("Stretch To Display Area: (?.*?)\r?$", DefaultOptions), + ["Strict Rendering Mode:"] = new("Strict Rendering Mode: (?.*?)\r?$", DefaultOptions), + ["Occlusion Queries:"] = new("Occlusion Queries: (?.*?)\r?$", DefaultOptions), + ["Vertex Cache:"] = new("Disable Vertex Cache: (?.*?)\r?$", DefaultOptions), + ["Frame Skip:"] = new("Enable Frame Skip: (?.*?)\r?$", DefaultOptions), + ["Blit:"] = new("Blit: (?.*?)\r?$", DefaultOptions), + ["Disable Asynchronous Shader Compiler:"] = new("Disable Asynchronous Shader Compiler: (?.*?)\r?$", DefaultOptions), + ["Shader Mode:"] = new("Shader Mode: (?.*?)\r?$", DefaultOptions), + ["Disable native float16 support:"] = new("Disable native float16 support: (?.*?)\r?$", DefaultOptions), + ["Multithreaded RSX:"] = new("Multithreaded RSX: (?.*?)\r?$", DefaultOptions), + ["Relaxed ZCULL Sync:"] = new("Relaxed ZCULL Sync: (?.*?)\r?$", DefaultOptions), + ["Resolution Scale:"] = new("Resolution Scale: (?.*?)\r?$", DefaultOptions), + ["Anisotropic Filter"] = new("Anisotropic Filter Override: (?.*?)\r?$", DefaultOptions), + ["Scalable Dimension:"] = new("Minimum Scalable Dimension: (?.*?)\r?$", DefaultOptions), + ["Driver Recovery Timeout:"] = new("Driver Recovery Timeout: (?.*?)\r?$", DefaultOptions), + ["Driver Wake-Up Delay:"] = new("Driver Wake-Up Delay: (?.*?)\r?$", DefaultOptions), + ["Vblank Rate:"] = new("Vblank Rate: (?.*?)\r?$", DefaultOptions), + ["12:"] = new(@"(D3D12|DirectX 12):\s*\r?\n\s*Adapter: (?.*?)\r?$", DefaultOptions), + ["Vulkan:"] = new(@"Vulkan:\s*\r?\n\s*Adapter: (?.*?)\r?$", DefaultOptions), + ["Force FIFO present mode:"] = new(@"Force FIFO present mode: (?.*?)\r?$", DefaultOptions), }, EndTrigger = new[] {"Audio:"}, }, new LogSection // Audio, Input/Output, System, Net, Miscellaneous { - Extractors = new Dictionary + Extractors = new() { - ["Renderer:"] = new Regex("Renderer: (?.*?)\r?$", DefaultOptions), - ["Downmix to Stereo:"] = new Regex("Downmix to Stereo: (?.*?)\r?$", DefaultOptions), - ["Master Volume:"] = new Regex("Master Volume: (?.*?)\r?$", DefaultOptions), - ["Enable Buffering:"] = new Regex("Enable Buffering: (?.*?)\r?$", DefaultOptions), - ["Desired Audio Buffer Duration:"] = new Regex("Desired Audio Buffer Duration: (?.*?)\r?$", DefaultOptions), - ["Enable Time Stretching:"] = new Regex("Enable Time Stretching: (?.*?)\r?$", DefaultOptions), + ["Renderer:"] = new("Renderer: (?.*?)\r?$", DefaultOptions), + ["Downmix to Stereo:"] = new("Downmix to Stereo: (?.*?)\r?$", DefaultOptions), + ["Master Volume:"] = new("Master Volume: (?.*?)\r?$", DefaultOptions), + ["Enable Buffering:"] = new("Enable Buffering: (?.*?)\r?$", DefaultOptions), + ["Desired Audio Buffer Duration:"] = new("Desired Audio Buffer Duration: (?.*?)\r?$", DefaultOptions), + ["Enable Time Stretching:"] = new("Enable Time Stretching: (?.*?)\r?$", DefaultOptions), - ["Pad:"] = new Regex("Pad: (?.*?)\r?$", DefaultOptions), + ["Pad:"] = new("Pad: (?.*?)\r?$", DefaultOptions), - ["Automatically start games after boot:"] = new Regex("Automatically start games after boot: (?.*?)\r?$", DefaultOptions), - ["Always start after boot:"] = new Regex("Always start after boot: (?.*?)\r?$", DefaultOptions), - ["Use native user interface:"] = new Regex("Use native user interface: (?.*?)\r?$", DefaultOptions), - ["Silence All Logs:"] = new Regex("Silence All Logs: (?.*?)\r?$", DefaultOptions), + ["Automatically start games after boot:"] = new("Automatically start games after boot: (?.*?)\r?$", DefaultOptions), + ["Always start after boot:"] = new("Always start after boot: (?.*?)\r?$", DefaultOptions), + ["Use native user interface:"] = new("Use native user interface: (?.*?)\r?$", DefaultOptions), + ["Silence All Logs:"] = new("Silence All Logs: (?.*?)\r?$", DefaultOptions), }, EndTrigger = new[] {"Log:"}, }, new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["Log:"] = new Regex(@"Log:\s*\r?\n?\s*(\{(?.*?)\}|(?(\s+\w+\:\s*\w+\r?\n)+))\r?$", DefaultOptions), + ["Log:"] = new(@"Log:\s*\r?\n?\s*(\{(?.*?)\}|(?(\s+\w+\:\s*\w+\r?\n)+))\r?$", DefaultOptions), }, EndTrigger = new[] {"·"}, OnSectionEnd = MarkAsComplete, }, new LogSection { - Extractors = new Dictionary + Extractors = new() { - ["LDR: Game:"] = new Regex(@"Game: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["LDR: Disc"] = new Regex(@"Disc( path)?: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["LDR: Path:"] = new Regex(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["LDR: Boot path:"] = new Regex(@"Boot path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["SYS: Game:"] = new Regex(@"Game: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["SYS: Path:"] = new Regex(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["SYS: Boot path:"] = new Regex(@"Boot path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), - ["Elf path:"] = new Regex(@"Elf path: (?/host_root/)?(?(?/dev_hdd0/game/(?[^/\r\n]+)/USRDIR/EBOOT\.BIN|.*?))\r?$", DefaultOptions), - ["Invalid or unsupported file format:"] = new Regex(@"Invalid or unsupported file format: (?.*?)\r?$", DefaultOptions), - ["SELF:"] = new Regex(@"(?Failed to decrypt)? SELF: (?Failed to (decrypt|load SELF))?.*\r?$", DefaultOptions), - ["SYS: Version:"] = new Regex(@"Version: (APP_VER=)?(?\S+) (/ |VERSION=)(?\S+).*?\r?$", DefaultOptions), - ["sceNp: npDrmIsAvailable(): Failed to verify"] = new Regex(@"Failed to verify (?(sce|npd)) file.*\r?$", DefaultOptions), - ["{rsx::thread} RSX: 4"] = new Regex(@"RSX:(\d|\.|\s|\w|-)* (?(\d+\.)*\d+)\r?\n[^\n]*?" + - @"RSX: [^\n]+\r?\n[^\n]*?" + - @"RSX: (?.*?)\r?\n[^\n]*?" + - @"RSX: Supported texel buffer size", DefaultOptions), - ["GL RENDERER:"] = new Regex(@"GL RENDERER: (?.*?)\r?$", DefaultOptions), - ["GL VERSION:"] = new Regex(@"GL VERSION: (?(\d|\.)+)(\d|\.|\s|\w|-)*?( (?(\d+\.)*\d+))?\r?$", DefaultOptions), - ["GLSL VERSION:"] = new Regex(@"GLSL VERSION: (?(\d|\.)+).*?\r?$", DefaultOptions), - ["texel buffer size reported:"] = new Regex(@"RSX: Supported texel buffer size reported: (?\d*?) bytes", DefaultOptions), - ["Physical device in"] = new Regex(@"Physical device ini?tialized\. GPU=(?.+), driver=(?-?\d+)\r?$", DefaultOptions), - ["Found vulkan-compatible GPU:"] = new Regex(@"Found vulkan-compatible GPU: (?.+)\r?$", DefaultOptions), - ["Renderer initialized on device"] = new Regex(@"Renderer initialized on device '(?.+)'\r?$", DefaultOptions), - ["RSX: Failed to compile shader"] = new Regex(@"RSX: Failed to compile shader: ERROR: (?.+?)\r?$", DefaultOptions), - ["RSX: Compilation failed"] = new Regex(@"RSX: Compilation failed: ERROR: (?.+?)\r?$", DefaultOptions), - ["RSX: Unsupported device"] = new Regex(@"RSX: Unsupported device: (?.+)\..+?\r?$", DefaultOptions), - ["RSX: Your GPU does not support"] = new Regex(@"RSX: Your GPU does not support (?.+)\..+?\r?$", DefaultOptions), - ["RSX: GPU/driver lacks support"] = new Regex(@"RSX: GPU/driver lacks support for (?.+)\..+?\r?$", DefaultOptions), - ["RSX: Swapchain:"] = new Regex(@"RSX: Swapchain: present mode (?\d+?) in use.+?\r?$", DefaultOptions), - ["F "] = new Regex(@"F \d+:\d+:\d+\.\d+ (({(?[^}]+)} )?(\w+:\s*|(\w+:\s*)?(class [^\r\n]+ thrown: ))\r?\n?)(?.*?)(\r?\n)(\r?\n|\xC2\xB7)", DefaultSingleLineOptions), - ["Failed to load RAP file:"] = new Regex(@"Failed to load RAP file: (?.*?\.rap).*\r?$", DefaultOptions), - ["Rap file not found:"] = new Regex(@"Rap file not found: (\xE2\x80\x9C)?(?.*?)(\xE2\x80\x9D)?\r?$", DefaultOptions), - ["Pad handler expected but none initialized"] = new Regex(@"(?Pad handler expected but none initialized).*?\r?$", DefaultOptions), - ["Failed to bind device"] = new Regex(@"Failed to bind device (?.+) to handler (?.+).*\r?$", DefaultOptions), - ["Input:"] = new Regex(@"Input: (?.*?) device .+ connected\r?$", DefaultOptions), - ["XAudio2Thread"] = new Regex(@"XAudio2Thread\s*: (?.+failed\s*\((?0x.+)\).*)\r?$", DefaultOptions), - ["cellAudio Thread"] = new Regex(@"XAudio2Backend\s*: (?.+failed\s*\((?0x.+)\).*)\r?$", DefaultOptions), - ["using a Null renderer instead"] = new Regex(@"Audio renderer (?.+) could not be initialized\r?$", DefaultOptions), - ["PPU executable hash:"] = new Regex(@"PPU executable hash: PPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), - ["OVL executable hash:"] = new Regex(@"OVL executable hash: OVL-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), - ["SPU executable hash:"] = new Regex(@"SPU executable hash: SPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), - [": Applied patch"] = new Regex(@"Applied patch \(hash='(?:\w{3}-[0-9a-f]+)', description='(?.+?)', author='(?:.+?)', patch_version='(?:.+?)', file_version='(?:.+?)'\) \(<- (?:[1-9]\d*)\).*\r?$", DefaultOptions), - ["Loaded SPU image:"] = new Regex(@"Loaded SPU image: SPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), - ["'sys_fs_stat' failed"] = new Regex(@"'sys_fs_stat' failed (?!with 0x8001002c).+\xE2\x80\x9C(/dev_bdvd/(?.+)|/dev_hdd0/game/NP\w+/(?.+))\xE2\x80\x9D.*?\r?$", DefaultOptions), - ["'sys_fs_open' failed"] = new Regex(@"'sys_fs_open' failed (?!with 0x8001002c).+\xE2\x80\x9C(/dev_bdvd/(?.+)|/dev_hdd0/game/NP\w+/(?.+))\xE2\x80\x9D.*?\r?$", DefaultOptions), - ["'sys_fs_opendir' failed"] = new Regex(@"'sys_fs_opendir' failed .+\xE2\x80\x9C/dev_bdvd/(?.+)\xE2\x80\x9D.*?\r?$", DefaultOptions), - ["EDAT: "] = new Regex(@"EDAT: Block at offset (?0x[0-9a-f]+) has invalid hash!.*?\r?$", DefaultOptions), - ["PS3 firmware is not installed"] = new Regex(@"(?PS3 firmware is not installed.+)\r?$", DefaultOptions), - ["do you have the PS3 firmware installed"] = new Regex(@"(?do you have the PS3 firmware installed.*)\r?$", DefaultOptions), - ["Unimplemented syscall"] = new Regex(@"U \d+:\d+:\d+\.\d+ ({(?.+?)} )?.*Unimplemented syscall (?.*)\r?$", DefaultOptions), - ["Could not enqueue"] = new Regex(@"cellAudio: Could not enqueue buffer onto audio backend(?.).*\r?$", DefaultOptions), - ["{PPU["] = new Regex(@"{PPU\[.+\]} (?[^ :]+)( TODO)?: (?!\xE2\x80\x9C)(?[^ :]+?)\(.*\r?$", DefaultOptions), - ["⁂"] = new Regex(@"\xE2\x81\x82 (?[^ :\[]+?) .*\r?$", DefaultOptions), - ["undub"] = new Regex(@"(\b|_)(?(undub|translation patch))(\b|_)", DefaultOptions | RegexOptions.IgnoreCase), + ["LDR: Game:"] = new(@"Game: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["LDR: Disc"] = new(@"Disc( path)?: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["LDR: Path:"] = new(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["LDR: Boot path:"] = new(@"Boot path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["SYS: Game:"] = new(@"Game: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["SYS: Path:"] = new(@"Path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["SYS: Boot path:"] = new(@"Boot path: (?.*(?/dev_hdd0/game/(?[^/\r\n]+)).*|.*)\r?$", DefaultOptions), + ["Elf path:"] = new(@"Elf path: (?/host_root/)?(?(?/dev_hdd0/game/(?[^/\r\n]+)/USRDIR/EBOOT\.BIN|.*?))\r?$", DefaultOptions), + ["Invalid or unsupported file format:"] = new(@"Invalid or unsupported file format: (?.*?)\r?$", DefaultOptions), + ["SELF:"] = new(@"(?Failed to decrypt)? SELF: (?Failed to (decrypt|load SELF))?.*\r?$", DefaultOptions), + ["SYS: Version:"] = new(@"Version: (APP_VER=)?(?\S+) (/ |VERSION=)(?\S+).*?\r?$", DefaultOptions), + ["sceNp: npDrmIsAvailable(): Failed to verify"] = new(@"Failed to verify (?(sce|npd)) file.*\r?$", DefaultOptions), + ["{rsx::thread} RSX: 4"] = new(@"RSX:(\d|\.|\s|\w|-)* (?(\d+\.)*\d+)\r?\n[^\n]*?" + + @"RSX: [^\n]+\r?\n[^\n]*?" + + @"RSX: (?.*?)\r?\n[^\n]*?" + + @"RSX: Supported texel buffer size", DefaultOptions), + ["GL RENDERER:"] = new(@"GL RENDERER: (?.*?)\r?$", DefaultOptions), + ["GL VERSION:"] = new(@"GL VERSION: (?(\d|\.)+)(\d|\.|\s|\w|-)*?( (?(\d+\.)*\d+))?\r?$", DefaultOptions), + ["GLSL VERSION:"] = new(@"GLSL VERSION: (?(\d|\.)+).*?\r?$", DefaultOptions), + ["texel buffer size reported:"] = new(@"RSX: Supported texel buffer size reported: (?\d*?) bytes", DefaultOptions), + ["Physical device in"] = new(@"Physical device ini?tialized\. GPU=(?.+), driver=(?-?\d+)\r?$", DefaultOptions), + ["Found vulkan-compatible GPU:"] = new(@"Found vulkan-compatible GPU: (?.+)\r?$", DefaultOptions), + ["Renderer initialized on device"] = new(@"Renderer initialized on device '(?.+)'\r?$", DefaultOptions), + ["RSX: Failed to compile shader"] = new(@"RSX: Failed to compile shader: ERROR: (?.+?)\r?$", DefaultOptions), + ["RSX: Compilation failed"] = new(@"RSX: Compilation failed: ERROR: (?.+?)\r?$", DefaultOptions), + ["RSX: Unsupported device"] = new(@"RSX: Unsupported device: (?.+)\..+?\r?$", DefaultOptions), + ["RSX: Your GPU does not support"] = new(@"RSX: Your GPU does not support (?.+)\..+?\r?$", DefaultOptions), + ["RSX: GPU/driver lacks support"] = new(@"RSX: GPU/driver lacks support for (?.+)\..+?\r?$", DefaultOptions), + ["RSX: Swapchain:"] = new(@"RSX: Swapchain: present mode (?\d+?) in use.+?\r?$", DefaultOptions), + ["F "] = new(@"F \d+:\d+:\d+\.\d+ (({(?[^}]+)} )?(\w+:\s*|(\w+:\s*)?(class [^\r\n]+ thrown: ))\r?\n?)(?.*?)(\r?\n)(\r?\n|\xC2\xB7)", DefaultSingleLineOptions), + ["Failed to load RAP file:"] = new(@"Failed to load RAP file: (?.*?\.rap).*\r?$", DefaultOptions), + ["Rap file not found:"] = new(@"Rap file not found: (\xE2\x80\x9C)?(?.*?)(\xE2\x80\x9D)?\r?$", DefaultOptions), + ["Pad handler expected but none initialized"] = new(@"(?Pad handler expected but none initialized).*?\r?$", DefaultOptions), + ["Failed to bind device"] = new(@"Failed to bind device (?.+) to handler (?.+).*\r?$", DefaultOptions), + ["Input:"] = new(@"Input: (?.*?) device .+ connected\r?$", DefaultOptions), + ["XAudio2Thread"] = new(@"XAudio2Thread\s*: (?.+failed\s*\((?0x.+)\).*)\r?$", DefaultOptions), + ["cellAudio Thread"] = new(@"XAudio2Backend\s*: (?.+failed\s*\((?0x.+)\).*)\r?$", DefaultOptions), + ["using a Null renderer instead"] = new(@"Audio renderer (?.+) could not be initialized\r?$", DefaultOptions), + ["PPU executable hash:"] = new(@"PPU executable hash: PPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), + ["OVL executable hash:"] = new(@"OVL executable hash: OVL-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), + ["SPU executable hash:"] = new(@"SPU executable hash: SPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), + [": Applied patch"] = new(@"Applied patch \(hash='(?:\w{3}-[0-9a-f]+)', description='(?.+?)', author='(?:.+?)', patch_version='(?:.+?)', file_version='(?:.+?)'\) \(<- (?:[1-9]\d*)\).*\r?$", DefaultOptions), + ["Loaded SPU image:"] = new(@"Loaded SPU image: SPU-(?\w+ \(<-\s*\d+\)).*?\r?$", DefaultOptions), + ["'sys_fs_stat' failed"] = new(@"'sys_fs_stat' failed (?!with 0x8001002c).+\xE2\x80\x9C(/dev_bdvd/(?.+)|/dev_hdd0/game/NP\w+/(?.+))\xE2\x80\x9D.*?\r?$", DefaultOptions), + ["'sys_fs_open' failed"] = new(@"'sys_fs_open' failed (?!with 0x8001002c).+\xE2\x80\x9C(/dev_bdvd/(?.+)|/dev_hdd0/game/NP\w+/(?.+))\xE2\x80\x9D.*?\r?$", DefaultOptions), + ["'sys_fs_opendir' failed"] = new(@"'sys_fs_opendir' failed .+\xE2\x80\x9C/dev_bdvd/(?.+)\xE2\x80\x9D.*?\r?$", DefaultOptions), + ["EDAT: "] = new(@"EDAT: Block at offset (?0x[0-9a-f]+) has invalid hash!.*?\r?$", DefaultOptions), + ["PS3 firmware is not installed"] = new(@"(?PS3 firmware is not installed.+)\r?$", DefaultOptions), + ["do you have the PS3 firmware installed"] = new(@"(?do you have the PS3 firmware installed.*)\r?$", DefaultOptions), + ["Unimplemented syscall"] = new(@"U \d+:\d+:\d+\.\d+ ({(?.+?)} )?.*Unimplemented syscall (?.*)\r?$", DefaultOptions), + ["Could not enqueue"] = new(@"cellAudio: Could not enqueue buffer onto audio backend(?.).*\r?$", DefaultOptions), + ["{PPU["] = new(@"{PPU\[.+\]} (?[^ :]+)( TODO)?: (?!\xE2\x80\x9C)(?[^ :]+?)\(.*\r?$", DefaultOptions), + ["⁂"] = new(@"\xE2\x81\x82 (?[^ :\[]+?) .*\r?$", DefaultOptions), + ["undub"] = new(@"(\b|_)(?(undub|translation patch))(\b|_)", DefaultOptions | RegexOptions.IgnoreCase), }, OnSectionEnd = MarkAsCompleteAndReset, EndTrigger = new[] { "Stopping emulator...", "All threads stopped...", "LDR: Booting from"}, } }; - private static readonly HashSet MultiValueItems = new HashSet + private static readonly HashSet MultiValueItems = new() { "pad_handler", "fatal_error_context", diff --git a/CompatBot/EventHandlers/LogParsing/LogParser.PipeReader.cs b/CompatBot/EventHandlers/LogParsing/LogParser.PipeReader.cs index 42d58a36..518c373e 100644 --- a/CompatBot/EventHandlers/LogParsing/LogParser.PipeReader.cs +++ b/CompatBot/EventHandlers/LogParsing/LogParser.PipeReader.cs @@ -14,7 +14,7 @@ namespace CompatBot.EventHandlers.LogParsing { private static readonly byte[] Bom = {0xEF, 0xBB, 0xBF}; - private static readonly PoorMansTaskScheduler TaskScheduler = new PoorMansTaskScheduler(); + private static readonly PoorMansTaskScheduler TaskScheduler = new(); public static async Task ReadPipeAsync(PipeReader reader, CancellationToken cancellationToken) { diff --git a/CompatBot/EventHandlers/LogParsing/POCOs/LogParseState.cs b/CompatBot/EventHandlers/LogParsing/POCOs/LogParseState.cs index a3c4fca3..5f4fba06 100644 --- a/CompatBot/EventHandlers/LogParsing/POCOs/LogParseState.cs +++ b/CompatBot/EventHandlers/LogParsing/POCOs/LogParseState.cs @@ -10,20 +10,20 @@ namespace CompatBot.EventHandlers.LogParsing.POCOs { public NameValueCollection? CompletedCollection; public NameUniqueObjectCollection? CompleteMultiValueCollection; - public NameValueCollection WipCollection = new NameValueCollection(); - public NameUniqueObjectCollection WipMultiValueCollection = new NameUniqueObjectCollection(); - public readonly Dictionary ValueHitStats = new Dictionary(); - public readonly Dictionary> Syscalls = new Dictionary>(); + public NameValueCollection WipCollection = new(); + public NameUniqueObjectCollection WipMultiValueCollection = new(); + public readonly Dictionary ValueHitStats = new(); + public readonly Dictionary> Syscalls = new(); public int Id = 0; public ErrorCode Error = ErrorCode.None; - public readonly Dictionary FilterTriggers = new Dictionary(); + public readonly Dictionary FilterTriggers = new(); public Piracystring? SelectedFilter; public string? SelectedFilterContext; public long ReadBytes; public long TotalBytes; public TimeSpan ParsingTime; #if DEBUG - public readonly Dictionary ExtractorHitStats = new Dictionary(); + public readonly Dictionary ExtractorHitStats = new(); #endif public enum ErrorCode diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/DropboxHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/DropboxHandler.cs index b8a8b0ca..acba879b 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/DropboxHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/DropboxHandler.cs @@ -16,7 +16,7 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers internal sealed class DropboxHandler : BaseSourceHandler { //https://www.dropbox.com/s/62ls9lw5i52fuib/RPCS3.log.gz?dl=0 - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)?(www\.)?dropbox\.com/s/(?[^/\s]+)/(?[^/\?\s])(/dl=[01])?)", DefaultOptions); + private static readonly Regex ExternalLink = new(@"(?(https?://)?(www\.)?dropbox\.com/s/(?[^/\s]+)/(?[^/\?\s])(/dl=[01])?)", DefaultOptions); public override async Task<(ISource? source, string? failReason)> FindHandlerAsync(DiscordMessage message, ICollection handlers) { diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GenericLinkHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GenericLinkHandler.cs index 153f129c..bc28db1f 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GenericLinkHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GenericLinkHandler.cs @@ -14,7 +14,7 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers { internal sealed class GenericLinkHandler : BaseSourceHandler { - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)?(github\.com/RPCS3/rpcs3|cdn\.discordapp\.com/attachments)/.*/(?[^/\?\s]+\.(gz|zip|rar|7z|log)))", DefaultOptions); + private static readonly Regex ExternalLink = new(@"(?(https?://)?(github\.com/RPCS3/rpcs3|cdn\.discordapp\.com/attachments)/.*/(?[^/\?\s]+\.(gz|zip|rar|7z|log)))", DefaultOptions); public override async Task<(ISource? source, string? failReason)> FindHandlerAsync(DiscordMessage message, ICollection handlers) { diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs index bb7286f6..eee8307c 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/GoogleDriveHandler.cs @@ -18,7 +18,7 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers { internal sealed class GoogleDriveHandler: BaseSourceHandler { - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)?drive\.google\.com/(open\?id=|file/d/)(?[^/>\s]+))", DefaultOptions); + private static readonly Regex ExternalLink = new(@"(?(https?://)?drive\.google\.com/(open\?id=|file/d/)(?[^/>\s]+))", DefaultOptions); private static readonly string[] Scopes = { DriveService.Scope.DriveReadonly }; private static readonly string ApplicationName = "RPCS3 Compatibility Bot 2.0"; diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/MegaHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/MegaHandler.cs index 7ab96b0b..54cb8945 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/MegaHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/MegaHandler.cs @@ -15,7 +15,7 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers { // mega.nz/#!8IJHBYyB!jw21m-GCs85uzj9E5XRysqyJCsNfZS0Zx4Eu9_zvuUM // mega.nz/file/8IJHBYyB#jw21m-GCs85uzj9E5XRysqyJCsNfZS0Zx4Eu9_zvuUM - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)?mega(\.co)?\.nz/(#(?[^/>\s]+)|file/(?[^/>\s]+)))", DefaultOptions); + private static readonly Regex ExternalLink = new(@"(?(https?://)?mega(\.co)?\.nz/(#(?[^/>\s]+)|file/(?[^/>\s]+)))", DefaultOptions); private static readonly IProgress doodad = new Progress(_ => { }); public override async Task<(ISource? source, string? failReason)> FindHandlerAsync(DiscordMessage message, ICollection handlers) diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/OneDriveSourceHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/OneDriveSourceHandler.cs index 6fa39b68..d2d7112a 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/OneDriveSourceHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/OneDriveSourceHandler.cs @@ -18,8 +18,8 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers { internal sealed class OneDriveSourceHandler : BaseSourceHandler { - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)?(1drv\.ms|onedrive\.live\.com)/[^>\s]+)", DefaultOptions); - private static readonly Client client = new Client(); + private static readonly Regex ExternalLink = new(@"(?(https?://)?(1drv\.ms|onedrive\.live\.com)/[^>\s]+)", DefaultOptions); + private static readonly Client client = new(); public async override Task<(ISource? source, string? failReason)> FindHandlerAsync(DiscordMessage message, ICollection handlers) { diff --git a/CompatBot/EventHandlers/LogParsing/SourceHandlers/PastebinHandler.cs b/CompatBot/EventHandlers/LogParsing/SourceHandlers/PastebinHandler.cs index 2f11ef9d..215400fb 100644 --- a/CompatBot/EventHandlers/LogParsing/SourceHandlers/PastebinHandler.cs +++ b/CompatBot/EventHandlers/LogParsing/SourceHandlers/PastebinHandler.cs @@ -13,7 +13,7 @@ namespace CompatBot.EventHandlers.LogParsing.SourceHandlers { internal sealed class PastebinHandler : BaseSourceHandler { - private static readonly Regex ExternalLink = new Regex(@"(?(https?://)pastebin.com/(raw/)?(?[^/>\s]+))", DefaultOptions); + private static readonly Regex ExternalLink = new(@"(?(https?://)pastebin.com/(raw/)?(?[^/>\s]+))", DefaultOptions); public override async Task<(ISource? source, string? failReason)> FindHandlerAsync(DiscordMessage message, ICollection handlers) { diff --git a/CompatBot/EventHandlers/LogParsingHandler.cs b/CompatBot/EventHandlers/LogParsingHandler.cs index dd18beff..bce0072f 100644 --- a/CompatBot/EventHandlers/LogParsingHandler.cs +++ b/CompatBot/EventHandlers/LogParsingHandler.cs @@ -47,7 +47,7 @@ namespace CompatBot.EventHandlers new PlainTextHandler(), }; - private static readonly SemaphoreSlim QueueLimiter = new SemaphoreSlim(Math.Max(1, Environment.ProcessorCount / 2), Math.Max(1, Environment.ProcessorCount / 2)); + private static readonly SemaphoreSlim QueueLimiter = new(Math.Max(1, Environment.ProcessorCount / 2), Math.Max(1, Environment.ProcessorCount / 2)); private delegate void OnLog(DiscordClient client, DiscordChannel channel, DiscordMessage message, DiscordMember? requester = null, bool checkExternalLinks = false, bool force = false); private static event OnLog OnNewLog; diff --git a/CompatBot/EventHandlers/MediaScreenshotMonitor.cs b/CompatBot/EventHandlers/MediaScreenshotMonitor.cs index 1c5c8309..b60772da 100644 --- a/CompatBot/EventHandlers/MediaScreenshotMonitor.cs +++ b/CompatBot/EventHandlers/MediaScreenshotMonitor.cs @@ -22,8 +22,8 @@ namespace CompatBot.EventHandlers internal sealed class MediaScreenshotMonitor { private readonly DiscordClient client; - private readonly ComputerVisionClient cvClient = new ComputerVisionClient(new ApiKeyServiceClientCredentials(Config.AzureComputerVisionKey)) {Endpoint = Config.AzureComputerVisionEndpoint}; - private readonly SemaphoreSlim workSemaphore = new SemaphoreSlim(0); + private readonly ComputerVisionClient cvClient = new(new ApiKeyServiceClientCredentials(Config.AzureComputerVisionKey)) {Endpoint = Config.AzureComputerVisionEndpoint}; + private readonly SemaphoreSlim workSemaphore = new(0); private readonly ConcurrentQueue<(MessageCreateEventArgs evt, Guid readOperationId)> workQueue = new ConcurrentQueue<(MessageCreateEventArgs args, Guid readOperationId)>(); public static int MaxQueueLength { get; private set; } = 0; diff --git a/CompatBot/EventHandlers/NewBuildsMonitor.cs b/CompatBot/EventHandlers/NewBuildsMonitor.cs index 04877b56..c0e05b73 100644 --- a/CompatBot/EventHandlers/NewBuildsMonitor.cs +++ b/CompatBot/EventHandlers/NewBuildsMonitor.cs @@ -13,11 +13,11 @@ namespace CompatBot.EventHandlers { internal static class NewBuildsMonitor { - private static readonly Regex BuildResult = new Regex(@"\[rpcs3:master\] \d+ new commit", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); + private static readonly Regex BuildResult = new(@"\[rpcs3:master\] \d+ new commit", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); private static readonly TimeSpan PassiveCheckInterval = TimeSpan.FromMinutes(20); private static readonly TimeSpan ActiveCheckInterval = TimeSpan.FromSeconds(20); private static readonly TimeSpan ActiveCheckResetThreshold = TimeSpan.FromMinutes(10); - private static readonly ConcurrentQueue<(DateTime start, DateTime end)> ExpectedNewBuildTimeFrames = new ConcurrentQueue<(DateTime start, DateTime end)>(); + private static readonly ConcurrentQueue<(DateTime start, DateTime end)> ExpectedNewBuildTimeFrames = new(); public static Task OnMessageCreated(DiscordClient _, MessageCreateEventArgs args) { diff --git a/CompatBot/EventHandlers/PostLogHelpHandler.cs b/CompatBot/EventHandlers/PostLogHelpHandler.cs index 5aa4e729..7922ca55 100644 --- a/CompatBot/EventHandlers/PostLogHelpHandler.cs +++ b/CompatBot/EventHandlers/PostLogHelpHandler.cs @@ -14,10 +14,10 @@ namespace CompatBot.EventHandlers internal static class PostLogHelpHandler { private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture; - private static readonly Regex UploadLogMention = new Regex(@"\b((?(vul[ck][ae]n(-?1)?))|(?(post|upload|send|give)(ing)?\s+((a|the|rpcs3('s)?|your|you're|ur|my|full|game)\s+)*\blogs?))\b", DefaultOptions); - private static readonly SemaphoreSlim TheDoor = new SemaphoreSlim(1, 1); + private static readonly Regex UploadLogMention = new(@"\b((?(vul[ck][ae]n(-?1)?))|(?(post|upload|send|give)(ing)?\s+((a|the|rpcs3('s)?|your|you're|ur|my|full|game)\s+)*\blogs?))\b", DefaultOptions); + private static readonly SemaphoreSlim TheDoor = new(1, 1); private static readonly TimeSpan ThrottlingThreshold = TimeSpan.FromSeconds(5); - private static readonly Dictionary DefaultExplanation = new Dictionary + private static readonly Dictionary DefaultExplanation = new() { ["log"] = new Explanation { Text = "To upload log, run the game, then completely close RPCS3, then drag and drop rpcs3.log.gz from the RPCS3 folder into Discord. The file may have a zip or rar icon." }, ["vulkan-1"] = new Explanation { Text = "Please remove all the traces of video drivers using DDU, and then reinstall the latest driver version for your GPU." }, diff --git a/CompatBot/EventHandlers/ProductCodeLookup.cs b/CompatBot/EventHandlers/ProductCodeLookup.cs index 3527e356..4053eed4 100644 --- a/CompatBot/EventHandlers/ProductCodeLookup.cs +++ b/CompatBot/EventHandlers/ProductCodeLookup.cs @@ -18,8 +18,8 @@ namespace CompatBot.EventHandlers internal static class ProductCodeLookup { // see http://www.psdevwiki.com/ps3/Productcode - public static readonly Regex ProductCode = new Regex(@"(?(?:[BPSUVX][CL]|P[ETU]|NP)[AEHJKPUIX][ABJKLMPQRS]|MRTC)[ \-]?(?\d{5})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Client CompatClient = new Client(); + public static readonly Regex ProductCode = new(@"(?(?:[BPSUVX][CL]|P[ETU]|NP)[AEHJKPUIX][ABJKLMPQRS]|MRTC)[ \-]?(?\d{5})", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Client CompatClient = new(); public static async Task OnMessageCreated(DiscordClient c, MessageCreateEventArgs args) { diff --git a/CompatBot/EventHandlers/Starbucks.cs b/CompatBot/EventHandlers/Starbucks.cs index abf53f8d..7ca1b520 100644 --- a/CompatBot/EventHandlers/Starbucks.cs +++ b/CompatBot/EventHandlers/Starbucks.cs @@ -13,7 +13,7 @@ namespace CompatBot.EventHandlers { internal static class Starbucks { - private static readonly Dictionary TextMap = new Dictionary + private static readonly Dictionary TextMap = new() { [DiscordEmoji.FromUnicode("Ⓜ")] = "M", [DiscordEmoji.FromUnicode("🅰")] = "A", diff --git a/CompatBot/EventHandlers/UsernameSpoofMonitor.cs b/CompatBot/EventHandlers/UsernameSpoofMonitor.cs index 27028eb3..72f9d646 100644 --- a/CompatBot/EventHandlers/UsernameSpoofMonitor.cs +++ b/CompatBot/EventHandlers/UsernameSpoofMonitor.cs @@ -16,9 +16,9 @@ namespace CompatBot.EventHandlers { internal static class UsernameSpoofMonitor { - private static readonly Dictionary UsernameMapping = new Dictionary(); - private static readonly SemaphoreSlim UsernameLock = new SemaphoreSlim(1, 1); - private static readonly MemoryCache SpoofingReportThrottlingCache = new MemoryCache(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); + private static readonly Dictionary UsernameMapping = new(); + private static readonly SemaphoreSlim UsernameLock = new(1, 1); + private static readonly MemoryCache SpoofingReportThrottlingCache = new(new MemoryCacheOptions{ ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); private static readonly TimeSpan SnoozeDuration = TimeSpan.FromHours(1); public static async Task OnUserUpdated(DiscordClient c, UserUpdateEventArgs args) diff --git a/CompatBot/EventHandlers/UsernameZalgoMonitor.cs b/CompatBot/EventHandlers/UsernameZalgoMonitor.cs index b277c15c..6b3266cd 100644 --- a/CompatBot/EventHandlers/UsernameZalgoMonitor.cs +++ b/CompatBot/EventHandlers/UsernameZalgoMonitor.cs @@ -13,7 +13,7 @@ namespace CompatBot.EventHandlers { public static class UsernameZalgoMonitor { - private static readonly HashSet OversizedChars = new HashSet + private static readonly HashSet OversizedChars = new() { '꧁', '꧂', '⎝', '⎠', '⧹', '⧸', '⎛', '⎞', }; diff --git a/CompatBot/Program.cs b/CompatBot/Program.cs index 77fa7de8..13e2242f 100644 --- a/CompatBot/Program.cs +++ b/CompatBot/Program.cs @@ -25,8 +25,8 @@ namespace CompatBot { internal static class Program { - private static readonly SemaphoreSlim InstanceCheck = new SemaphoreSlim(0, 1); - private static readonly SemaphoreSlim ShutdownCheck = new SemaphoreSlim(0, 1); + private static readonly SemaphoreSlim InstanceCheck = new(0, 1); + private static readonly SemaphoreSlim ShutdownCheck = new(0, 1); // pre-load the assembly so it won't fail after framework update while the process is still running private static readonly Assembly diagnosticsAssembly = Assembly.Load(typeof(Process).Assembly.GetName()); internal const ulong InvalidChannelId = 13; diff --git a/CompatBot/ThumbScrapper/GameTdbScraper.cs b/CompatBot/ThumbScrapper/GameTdbScraper.cs index 9dc94013..efaf29f6 100644 --- a/CompatBot/ThumbScrapper/GameTdbScraper.cs +++ b/CompatBot/ThumbScrapper/GameTdbScraper.cs @@ -20,8 +20,8 @@ namespace CompatBot.ThumbScrapper internal static class GameTdbScraper { private static readonly HttpClient HttpClient = HttpClientFactory.Create(new CompressionMessageHandler()); - private static readonly Uri TitleDownloadLink = new Uri("https://www.gametdb.com/ps3tdb.zip?LANG=EN"); - private static readonly Regex CoverArtLink = new Regex(@"(?https?://art\.gametdb\.com/ps3/cover(?!full)[/\w\d]+\.jpg(\?\d+)?)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ExplicitCapture); + private static readonly Uri TitleDownloadLink = new("https://www.gametdb.com/ps3tdb.zip?LANG=EN"); + private static readonly Regex CoverArtLink = new(@"(?https?://art\.gametdb\.com/ps3/cover(?!full)[/\w\d]+\.jpg(\?\d+)?)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ExplicitCapture); //private static readonly List PreferredOrder = new List{"coverHQ", "coverM", "cover"}; public static async Task RunAsync(CancellationToken cancellationToken) diff --git a/CompatBot/ThumbScrapper/PsnScraper.cs b/CompatBot/ThumbScrapper/PsnScraper.cs index ee217a1a..9f520a08 100644 --- a/CompatBot/ThumbScrapper/PsnScraper.cs +++ b/CompatBot/ThumbScrapper/PsnScraper.cs @@ -16,12 +16,12 @@ namespace CompatBot.ThumbScrapper { internal sealed class PsnScraper { - private static readonly PsnClient.Client Client = new PsnClient.Client(); - public static readonly Regex ContentIdMatcher = new Regex(@"(?(?(?\w\w)(?\d{4}))-(?(?\w{4})(?\d{5}))_(?\d\d)-(?