diff --git a/Common.ruleset b/Common.ruleset index 27718bbaf4..50c3acdcbb 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -198,7 +198,7 @@ - + diff --git a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs index 809bc2dee9..4ec6bf217d 100644 --- a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs +++ b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs @@ -153,19 +153,10 @@ namespace BizHawk.Client.EmuHawk ret.Nodes.Add(serviceNode); } - - var knownServices = Emulation.Common.ReflectionCache.Types - .Where(t => typeof(IEmulatorService).IsAssignableFrom(t)) - .Where(t => t != typeof(IEmulatorService)) - .Where(t => t != typeof(ITextStatable)) // Hack for now, eventually we can get rid of this interface in favor of a default implementation - .Where(t => t.IsInterface); - - var additionalServices = knownServices - .Where(t => !ci.Services.ContainsKey(t.ToString())) - .Where(t => !ci.NotApplicableTypes.Contains(t.ToString())) - .Where(t => !typeof(ISpecializedEmulatorService).IsAssignableFrom(t)); // We don't want to show these as unimplemented, they aren't expected services - - foreach (Type service in additionalServices) + foreach (var service in Emulation.Common.ReflectionCache.Types.Where(t => t.IsInterface + && typeof(IEmulatorService).IsAssignableFrom(t) && !typeof(ISpecializedEmulatorService).IsAssignableFrom(t) // don't show ISpecializedEmulatorService subinterfaces as "missing" as there's no expectation that they'll be implemented eventually + && t != typeof(IEmulatorService) && t != typeof(ITextStatable) // denylisting ITextStatable is a hack for now, eventually we can get merge it into IStatable w/ default interface methods + && !ci.Services.ContainsKey(t.ToString()) && !ci.NotApplicableTypes.Contains(t.ToString()))) { string img = "Bad"; var serviceNode = new TreeNode diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs index 4088e979da..bc1a2a484d 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs @@ -33,8 +33,7 @@ namespace BizHawk.Client.EmuHawk else { visibleColumns = _columns.VisibleColumns - .Where(c => c.Right > _hBar.Value) - .Where(c => c.Left - _hBar.Value < e.ClipRectangle.Width) + .Where(c => c.Right > _hBar.Value && c.Left - _hBar.Value < e.ClipRectangle.Width) .ToList(); } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 2dbc0b6f19..61099c0815 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -2070,8 +2070,8 @@ namespace BizHawk.Client.EmuHawk } private static readonly IList SpecializedTools = ReflectionCache.Types - .Where(t => typeof(IToolForm).IsAssignableFrom(t) && !t.IsAbstract) - .Where(t => t.GetCustomAttribute() != null) + .Where(static t => !t.IsAbstract && typeof(IToolForm).IsAssignableFrom(t) + && t.GetCustomAttribute() is not null) .ToList(); private ISet _availableAccelerators; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 6d24070431..485d7389d1 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -1218,8 +1218,7 @@ namespace BizHawk.Client.EmuHawk ColumnsSubMenu.DropDownItems.Clear(); var columns = TasView.AllColumns - .Where(c => !string.IsNullOrWhiteSpace(c.Text)) - .Where(c => c.Name != "FrameColumn") + .Where(static c => !string.IsNullOrWhiteSpace(c.Text) && c.Name is not "FrameColumn") .ToList(); int workingHeight = Screen.FromControl(this).WorkingArea.Height; diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolBox.cs b/src/BizHawk.Client.EmuHawk/tools/ToolBox.cs index fceef06a9d..00cf18f0ef 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolBox.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolBox.cs @@ -45,11 +45,10 @@ namespace BizHawk.Client.EmuHawk ToolBoxStrip.Items.Clear(); var tools = EmuHawk.ReflectionCache.Types - .Where(t => typeof(IToolForm).IsAssignableFrom(t)) - .Where(t => typeof(Form).IsAssignableFrom(t)) - .Where(t => !typeof(ToolBox).IsAssignableFrom(t)) - .Where(t => ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) - .Where(t => VersionInfo.DeveloperBuild || !t.GetCustomAttributes(false).OfType().Any(a => !a.Released)); + .Where(t => typeof(IToolForm).IsAssignableFrom(t) && typeof(Form).IsAssignableFrom(t) + && !typeof(ToolBox).IsAssignableFrom(t) + && ServiceInjector.IsAvailable(Emulator.ServiceProvider, t) + && (VersionInfo.DeveloperBuild || !t.GetCustomAttributes(false).OfType().Any(static a => !a.Released))); /* for (int i = 0; i < tools.Count(); i++) diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs index f108196f3a..0bcfbe8df6 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -490,9 +490,7 @@ namespace BizHawk.Client.EmuHawk } public IEnumerable AvailableTools => EmuHawk.ReflectionCache.Types - .Where(t => typeof(IToolForm).IsAssignableFrom(t)) - .Where(t => !t.IsInterface) - .Where(IsAvailable); + .Where(t => !t.IsInterface && typeof(IToolForm).IsAssignableFrom(t) && IsAvailable(t)); /// /// Calls UpdateValues() on an instance of T, if it exists diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index eb73129d92..deb44590a6 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -570,7 +570,7 @@ namespace BizHawk.Client.EmuHawk } } - ErrorIconButton.Visible = _watches.Where(watch => !watch.IsSeparator).Any(watch => !watch.IsValid); + ErrorIconButton.Visible = _watches.Any(static watch => !watch.IsSeparator && !watch.IsValid); MessageLabel.Text = message; } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs b/src/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs index f3427a50ba..462582d82a 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs @@ -25,11 +25,8 @@ namespace BizHawk.Emulation.Common // this also fully allows services that are not IEmulatorService Type coreType = core.GetType(); - var services = coreType.GetInterfaces() - .Where(t => typeof(IEmulatorService).IsAssignableFrom(t)) - .Where(t => t != typeof(IEmulatorService) && t != typeof(ISpecializedEmulatorService)); - - foreach (Type service in services) + foreach (var service in coreType.GetInterfaces().Where(static t => typeof(IEmulatorService).IsAssignableFrom(t) + && t != typeof(IEmulatorService) && t != typeof(ISpecializedEmulatorService))) { _services.Add(service, core); } diff --git a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs index 5d37bf7bcc..49587912c5 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs @@ -69,9 +69,7 @@ namespace BizHawk.Emulation.Cores.Waterbox .ToArray(); var memoryDomains = _memoryAreas.Select(a => WaterboxMemoryDomain.Create(a, _exe)).ToList(); - var primaryDomain = memoryDomains - .Where(md => md.Definition.Flags.HasFlag(LibWaterboxCore.MemoryDomainFlags.Primary)) - .Single(); + var primaryDomain = memoryDomains.Single(static md => md.Definition.Flags.HasFlag(LibWaterboxCore.MemoryDomainFlags.Primary)); var mdl = new MemoryDomainList( memoryDomains.Cast()