From 0e3d786c7054d4481fbe2684fc9fcb40577d154a Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 26 May 2025 06:20:29 +1000 Subject: [PATCH] Sort services by name in `Help` > `Features...` --- .../CoreFeatureAnalysis.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs index a335f7e16d..37f6120a42 100644 --- a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs +++ b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using System.Reflection; using BizHawk.Client.Common; +using BizHawk.Common.CollectionExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores; @@ -24,27 +25,15 @@ namespace BizHawk.Client.EmuHawk { CoreName = emu.Attributes().CoreName; Released = emu.Attributes().Released; - Services = new Dictionary(); var ser = emu.ServiceProvider; - foreach (Type t in ser.AvailableServices.Where(type => type != emu.GetType())) - { - var si = new ServiceInfo(t, ser.GetService(t)); - Services.Add(si.TypeName, si); - } - + Services = ser.AvailableServices.Except([ emu.GetType() ]) + .Select(t => new ServiceInfo(t, ser.GetService(t))) + .OrderBy(si => si.TypeName) + .ToDictionary(static si => si.TypeName); var notApplicableAttribute = ((ServiceNotApplicableAttribute)Attribute .GetCustomAttribute(emu.GetType(), typeof(ServiceNotApplicableAttribute))); - - if (notApplicableAttribute != null) - { - NotApplicableTypes = notApplicableAttribute.NotApplicableTypes - .Select(x => x.ToString()) - .ToList(); - } - else - { - NotApplicableTypes = new List(); - } + NotApplicableTypes = (notApplicableAttribute?.NotApplicableTypes ?? [ ]) + .Select(static x => x.ToString()).Order().ToList(); } }