From bca9e599cc02edcc6e9bcfba2138d916ae6a3a79 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Jan 2022 17:27:42 -0500 Subject: remove unneeded dictionary patch The dictionary errors were improved in .NET 5, so they include the key automatically. --- src/SMAPI.Mods.ErrorHandler/ModEntry.cs | 1 - .../Patches/DictionaryPatcher.cs | 98 ---------------------- 2 files changed, 99 deletions(-) delete mode 100644 src/SMAPI.Mods.ErrorHandler/Patches/DictionaryPatcher.cs (limited to 'src/SMAPI.Mods.ErrorHandler') diff --git a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs index 067f6a8d..7286e316 100644 --- a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs +++ b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs @@ -30,7 +30,6 @@ namespace StardewModdingAPI.Mods.ErrorHandler // apply patches HarmonyPatcher.Apply(this.ModManifest.UniqueID, this.Monitor, new DialoguePatcher(monitorForGame, this.Helper.Reflection), - new DictionaryPatcher(this.Helper.Reflection), new EventPatcher(monitorForGame), new GameLocationPatcher(monitorForGame), new IClickableMenuPatcher(), diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/DictionaryPatcher.cs b/src/SMAPI.Mods.ErrorHandler/Patches/DictionaryPatcher.cs deleted file mode 100644 index 8ceafcc5..00000000 --- a/src/SMAPI.Mods.ErrorHandler/Patches/DictionaryPatcher.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using HarmonyLib; -using StardewModdingAPI.Internal.Patching; -using StardewValley.GameData; -using StardewValley.GameData.HomeRenovations; -using StardewValley.GameData.Movies; - -namespace StardewModdingAPI.Mods.ErrorHandler.Patches -{ - /// Harmony patches for which add the accessed key to exceptions. - /// Patch methods must be static for Harmony to work correctly. See the Harmony documentation before renaming patch arguments. - [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] - [SuppressMessage("ReSharper", "IdentifierTypo", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] - internal class DictionaryPatcher : BasePatcher - { - /********* - ** Fields - *********/ - /// Simplifies access to private code. - private static IReflectionHelper Reflection; - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// Simplifies access to private code. - public DictionaryPatcher(IReflectionHelper reflector) - { - DictionaryPatcher.Reflection = reflector; - } - - /// - public override void Apply(Harmony harmony, IMonitor monitor) - { - Type[] keyTypes = { typeof(int), typeof(string) }; - Type[] valueTypes = { typeof(int), typeof(string), typeof(HomeRenovation), typeof(MovieData), typeof(SpecialOrderData) }; - - foreach (Type keyType in keyTypes) - { - foreach (Type valueType in valueTypes) - { - Type dictionaryType = typeof(Dictionary<,>).MakeGenericType(keyType, valueType); - - harmony.Patch( - original: AccessTools.Method(dictionaryType, "get_Item") ?? throw new InvalidOperationException($"Can't find method {PatchHelper.GetMethodString(dictionaryType, "get_Item")} to patch."), - finalizer: this.GetHarmonyMethod(nameof(DictionaryPatcher.Finalize_GetItem)) - ); - - harmony.Patch( - original: AccessTools.Method(dictionaryType, "Add") ?? throw new InvalidOperationException($"Can't find method {PatchHelper.GetMethodString(dictionaryType, "Add")} to patch."), - finalizer: this.GetHarmonyMethod(nameof(DictionaryPatcher.Finalize_Add)) - ); - } - } - } - - - /********* - ** Private methods - *********/ - /// The method to call after the dictionary indexer throws an exception. - /// The dictionary key being fetched. - /// The exception thrown by the wrapped method, if any. - /// Returns the exception to throw, if any. - private static Exception Finalize_GetItem(object key, Exception __exception) - { - if (__exception is KeyNotFoundException) - DictionaryPatcher.AddKey(__exception, key); - - return __exception; - } - - /// The method to call after a dictionary insert throws an exception. - /// The dictionary key being inserted. - /// The exception thrown by the wrapped method, if any. - /// Returns the exception to throw, if any. - private static Exception Finalize_Add(object key, Exception __exception) - { - if (__exception is ArgumentException) - DictionaryPatcher.AddKey(__exception, key); - - return __exception; - } - - /// Add the dictionary key to an exception message. - /// The exception whose message to edit. - /// The dictionary key. - private static void AddKey(Exception exception, object key) - { - DictionaryPatcher.Reflection - .GetField(exception, "_message") - .SetValue($"{exception.Message}\nkey: '{key}'"); - } - } -} -- cgit From 4da9e954df3846d01aa0536f4e8143466a1d62f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 11 Feb 2022 00:49:49 -0500 Subject: use Array.Empty to avoid unneeded array allocations --- src/SMAPI.Internal/ExceptionHelper.cs | 2 +- src/SMAPI.Mods.ErrorHandler/ModEntry.cs | 2 +- src/SMAPI.Tests/Core/ModResolverTests.cs | 16 ++++++++-------- .../Framework/Clients/WebApi/ModEntryModel.cs | 4 +++- .../Framework/Clients/WebApi/ModExtendedMetadataModel.cs | 3 ++- .../Framework/Clients/WebApi/ModSearchEntryModel.cs | 4 +++- .../Framework/Clients/Wiki/ChangeDescriptor.cs | 2 +- src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs | 2 +- .../Framework/Clients/Wiki/WikiDataOverrideEntry.cs | 4 +++- src/SMAPI.Toolkit/Framework/ModData/ModDatabase.cs | 2 +- src/SMAPI.Toolkit/Serialization/Models/Manifest.cs | 7 ++++--- src/SMAPI.Web/Controllers/IndexController.cs | 2 +- src/SMAPI.Web/Controllers/ModsApiController.cs | 2 +- .../Framework/Caching/Wiki/WikiCacheMemoryRepository.cs | 2 +- src/SMAPI.Web/Framework/Clients/GenericModPage.cs | 3 ++- src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs | 2 +- .../ViewModels/JsonValidator/JsonValidatorModel.cs | 2 +- src/SMAPI.Web/Views/LogParser/Index.cshtml | 2 +- src/SMAPI.Web/Views/Mods/Index.cshtml | 2 +- src/SMAPI/Events/ButtonsChangedEventArgs.cs | 2 +- src/SMAPI/Framework/Events/ManagedEvent.cs | 2 +- src/SMAPI/Framework/Models/SConfig.cs | 4 ++-- src/SMAPI/Framework/SCore.cs | 6 +++--- .../FieldWatchers/ImmutableCollectionWatcher.cs | 5 +++-- src/SMAPI/Framework/StateTracking/LocationTracker.cs | 3 ++- .../Framework/StateTracking/Snapshots/PlayerSnapshot.cs | 2 +- src/SMAPI/Framework/TemporaryHacks/MiniMonoModHotfix.cs | 2 +- src/SMAPI/Metadata/CoreAssetPropagator.cs | 2 +- src/SMAPI/Utilities/Keybind.cs | 4 ++-- src/SMAPI/Utilities/KeybindList.cs | 4 ++-- 30 files changed, 56 insertions(+), 45 deletions(-) (limited to 'src/SMAPI.Mods.ErrorHandler') diff --git a/src/SMAPI.Internal/ExceptionHelper.cs b/src/SMAPI.Internal/ExceptionHelper.cs index 05b96c2e..03d48911 100644 --- a/src/SMAPI.Internal/ExceptionHelper.cs +++ b/src/SMAPI.Internal/ExceptionHelper.cs @@ -25,7 +25,7 @@ namespace StardewModdingAPI.Internal case ReflectionTypeLoadException ex: string summary = ex.ToString(); - foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0]) + foreach (Exception childEx in ex.LoaderExceptions ?? Array.Empty()) summary += $"\n\n{childEx?.GetLogSummary()}"; message = summary; break; diff --git a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs index 7286e316..2d6242cf 100644 --- a/src/SMAPI.Mods.ErrorHandler/ModEntry.cs +++ b/src/SMAPI.Mods.ErrorHandler/ModEntry.cs @@ -80,7 +80,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler MethodInfo getMonitorForGame = coreType.GetMethod("GetMonitorForGame") ?? throw new InvalidOperationException("Can't access the SMAPI's 'GetMonitorForGame' method. This mod may not work correctly."); - return (IMonitor)getMonitorForGame.Invoke(core, new object[0]) ?? this.Monitor; + return (IMonitor)getMonitorForGame.Invoke(core, Array.Empty()) ?? this.Monitor; } } } diff --git a/src/SMAPI.Tests/Core/ModResolverTests.cs b/src/SMAPI.Tests/Core/ModResolverTests.cs index da3446bb..1755f644 100644 --- a/src/SMAPI.Tests/Core/ModResolverTests.cs +++ b/src/SMAPI.Tests/Core/ModResolverTests.cs @@ -123,7 +123,7 @@ namespace SMAPI.Tests.Core [Test(Description = "Assert that validation doesn't fail if there are no mods installed.")] public void ValidateManifests_NoMods_DoesNothing() { - new ModResolver().ValidateManifests(new ModMetadata[0], apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null); + new ModResolver().ValidateManifests(Array.Empty(), apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null); } [Test(Description = "Assert that validation skips manifests that have already failed without calling any other properties.")] @@ -144,7 +144,7 @@ namespace SMAPI.Tests.Core public void ValidateManifests_ModStatus_AssumeBroken_Fails() { // arrange - Mock mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true); + Mock mock = this.GetMetadata("Mod A", Array.Empty(), allowStatusChange: true); this.SetupMetadataForValidation(mock, new ModDataRecordVersionedFields { Status = ModStatus.AssumeBroken @@ -161,7 +161,7 @@ namespace SMAPI.Tests.Core public void ValidateManifests_MinimumApiVersion_Fails() { // arrange - Mock mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true); + Mock mock = this.GetMetadata("Mod A", Array.Empty(), allowStatusChange: true); mock.Setup(p => p.Manifest).Returns(this.GetManifest(minimumApiVersion: "1.1")); this.SetupMetadataForValidation(mock); @@ -190,9 +190,9 @@ namespace SMAPI.Tests.Core public void ValidateManifests_DuplicateUniqueID_Fails() { // arrange - Mock modA = this.GetMetadata("Mod A", new string[0], allowStatusChange: true); + Mock modA = this.GetMetadata("Mod A", Array.Empty(), allowStatusChange: true); Mock modB = this.GetMetadata(this.GetManifest(id: "Mod A", name: "Mod B", version: "1.0"), allowStatusChange: true); - Mock modC = this.GetMetadata("Mod C", new string[0], allowStatusChange: false); + Mock modC = this.GetMetadata("Mod C", Array.Empty(), allowStatusChange: false); foreach (Mock mod in new[] { modA, modB, modC }) this.SetupMetadataForValidation(mod); @@ -236,7 +236,7 @@ namespace SMAPI.Tests.Core public void ProcessDependencies_NoMods_DoesNothing() { // act - IModMetadata[] mods = new ModResolver().ProcessDependencies(new IModMetadata[0], new ModDatabase()).ToArray(); + IModMetadata[] mods = new ModResolver().ProcessDependencies(Array.Empty(), new ModDatabase()).ToArray(); // assert Assert.AreEqual(0, mods.Length, 0, "Expected to get an empty list of mods."); @@ -490,8 +490,8 @@ namespace SMAPI.Tests.Core EntryDll = entryDll ?? $"{Sample.String()}.dll", ContentPackFor = contentPackForID != null ? new ManifestContentPackFor { UniqueID = contentPackForID } : null, MinimumApiVersion = minimumApiVersion != null ? new SemanticVersion(minimumApiVersion) : null, - Dependencies = dependencies ?? new IManifestDependency[0], - UpdateKeys = new string[0] + Dependencies = dependencies ?? Array.Empty(), + UpdateKeys = Array.Empty() }; } diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs index 2f58a3f1..0115fbf3 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs @@ -1,3 +1,5 @@ +using System; + namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Metadata about a mod. @@ -16,6 +18,6 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi public ModExtendedMetadataModel Metadata { get; set; } /// The errors that occurred while fetching update data. - public string[] Errors { get; set; } = new string[0]; + public string[] Errors { get; set; } = Array.Empty(); } } diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs index 5c2ce366..0fa4a74d 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; @@ -17,7 +18,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi ** Mod info ****/ /// The mod's unique ID. A mod may have multiple current IDs in rare cases (e.g. due to parallel releases or unofficial updates). - public string[] ID { get; set; } = new string[0]; + public string[] ID { get; set; } = Array.Empty(); /// The mod's display name. public string Name { get; set; } diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs index bf81e102..404d4618 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/ModSearchEntryModel.cs @@ -1,3 +1,5 @@ +using System; + namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Specifies the identifiers for a mod to match. @@ -37,7 +39,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { this.ID = id; this.InstalledVersion = installedVersion; - this.UpdateKeys = updateKeys ?? new string[0]; + this.UpdateKeys = updateKeys ?? Array.Empty(); } } } diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/ChangeDescriptor.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/ChangeDescriptor.cs index f1feb44b..2ed255c8 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/ChangeDescriptor.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/ChangeDescriptor.cs @@ -179,7 +179,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki errors = rawErrors.ToArray(); } else - errors = new string[0]; + errors = Array.Empty(); // build model return new ChangeDescriptor( diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs index f85e82e1..0f5a0ec3 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs @@ -239,7 +239,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki string raw = this.GetAttribute(element, name); return !string.IsNullOrWhiteSpace(raw) ? raw.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToArray() - : new string[0]; + : Array.Empty(); } /// Get an attribute value and parse it as an enum value. diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiDataOverrideEntry.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiDataOverrideEntry.cs index 0587e09d..03c0d214 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiDataOverrideEntry.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiDataOverrideEntry.cs @@ -1,3 +1,5 @@ +using System; + #nullable enable namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki @@ -9,7 +11,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki ** Accessors *********/ /// The unique mod IDs for the mods to override. - public string[] Ids { get; set; } = new string[0]; + public string[] Ids { get; set; } = Array.Empty(); /// Maps local versions to a semantic version for update checks. public ChangeDescriptor? ChangeLocalVersions { get; set; } diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDatabase.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDatabase.cs index a9da884a..5b7e2a02 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDatabase.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDatabase.cs @@ -22,7 +22,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData *********/ /// Construct an empty instance. public ModDatabase() - : this(new ModDataRecord[0], key => null) { } + : this(Array.Empty(), key => null) { } /// Construct an instance. /// The underlying mod data records indexed by default display name. diff --git a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs index 46b654a5..4ad97b6d 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; @@ -68,7 +69,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models this.Description = description; this.Version = version; this.UniqueID = uniqueID; - this.UpdateKeys = new string[0]; + this.UpdateKeys = Array.Empty(); this.ContentPackFor = new ManifestContentPackFor { UniqueID = contentPackFor }; } @@ -77,8 +78,8 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models [OnDeserialized] public void OnDeserialized(StreamingContext context) { - this.Dependencies ??= new IManifestDependency[0]; - this.UpdateKeys ??= new string[0]; + this.Dependencies ??= Array.Empty(); + this.UpdateKeys ??= Array.Empty(); } } } diff --git a/src/SMAPI.Web/Controllers/IndexController.cs b/src/SMAPI.Web/Controllers/IndexController.cs index f2f4c342..5097997c 100644 --- a/src/SMAPI.Web/Controllers/IndexController.cs +++ b/src/SMAPI.Web/Controllers/IndexController.cs @@ -96,7 +96,7 @@ namespace StardewModdingAPI.Web.Controllers { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(release.Body); - foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//*[@class='noinclude']")?.ToArray() ?? new HtmlNode[0]) + foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//*[@class='noinclude']")?.ToArray() ?? Array.Empty()) node.Remove(); release.Body = doc.DocumentNode.InnerHtml.Trim(); } diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 37d763cc..dfe2504b 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -79,7 +79,7 @@ namespace StardewModdingAPI.Web.Controllers public async Task> PostAsync([FromBody] ModSearchModel model, [FromRoute] string version) { if (model?.Mods == null) - return new ModEntryModel[0]; + return Array.Empty(); ModUpdateCheckConfig config = this.Config.Value; diff --git a/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs b/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs index 064a7c3c..d037a123 100644 --- a/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs +++ b/src/SMAPI.Web/Framework/Caching/Wiki/WikiCacheMemoryRepository.cs @@ -15,7 +15,7 @@ namespace StardewModdingAPI.Web.Framework.Caching.Wiki private Cached Metadata; /// The cached wiki data. - private Cached[] Mods = new Cached[0]; + private Cached[] Mods = Array.Empty>(); /********* diff --git a/src/SMAPI.Web/Framework/Clients/GenericModPage.cs b/src/SMAPI.Web/Framework/Clients/GenericModPage.cs index 622e6c56..a5f7c9b9 100644 --- a/src/SMAPI.Web/Framework/Clients/GenericModPage.cs +++ b/src/SMAPI.Web/Framework/Clients/GenericModPage.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using StardewModdingAPI.Toolkit.Framework.UpdateData; @@ -26,7 +27,7 @@ namespace StardewModdingAPI.Web.Framework.Clients public string Url { get; set; } /// The mod downloads. - public IModDownload[] Downloads { get; set; } = new IModDownload[0]; + public IModDownload[] Downloads { get; set; } = Array.Empty(); /// The mod availability status on the remote site. public RemoteModStatus Status { get; set; } = RemoteModStatus.Ok; diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs index 87b20eb0..693a16ec 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs @@ -42,7 +42,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models public DateTimeOffset Timestamp { get; set; } /// Metadata about installed mods and content packs. - public LogModInfo[] Mods { get; set; } = new LogModInfo[0]; + public LogModInfo[] Mods { get; set; } = Array.Empty(); /// The log messages. public LogMessage[] Messages { get; set; } diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs index 0ea69911..e659b389 100644 --- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs +++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator public string Content { get; set; } /// The schema validation errors, if any. - public JsonValidatorErrorModel[] Errors { get; set; } = new JsonValidatorErrorModel[0]; + public JsonValidatorErrorModel[] Errors { get; set; } = Array.Empty(); /// A non-blocking warning while uploading the file. public string UploadWarning { get; set; } diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 91fc3535..993e7244 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -15,7 +15,7 @@ string curPageUrl = this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID }, absoluteUrl: true); - ISet screenIds = new HashSet(Model.ParsedLog?.Messages?.Select(p => p.ScreenId) ?? new int[0]); + ISet screenIds = new HashSet(Model.ParsedLog?.Messages?.Select(p => p.ScreenId) ?? Array.Empty()); } @section Head { diff --git a/src/SMAPI.Web/Views/Mods/Index.cshtml b/src/SMAPI.Web/Views/Mods/Index.cshtml index 8a764803..416468e4 100644 --- a/src/SMAPI.Web/Views/Mods/Index.cshtml +++ b/src/SMAPI.Web/Views/Mods/Index.cshtml @@ -19,7 +19,7 @@