From 14b5bd66c059d0650a6548ae614b510758502d81 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Mon, 18 Aug 2025 23:56:49 -0700 Subject: [PATCH] Minor warnings/lints --- Craftimizer/ImGuiUtils.cs | 2 +- Craftimizer/Windows/MacroClipboard.cs | 2 +- Craftimizer/Windows/MacroEditor.cs | 12 +++++++++++- Craftimizer/Windows/MacroList.cs | 2 +- Craftimizer/Windows/RecipeNote.cs | 2 +- Craftimizer/Windows/Settings.cs | 3 ++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Craftimizer/ImGuiUtils.cs b/Craftimizer/ImGuiUtils.cs index 849147d..2e80df0 100644 --- a/Craftimizer/ImGuiUtils.cs +++ b/Craftimizer/ImGuiUtils.cs @@ -356,7 +356,7 @@ internal static class ImGuiUtils public SearchableComboData(IEnumerable items, T selectedItem, Func getString) { - this.items = items.ToImmutableArray(); + this.items = [.. items]; filteredItems = [selectedItem]; this.selectedItem = selectedItem; this.getString = getString; diff --git a/Craftimizer/Windows/MacroClipboard.cs b/Craftimizer/Windows/MacroClipboard.cs index 1177e7b..d585cae 100644 --- a/Craftimizer/Windows/MacroClipboard.cs +++ b/Craftimizer/Windows/MacroClipboard.cs @@ -19,7 +19,7 @@ public sealed class MacroClipboard : Window, IDisposable public MacroClipboard(IEnumerable macros) : base("Macro Clipboard", WindowFlags) { - Macros = new(macros); + Macros = [.. macros]; IsOpen = true; AllowPinning = false; diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 5e7a181..cd6b1ba 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -719,9 +719,19 @@ public sealed class MacroEditor : Window, IDisposable public bool Equals(RecipeWrapper other) => Recipe.RowId == other.Recipe.RowId; + + public override bool Equals(object? obj) + { + return obj is RecipeWrapper other && Equals(other); + } + + public override int GetHashCode() + { + return unchecked((int)Recipe.RowId); + } } - private readonly List searchableRecipes = LuminaSheets.RecipeSheet.Where(r => r.RecipeLevelTable.RowId != 0 && r.ItemResult.RowId != 0).Select(r => new RecipeWrapper(r)).ToList(); + private readonly List searchableRecipes = [.. LuminaSheets.RecipeSheet.Where(r => r.RecipeLevelTable.RowId != 0 && r.ItemResult.RowId != 0).Select(r => new RecipeWrapper(r))]; private bool DrawRecipeParams() { diff --git a/Craftimizer/Windows/MacroList.cs b/Craftimizer/Windows/MacroList.cs index 969fbbf..9d16d67 100644 --- a/Craftimizer/Windows/MacroList.cs +++ b/Craftimizer/Windows/MacroList.cs @@ -343,7 +343,7 @@ public sealed class MacroList : Window, IDisposable { if (string.IsNullOrWhiteSpace(searchText)) { - sortedMacros = new(Macros); + sortedMacros = [.. Macros]; isUnsorted = true; return; } diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 2782de5..e2625e9 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -1191,7 +1191,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable config = config.FilterSpecialistActions(); var mctsConfig = new MCTSConfig(config); var simulator = new SimulatorNoRandom(); - List macros = new(Service.Configuration.Macros); + List macros = [.. Service.Configuration.Macros]; token.ThrowIfCancellationRequested(); diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index 2db1688..30de21e 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -77,6 +77,7 @@ public sealed class Settings : Window, IDisposable { ImGui.SetNextItemWidth(OptionWidth); var text = value.ToString(); + ArgumentNullException.ThrowIfNull(text, nameof(value)); if (ImGui.InputText(label, ref text, 8, ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.CharsDecimal)) { if (T.TryParse(text, null, out var newValue)) @@ -791,7 +792,7 @@ public sealed class Settings : Window, IDisposable isDirty = false; var recipeData = Service.Plugin.GetDefaultStats().Recipe; - HashSet pool = new(actionPool); + HashSet pool = [.. actionPool]; var imageSize = ImGui.GetFrameHeight() * 2; var spacing = ImGui.GetStyle().ItemSpacing.Y;