From 75502e7ffb5be5af8c23d52ad446b10b0e8efc1d Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 6 Jun 2024 14:33:08 +1000 Subject: [PATCH] Unimplement `IEnumerable` on `RecentFiles` and `PathEntryCollection` --- src/BizHawk.Client.Common/RecentFiles.cs | 5 +---- src/BizHawk.Client.Common/config/PathEntryCollection.cs | 7 +------ src/BizHawk.Client.EmuHawk/config/PathConfig.cs | 6 +++--- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/BizHawk.Client.Common/RecentFiles.cs b/src/BizHawk.Client.Common/RecentFiles.cs index 041cd97177..27374c7347 100644 --- a/src/BizHawk.Client.Common/RecentFiles.cs +++ b/src/BizHawk.Client.Common/RecentFiles.cs @@ -1,13 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; namespace BizHawk.Client.Common { - [JsonObject] - public class RecentFiles : IEnumerable + public class RecentFiles { // ReSharper disable once FieldCanBeMadeReadOnly.Local private List recentlist; @@ -43,7 +41,6 @@ namespace BizHawk.Client.Common public string this[int index] => recentlist.Any() ? recentlist[index] : ""; public IEnumerator GetEnumerator() => recentlist.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public void Clear() { diff --git a/src/BizHawk.Client.Common/config/PathEntryCollection.cs b/src/BizHawk.Client.Common/config/PathEntryCollection.cs index c2dec1d2c7..524462c497 100644 --- a/src/BizHawk.Client.Common/config/PathEntryCollection.cs +++ b/src/BizHawk.Client.Common/config/PathEntryCollection.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -12,8 +11,7 @@ using Newtonsoft.Json; namespace BizHawk.Client.Common { - [JsonObject] - public class PathEntryCollection : IEnumerable + public class PathEntryCollection { private static readonly string COMBINED_SYSIDS_GB = string.Join("_", VSystemID.Raw.GB, VSystemID.Raw.GBC, VSystemID.Raw.SGB); @@ -120,9 +118,6 @@ namespace BizHawk.Client.Common public bool UseRecentForRoms { get; set; } public string LastRomPath { get; set; } = "."; - public IEnumerator GetEnumerator() => Paths.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public PathEntry this[string system, string type] => Paths.Find(p => p.IsSystem(system) && p.Type == type) ?? TryGetDebugPath(system, type); diff --git a/src/BizHawk.Client.EmuHawk/config/PathConfig.cs b/src/BizHawk.Client.EmuHawk/config/PathConfig.cs index 5681de6602..1f6c6d4822 100644 --- a/src/BizHawk.Client.EmuHawk/config/PathConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/PathConfig.cs @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk { RecentForROMs.Checked = _pathEntries.UseRecentForRoms; - DoTabs(_pathEntries.ToList(), _sysID); + DoTabs(_pathEntries.Paths, focusTabOfSystem: _sysID); DoRomToggle(); } @@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk tcMain.Visible = false; PathTabControl.TabPages.Clear(); - var systems = _pathEntries.Select(e => e.System).Distinct() // group entries by "system" (intentionally using instance field here, not parameter) + var systems = _pathEntries.Paths.Select(static e => e.System).Distinct() // group entries by "system" (intentionally using instance field here, not parameter) .Select(sys => (SysGroup: sys, DisplayName: PathEntryCollection.GetDisplayNameFor(sys))) .OrderBy(tuple => tuple.DisplayName) .ToList(); @@ -218,7 +218,7 @@ namespace BizHawk.Client.EmuHawk foreach (var t in AllPathControls.OfType()) { - var pathEntry = _pathEntries.First(p => p.System == t.Parent.Name && p.Type == t.Name); + var pathEntry = _pathEntries.Paths.First(p => p.System == t.Parent.Name && p.Type == t.Name); pathEntry.Path = t.Text; }