diff --git a/src/SMAPI.ModBuildConfig/Framework/ContentPackFileManager.cs b/src/SMAPI.ModBuildConfig/Framework/ContentPackFileManager.cs index bb2c4f4b..4e222c77 100644 --- a/src/SMAPI.ModBuildConfig/Framework/ContentPackFileManager.cs +++ b/src/SMAPI.ModBuildConfig/Framework/ContentPackFileManager.cs @@ -39,7 +39,7 @@ internal class ContentPackFileManager : IModFileManager public ContentPackFileManager(string projectDir, string contentPackDir, string version, string[] ignoreFilePaths, Regex[] ignoreFilePatterns, bool validateManifest) { // get folders - DirectoryInfo projectDirInfo = new DirectoryInfo(Path.Combine(projectDir, contentPackDir)); + DirectoryInfo projectDirInfo = new(Path.Combine(projectDir, contentPackDir)); if (!projectDirInfo.Exists) throw GetError($"that folder doesn't exist at {projectDirInfo.FullName}"); diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index f37d9770..64df125b 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -251,7 +251,7 @@ internal class ItemRepository { try { - SearchableItem item = new SearchableItem(type, key, createItem); + SearchableItem item = new(type, key, createItem); item.Item.getDescription(); // force-load item data, so it crashes here if it's invalid if (item.Item.Name is null or "Error Item") diff --git a/src/SMAPI.Tests.ModApiProvider/Framework/SimpleApi.cs b/src/SMAPI.Tests.ModApiProvider/Framework/SimpleApi.cs index 2890f90f..d58a3d71 100644 --- a/src/SMAPI.Tests.ModApiProvider/Framework/SimpleApi.cs +++ b/src/SMAPI.Tests.ModApiProvider/Framework/SimpleApi.cs @@ -105,7 +105,7 @@ public class SimpleApi : BaseApi outReference = new PerScreen(() => inputNumber); outComplexType = new Dictionary> { - [inputNumber] = new PerScreen(() => inputNumber) + [inputNumber] = new(() => inputNumber) }; return true; diff --git a/src/SMAPI.Toolkit/Framework/Clients/CompatibilityRepo/ChangeDescriptor.cs b/src/SMAPI.Toolkit/Framework/Clients/CompatibilityRepo/ChangeDescriptor.cs index 5ec2146c..29daaf56 100644 --- a/src/SMAPI.Toolkit/Framework/Clients/CompatibilityRepo/ChangeDescriptor.cs +++ b/src/SMAPI.Toolkit/Framework/Clients/CompatibilityRepo/ChangeDescriptor.cs @@ -108,7 +108,7 @@ public class ChangeDescriptor // add values if (this.Add.Any()) { - HashSet curValues = new HashSet(values.Select(p => p.Trim()), StringComparer.OrdinalIgnoreCase); + HashSet curValues = new(values.Select(p => p.Trim()), StringComparer.OrdinalIgnoreCase); foreach (string add in this.Add) { if (!curValues.Contains(add)) @@ -126,7 +126,7 @@ public class ChangeDescriptor if (!this.HasChanges) return string.Empty; - List descriptors = new List(this.Add.Count + this.Remove.Count + this.Replace.Count); + List descriptors = new(this.Add.Count + this.Remove.Count + this.Replace.Count); foreach (string add in this.Add) descriptors.Add($"+{add}"); foreach (string remove in this.Remove) diff --git a/src/SMAPI.Toolkit/Framework/ManifestValidator.cs b/src/SMAPI.Toolkit/Framework/ManifestValidator.cs index b322afcd..2a98cef3 100644 --- a/src/SMAPI.Toolkit/Framework/ManifestValidator.cs +++ b/src/SMAPI.Toolkit/Framework/ManifestValidator.cs @@ -54,7 +54,7 @@ public static class ManifestValidator // validate required fields { - List missingFields = new List(3); + List missingFields = new(3); if (string.IsNullOrWhiteSpace(manifest.Name)) missingFields.Add(nameof(IManifest.Name)); diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs index e38f988f..306ed64c 100644 --- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs +++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs @@ -21,9 +21,9 @@ public class ModScanner /// A list of filesystem entry names to ignore when checking whether a folder should be treated as a mod. private readonly HashSet IgnoreFilesystemNames = [ - new Regex(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager - new Regex(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // macOS - new Regex(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) + new(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager + new(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // macOS + new(@"^(?:desktop\.ini|Thumbs\.db)$", RegexOptions.Compiled | RegexOptions.IgnoreCase) ]; /// A list of file extensions to ignore when searching for mod files. diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index ed32a170..7ca8f55f 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -95,7 +95,7 @@ internal class LogParserController : Controller // note: avoid this.Request.Form, which fails if any mod logged a null character. string? input; { - using StreamReader reader = new StreamReader(this.Request.Body); + using StreamReader reader = new(this.Request.Body); NameValueCollection parsed = HttpUtility.ParseQueryString(await reader.ReadToEndAsync()); input = parsed["input"]; if (string.IsNullOrWhiteSpace(input)) diff --git a/src/SMAPI/Framework/Input/SInputState.cs b/src/SMAPI/Framework/Input/SInputState.cs index fd5fd554..8c7b7812 100644 --- a/src/SMAPI/Framework/Input/SInputState.cs +++ b/src/SMAPI/Framework/Input/SInputState.cs @@ -74,7 +74,7 @@ internal sealed class SInputState : InputState var mouse = new MouseStateBuilder(base.GetMouseState()); Vector2 cursorAbsolutePos = new((mouse.X * zoomMultiplier) + Game1.viewport.X, (mouse.Y * zoomMultiplier) + Game1.viewport.Y); Vector2? playerTilePos = Context.IsPlayerFree ? Game1.player.Tile : null; - HashSet reallyDown = new HashSet(this.GetPressedButtons(keyboard, mouse, controller)); + HashSet reallyDown = new(this.GetPressedButtons(keyboard, mouse, controller)); // apply overrides bool hasOverrides = false; @@ -94,7 +94,7 @@ internal sealed class SInputState : InputState // get button states var pressedButtons = hasOverrides - ? new HashSet(this.GetPressedButtons(keyboard, mouse, controller)) + ? new(this.GetPressedButtons(keyboard, mouse, controller)) : reallyDown; var activeButtons = this.DeriveStates(this.ButtonStates, pressedButtons); diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/Internal/InventoryToNetObjectList.cs b/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/Internal/InventoryToNetObjectList.cs index a0d23b72..737c2553 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/Internal/InventoryToNetObjectList.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/Internal/InventoryToNetObjectList.cs @@ -12,7 +12,7 @@ internal class InventoryToNetObjectList : NetObjectList ** Fields *********/ /// A cached lookup of inventory wrappers. - private static readonly Dictionary CachedWrappers = new Dictionary(ReferenceEqualityComparer.Instance); + private static readonly Dictionary CachedWrappers = new(ReferenceEqualityComparer.Instance); /// The underlying inventory to track. private readonly Inventory Inventory; diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/NpcFacade.cs b/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/NpcFacade.cs index 8eff8979..88bed113 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/NpcFacade.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/NpcFacade.cs @@ -38,7 +38,7 @@ public abstract class NpcFacade : NPC, IRewriteFacade public static NPC Constructor(AnimatedSprite sprite, Vector2 position, string defaultMap, int facingDir, string name, Dictionary schedule, Texture2D portrait, bool eventActor, string? syncedPortraitPath = null) { - NPC npc = new NPC(sprite, position, defaultMap, facingDir, name, portrait, eventActor); + NPC npc = new(sprite, position, defaultMap, facingDir, name, portrait, eventActor); if (!string.IsNullOrWhiteSpace(syncedPortraitPath)) { diff --git a/src/SMAPI/Framework/ModLoading/TypeReferenceComparer.cs b/src/SMAPI/Framework/ModLoading/TypeReferenceComparer.cs index fd8d9348..db521561 100644 --- a/src/SMAPI/Framework/ModLoading/TypeReferenceComparer.cs +++ b/src/SMAPI/Framework/ModLoading/TypeReferenceComparer.cs @@ -110,7 +110,7 @@ internal class TypeReferenceComparer : IEqualityComparer { int openGenerics = 0; - Queue queue = new Queue(typeName); + Queue queue = new(typeName); string symbol = ""; while (queue.Any()) { diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index f7ea95d0..862e16e2 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -442,7 +442,7 @@ internal class SCore : IDisposable // apply load order customizations if (this.Settings.ModsToLoadEarly.Any() || this.Settings.ModsToLoadLate.Any()) { - HashSet installedIds = new HashSet(mods.Select(p => p.Manifest?.UniqueID).Where(p => p is not null)!, StringComparer.OrdinalIgnoreCase); + HashSet installedIds = new(mods.Select(p => p.Manifest?.UniqueID).Where(p => p is not null)!, StringComparer.OrdinalIgnoreCase); string[] missingEarlyMods = this.Settings.ModsToLoadEarly.Where(id => !installedIds.Contains(id)).OrderBy(p => p, StringComparer.OrdinalIgnoreCase).ToArray(); string[] missingLateMods = this.Settings.ModsToLoadLate.Where(id => !installedIds.Contains(id)).OrderBy(p => p, StringComparer.OrdinalIgnoreCase).ToArray(); diff --git a/src/SMAPI/Framework/SMultiplayer.cs b/src/SMAPI/Framework/SMultiplayer.cs index e537d194..f0b3a8e8 100644 --- a/src/SMAPI/Framework/SMultiplayer.cs +++ b/src/SMAPI/Framework/SMultiplayer.cs @@ -502,7 +502,7 @@ internal class SMultiplayer : Multiplayer } // get player IDs - HashSet playerIds = new HashSet(model.ToPlayerIds ?? this.GetKnownPlayerIds()); + HashSet playerIds = new(model.ToPlayerIds ?? this.GetKnownPlayerIds()); // notify local mods if (playerIds.Contains(Game1.player.UniqueMultiplayerID)) diff --git a/src/SMAPI/Framework/TemporaryHacks/MiniMonoModHotfix.cs b/src/SMAPI/Framework/TemporaryHacks/MiniMonoModHotfix.cs index 28cf81d6..e89eb3d7 100644 --- a/src/SMAPI/Framework/TemporaryHacks/MiniMonoModHotfix.cs +++ b/src/SMAPI/Framework/TemporaryHacks/MiniMonoModHotfix.cs @@ -187,7 +187,7 @@ static class MiniMonoModHotfix private static void _FixReflectionCacheOrder(Array orig) where T : MemberInfo { // Sort using a short-lived list. - List list = new List(orig.Length); + List list = new(orig.Length); for (int i = 0; i < orig.Length; i++) list.Add((T)orig.GetValue(i)!);