diff --git a/.global.editorconfig.ini b/.global.editorconfig.ini index 3a4c5b40e61..a95753484c1 100644 --- a/.global.editorconfig.ini +++ b/.global.editorconfig.ini @@ -63,6 +63,11 @@ dotnet_code_quality.CA1305.excluded_symbol_names = T:System.Byte|T:System.SByte| # Specify marshalling for P/Invoke string arguments dotnet_diagnostic.CA2101.severity = suggestion +## Reliability rules + +# ThreadStatic fields should not use inline initialization +dotnet_diagnostic.CA2019.severity = error + ## Performance rules # Do not initialize unnecessarily @@ -73,6 +78,10 @@ dotnet_diagnostic.CA1822.severity = silent dotnet_code_quality.CA1826.exclude_ordefault_methods = true # Avoid StringBuilder parameters for P/Invokes dotnet_diagnostic.CA1838.severity = suggestion +# Use concrete types when possible for improved performance +dotnet_diagnostic.CA1859.severity = suggestion +# Avoid constant arrays as arguments +dotnet_diagnostic.CA1861.severity = none ## Usage rules diff --git a/Common.props b/Common.props index 96661aaf89f..c5ac89bffdb 100644 --- a/Common.props +++ b/Common.props @@ -1,6 +1,6 @@ - 6 + 8 Recommended Recommended Recommended diff --git a/src/BizHawk.BizInvoke/BizInvoker.cs b/src/BizHawk.BizInvoke/BizInvoker.cs index a1bc4a4d9ed..e469a286069 100644 --- a/src/BizHawk.BizInvoke/BizInvoker.cs +++ b/src/BizHawk.BizInvoke/BizInvoker.cs @@ -26,7 +26,7 @@ public static class BizInvoker /// /// holds information about a proxy implementation, including type and setup hooks /// - private class InvokerImpl + private sealed class InvokerImpl { private readonly Action _connectCallingConventionAdapter; diff --git a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs index b44865668dd..c12d1694920 100644 --- a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs +++ b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs @@ -15,7 +15,7 @@ namespace BizHawk.BizInvoke public static unsafe class BizInvokerUtilities { [StructLayout(LayoutKind.Explicit)] - private class U + private sealed class U { [FieldOffset(0)] public readonly U1? First; @@ -32,14 +32,14 @@ public U(U2 second) } [StructLayout(LayoutKind.Explicit)] - private class U1 + private sealed class U1 { [FieldOffset(0)] public UIntPtr P; } [StructLayout(LayoutKind.Explicit)] - private class U2 + private sealed class U2 { [FieldOffset(0)] public object Target; @@ -47,7 +47,7 @@ private class U2 public U2(object target) => Target = target; } - private class CF + private sealed class CF { public int FirstField = 0; } diff --git a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs index c3e8ad6d5b7..74d848d93ce 100644 --- a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs +++ b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs @@ -92,7 +92,7 @@ public interface ICallbackAdjuster public static class CallingConventionAdapters { - private class NativeConvention : ICallingConventionAdapter + private sealed class NativeConvention : ICallingConventionAdapter { public IntPtr GetArrivalFunctionPointer(IntPtr p, InvokerParameterInfo pp, object lifetime) => p; @@ -132,9 +132,9 @@ public static ICallingConventionAdapter MakeWaterboxDepartureOnly(ICallbackAdjus public static ICallingConventionAdapter GetWaterboxUnsafeUnwrapped() => WaterboxAdapter.WaterboxWrapper; - private class WaterboxAdapter : ICallingConventionAdapter + private sealed class WaterboxAdapter : ICallingConventionAdapter { - private class ReferenceEqualityComparer : IEqualityComparer + private sealed class ReferenceEqualityComparer : IEqualityComparer { public bool Equals(Delegate x, Delegate y) => x == y; @@ -218,19 +218,14 @@ public IntPtr GetFunctionPointerForDelegate(Delegate d) /// Calling Convention Adapter for where host code expects msabi and guest code is sysv. /// Does not handle anything Waterbox specific. /// - private class MsHostSysVGuest : ICallingConventionAdapter + private sealed class MsHostSysVGuest : ICallingConventionAdapter { // This is implemented by using thunks defined in a small dll, and putting stubs on top of them that close over the // function pointer parameter. A dll is used here to easily set unwind information (allowing SEH exceptions to work). // TODO: Another dll might be required for ARM64? Investigate private const int BlockSize = 32; - private static readonly IImportResolver ThunkDll; - - static MsHostSysVGuest() - { - ThunkDll = new DynamicLibraryImportResolver("libbizabiadapter_msabi_sysv.dll", hasLimitedLifetime: false); - } + private static readonly DynamicLibraryImportResolver ThunkDll = new("libbizabiadapter_msabi_sysv.dll", hasLimitedLifetime: false); private readonly MemoryBlock _memory; private readonly object _sync = new(); diff --git a/src/BizHawk.Bizware.Audio/OpenALSoundOutput.cs b/src/BizHawk.Bizware.Audio/OpenALSoundOutput.cs index 9b53deb798b..775ae84195d 100644 --- a/src/BizHawk.Bizware.Audio/OpenALSoundOutput.cs +++ b/src/BizHawk.Bizware.Audio/OpenALSoundOutput.cs @@ -255,7 +255,7 @@ private void AllocateTempSampleBuffer(int sampleCount) } } - private class BufferPool : IDisposable + private sealed class BufferPool : IDisposable { private readonly Stack _availableItems = new(); private readonly Queue _obtainedItems = new(); @@ -285,7 +285,7 @@ public BufferPoolItem ReleaseOne() return item; } - public class BufferPoolItem + public sealed class BufferPoolItem { public uint BufferID { get; } = _al.GenBuffer(); public int Length { get; set; } diff --git a/src/BizHawk.Bizware.Audio/SDL2WavStream.cs b/src/BizHawk.Bizware.Audio/SDL2WavStream.cs index 9b4da0ddc80..fdaf6c6d50d 100644 --- a/src/BizHawk.Bizware.Audio/SDL2WavStream.cs +++ b/src/BizHawk.Bizware.Audio/SDL2WavStream.cs @@ -135,7 +135,7 @@ public void Write(ReadOnlySpan buffer) public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); - private unsafe class SDLRwOpsStreamWrapper : IDisposable + private sealed unsafe class SDLRwOpsStreamWrapper : IDisposable { public IntPtr Rw { get; private set; } private readonly Stream _s; diff --git a/src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs b/src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs index 974571c5442..b6f5fd746e6 100644 --- a/src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs +++ b/src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs @@ -192,7 +192,7 @@ public void PlayWavFile(Stream wavFile, double volume) _wavVoice.Start(); } - private class BufferPool : IDisposable + private sealed class BufferPool : IDisposable { private readonly List _availableItems = new(); private readonly Queue _obtainedItems = new(); @@ -235,7 +235,7 @@ public void Release(int buffersQueued) _availableItems.Add(_obtainedItems.Dequeue()); } - public class BufferPoolItem + public sealed class BufferPoolItem { public int MaxLength { get; } public AudioBuffer AudioBuffer { get; } diff --git a/src/BizHawk.Bizware.Graphics/D3D11/D3D11Pipeline.cs b/src/BizHawk.Bizware.Graphics/D3D11/D3D11Pipeline.cs index b41766a4b86..a95cf14fc16 100644 --- a/src/BizHawk.Bizware.Graphics/D3D11/D3D11Pipeline.cs +++ b/src/BizHawk.Bizware.Graphics/D3D11/D3D11Pipeline.cs @@ -15,7 +15,7 @@ namespace BizHawk.Bizware.Graphics { - internal class D3D11Pipeline : IPipeline + internal sealed class D3D11Pipeline : IPipeline { private readonly D3D11Resources _resources; private ID3D11Device Device => _resources.Device; @@ -43,7 +43,7 @@ internal class D3D11Pipeline : IPipeline private readonly Dictionary _vsSamplers = new(); private readonly Dictionary _psSamplers = new(); - public class D3D11PendingBuffer + public sealed class D3D11PendingBuffer { public IntPtr VSPendingBuffer, PSPendingBuffer; public int VSBufferSize, PSBufferSize; diff --git a/src/BizHawk.Bizware.Graphics/D3D11/D3D11SwapChain.cs b/src/BizHawk.Bizware.Graphics/D3D11/D3D11SwapChain.cs index 52754936c3a..f14db15a2ba 100644 --- a/src/BizHawk.Bizware.Graphics/D3D11/D3D11SwapChain.cs +++ b/src/BizHawk.Bizware.Graphics/D3D11/D3D11SwapChain.cs @@ -25,7 +25,7 @@ public ControlParameters(IntPtr handle, int width, int height, bool vsync, bool } } - internal class SwapChainResources : IDisposable + internal sealed class SwapChainResources : IDisposable { public ID3D11Device Device; public ID3D11DeviceContext Context; diff --git a/src/BizHawk.Bizware.Graphics/OpenGL/OpenGLPipeline.cs b/src/BizHawk.Bizware.Graphics/OpenGL/OpenGLPipeline.cs index 64397a0d98c..bd1d1e9a596 100644 --- a/src/BizHawk.Bizware.Graphics/OpenGL/OpenGLPipeline.cs +++ b/src/BizHawk.Bizware.Graphics/OpenGL/OpenGLPipeline.cs @@ -9,7 +9,7 @@ namespace BizHawk.Bizware.Graphics { - internal class OpenGLPipeline : IPipeline + internal sealed class OpenGLPipeline : IPipeline { private readonly GL GL; diff --git a/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs b/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs index 6abece178d4..59c829abf44 100644 --- a/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs +++ b/src/BizHawk.Bizware.Graphics/Renderers/ImGui2DRenderer.cs @@ -146,13 +146,13 @@ private void ResetDrawList() EnableBlending = _pendingBlendEnable; } - protected class ImGuiUserTexture + protected sealed class ImGuiUserTexture { public Bitmap Bitmap; public bool WantCache; } - protected class DrawStringArgs + protected sealed class DrawStringArgs { public string Str; public Font Font; diff --git a/src/BizHawk.Bizware.Graphics/Renderers/SDLImGui2DRenderer.cs b/src/BizHawk.Bizware.Graphics/Renderers/SDLImGui2DRenderer.cs index b9379137579..b071ebf497a 100644 --- a/src/BizHawk.Bizware.Graphics/Renderers/SDLImGui2DRenderer.cs +++ b/src/BizHawk.Bizware.Graphics/Renderers/SDLImGui2DRenderer.cs @@ -13,7 +13,7 @@ namespace BizHawk.Bizware.Graphics /// Wraps SDL2's software rendering with an ImGui 2D renderer /// Used for the GDI+ IGL, which doesn't understand vertexes and such /// - internal class SDLImGui2DRenderer : ImGui2DRenderer + internal sealed class SDLImGui2DRenderer : ImGui2DRenderer { // SDL's software renderer sometimes doesn't fill in shapes all the way with a thickness of 1 // a thickness of 2 seems to suffice however diff --git a/src/BizHawk.Bizware.Input/SDL2/SDL2Gamepad.cs b/src/BizHawk.Bizware.Input/SDL2/SDL2Gamepad.cs index 02550ed279c..d60e488e06c 100644 --- a/src/BizHawk.Bizware.Input/SDL2/SDL2Gamepad.cs +++ b/src/BizHawk.Bizware.Input/SDL2/SDL2Gamepad.cs @@ -7,7 +7,7 @@ namespace BizHawk.Bizware.Input /// /// SDL2 Gamepad Handler /// - internal class SDL2Gamepad : IDisposable + internal sealed class SDL2Gamepad : IDisposable { // indexed by instance id private static readonly Dictionary Gamepads = new(); diff --git a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs index c725a8f2f60..fe4d9a9d522 100644 --- a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs +++ b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs @@ -36,7 +36,7 @@ public override bool NotApplicableTo(string romHash, string? sysID) [AttributeUsage(AttributeTargets.Class)] public sealed class RomList : ExternalToolApplicabilityAttributeBase { - private readonly IList _romHashes; + private readonly List _romHashes; private readonly string _sysID; diff --git a/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs b/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs index eb482750982..a4604257d2e 100644 --- a/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs +++ b/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs @@ -229,22 +229,22 @@ public class ShaderPass public Vector2 Scale; } - private static string FetchString(IDictionary dict, string key, string @default) + private static string FetchString(Dictionary dict, string key, string @default) { return dict.TryGetValue(key, out var str) ? str : @default; } - private static int FetchInt(IDictionary dict, string key, int @default) + private static int FetchInt(Dictionary dict, string key, int @default) { return dict.TryGetValue(key, out var str) ? int.Parse(str) : @default; } - private static float FetchFloat(IDictionary dict, string key, float @default) + private static float FetchFloat(Dictionary dict, string key, float @default) { return dict.TryGetValue(key, out var str) ? float.Parse(str, NumberFormatInfo.InvariantInfo) : @default; } - private static bool FetchBool(IDictionary dict, string key, bool @default) + private static bool FetchBool(Dictionary dict, string key, bool @default) { return dict.TryGetValue(key, out var str) ? ParseBool(str) : @default; } diff --git a/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs b/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs index 4382fadb833..cc284a304f1 100644 --- a/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs +++ b/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs @@ -137,7 +137,7 @@ public void DrawMessages(IBlitter g) _messages.RemoveAll(m => DateTime.Now > m.ExpireAt); - if (_messages.Any()) + if (_messages.Count != 0) { if (_config.StackOSDMessages) { diff --git a/src/BizHawk.Client.Common/RecentFiles.cs b/src/BizHawk.Client.Common/RecentFiles.cs index 5f37582d1b0..b94d75622a2 100644 --- a/src/BizHawk.Client.Common/RecentFiles.cs +++ b/src/BizHawk.Client.Common/RecentFiles.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json; namespace BizHawk.Client.Common @@ -29,15 +28,15 @@ public RecentFiles(int max) public bool Frozen { get; set; } [JsonIgnore] - public bool Empty => !recentlist.Any(); + public bool Empty => recentlist.Count == 0; [JsonIgnore] public int Count => recentlist.Count; [JsonIgnore] - public string MostRecent => recentlist.Any() ? recentlist[0] : ""; + public string MostRecent => recentlist.Count != 0 ? recentlist[0] : ""; - public string this[int index] => recentlist.Any() ? recentlist[index] : ""; + public string this[int index] => recentlist.Count != 0 ? recentlist[index] : ""; public IEnumerator GetEnumerator() => recentlist.GetEnumerator(); diff --git a/src/BizHawk.Client.Common/RomGame.cs b/src/BizHawk.Client.Common/RomGame.cs index eda1d3d065d..38f85c3f5b5 100644 --- a/src/BizHawk.Client.Common/RomGame.cs +++ b/src/BizHawk.Client.Common/RomGame.cs @@ -63,7 +63,9 @@ public RomGame(HawkFile file, string patch) NotInDatabase = true }; +#pragma warning disable CA1862 // incorrect detection, see https://github.com/dotnet/roslyn-analyzers/issues/7074 if (!string.IsNullOrWhiteSpace(GameInfo.Name) && GameInfo.Name == GameInfo.Name.ToUpperInvariant()) +#pragma warning restore CA1862 { GameInfo.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(GameInfo.Name.ToLowerInvariant()); } diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 7c59501a540..0221351d461 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -386,7 +386,7 @@ private IEmulator MakeCoreFromCoreInventory(CoreInventoryParameters cip, string return (int)CorePriority.UserPreference; } - if (string.Equals(c.Name, dbForcedCoreName, StringComparison.OrdinalIgnoreCase)) + if (c.Name.Equals(dbForcedCoreName, StringComparison.OrdinalIgnoreCase)) { return (int)CorePriority.GameDbPreference; } @@ -532,7 +532,7 @@ static byte[] CbDeflater(Stream instream, int size) private static bool IsDiscForXML(string system, string path) { var ext = Path.GetExtension(path); - if (system == VSystemID.Raw.Arcade && ext.ToLowerInvariant() == ".chd") + if (system == VSystemID.Raw.Arcade && ext.Equals(".chd", StringComparison.OrdinalIgnoreCase)) { return false; } diff --git a/src/BizHawk.Client.Common/controllers/StickyControllers.cs b/src/BizHawk.Client.Common/controllers/StickyControllers.cs index 6baef48d69a..05d8b2e310f 100644 --- a/src/BizHawk.Client.Common/controllers/StickyControllers.cs +++ b/src/BizHawk.Client.Common/controllers/StickyControllers.cs @@ -74,14 +74,10 @@ public void MassToggleStickyState(List buttons) { foreach (var button in buttons.Where(button => !_justPressed.Contains(button))) { - if (_buttonHolds.Contains(button)) + if (!_buttonHolds.Add(button)) { _buttonHolds.Remove(button); } - else - { - _buttonHolds.Add(button); - } } _justPressed = buttons; diff --git a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs index afc8474a5de..a6b2058f3fb 100644 --- a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs +++ b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs @@ -89,9 +89,9 @@ public void ToggleAutoStickies() private static Controller BindToDefinition( ControllerDefinition def, - IDictionary> allBinds, - IDictionary> analogBinds, - IDictionary> feedbackBinds) + Dictionary> allBinds, + Dictionary> analogBinds, + Dictionary> feedbackBinds) { var ret = new Controller(def); if (allBinds.TryGetValue(def.Name, out var binds)) @@ -129,7 +129,7 @@ private static Controller BindToDefinition( private static AutofireController BindToDefinitionAF( IEmulator emulator, - IDictionary> allBinds, + Dictionary> allBinds, int on, int off) { diff --git a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs index fb6d7dd6cd5..dc555c82ca5 100644 --- a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -146,7 +146,7 @@ public string ToSublime2CompletionList() var sb = new StringBuilder(); - if (f.ParameterList.Any()) + if (f.ParameterList.Length != 0) { sb .Append($"{f.Library}.{f.Name}("); diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs index 2b828388d35..1b39d781903 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.ModeApi.cs @@ -1,6 +1,4 @@ -using System.Linq; - -namespace BizHawk.Client.Common +namespace BizHawk.Client.Common { public partial class Bk2Movie { @@ -9,7 +7,7 @@ public partial class Bk2Movie public virtual void StartNewRecording() { Mode = MovieMode.Record; - if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Any()) + if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Count != 0) { SaveBackup(); MakeBackup = false; diff --git a/src/BizHawk.Client.Common/movie/bk2/StringLogs.cs b/src/BizHawk.Client.Common/movie/bk2/StringLogs.cs index c2c3649012f..56d780cfc00 100644 --- a/src/BizHawk.Client.Common/movie/bk2/StringLogs.cs +++ b/src/BizHawk.Client.Common/movie/bk2/StringLogs.cs @@ -87,7 +87,7 @@ public void Dispose() { } /// internal class StreamStringLog : IStringLog { - private readonly Stream _stream; + private readonly FileStream _stream; private readonly List _offsets = new List(); private readonly BinaryWriter _bw; private readonly BinaryReader _br; diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index 9aecad60a47..607e6524083 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -107,7 +107,7 @@ public void RemoveFrame(int frame) public void RemoveFrames(ICollection frames) { - if (frames.Any()) + if (frames.Count != 0) { // Separate the given frames into contiguous blocks // and process each block independently diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs index 5b5dc737a12..e8296590a02 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs @@ -33,7 +33,7 @@ private void AddTasProjLumps(ZipStateSaver bs, bool isBackup = false) bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(inputRollSettingsJson)); } - if (VerificationLog.Any()) + if (VerificationLog.Count != 0) { bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog())); } diff --git a/src/BizHawk.Client.Common/savestates/ZipStateSaver.cs b/src/BizHawk.Client.Common/savestates/ZipStateSaver.cs index 7cd3db218b4..0c186ddbaf6 100644 --- a/src/BizHawk.Client.Common/savestates/ZipStateSaver.cs +++ b/src/BizHawk.Client.Common/savestates/ZipStateSaver.cs @@ -6,7 +6,7 @@ namespace BizHawk.Client.Common { public class ZipStateSaver : IDisposable { - private readonly IZipWriter _zip; + private readonly FrameworkZipWriter _zip; private bool _isDisposed; private static void WriteZipVersion(Stream s) @@ -23,12 +23,12 @@ private static void WriteEmuVersion(Stream s) public ZipStateSaver(string path, int compressionLevel) { - _zip = new FrameworkZipWriter(path, compressionLevel); - - // we put these in every zip, so we know where they came from - // a bit redundant for movie files given their headers, but w/e + _zip = new FrameworkZipWriter(path, compressionLevel); + + // we put these in every zip, so we know where they came from + // a bit redundant for movie files given their headers, but w/e PutLump(BinaryStateLump.ZipVersion, WriteZipVersion, false); - PutLump(BinaryStateLump.BizVersion, WriteEmuVersion, false); + PutLump(BinaryStateLump.BizVersion, WriteEmuVersion, false); } public void PutLump(BinaryStateLump lump, Action callback, bool zstdCompress = true) @@ -51,9 +51,9 @@ public void PutLump(BinaryStateLump lump, Action callback) // don't zstd compress text, as it's annoying for users PutLump(lump, s => { - TextWriter tw = new StreamWriter(s); - callback(tw); - tw.Flush(); + StreamWriter writer = new StreamWriter(s); + callback(writer); + writer.Flush(); }, false); } diff --git a/src/BizHawk.Client.Common/tools/CheatList.cs b/src/BizHawk.Client.Common/tools/CheatList.cs index 493bc2568b8..b5e49481036 100644 --- a/src/BizHawk.Client.Common/tools/CheatList.cs +++ b/src/BizHawk.Client.Common/tools/CheatList.cs @@ -92,7 +92,7 @@ public void NewList(string defaultFileName, bool autosave = false) { _defaultFileName = defaultFileName; - if (_cheatList.Any() && _changes && autosave) + if (_cheatList.Count != 0 && _changes && autosave) { if (string.IsNullOrEmpty(CurrentFileName)) { @@ -224,7 +224,7 @@ public void SaveOnClose() { if (_config.AutoSaveOnClose) { - if (Changes && _cheatList.Any()) + if (Changes && _cheatList.Count != 0) { if (string.IsNullOrWhiteSpace(CurrentFileName)) { @@ -233,7 +233,7 @@ public void SaveOnClose() SaveFile(CurrentFileName); } - else if (!_cheatList.Any() && !string.IsNullOrWhiteSpace(CurrentFileName)) + else if (_cheatList.Count == 0 && !string.IsNullOrWhiteSpace(CurrentFileName)) { File.Delete(CurrentFileName); _config.Recent.Remove(CurrentFileName); diff --git a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index 57605734cac..90bc6be7125 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk { [VideoWriter("vfwavi", "AVI writer", "Uses the Microsoft AVIFIL32 system to write .avi files. Audio is uncompressed; Video can be compressed with any installed VCM codec. Splits on 2G and resolution change.")] - internal class AviWriter : IVideoWriter + internal sealed class AviWriter : IVideoWriter { private CodecToken _currVideoCodecToken; private AviWriterSegment _currSegment; @@ -111,7 +111,7 @@ private void ThreadProc() // we can't pass the IVideoProvider we get to another thread, because it doesn't actually keep a local copy of its data, // instead grabbing it from the emu as needed. this causes frame loss/dupping as a race condition // instead we pass this - private class VideoCopy : IVideoProvider + private sealed class VideoCopy : IVideoProvider { private readonly int[] _vb; public int VirtualWidth { get; } @@ -275,8 +275,7 @@ public IDisposable AcquireVideoCodecToken(Config config) try { - var ret = tempSegment.AcquireVideoCodecToken(_dialogParent.AsWinFormsHandle().Handle, _currVideoCodecToken); - var token = (CodecToken)ret; + var token = tempSegment.AcquireVideoCodecToken(_dialogParent.AsWinFormsHandle().Handle, _currVideoCodecToken); config.AviCodecToken = token?.Serialize(); return token; } @@ -287,7 +286,7 @@ public IDisposable AcquireVideoCodecToken(Config config) } } - private class Parameters + private sealed class Parameters { public int width, height; public int pitch; //in bytes @@ -398,7 +397,7 @@ public void SetAudioParameters(int sampleRate, int channels, int bits) Segment(); } - public class CodecToken : IDisposable + public sealed class CodecToken : IDisposable { public void Dispose() { @@ -570,7 +569,7 @@ public void SetMetaData(string gameName, string authors, ulong lengthMS, ulong r { } - private class AviWriterSegment : IDisposable + private sealed class AviWriterSegment : IDisposable { static AviWriterSegment() { @@ -608,7 +607,7 @@ private IntPtr GetStaticGlobalBuf(int amount) return _pGlobalBuf; } - private class OutputStatus + private sealed class OutputStatus { public int video_frames; public int video_bytes; @@ -709,7 +708,7 @@ static int mmioFOURCC(string str) => ( /// acquires a video codec configuration from the user /// no file open (need to call ) - public IDisposable AcquireVideoCodecToken(IntPtr hwnd, CodecToken lastCodecToken) + public CodecToken AcquireVideoCodecToken(IntPtr hwnd, CodecToken lastCodecToken) { if (!_isOpen) { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs index d4f6710a67c..2f90d474da8 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs @@ -115,7 +115,7 @@ public void SetDefaultVideoCodecToken(Config config) /// /// the underlying stream we're writing to /// - private Stream _f; + private FileStream _f; /// /// a final byte we must write before closing the stream diff --git a/src/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs index f0bf9bf6993..fd2c95a11ce 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs @@ -49,11 +49,11 @@ public void AddFrame(IVideoProvider source) var name = Path.Combine(dir!, $"{fileNoExt}_{_frame}{ext}"); BitmapBuffer bb = new BitmapBuffer(source.BufferWidth, source.BufferHeight, source.GetVideoBuffer()); using var bmp = bb.ToSysdrawingBitmap(); - if (ext.ToUpperInvariant() == ".PNG") + if (ext.Equals(".PNG", StringComparison.OrdinalIgnoreCase)) { bmp.Save(name, ImageFormat.Png); } - else if (ext.ToUpperInvariant() == ".JPG") + else if (ext.Equals(".JPG", StringComparison.OrdinalIgnoreCase)) { bmp.Save(name, ImageFormat.Jpeg); } @@ -65,7 +65,7 @@ public void AddSamples(short[] samples) { } - private class CodecToken : IDisposable + private sealed class CodecToken : IDisposable { public void Dispose() { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs index 8d0800ebf1d..410be3334da 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs @@ -42,7 +42,7 @@ private static CompressionLevel GetCompressionLevel(int v) /// /// carries private compression information data /// - private class CodecToken : IDisposable + private sealed class CodecToken : IDisposable { public void Dispose() { @@ -94,7 +94,7 @@ public CodecToken() /// metadata for a movie /// not needed if we aren't dumping something that's not a movie /// - private class MovieMetaData + private sealed class MovieMetaData { /// /// name of the game (rom) @@ -123,7 +123,7 @@ private class MovieMetaData /// /// represents a JMD file packet ready to be written except for sorting and timestamp offset /// - private class JmdPacket + private sealed class JmdPacket { public ushort Stream { get; set; } public ulong Timestamp { get; set; } // final muxed timestamp will be relative to previous @@ -135,7 +135,7 @@ private class JmdPacket /// writes JMD file packets to an underlying bytestream /// handles one video, one pcm audio, and one metadata track /// - private class JmdFile + private sealed class JmdFile { // current timestamp position private ulong _timestampOff; @@ -600,7 +600,7 @@ public void SetAudioParameters(int sampleRate, int channels, int bits) public void OpenFile(string baseName) { string ext = Path.GetExtension(baseName); - if (ext == null || ext.ToLowerInvariant() != ".jmd") + if (ext == null || !ext.Equals(".jmd", StringComparison.OrdinalIgnoreCase)) { baseName += ".jmd"; } diff --git a/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs b/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs index 0d37dbbccb1..c6a8cce44be 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs @@ -199,7 +199,7 @@ private static uint NutCRC32(byte[] buf) /// /// writes a single packet out, including CheckSums /// - private class NutPacket : Stream + private sealed class NutPacket : Stream { public enum StartCode : ulong { @@ -290,7 +290,7 @@ public override void Write(byte[] buffer, int offset, int count) /// /// stores basic AV parameters /// - private class AVParams + private sealed class AVParams { public int Width { get; set; } public int Height { get; set; } @@ -424,7 +424,7 @@ private void WriteAudioHeader() /// stores a single frame with syncpoint, in mux-ready form /// used because reordering of audio and video can be needed for proper interleave /// - private class NutFrame + private sealed class NutFrame { /// /// data ready to be written to stream/disk diff --git a/src/BizHawk.Client.EmuHawk/AVOut/NutWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/NutWriter.cs index 08734b59b18..9391649d635 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/NutWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/NutWriter.cs @@ -16,7 +16,7 @@ public class NutWriter : IVideoWriter /// /// dummy codec token class /// - private class NutWriterToken : IDisposable + private sealed class NutWriterToken : IDisposable { public void Dispose() { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs index 7dc76f9606a..a6a7aa95883 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs @@ -75,7 +75,7 @@ public void AddSamples(short[] samples) public bool UsesVideo => true; - private class DummyDisposable : IDisposable + private sealed class DummyDisposable : IDisposable { public void Dispose() { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs index d6e5d4c4a46..79107b37b19 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs @@ -88,7 +88,7 @@ private void GetPaths(int index, out string png, out string wav) wav = $"{path}.wav"; } - private class FrameInfo + private sealed class FrameInfo { public string WavPath { get; set; } public string PngPath { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs index 51e50491dd3..ab0171f984a 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs @@ -223,7 +223,7 @@ public void SetFrame(int frame) { } public bool UsesVideo => false; - private class WavWriterVToken : IDisposable + private sealed class WavWriterVToken : IDisposable { public void Dispose() { } } diff --git a/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs b/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs index 3a95e417836..93b3b438cea 100644 --- a/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs +++ b/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk { public partial class ArchiveChooser : Form { - private readonly IList _archiveItems = new List(); + private readonly List _archiveItems = new List(); private readonly ToolTip _errorBalloon = new ToolTip(); private static bool _useRegEx; @@ -34,7 +34,7 @@ public ArchiveChooser(HawkFile hawkFile) lvi.Text = item.Name; long size = item.Size; var extension = Path.GetExtension(item.Name); - if (extension != null && size % 1024 == 16 && extension.ToUpperInvariant() == ".NES") + if (extension != null && size % 1024 == 16 && extension.Equals(".NES", StringComparison.OrdinalIgnoreCase)) size -= 16; lvi.SubItems[1].Text = Util.FormatFileSize(size); _archiveItems.Add(lvi); @@ -200,7 +200,7 @@ private interface IMatcher bool Matches(ListViewItem value); } - private class SimpleMatcher : IMatcher + private sealed class SimpleMatcher : IMatcher { public string[] Keys { get; set; } public bool Matches(ListViewItem value) @@ -218,7 +218,7 @@ public bool Matches(ListViewItem value) } } - private class RegExMatcher : IMatcher + private sealed class RegExMatcher : IMatcher { public Regex Matcher { get; set; } public bool Matches(ListViewItem value) diff --git a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs index 6442d1299ab..39c6acbab81 100644 --- a/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs +++ b/src/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs @@ -12,7 +12,7 @@ namespace BizHawk.Client.EmuHawk { public partial class CoreFeatureAnalysis : ToolFormBase, IToolFormAutoConfig { - private class CoreInfo + private sealed class CoreInfo { public string CoreName { get; set; } public bool Released { get; set; } @@ -48,7 +48,7 @@ public CoreInfo(IEmulator emu) } } - private class ServiceInfo + private sealed class ServiceInfo { public string TypeName { get; set; } public bool Complete { get; set; } @@ -81,7 +81,7 @@ public ServiceInfo(Type serviceType, object service) } } - private class FunctionInfo + private sealed class FunctionInfo { public string TypeName { get; set; } public bool Complete { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs b/src/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs index 91815f3b414..456d3d4863d 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs @@ -20,7 +20,7 @@ public GdiPlusRenderer(Font font) _currentFont = font; } - private class GdiPlusGraphicsLock : IDisposable + private sealed class GdiPlusGraphicsLock : IDisposable { public void Dispose() { diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/ExceptionBox.cs b/src/BizHawk.Client.EmuHawk/CustomControls/ExceptionBox.cs index 917aa67199c..38758f79e95 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/ExceptionBox.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/ExceptionBox.cs @@ -66,7 +66,7 @@ private void timer1_Tick(object sender, EventArgs e) } //http://stackoverflow.com/questions/2636065/alpha-in-forecolor - private class MyLabel : Label + private sealed class MyLabel : Label { protected override void OnPaint(PaintEventArgs e) { diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs index 73ab2bcaf7b..43d4bd7342c 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs @@ -44,7 +44,7 @@ protected override void OnPaint(PaintEventArgs e) var lastVisibleRow = firstVisibleRow + visibleRows; var needsColumnRedraw = HorizontalOrientation || e.ClipRectangle.Y < ColumnHeight; - if (visibleColumns.Any() && needsColumnRedraw) + if (visibleColumns.Count != 0 && needsColumnRedraw) { DrawColumnBg(visibleColumns, e.ClipRectangle); DrawColumnText(visibleColumns); @@ -215,7 +215,7 @@ private void DrawData(List visibleColumns, int firstVisibleRow, int return; } - if (!visibleColumns.Any()) + if (visibleColumns.Count == 0) { return; } @@ -342,7 +342,7 @@ private void DrawColumnBg(List visibleColumns, Rectangle rect) y += GetHColHeight(j); } - if (visibleColumns.Any()) + if (visibleColumns.Count != 0) { _renderer.Line(1, y, MaxColumnWidth, y); } @@ -367,7 +367,7 @@ private void DrawColumnBg(List visibleColumns, Rectangle rect) } // Draw right most line - if (visibleColumns.Any()) + if (visibleColumns.Count != 0) { int right = TotalColWidth - _hBar.Value; if (right <= rect.Left + rect.Width) @@ -482,7 +482,7 @@ private void DrawBg(List visibleColumns, Rectangle rect, int firstVi _renderer.Line(x, y, x, rect.Height - 1); } - if (visibleColumns.Any()) + if (visibleColumns.Count != 0) { int x = TotalColWidth - _hBar.Value; _renderer.Line(x, y, x, rect.Height - 1); @@ -586,7 +586,7 @@ private void DrawCellBG(Color color, Cell cell, List visibleColumns, // Calls QueryItemBkColor callback for all visible cells and fills in the background of those cells. private void DoBackGroundCallback(List visibleColumns, Rectangle rect, int firstVisibleRow, int lastVisibleRow) { - if (!visibleColumns.Any()) + if (visibleColumns.Count == 0) { return; } diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index b1174f473bf..7024d77fc89 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk // Row width is specified for horizontal orientation public partial class InputRoll : Control { - private readonly IControlRenderer _renderer; + private readonly GdiPlusRenderer _renderer; private readonly CellList _selectedItems = new(); diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/MsgBox.cs b/src/BizHawk.Client.EmuHawk/CustomControls/MsgBox.cs index 13345782cbf..4e5c75e7c43 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/MsgBox.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/MsgBox.cs @@ -7,7 +7,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls /// /// A customizable Dialog box with 3 buttons, custom icon, and checkbox. /// - internal partial class MsgBox : Form + internal sealed partial class MsgBox : Form { private readonly Icon _msgIcon; private static readonly int FormYMargin = UIHelper.ScaleY(10); diff --git a/src/BizHawk.Client.EmuHawk/LogWindow.cs b/src/BizHawk.Client.EmuHawk/LogWindow.cs index 320ef5a317e..6b0c5b690b2 100644 --- a/src/BizHawk.Client.EmuHawk/LogWindow.cs +++ b/src/BizHawk.Client.EmuHawk/LogWindow.cs @@ -205,7 +205,7 @@ private void AddToGameDbBtn_Click(object sender, EventArgs e) } } - private class LogWriter : TextWriter + private sealed class LogWriter : TextWriter { public override void Write(char[] buffer, int offset, int count) { diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 78829b0aa81..371636d8847 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -1377,7 +1377,7 @@ public void TakeScreenshot(string path) using (var bb = Config.ScreenshotCaptureOsd ? CaptureOSD() : MakeScreenshotImage()) { using var img = bb.ToSysdrawingBitmap(); - if (Path.GetExtension(path).ToUpperInvariant() == ".JPG") + if (Path.GetExtension(path).Equals(".JPG", StringComparison.OrdinalIgnoreCase)) { img.Save(fi.FullName, ImageFormat.Jpeg); } @@ -2026,7 +2026,7 @@ private void RewireSound() && t.GetCustomAttribute() is not null) .ToList(); - private ISet _availableAccelerators; + private HashSet _availableAccelerators; private ISet AvailableAccelerators { @@ -2055,9 +2055,8 @@ private void DisplayDefaultCoreMenu() for (var i = 0; i < sysID.Length; i++) { var upper = char.ToUpperInvariant(sysID[i]); - if (AvailableAccelerators.Contains(upper)) + if (AvailableAccelerators.Remove(upper)) { - AvailableAccelerators.Remove(upper); sysID = sysID.Insert(i, "&"); break; } @@ -3713,7 +3712,7 @@ private bool LoadRomInternal(string path, LoadRomArgs args, out bool failureIsFr InputManager.SyncControls(Emulator, MovieSession, Config); _multiDiskMode = false; - if (oaOpenrom != null && Path.GetExtension(oaOpenrom.Path.Replace("|", "")).ToLowerInvariant() == ".xml" && Emulator is not LibsnesCore) + if (oaOpenrom != null && Path.GetExtension(oaOpenrom.Path.Replace("|", "")).Equals(".xml", StringComparison.OrdinalIgnoreCase) && Emulator is not LibsnesCore) { // this is a multi-disk bundler file // determine the xml assets and create RomStatusDetails for all of them diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RAIntegration.Update.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RAIntegration.Update.cs index 668df2be2da..22b8137ea5a 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RAIntegration.Update.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RAIntegration.Update.cs @@ -19,7 +19,7 @@ public partial class RAIntegration public static bool IsAvailable => _RA != null; // can't have both a proxy with a monitor and without one, so... - private class DummyMonitor : IMonitor + private sealed class DummyMonitor : IMonitor { public void Enter() {} public void Exit() {} diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs index b047be02a0e..b5d5c4c324b 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs @@ -98,7 +98,7 @@ private static void CloseFileCallback(IntPtr file_handle) handle.Free(); } - private class RCTrack : IDisposable + private sealed class RCTrack : IDisposable { private readonly Disc _disc; private readonly DiscSectorReader _dsr; @@ -467,4 +467,4 @@ VSystemID.Raw.GEN when rom.GameInfo.GetBool("32X", false) => ConsoleID.Sega32X, : "Failed to generate RC Hash"); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Hardcore.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Hardcore.cs index 5348a2cf278..d9c18d48cd5 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Hardcore.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Hardcore.cs @@ -123,7 +123,7 @@ protected void CheckHardcoreModeConditions() HandleHardcoreModeDisable("Using MAME in hardcore mode is not allowed."); break; case NymaCore nyma: - if (nyma.GetSettings().DisabledLayers.Any()) + if (nyma.GetSettings().DisabledLayers.Count != 0) { HandleHardcoreModeDisable($"Disabling {Emu.GetType().Name}'s graphics layers in hardcore mode is not allowed."); } diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Memory.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Memory.cs index b7c9188b16c..b3e11eaf062 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Memory.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RetroAchievements.Memory.cs @@ -190,7 +190,7 @@ public MemFunctions(MemoryDomain domain, uint domainAddrStart, long bankSize, ui } } - private class NullMemFunctions : MemFunctions + private sealed class NullMemFunctions : MemFunctions { public NullMemFunctions(long bankSize) : base(null, 0, bankSize) @@ -202,7 +202,7 @@ public NullMemFunctions(long bankSize) } // this is a complete hack because the libretro Intelli core sucks and so achievements are made expecting this format - private class IntelliMemFunctions : MemFunctions + private sealed class IntelliMemFunctions : MemFunctions { protected override uint FixAddr(uint addr) => (addr >> 1) + (~addr & 1); @@ -265,7 +265,7 @@ public IntelliMemFunctions(MemoryDomain domain) } // our vram is unpacked, but RA expects it packed - private class ChanFMemFunctions(MemoryDomain vram) + private sealed class ChanFMemFunctions(MemoryDomain vram) : MemFunctions(null, 0, 0x800) { private byte ReadVRAMPacked(uint addr) diff --git a/src/BizHawk.Client.EmuHawk/ScreenSaver.cs b/src/BizHawk.Client.EmuHawk/ScreenSaver.cs index 72163977e5d..acd5772064d 100644 --- a/src/BizHawk.Client.EmuHawk/ScreenSaver.cs +++ b/src/BizHawk.Client.EmuHawk/ScreenSaver.cs @@ -13,7 +13,7 @@ private interface IScreenBlankTimer int Duration { get; set; } } - private class Win32ScreenBlankTimer : IScreenBlankTimer + private sealed class Win32ScreenBlankTimer : IScreenBlankTimer { public int Duration { @@ -34,7 +34,7 @@ public int Duration } } - private class UnixScreenBlankTimer : IScreenBlankTimer + private sealed class UnixScreenBlankTimer : IScreenBlankTimer { public int Duration { get; set; } = 0; //TODO implementation } @@ -57,4 +57,4 @@ public static void ResetTimerPeriodically() ResetTimerImmediate(); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs b/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs index 57860d9bd3a..6d6fc44ab78 100644 --- a/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs @@ -143,14 +143,15 @@ PanelCreator createPanel : "Console"; // anything that wants not console can set it in the categorylabels } - if (!buckets.ContainsKey(categoryLabel)) + if (!buckets.TryGetValue(categoryLabel, out var bucket)) { var l = new List(); - buckets.Add(categoryLabel, l); + bucket = l; + buckets.Add(categoryLabel, bucket); orderedBuckets.Add(new KeyValuePair>(categoryLabel, l)); } - buckets[categoryLabel].Add(button); + bucket.Add(button); } if (orderedBuckets.Count == 1) diff --git a/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs b/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs index 4c091231726..2619c5583b8 100644 --- a/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/FirmwareConfig.cs @@ -100,7 +100,7 @@ public partial class FirmwareConfig : Form, IDialogParent private Font _fixedFont, _boldFont, _boldFixedFont; - private class ListViewSorter : IComparer + private sealed class ListViewSorter : IComparer { public int Column { get; set; } public int Sign { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 2af710f43e0..32517afba2c 100644 --- a/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/src/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -153,9 +153,9 @@ private void Run() return null; } - private IBasicMovieInfo LoadMovieInfo(HawkFile hf, bool force) + private BasicMovieInfo LoadMovieInfo(HawkFile hf, bool force) { - IBasicMovieInfo movie = new BasicMovieInfo(hf.CanonicalFullPath); + var movie = new BasicMovieInfo(hf.CanonicalFullPath); try { diff --git a/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index 62aed29b751..58ea776e171 100644 --- a/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/src/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -472,7 +472,7 @@ private void ClearStatsContextMenuItem_Click(object sender, EventArgs e) Frames = 0; } - private class BotAttempt + private sealed class BotAttempt { public long Attempt { get; set; } public int Maximize { get; set; } @@ -524,7 +524,7 @@ private void copy_curent_to_best() _bestBotAttempt.is_Reset = false; } - private class BotData + private sealed class BotData { public BotAttempt Best { get; set; } public Dictionary ControlProbabilities { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 0c6ed44be97..664c33c0e3e 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -400,7 +400,7 @@ private void CheatsSubMenu_DropDownOpened(object sender, EventArgs e) private void RemoveCheatMenuItem_Click(object sender, EventArgs e) { var items = SelectedItems.ToList(); - if (items.Any()) + if (items.Count != 0) { foreach (var item in items) { @@ -600,7 +600,7 @@ private void CheatsContextMenu_Opening(object sender, CancelEventArgs e) private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e) { var selected = SelectedCheats.ToList(); - if (selected.Any()) + if (selected.Count != 0) { Tools.Load(); diff --git a/src/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs b/src/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs index cf352002333..11c59d3c13d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs @@ -185,7 +185,7 @@ private void RemoveBreakpointButton_Click(object sender, EventArgs e) if (EditableItems.Any()) { var items = EditableItems.ToList(); - if (items.Any()) + if (items.Count != 0) { foreach (var item in items) { @@ -216,7 +216,7 @@ private void BreakpointView_ItemActivate(object sender, EventArgs e) if (EditableItems.Any()) { var items = EditableItems.ToList(); - if (items.Any()) + if (items.Count != 0) { foreach (var item in items) item.Active = !item.Active; BreakpointView.VirtualListSize = _breakpoints.Count; diff --git a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index 7d483be0a30..4a9d17d102a 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -90,7 +90,7 @@ private void DisassemblerView_QueryItemText(int index, RollColumn column, out st private void DisassemblerView_QueryItemBkColor(int index, RollColumn column, ref Color color) { - if (_disassemblyLines.Any() && index < _disassemblyLines.Count) + if (_disassemblyLines.Count != 0 && index < _disassemblyLines.Count) { if (_disassemblyLines[index].Address == _currentDisassemblerAddress) { diff --git a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 1fec01de636..0eab70188d6 100644 --- a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -45,7 +45,7 @@ public N64MatrixDisplayDialog(IReadOnlyList> strings) } } - private class NullMemoryDomain : MemoryDomain + private sealed class NullMemoryDomain : MemoryDomain { public override byte PeekByte(long addr) => 0; @@ -125,7 +125,7 @@ private static FilesystemFilterSet CreateBinaryDumpFSFilterSet(string ext) [ConfigPersist] private RecentFiles RecentTables { get; set; } - internal class ColorConfig + internal sealed class ColorConfig { public Color Background { get; set; } = SystemColors.Control; public Color Foreground { get; set; } = SystemColors.ControlText; @@ -273,7 +273,7 @@ public void SetToAddresses(IEnumerable addresses, MemoryDomain domain, Wat DataSize = (int)size; SetDataSize(DataSize); var addrList = addresses.ToList(); - if (addrList.Any()) + if (addrList.Count != 0) { SetMemoryDomain(domain.Name); SetHighlighted(addrList[0]); @@ -287,7 +287,7 @@ public void SetToAddresses(IEnumerable addresses, MemoryDomain domain, Wat public byte[] ConvertTextToBytes(string str) { - if (_textTable.Any()) + if (_textTable.Count != 0) { var byteArr = new byte[str.Length]; for (var i = 0; i < str.Length; i++) @@ -699,7 +699,7 @@ private void SetMemoryDomain(string name) : SystemColors.ControlDarkDark; if (_highlightedAddress >= _domain.Size - || (_secondaryHighlightedAddresses.Any() && _secondaryHighlightedAddresses.Max() >= _domain.Size)) + || (_secondaryHighlightedAddresses.Count != 0 && _secondaryHighlightedAddresses.Max() >= _domain.Size)) { _highlightedAddress = null; _secondaryHighlightedAddresses.Clear(); @@ -715,7 +715,7 @@ private void UpdateGroupBoxTitle() { var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0'); var viewerText = $"{Emulator.SystemId} {_domain}{(_domain.Writable ? string.Empty : " (READ-ONLY)")} - {addressesString} addresses"; - if (_nibbles.Any()) + if (_nibbles.Count != 0) { viewerText += $" Typing: ({MakeNibbles()})"; } @@ -786,7 +786,7 @@ private void UpdateFormText() { var newTitle = "Hex Editor"; newTitle += " - Editing Address 0x" + string.Format(_numDigitsStr, _highlightedAddress); - if (_secondaryHighlightedAddresses.Any()) + if (_secondaryHighlightedAddresses.Count != 0) { newTitle += $" (Selected 0x{_secondaryHighlightedAddresses.Count + (_secondaryHighlightedAddresses.Contains(_highlightedAddress.Value) ? 0 : 1):X})"; } @@ -850,7 +850,7 @@ private bool IsFrozen(long address) private void FreezeHighlighted() { - if (!_highlightedAddress.HasValue && !_secondaryHighlightedAddresses.Any()) + if (!_highlightedAddress.HasValue && _secondaryHighlightedAddresses.Count == 0) { return; } @@ -870,7 +870,7 @@ private void FreezeHighlighted() watch.Value)); } - if (_secondaryHighlightedAddresses.Any()) + if (_secondaryHighlightedAddresses.Count != 0) { foreach (var address in _secondaryHighlightedAddresses) { @@ -894,7 +894,7 @@ private void FreezeHighlighted() private void UnfreezeHighlighted() { - if (!_highlightedAddress.HasValue && !_secondaryHighlightedAddresses.Any()) + if (!_highlightedAddress.HasValue && _secondaryHighlightedAddresses.Count == 0) { return; } @@ -904,7 +904,7 @@ private void UnfreezeHighlighted() MainForm.CheatList.RemoveRange(MainForm.CheatList.Where(x => x.Contains(_highlightedAddress.Value))); } - if (_secondaryHighlightedAddresses.Any()) + if (_secondaryHighlightedAddresses.Count != 0) { MainForm.CheatList.RemoveRange( MainForm.CheatList.Where(cheat => !cheat.IsSeparator && cheat.Domain == _domain @@ -1265,7 +1265,7 @@ private void FileSubMenu_DropDownOpened(object sender, EventArgs e) SaveAsBinaryMenuItem.Text = "Save as binary..."; } - CloseTableFileMenuItem.Enabled = _textTable.Any(); + CloseTableFileMenuItem.Enabled = _textTable.Count != 0; } private void SaveMenuItem_Click(object sender, EventArgs e) @@ -1371,7 +1371,7 @@ private void EditMenuItem_DropDownOpened(object sender, EventArgs e) var data = Clipboard.GetDataObject(); PasteMenuItem.Enabled = _domain.Writable - && (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any()) + && (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Count != 0) && data != null && data.GetDataPresent(DataFormats.Text); @@ -1599,7 +1599,7 @@ private void GoToAddressMenuItem_Click(object sender, EventArgs e) private void AddToRamWatchMenuItem_Click(object sender, EventArgs e) { - if (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any()) + if (_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Count != 0) { Tools.LoadRamWatch(true); } @@ -1655,12 +1655,12 @@ private void PokeAddressMenuItem_Click(object sender, EventArgs e) addresses.Add(_highlightedAddress.Value); } - if (_secondaryHighlightedAddresses.Any()) + if (_secondaryHighlightedAddresses.Count != 0) { addresses.AddRange(_secondaryHighlightedAddresses); } - if (addresses.Any()) + if (addresses.Count != 0) { var watches = addresses.Select( address => Watch.GenerateWatch( @@ -1961,7 +1961,7 @@ private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e) { var data = Clipboard.GetDataObject(); - var selectionNotEmpty = _highlightedAddress is not null || _secondaryHighlightedAddresses.Any(); + var selectionNotEmpty = _highlightedAddress is not null || _secondaryHighlightedAddresses.Count != 0; CopyContextItem.Visible = AddToRamWatchContextItem.Visible = selectionNotEmpty; FreezeContextItem.Visible = PokeContextItem.Visible @@ -2176,11 +2176,7 @@ private void AddressesLabel_MouseDown(object sender, MouseEventArgs e) { ClearHighlighted(); } - else if (_secondaryHighlightedAddresses.Contains(pointedAddress)) - { - _secondaryHighlightedAddresses.Remove(pointedAddress); - } - else + else if (!_secondaryHighlightedAddresses.Remove(pointedAddress)) { _secondaryHighlightedAddresses.Add(pointedAddress); } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index f2bb6d35f27..e64e425cfc2 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -16,7 +16,7 @@ namespace BizHawk.Client.EmuHawk [LuaLibrary(released: true)] public sealed class TAStudioLuaLibrary : LuaLibraryBase { - private static readonly IDictionary _iconCache = new Dictionary(); + private static readonly Dictionary _iconCache = new Dictionary(); public ToolManager Tools { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs index 0c0a6477f12..bce97516c1d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaButton.cs @@ -2,7 +2,7 @@ namespace BizHawk.Client.EmuHawk { - internal class LuaButton : Button + internal sealed class LuaButton : Button { protected override void OnClick(EventArgs e) { diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 1e13fe4e106..7e14bac5d7c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -940,7 +940,7 @@ private void EditScriptMenuItem_Click(object sender, EventArgs e) private void RemoveScriptMenuItem_Click(object sender, EventArgs e) { var items = SelectedItems.ToList(); - if (items.Any()) + if (items.Count != 0) { foreach (var item in items) { @@ -1202,10 +1202,10 @@ private void ScriptListContextMenu_Opening(object sender, CancelEventArgs e) private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e) { RegisteredFunctionsContextItem.Enabled = LuaImp.RegisteredFunctions.Any(); - CopyContextItem.Enabled = OutputBox.SelectedText.Any(); + CopyContextItem.Enabled = OutputBox.SelectedText.Length != 0; ClearConsoleContextItem.Enabled = SelectAllContextItem.Enabled = - OutputBox.Text.Any(); + OutputBox.Text.Length != 0; ClearRegisteredFunctionsLogContextItem.Enabled = LuaImp.RegisteredFunctions.Any(); diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs index 3de83611529..7ea9e6bc2ef 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs @@ -92,7 +92,7 @@ private void FunctionView_ColumnClick(object sender, ColumnClickEventArgs e) OrderColumn(e.Column); } - private class Sorting + private sealed class Sorting { private int _column = 1; diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs index 5ac0a3922f9..ead821b62bf 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs @@ -166,7 +166,7 @@ void EnumerateLuaFunctions(string name, Type type, LuaLibraryBase instance) public bool IsInInputOrMemoryCallback { get; set; } - private readonly IDictionary Libraries = new Dictionary(); + private readonly Dictionary Libraries = new Dictionary(); private EventWaitHandle LuaWait; diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaTextBox.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaTextBox.cs index d67658db6de..f3c6efee292 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaTextBox.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaTextBox.cs @@ -10,7 +10,7 @@ internal enum BoxType All, Signed, Unsigned, Hex } - internal class LuaTextBox : TextBox + internal sealed class LuaTextBox : TextBox { private BoxType _boxType = BoxType.All; diff --git a/src/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs b/src/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs index 6a6c9aefcc7..3e3d2154f78 100644 --- a/src/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs +++ b/src/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs @@ -94,7 +94,7 @@ private struct NoiseState public int Note; } - private class ApuState + private sealed class ApuState { public PulseState Pulse0; public PulseState Pulse1; diff --git a/src/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs b/src/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs index edf80338169..64951597496 100644 --- a/src/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs @@ -152,7 +152,7 @@ protected override void UpdateAfter() lvChannels.EndUpdate(); } - private class PsgEntry + private sealed class PsgEntry { public int Index { get; set; } public bool Active { get; set; } diff --git a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 1e893c75eb7..6d052011ada 100644 --- a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -505,7 +505,7 @@ private static SNESGraphicsDecoder.BGMode BGModeForDisplayType(eDisplayType type } } - private class DisplayTypeItem + private sealed class DisplayTypeItem { public eDisplayType Type { get; } public string Descr { get; } @@ -516,7 +516,7 @@ public DisplayTypeItem(string descr, eDisplayType type) } } - private class PaletteTypeItem + private sealed class PaletteTypeItem { public SnesColors.ColorType Type { get; } public string Descr { get; } @@ -930,7 +930,7 @@ private void viewer_MouseMove(object sender, MouseEventArgs e) } } - private class MapEntryState + private sealed class MapEntryState { public SNESGraphicsDecoder.TileEntry entry; public int bgnum; @@ -938,7 +938,7 @@ private class MapEntryState } private MapEntryState currMapEntryState; - private class TileDataState + private sealed class TileDataState { public eDisplayType Type; public int Bpp; @@ -948,7 +948,7 @@ private class TileDataState } private TileDataState currTileDataState; - private class ObjDataState + private sealed class ObjDataState { public int Number; } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index 293bdd2957f..e2a5fbce685 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -124,7 +124,7 @@ private void QueryItemBkColor(int index, RollColumn column, ref Color color) // used to capture a reserved state immediately on branch creation // while also not doing a double state - private class BufferedStatable : IStatable + private sealed class BufferedStatable : IStatable { private readonly byte[] _bufferedState; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 6e05848efca..1a3b2009920 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -1387,7 +1387,7 @@ public void EditAnalogProgrammatically(KeyEventArgs e) } } - if (_extraAxisRows.Any()) + if (_extraAxisRows.Count != 0) { foreach (int row in _extraAxisRows) { diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index a2d506b2a54..3d01554453c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -938,7 +938,7 @@ private void SetSplicer() // TODO: columns selected? var selectedRowCount = TasView.SelectedRows.Count(); var temp = $"Selected: {selectedRowCount} {(selectedRowCount == 1 ? "frame" : "frames")}, States: {CurrentTasMovie.TasStateManager.Count}"; - if (_tasClipboard.Any()) temp += $", Clipboard: {_tasClipboard.Count} {(_tasClipboard.Count == 1 ? "frame" : "frames")}"; + if (_tasClipboard.Count != 0) temp += $", Clipboard: {_tasClipboard.Count} {(_tasClipboard.Count == 1 ? "frame" : "frames")}"; SplicerStatusLabel.Text = temp; } diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs index e4c112499d9..9d80823da91 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -793,7 +793,7 @@ public void FastUpdateAfter() } } - private static readonly IList PossibleToolTypeNames = EmuHawk.ReflectionCache.Types.Select(t => t.AssemblyQualifiedName).ToList(); + private static readonly List PossibleToolTypeNames = EmuHawk.ReflectionCache.Types.Select(t => t.AssemblyQualifiedName).ToList(); public bool IsAvailable(Type tool) { diff --git a/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index fbd279661e7..3379160d769 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -125,7 +125,7 @@ private void TraceLogger_Load(object sender, EventArgs e) SetTracerBoxTitle(); } - private class CallbackSink : ITraceSink + private sealed class CallbackSink : ITraceSink { public void Put(TraceInfo info) { @@ -241,7 +241,7 @@ private void SetTracerBoxTitle() { TracerBox.Text = "Trace log - logging to file..."; } - else if (_instructions.Any()) + else if (_instructions.Count != 0) { TracerBox.Text = $"Trace log - logging - {_instructions.Count} instructions"; } @@ -252,7 +252,7 @@ private void SetTracerBoxTitle() } else { - if (_instructions.Any()) + if (_instructions.Count != 0) { TracerBox.Text = $"Trace log - {_instructions.Count} instructions"; } diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index e1e81378144..1130d10ded9 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -812,7 +812,7 @@ private void SetToFastMode() private void RemoveAddresses() { var indices = SelectedIndices.ToList(); - if (indices.Any()) + if (indices.Count != 0) { SetRemovedMessage(indices.Count); _searches.RemoveRange(indices); @@ -865,7 +865,7 @@ private void LoadWatchFile(FileInfo file, bool append, bool truncate = false) private void AddToRamWatch() { var watches = SelectedWatches.ToList(); - if (watches.Any()) + if (watches.Count != 0) { Tools.LoadRamWatch(true); watches.ForEach(Tools.RamWatch.AddWatch); diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index b3cb6a3fdd3..dba8a5fb7c3 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -327,7 +327,7 @@ private void MinimalUpdate() return; } - if (_watches.Any()) + if (_watches.Count != 0) { _watches.UpdateValues(Config.RamWatchDefinePrevious); DisplayOnScreenWatches(); @@ -342,7 +342,7 @@ private void FrameUpdate() } DisplayManager.OSD.ClearRamWatches(); - if (_watches.Any()) + if (_watches.Count != 0) { _watches.UpdateValues(Config.RamWatchDefinePrevious); DisplayOnScreenWatches(); @@ -898,7 +898,7 @@ private void ClearChangeCountsMenuItem_Click(object sender, EventArgs e) private void MoveUpMenuItem_Click(object sender, EventArgs e) { var indexes = SelectedIndices.ToList(); - if (!indexes.Any() || indexes[0] == 0) + if (indexes.Count == 0 || indexes[0] == 0) { return; } @@ -954,7 +954,7 @@ private void MoveDownMenuItem_Click(object sender, EventArgs e) private void MoveTopMenuItem_Click(object sender, EventArgs e) { var indexes = SelectedIndices.ToList(); - if (!indexes.Any()) + if (indexes.Count == 0) { return; } @@ -1177,7 +1177,7 @@ private void UnfreezeAllContextMenuItem_Click(object sender, EventArgs e) private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e) { var selected = SelectedWatches.ToList(); - if (selected.Any()) + if (selected.Count != 0) { Tools.Load(); ViewInHexEditor( @@ -1193,7 +1193,7 @@ private void ReadBreakpointContextMenuItem_Click(object sender, EventArgs e) { var selected = SelectedWatches.ToList(); - if (selected.Any()) + if (selected.Count != 0) { var debugger = Tools.Load(); @@ -1208,7 +1208,7 @@ private void WriteBreakpointContextMenuItem_Click(object sender, EventArgs e) { var selected = SelectedWatches.ToList(); - if (selected.Any()) + if (selected.Count != 0) { var debugger = Tools.Load(); diff --git a/src/BizHawk.Common/Log.cs b/src/BizHawk.Common/Log.cs index 8689e91ad14..c5a4d7e0c5e 100644 --- a/src/BizHawk.Common/Log.cs +++ b/src/BizHawk.Common/Log.cs @@ -31,10 +31,7 @@ public static void EnableDomain(string domain) public static void DisableDomain(string domain) { - if (EnabledLogDomains.Contains(domain)) - { - EnabledLogDomains.Remove(domain); - } + EnabledLogDomains.Remove(domain); } // -------------- Logging Action Configuration -------------- diff --git a/src/BizHawk.Common/OSTailoredCode.cs b/src/BizHawk.Common/OSTailoredCode.cs index 3449f7d8b4c..b4e6d51aa13 100644 --- a/src/BizHawk.Common/OSTailoredCode.cs +++ b/src/BizHawk.Common/OSTailoredCode.cs @@ -143,7 +143,7 @@ public interface ILinkedLibManager string GetErrorMessage(); } - private class LinuxLLManager : ILinkedLibManager + private sealed class LinuxLLManager : ILinkedLibManager { public int FreeByPtr(IntPtr hModule) => LinuxDlfcnImports.dlclose(hModule); @@ -176,7 +176,7 @@ public string GetErrorMessage() // this is just a copy paste of LinuxLLManager using PosixDlfcnImports instead of LinuxDlfcnImports // TODO: probably could do some OOP magic so there isn't just a copy paste here - private class PosixLLManager : ILinkedLibManager + private sealed class PosixLLManager : ILinkedLibManager { public int FreeByPtr(IntPtr hModule) => PosixDlfcnImports.dlclose(hModule); @@ -207,7 +207,7 @@ public string GetErrorMessage() } } - private class WindowsLLManager : ILinkedLibManager + private sealed class WindowsLLManager : ILinkedLibManager { public int FreeByPtr(IntPtr hModule) => FreeLibrary(hModule) ? 0 : 1; diff --git a/src/BizHawk.Common/SpanStream.cs b/src/BizHawk.Common/SpanStream.cs index b8959d89f46..c4110ca2704 100644 --- a/src/BizHawk.Common/SpanStream.cs +++ b/src/BizHawk.Common/SpanStream.cs @@ -19,7 +19,7 @@ public static ISpanStream GetOrBuild(Stream s) return s as ISpanStream ?? new SpanStreamAdapter(s); } - private class SpanStreamAdapter : ISpanStream + private sealed class SpanStreamAdapter : ISpanStream { public SpanStreamAdapter(Stream stream) { diff --git a/src/BizHawk.Common/UndoHistory.cs b/src/BizHawk.Common/UndoHistory.cs index 88969c92fba..e4b30279cb7 100644 --- a/src/BizHawk.Common/UndoHistory.cs +++ b/src/BizHawk.Common/UndoHistory.cs @@ -12,7 +12,7 @@ public class UndoHistory /// private int _curPos; - private readonly IList _history = new List(); + private readonly List _history = new List(); public bool CanRedo => Enabled && _curPos < _history.Count; diff --git a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 0628d67ce43..ed944262509 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -65,7 +65,7 @@ public ITraceSink? Sink public string Header { get; } #nullable disable - private class TracingMemoryCallback : IMemoryCallback + private sealed class TracingMemoryCallback : IMemoryCallback { public TracingMemoryCallback(MemoryCallbackDelegate callback, string scope) { diff --git a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 999ba29d813..0cb1c1defc3 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -166,7 +166,7 @@ public int PlayerCount public bool Any() { - return BoolButtons.Any() || Axes.Any(); + return BoolButtons.Any() || Axes.Count != 0; } } } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/LinkedMemoryDomains.cs b/src/BizHawk.Emulation.Common/Base Implementations/LinkedMemoryDomains.cs index 23047f428fe..e61facd5284 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/LinkedMemoryDomains.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/LinkedMemoryDomains.cs @@ -34,7 +34,7 @@ private static List LinkMemoryDomains(IEmulator[] linkedCores, int return mm; } - private class WrappedMemoryDomain : MemoryDomain + private sealed class WrappedMemoryDomain : MemoryDomain { private readonly MemoryDomain _m; @@ -54,7 +54,7 @@ public WrappedMemoryDomain(string name, MemoryDomain m) public override void PokeByte(long addr, byte val) => _m.PokeByte(addr, val); } - private class LinkedSystemBus : MemoryDomain + private sealed class LinkedSystemBus : MemoryDomain { private readonly MemoryDomain[] _linkedSystemBuses; private readonly LinkedDisassemblable _linkedDisassemblable; diff --git a/src/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs b/src/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs index d9af496981b..5e676c8d503 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs @@ -250,7 +250,7 @@ public MemoryCallback(string scope, MemoryCallbackType type, string name, Memory /// /// Reentrancy from ItemAdded and ItemRemoved events is not allowed. /// - internal class MemoryCallbackCollection : IReadOnlyCollection + internal sealed class MemoryCallbackCollection : IReadOnlyCollection { private List _items = new(); private int _copyOnWriteRequired = 0; diff --git a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs index 402d2202330..65b69355105 100644 --- a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs +++ b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs @@ -63,7 +63,7 @@ public static ControllerDefinition GetMerged( public class ControlDefUnMerger { - private class DummyController : IController + private sealed class DummyController : IController { private readonly IReadOnlyDictionary _buttonAxisRemaps; diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index 4cf2de773a8..6fe199972fc 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -26,7 +26,7 @@ public static class Database private static string _bundledRoot = null; - private static IList _expected = null; + private static List _expected = null; private static string _userRoot = null; @@ -482,7 +482,9 @@ public static GameInfo GetGameInfo(byte[] romData, string fileName) game.Name = Path.GetFileNameWithoutExtension(fileName)?.Replace('_', ' '); // If filename is all-caps, then attempt to proper-case the title. +#pragma warning disable CA1862 // incorrect detection, see https://github.com/dotnet/roslyn-analyzers/issues/7074 if (!string.IsNullOrWhiteSpace(game.Name) && game.Name == game.Name.ToUpperInvariant()) +#pragma warning restore CA1862 { game.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(game.Name.ToLowerInvariant()); } diff --git a/src/BizHawk.Emulation.Common/filetype_detectors/SatellaviewFileTypeDetector.cs b/src/BizHawk.Emulation.Common/filetype_detectors/SatellaviewFileTypeDetector.cs index 1d7d8cc1a2a..998eb53d2e2 100644 --- a/src/BizHawk.Emulation.Common/filetype_detectors/SatellaviewFileTypeDetector.cs +++ b/src/BizHawk.Emulation.Common/filetype_detectors/SatellaviewFileTypeDetector.cs @@ -99,7 +99,7 @@ public bool VerifyChecksum(ReadOnlySpan rom) private const int THRESHOLD = 3; - private static bool CheckHeaderHeuristics(bool checkHiROM, ReadOnlySpan rom, IList warnings) + private static bool CheckHeaderHeuristics(bool checkHiROM, ReadOnlySpan rom, List warnings) { SatellaviewHeader header = new(rom.Slice(start: checkHiROM ? 0xFFB0 : 0x7FB0, length: HEADER_LENGTH)); var corruption = 0; diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.ComponentModel.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.ComponentModel.cs index 9a95ee2994c..b37b1d3fe8d 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.ComponentModel.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.ComponentModel.cs @@ -134,7 +134,7 @@ public override void SetValue(object component, object value) ((MAMESyncSettings)component).DriverSettings[Setting.LookupKey] = s; } - private class MyTypeConverter : TypeConverter + private sealed class MyTypeConverter : TypeConverter { public MyTypeConverter(DriverSetting setting) => Setting = setting; @@ -151,4 +151,4 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul => Setting.Options[(string)value] ?? Setting.Options[Setting.DefaultValue]; } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs index a2b5e39ce20..df117a06289 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.ISettable.cs @@ -101,7 +101,7 @@ public void FetchDefaultGameSettings() setting.Options.Add(opt[0], opt[1]); } - if (options.Any()) + if (options.Length != 0) { CurrentDriverSettings.Add(setting); } diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index c5fba2de3d1..bffe515f808 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -263,7 +263,7 @@ string MakeFileName(IRomAsset rom) foreach (var rom in roms) { // only close non-chd files - if (rom.Extension.ToLowerInvariant() != ".chd") + if (!rom.Extension.Equals(".chd", StringComparison.OrdinalIgnoreCase)) { _exe.RemoveReadonlyFile(MakeFileName(rom)); } diff --git a/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs b/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs index 203fb7b8d79..5d0cdfd3947 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs @@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Cores.Components.W65816 { - internal class W65816_DisassemblerService : IDisassemblable + internal sealed class W65816_DisassemblerService : IDisassemblable { public string Cpu { get; set; } @@ -27,7 +27,7 @@ public string Disassemble(MemoryDomain m, uint addr, out int length) /// The DisPel software is unlicensed, and is thus assumed to be copyrighted without any transfer of rights. /// This reproduction is made with the assumption that it cannot be infringing because every part of its structure is necessary for its function (in the US, scènes à faire). /// - internal class W65816 + internal sealed class W65816 { //unsigned char *mem, unsigned long pos, unsigned char *flag, char *inst, unsigned char tsrc //TODO - what ha ppens at the end of memory? make sure peek wraps around? diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs index 468b25b28f4..1799b676bfa 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs @@ -80,7 +80,7 @@ public int CurrentDataBlockIndex { get { - if (DataBlocks.Any()) + if (DataBlocks.Count != 0) { return _currentDataBlockIndex; } diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs index 37381369288..00e3bb79e49 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs @@ -677,7 +677,7 @@ public enum SkipDirection /// /// Class that holds information about a specific command /// - private class Command + private sealed class Command { // /// // /// Mask to remove potential parameter bits (5,6, and or 7) in order to identify the command diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs index 242c42db66e..4f75ede9ab7 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// internal sealed class SoundProviderMixer : ISoundProvider { - private class Provider + private sealed class Provider { public ISoundProvider SoundProvider { get; set; } public string ProviderDescription { get; set; } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs index a2dec44f0cc..8d5feaedbef 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000A.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge // to pull down EXROM. Also, accesses to LOROM while it is active // discharge the capacitor. // Thanks to VICE team for the info: http://vice-emu.sourceforge.net/vice_15.html - internal class Mapper000A : CartridgeDevice + internal sealed class Mapper000A : CartridgeDevice { // This constant differs depending on whose research you reference. TODO: Verify. private const int RESET_CAPACITOR_CYCLES = 512; diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0011.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0011.cs index 1f5e67489d9..d508a540259 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0011.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0011.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge // to the System 3 mapper (000F) except that bank switching is // done by reads to the DExx region instead of writes. // This is why mapper 0011 inherits directly from 000F. - internal class Mapper0011 : Mapper000F + internal sealed class Mapper0011 : Mapper000F { public Mapper0011(IList newAddresses, IList newBanks, IList newData) : base(newAddresses, newBanks, newData) diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs index 4bc455c97a9..d53af14d6d8 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper002B.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge // 32 banks of 8KB. // DFxx = status register, xxABBBBB. A=enable cart, B=bank // Thanks to VICE team for the info: http://vice-emu.sourceforge.net/vice_15.html - internal class Mapper002B : CartridgeDevice + internal sealed class Mapper002B : CartridgeDevice { private readonly int[] _rom; diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs index 5f66138ee5e..147366a4f11 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs @@ -677,7 +677,7 @@ public enum SkipDirection /// /// Class that holds information about a specific command /// - private class Command + private sealed class Command { // /// // /// Mask to remove potential parameter bits (5,6, and or 7) in order to identify the command diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Screen.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Screen.cs index 31e01296d1d..fb40122bc6e 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Screen.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Screen.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// 128K/+2 ULA /// - internal class ScreenPentagon128 : ULA + internal sealed class ScreenPentagon128 : ULA { public ScreenPentagon128(SpectrumBase machine) : base(machine) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Screen.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Screen.cs index 37e3a4b8a16..4e04adb730b 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Screen.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Screen.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// 128K/+2 ULA /// - internal class Screen128 : ULA + internal sealed class Screen128 : ULA { public Screen128(SpectrumBase machine) : base(machine) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs index 243581e569e..54602bb36f8 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs @@ -616,7 +616,7 @@ public override void InitROM(RomData romData) ROM 2: +3DOS ROM 3: 48 BASIC */ - Stream stream = new MemoryStream(RomData.RomBytes); + MemoryStream stream = new MemoryStream(RomData.RomBytes); stream.Read(ROM0, 0, 16384); stream.Read(ROM1, 0, 16384); stream.Read(ROM2, 0, 16384); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Screen.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Screen.cs index f3f2e6444d1..e58436a1694 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Screen.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Screen.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// +2A/+3 ULA /// - internal class Screen128Plus2a : ULA + internal sealed class Screen128Plus2a : ULA { public Screen128Plus2a(SpectrumBase machine) : base(machine) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs index ca174ac9036..3cf02d4da7f 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs @@ -617,7 +617,7 @@ public override void InitROM(RomData romData) ROM 2: +3DOS ROM 3: 48 BASIC */ - Stream stream = new MemoryStream(RomData.RomBytes); + MemoryStream stream = new MemoryStream(RomData.RomBytes); stream.Read(ROM0, 0, 16384); stream.Read(ROM1, 0, 16384); stream.Read(ROM2, 0, 16384); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Screen.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Screen.cs index 05981d8e15a..4e0e85fdc39 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Screen.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Screen.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// 48K ULA /// - internal class Screen48 : ULA + internal sealed class Screen48 : ULA { public Screen48(SpectrumBase machine) : base(machine) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs index defd68480f2..8c74fc43f81 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs @@ -57,7 +57,7 @@ public override bool CheckType(byte[] data) int majorVer = data[8]; int minorVer = data[9]; - if (ident.ToUpperInvariant() != "COMPRESSED SQUARE WAVE") + if (!ident.Equals("COMPRESSED SQUARE WAVE", StringComparison.OrdinalIgnoreCase)) { // this is not a valid CSW format file return false; @@ -80,7 +80,7 @@ public override void Read(byte[] data) // (first 22 bytes of the file) string ident = Encoding.ASCII.GetString(data, 0, 22); - if (ident.ToUpperInvariant() != "COMPRESSED SQUARE WAVE") + if (!ident.Equals("COMPRESSED SQUARE WAVE", StringComparison.OrdinalIgnoreCase)) { // this is not a valid CSW format file throw new Exception($"{nameof(CswConverter)}: This is not a valid CSW format file"); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs index 22f69db2301..41a0fef8162 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs @@ -67,7 +67,7 @@ public override bool CheckType(byte[] data) int majorVer = data[8]; int minorVer = data[9]; - if (ident.ToUpperInvariant() != "PZXT") + if (!ident.Equals("PZXT", StringComparison.OrdinalIgnoreCase)) { // this is not a valid PZX format file return false; @@ -96,7 +96,7 @@ 8 u8[size] data arbitrary amount of block data. // check whether this is a valid pzx format file by looking at the identifier in the header block string ident = Encoding.ASCII.GetString(data, 0, 4); - if (ident.ToUpperInvariant() != "PZXT") + if (!ident.Equals("PZXT", StringComparison.OrdinalIgnoreCase)) { // this is not a valid TZX format file throw new Exception($"{nameof(PzxConverter)}: This is not a valid PZX format file"); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs index 20187fb095e..6823412a72b 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs @@ -50,7 +50,7 @@ public override bool CheckType(byte[] data) // check whether this is a valid wav format file by looking at the identifier in the header string ident = Encoding.ASCII.GetString(data, 8, 4); - if (ident.ToUpperInvariant() != "WAVE") + if (!ident.Equals("WAVE", StringComparison.OrdinalIgnoreCase)) { // this is not a valid WAV format file return false; @@ -72,7 +72,7 @@ public override void Read(byte[] data) // check whether this is a valid pzx format file by looking at the identifier in the header block string ident = Encoding.ASCII.GetString(data, 8, 4); - if (ident.ToUpperInvariant() != "WAVE") + if (!ident.Equals("WAVE", StringComparison.OrdinalIgnoreCase)) { // this is not a valid TZX format file throw new Exception($"{nameof(WavConverter)}: This is not a valid WAV format file"); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs index 72ef083e686..04265d5278c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs @@ -232,12 +232,12 @@ private static string DetectMapper(byte[] rom) return "UNKNOWN"; } - private static bool IsProbablySC(IList rom) + private static bool IsProbablySC(byte[] rom) { // We assume a Superchip cart contains the same bytes for its entire // RAM area; obviously this test will fail if it doesn't // The RAM area will be the first 256 bytes of each 4K bank - var numBanks = rom.Count / 4096; + var numBanks = rom.Length / 4096; for (var i = 0; i < numBanks; i++) { var first = rom[i * 4096]; @@ -273,12 +273,12 @@ private static bool IsProbably3F(byte[] rom) }); } - private static bool IsProbably4A50(IList rom) + private static bool IsProbably4A50(byte[] rom) { // 4A50 carts store address $4A50 at the NMI vector, which // in this scheme is always in the last page of ROM at // $1FFA - $1FFB (at least this is true in rev 1 of the format) - if (rom[rom.Count - 6] == 0x50 && rom[rom.Count - 5] == 0x4A) + if (rom[rom.Length - 6] == 0x50 && rom[rom.Length - 5] == 0x4A) { return true; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs index df0d12f4565..18ef8e77bf6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs @@ -72,7 +72,7 @@ public void LoadStateBinary(BinaryReader reader) private readonly JsonSerializer _ser = new JsonSerializer { Formatting = Formatting.Indented }; private readonly byte[] _saveBuff; - private class TextStateData + private sealed class TextStateData { public int Frame; public int LagCount; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs index b90678a3adf..a27c3eefb85 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs @@ -122,7 +122,7 @@ public Encore(CoreLoadParameters lp) _serviceProvider.Register(_encoreVideoProvider); var romPath = lp.Roms[0].RomPath; - if (lp.Roms[0].Extension.ToLowerInvariant() == ".cia") + if (lp.Roms[0].Extension.Equals(".cia", StringComparison.OrdinalIgnoreCase)) { var message = new byte[1024]; var res = _core.Encore_InstallCIA(_context, romPath, message, message.Length); @@ -145,7 +145,7 @@ public Encore(CoreLoadParameters lp) for (var i = 1; i < lp.Roms.Count; i++) { // doesn't make sense if not a CIA - if (lp.Roms[i].Extension.ToLowerInvariant() != ".cia") + if (!lp.Roms[i].Extension.Equals(".cia", StringComparison.OrdinalIgnoreCase)) { Dispose(); throw new("ROMs after the index 0 should be CIAs"); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs index 6d0b6d2f059..061cf2aff87 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesControllers.cs @@ -81,7 +81,7 @@ public interface IBsnesController ControllerDefinition Definition { get; } } - internal class BsnesUnpluggedController : IBsnesController + internal sealed class BsnesUnpluggedController : IBsnesController { private static readonly ControllerDefinition _definition = new("(SNES Controller fragment)"); @@ -90,7 +90,7 @@ internal class BsnesUnpluggedController : IBsnesController public short GetState(IController controller, int index, int id) => 0; } - internal class BsnesController : IBsnesController + internal sealed class BsnesController : IBsnesController { private static readonly string[] Buttons = { @@ -128,7 +128,7 @@ public short GetState(IController controller, int index, int id) return (short) (controller.IsPressed(Buttons[id]) ? 1 : 0); } } - internal class BsnesExtendedController : IBsnesController + internal sealed class BsnesExtendedController : IBsnesController { private static readonly string[] Buttons = { @@ -171,7 +171,7 @@ public short GetState(IController controller, int index, int id) } } - internal class BsnesMouseController : IBsnesController + internal sealed class BsnesMouseController : IBsnesController { private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } } @@ -208,7 +208,7 @@ public short GetState(IController controller, int index, int id) } } - internal class BsnesMultitapController : IBsnesController + internal sealed class BsnesMultitapController : IBsnesController { private static readonly string[] Buttons = { @@ -253,7 +253,7 @@ public short GetState(IController controller, int index, int id) /// /// "Virtual" controller that behaves like a multitap controller, but with 16 instead of 12 buttons per controller. /// - internal class BsnesPayloadController : IBsnesController + internal sealed class BsnesPayloadController : IBsnesController { private static readonly string[] Buttons = { @@ -299,7 +299,7 @@ public short GetState(IController controller, int index, int id) } } - internal class BsnesSuperScopeController : IBsnesController + internal sealed class BsnesSuperScopeController : IBsnesController { private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause", "0Offscreen" } } @@ -322,7 +322,7 @@ public short GetState(IController controller, int index, int id) } } - internal class BsnesJustifierController : IBsnesController + internal sealed class BsnesJustifierController : IBsnesController { public BsnesJustifierController(bool chained) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SNESGraphicsDecoder.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SNESGraphicsDecoder.cs index f89217476db..1d8ada6923b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SNESGraphicsDecoder.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SNESGraphicsDecoder.cs @@ -592,7 +592,7 @@ public void SetBackColor(int snescol) } } - internal class OAMInfo : ISNESGraphicsDecoder.OAMInfo + internal sealed class OAMInfo : ISNESGraphicsDecoder.OAMInfo { public ushort X { get; } public byte Y { get; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAMemoryCallbackSystem.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAMemoryCallbackSystem.cs index 21e666ba570..9f91b90f542 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAMemoryCallbackSystem.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAMemoryCallbackSystem.cs @@ -207,7 +207,7 @@ public void Dispose() _core = IntPtr.Zero; } - private class CallbackContainer + private sealed class CallbackContainer { public CallbackContainer(IMemoryCallback callBack) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index 3dfe82e6bfe..fee73fb7e97 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -282,7 +282,7 @@ public IGPUMemoryAreas LockGPU() ); } - private class GPUMemoryAreas : IGPUMemoryAreas + private sealed class GPUMemoryAreas : IGPUMemoryAreas { public IntPtr Vram { get; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs index 822a5f9c191..6517fb62221 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // this occurs when the Boot Rom is loading the nintendo logo into VRAM // instead of tracking that in the main memory map where it will just slow things down for no reason // we'll clear the 'locked' flag when the last byte of the logo is read - internal class MapperSachen1 : MapperBase + internal sealed class MapperSachen1 : MapperBase { public int ROM_bank; public bool locked; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs index 51a67cb770c..4c3371b32f4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // this occurs when the Boot Rom is loading the nintendo logo into VRAM // instead of tracking that in the main memory map where it will just slow things down for no reason // we'll clear the 'locked' flag when the last byte of the logo is read - internal class MapperSachen2 : MapperBase + internal sealed class MapperSachen2 : MapperBase { public int ROM_bank; public bool locked, locked_GBC, finished; @@ -219,4 +219,4 @@ public override void SyncState(Serializer ser) ser.Sync(nameof(counter), ref counter); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs index adae5f4dd05..c1627fcda9e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs @@ -35,7 +35,7 @@ public IDictionary GetCpuFlagsAndRegisters() public void SetCpuRegister(string register, int value) { - if (register.Length == 9 && register.Substring(4, 5).ToUpperInvariant() == " BANK") + if (register.Length == 9 && register.Substring(4, 5).Equals(" BANK", StringComparison.OrdinalIgnoreCase)) { var type = (LibGambatte.BankType)Enum.Parse(typeof(LibGambatte.BankType), register.Substring(0, 4).ToUpperInvariant()); LibGambatte.gambatte_setbank(GambatteState, type, value); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs index 3350697e027..1a2fd3f81fe 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs @@ -97,7 +97,7 @@ private void NewSaveCoreSetBuff() private readonly JsonSerializer _ser = new() { Formatting = Formatting.Indented }; // other data in the text state besides core - internal class TextStateData + internal sealed class TextStateData { public int Frame; public int LagCount; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index e6c18eb3c42..07f536ce36c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -641,7 +641,7 @@ public IGPUMemoryAreas LockGPU() }; } - private class GPUMemoryAreas : IGPUMemoryAreas + private sealed class GPUMemoryAreas : IGPUMemoryAreas { public IntPtr Vram { get; init; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs index 3817e78acac..7019d431420 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs @@ -99,7 +99,7 @@ public void LoadStateBinary(BinaryReader reader) private readonly JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented }; - private class GBLSerialized + private sealed class GBLSerialized { public int NumCores; public TextState[] LinkedStates; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs index 23981348be2..ea4974a106c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs @@ -12,7 +12,7 @@ public partial class N64 { private readonly List _memoryDomains = new List(); - private IMemoryDomains MemoryDomains; + private MemoryDomainList MemoryDomains; private void MakeMemoryDomain(string name, mupen64plusApi.N64_MEMORY id, MemoryDomain.Endian endian, bool swizzled = false) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs index 58395a637da..654b77467b8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 { - internal class N64Audio : IDisposable + internal sealed class N64Audio : IDisposable { /// /// mupen64 DLL Api diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs index 7f8ec8793c8..e24196dcca1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 { - internal class N64VideoProvider : IVideoProvider, IDisposable + internal sealed class N64VideoProvider : IVideoProvider, IDisposable { private int[] frameBuffer; private mupen64plusVideoApi api; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs index f56faace1df..a0dcfd174f8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { - internal class mupen64plusAudioApi + internal sealed class mupen64plusAudioApi { /// /// Handle to native audio plugin diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs index 782608d63d9..9820d12ea32 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { - internal class mupen64plusInputApi + internal sealed class mupen64plusInputApi { private IntPtr InpDll; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs index 06883dae086..c309c49842d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { - internal class mupen64plusVideoApi + internal sealed class mupen64plusVideoApi { private IntPtr GfxDll; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs index eadb1572778..afa2bb23021 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs @@ -88,7 +88,7 @@ public override void WriteWram(int addr, byte value) // according to the latest on nesdev: // mapper 079: [.... PCCC] @ 4100 // mapper 113: [MCPP PCCC] @ 4100 (no games for this are in bootgod) - internal class AVE_NINA_006 : NesBoardBase + internal sealed class AVE_NINA_006 : NesBoardBase { //configuration private int prg_bank_mask_32k, chr_bank_mask_8k; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs index 2ee64a4d0df..25079f0c7ce 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs @@ -87,7 +87,7 @@ public override byte ReadPrg(int addr) } //AKA mapper 232 - internal class Camerica_Mapper232 : NesBoardBase + internal sealed class Camerica_Mapper232 : NesBoardBase { //configuration private int prg_bank_mask_16k; @@ -162,4 +162,4 @@ public override byte ReadPrg(int addr) } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs index 3909a01fb1f..c0eed84697d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs @@ -3,9 +3,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //http://wiki.nesdev.com/w/index.php/INES_Mapper_044 - internal class Mapper044 : MMC3Board_Base + internal sealed class Mapper044 : MMC3Board_Base { - public sealed override bool Configure(EDetectionOrigin origin) + public override bool Configure(EDetectionOrigin origin) { //analyze board type switch (Cart.BoardType) @@ -58,4 +58,4 @@ protected override int Get_CHRBank_1K(int addr) return (bank_1k & CHR_AND[block_select]) | CHR_OR[block_select]; } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs index 9154d0d3984..4ac3c49736d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES internal sealed class Mapper116 : NesBoardBase { [NesBoardImplCancel] - private class MMC3_CustomBoard : MMC3Board_Base + private sealed class MMC3_CustomBoard : MMC3Board_Base { public override void WritePrg(int addr, byte value) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs index b6bee772654..4c423c5d40d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class Mapper186 : NesBoardBase + internal sealed class Mapper186 : NesBoardBase { private byte[] _SRAM = new byte[3072]; private byte[] regs = new byte[4]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs index 7772852f52f..394d1c0b477 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { [NesBoardImplPriority] - internal class Namcot175_340 : NesBoardBase + internal sealed class Namcot175_340 : NesBoardBase { /* * Namcot 175 and 340. Simpler versions of the 129/163. Differences: diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs index 6233c0e4a85..fdccf684d25 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { // also, Namcot109, Namcot118, Namcot119 chips are this exact same thing - internal class Namcot108Chip + internal sealed class Namcot108Chip { private int reg_addr; private byte[] regs = new byte[8]; @@ -21,7 +21,7 @@ public Namcot108Chip(NesBoardBase board) Sync(); } - public virtual void SyncState(Serializer ser) + public void SyncState(Serializer ser) { ser.Sync(nameof(reg_addr), ref reg_addr); ser.Sync(nameof(regs), ref regs, false); @@ -30,7 +30,7 @@ public virtual void SyncState(Serializer ser) Sync(); } - public virtual void WritePRG(int addr, byte value) + public void WritePRG(int addr, byte value) { //($8001-$9FFF, odd) switch (addr & 0x6001) @@ -293,4 +293,4 @@ protected virtual void BaseSetup() } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index 8e7638db507..9e96ddc23e4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -90,7 +90,7 @@ public enum Rev private readonly int[] chr_banks_4k = new int[2]; private readonly int[] prg_banks_16k = new int[2]; - public class MMC1_SerialController + public sealed class MMC1_SerialController { //state private int shift_count, shift_val; @@ -580,7 +580,7 @@ public override byte ReadWram(int addr) } } - internal class SXROM : SuROM + internal sealed class SXROM : SuROM { //SXROM's PRG behaves similar to SuROM (and so inherits from it) //it also has some WRAM select bits like SoROM diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs index 08e9713e39a..cb9ea245fe4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs @@ -20,7 +20,7 @@ internal sealed class TAITO_TC0190FMC : NesBoardBase private int prg_bank_mask, chr_bank_mask; private bool pal16; - private class MMC3Variant : MMC3 + private sealed class MMC3Variant : MMC3 { public MMC3Variant(NesBoardBase board) : base(board,0) @@ -231,4 +231,4 @@ public override void AddressPpu(int addr) mmc3.AddressPPU(addr); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs index 0ccc0948ef7..de520c300b9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class UNIF_DREAMTECH01 : NesBoardBase + internal sealed class UNIF_DREAMTECH01 : NesBoardBase { // Korean Igo (Unl) [U][!] private int reg; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs index feba7a51526..8f39da9082d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { // Adapted from FCEUX src - internal class UNIF_BMC_64in1_NR : NesBoardBase + internal sealed class UNIF_BMC_64in1_NR : NesBoardBase { private byte[] regs = new byte[4]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs index 54efd26b182..c8cbc9294e2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { // 4-in-1 1993 (CK-001) [U][!].unf - internal class UNIF_BMC_8157 : NesBoardBase + internal sealed class UNIF_BMC_8157 : NesBoardBase { [MapperProp] public bool _4in1Mode; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs index e3faf713998..593a0b4a665 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class UNIF_BMC_A65AS : NesBoardBase + internal sealed class UNIF_BMC_A65AS : NesBoardBase { private int _prgReg; private bool _isPrg32kMode; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-T-262.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-T-262.cs index c736a0e1f53..0746bd392e9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-T-262.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-T-262.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class UNIF_BMC_T_262 : NesBoardBase + internal sealed class UNIF_BMC_T_262 : NesBoardBase { private bool _mode; private bool _locked; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs index 7d909b84829..3af94bbb58a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class UNIF_UNL_SHERO : MMC3Board_Base + internal sealed class UNIF_UNL_SHERO : MMC3Board_Base { [MapperProp] public bool RegionAsia = false; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs index 10fe87bedf1..5b3cfe50820 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs @@ -3,7 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - internal class UNIF_UNL_TF1201 : NesBoardBase + internal sealed class UNIF_UNL_TF1201 : NesBoardBase { private byte prg0; private byte prg1; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs index 603e7182554..bd418bf9626 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs @@ -253,7 +253,7 @@ public override void WriteWram(int addr, byte value) base.WriteWram(addr, value); } - private class SoundChannel + private sealed class SoundChannel { public SoundChannel(Action enqueuer) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index d1d4dc49bf9..b84c94b4514 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -299,7 +299,7 @@ private void LoadWriteLine(string format, params object[] arg) private void LoadWriteLine(object arg) { LoadWriteLine("{0}", arg); } - private class MyWriter : StringWriter + private sealed class MyWriter : StringWriter { public MyWriter(TextWriter _loadReport) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs index bd4c8937f6d..ac565be729e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs @@ -615,8 +615,8 @@ public byte ReadB(IController c) public class FamicomDeck : IControllerDeck { // two NES controllers are maintained internally - private readonly INesPort _player1 = new ControllerNES(false); - private readonly INesPort _player2 = new ControllerNES(true); + private readonly ControllerNES _player1 = new ControllerNES(false); + private readonly ControllerNES _player2 = new ControllerNES(true); private readonly IFamicomExpansion _player3; private readonly ControlDefUnMerger _player1U; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index bbeeccdefb4..6bc6061f52b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -221,7 +221,7 @@ public LibsnesCore(GameInfo game, byte[] romData, byte[] xmlData, string baseRom public bool IsSGB { get; } - private class SGBBoardInfo : IBoardInfo + private sealed class SGBBoardInfo : IBoardInfo { public string BoardName => "SGB"; } @@ -279,7 +279,7 @@ private string snes_path_request(int slot, string hint) // every rom requests msu1.rom... why? who knows. // also handle msu-1 pcm files here bool isMsu1Rom = hint == "msu1.rom"; - bool isMsu1Pcm = Path.GetExtension(hint).ToLowerInvariant() == ".pcm"; + bool isMsu1Pcm = Path.GetExtension(hint).Equals(".pcm", StringComparison.OrdinalIgnoreCase); if (isMsu1Rom || isMsu1Pcm) { // well, check if we have an msu-1 xml diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/ScanlineHookManager.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/ScanlineHookManager.cs index 74b3875e7c9..61a0970e19b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/ScanlineHookManager.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/ScanlineHookManager.cs @@ -39,7 +39,7 @@ public void HandleScanline(int scanline) } } - private class RegistrationRecord + private sealed class RegistrationRecord { public object Tag { get; set; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9xControllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9xControllers.cs index 2a405c03a89..4e24e60c780 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9xControllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9xControllers.cs @@ -81,7 +81,7 @@ private interface IControlDevice void ApplyState(IController controller, short[] input, int offset); } - private class Joypad : IControlDevice + private sealed class Joypad : IControlDevice { private static readonly string[] Buttons = { @@ -127,7 +127,7 @@ public void ApplyState(IController controller, short[] input, int offset) } } - private class Mouse : Analog + private sealed class Mouse : Analog { private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Mouse Left", "0Mouse Right" } } @@ -136,7 +136,7 @@ private static readonly ControllerDefinition _definition public override ControllerDefinition Definition => _definition; } - private class SuperScope : Analog + private sealed class SuperScope : Analog { private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause", "0Offscreen" } } @@ -145,7 +145,7 @@ private static readonly ControllerDefinition _definition public override ControllerDefinition Definition => _definition; } - private class Justifier : Analog + private sealed class Justifier : Analog { private static readonly ControllerDefinition _definition = new ControllerDefinition("(SNES Controller fragment)") { BoolButtons = { "0Trigger", "0Start", "0Offscreen" } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SameBoy/SameBoy.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SameBoy/SameBoy.cs index a8224f7ea72..65ff2280921 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SameBoy/SameBoy.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SameBoy/SameBoy.cs @@ -270,7 +270,7 @@ public IGPUMemoryAreas LockGPU() }; } - private class GPUMemoryAreas : IGPUMemoryAreas + private sealed class GPUMemoryAreas : IGPUMemoryAreas { public IntPtr Vram { get; init; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs index 9807b714ce4..90c1efd2f7c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs @@ -11,7 +11,7 @@ partial class PCEngine private readonly ArcadeCardPage[] ArcadePage = new ArcadeCardPage[4]; - private class ArcadeCardPage + private sealed class ArcadeCardPage { public byte Control; public int Base; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs index 7ccb69acb74..f8c4677d4d6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - internal class EEPROM93c46 + internal sealed class EEPROM93c46 { private enum EEPROMWriteMode { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs index c43a2e187cc..b44dda898e4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs @@ -31,7 +31,7 @@ public PutSettingsDirtyBits PutSyncSettings(GPGXSyncSettings o) return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None; } - private class UintToHexConverter : TypeConverter + private sealed class UintToHexConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); @@ -66,7 +66,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c } } - private class UshortToHexConverter : TypeConverter + private sealed class UshortToHexConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index c9c150d44cf..15e301f397b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -364,7 +364,7 @@ public void Dispose() /// /// Wraps the ShockDiscRef returned from the DLL and acts as a bridge between it and a DiscSystem disc /// - private class DiscInterface : IDisposable + private sealed class DiscInterface : IDisposable { public DiscInterface(Disc disc, Action cbActivity) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs index 31066bd3219..563c1f2b4a1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs @@ -15,7 +15,7 @@ private void InitIStatable() private readonly JsonSerializer ser = new() { Formatting = Formatting.Indented }; [StructLayout(LayoutKind.Sequential)] - private class TextStateData + private sealed class TextStateData { public bool IsLagFrame; public int LagCount; diff --git a/src/BizHawk.Emulation.Cores/CoreInventory.cs b/src/BizHawk.Emulation.Cores/CoreInventory.cs index a6515a34184..f704a997ef5 100644 --- a/src/BizHawk.Emulation.Cores/CoreInventory.cs +++ b/src/BizHawk.Emulation.Cores/CoreInventory.cs @@ -22,15 +22,6 @@ public class CoreInventory public class Core { - private class RomGameFake : IRomAsset - { - public byte[] RomData { get; set; } - public byte[] FileData { get; set; } - public string Extension { get; set; } - public string RomPath { get; set; } - public GameInfo Game { get; set; } - } - // map parameter names to locations in the constructor private readonly Dictionary _paramMap = new Dictionary(); // If true, this is a new style constructor that takes a CoreLoadParameters object diff --git a/src/BizHawk.Emulation.Cores/FileID.cs b/src/BizHawk.Emulation.Cores/FileID.cs index 05b415394b0..ae140b4c445 100644 --- a/src/BizHawk.Emulation.Cores/FileID.cs +++ b/src/BizHawk.Emulation.Cores/FileID.cs @@ -126,7 +126,7 @@ public class IdentifyParams public DiscSystem.Disc Disc; } - private class IdentifyJob + private sealed class IdentifyJob { public Stream Stream; public string Extension; @@ -239,7 +239,7 @@ private FileIDResults IdentifyDisc(IdentifyJob job) } } - private class SimpleMagicRecord + private sealed class SimpleMagicRecord { public int Offset; public string Key; @@ -296,7 +296,7 @@ private static class SimpleMagics }; } - private class ExtensionInfo + private sealed class ExtensionInfo { public ExtensionInfo(FileIDType defaultForExtension, FormatTester tester) { diff --git a/src/BizHawk.Emulation.Cores/Libretro/Libretro.cs b/src/BizHawk.Emulation.Cores/Libretro/Libretro.cs index 7067ba064b7..47c6254893b 100644 --- a/src/BizHawk.Emulation.Cores/Libretro/Libretro.cs +++ b/src/BizHawk.Emulation.Cores/Libretro/Libretro.cs @@ -28,7 +28,7 @@ static LibretroHost() private readonly LibretroApi api; private readonly IntPtr cbHandler; - private class BridgeGuard(IntPtr parentHandler) : IMonitor + private sealed class BridgeGuard(IntPtr parentHandler) : IMonitor { private static readonly object _sync = new(); private static IntPtr _activeHandler; @@ -129,7 +129,7 @@ public LibretroHost(CoreComm comm, IGameInfo game, string corePath, bool analysi } } - private class RetroData(object o, long len = 0) : IDisposable + private sealed class RetroData(object o, long len = 0) : IDisposable { private GCHandle _handle = GCHandle.Alloc(o, GCHandleType.Pinned); diff --git a/src/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs b/src/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs index 950e1bc2221..55bac609ee9 100644 --- a/src/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs +++ b/src/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs @@ -275,7 +275,7 @@ internal void SyncState(Serializer ser) ser.EndSection(); } - private class QueuedCommand + private sealed class QueuedCommand { public byte Register; public byte Value; diff --git a/src/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs b/src/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs index 9107858d48b..90eced20913 100644 --- a/src/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs +++ b/src/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs @@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Cores.Components { public class MMC5Audio { - private class Pulse + private sealed class Pulse { // regs private int V; diff --git a/src/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs b/src/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs index 7d0f0d95584..4265bcb8c3d 100644 --- a/src/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs +++ b/src/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Components /// public class Sunsoft5BAudio { - private class Pulse + private sealed class Pulse { private readonly Action SendDiff; // regs diff --git a/src/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs b/src/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs index dbf53e2af17..c1c7290411c 100644 --- a/src/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs +++ b/src/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs @@ -226,7 +226,7 @@ public void GetSamplesSync(out short[] samples, out int nsamp) /// /// Instantiated for every ISoundProvider source that is added to the mixer /// - private class ChildProvider + private sealed class ChildProvider { /// /// The Child ISoundProvider diff --git a/src/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs b/src/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs index 7be9ddebd3d..6e40ece0a1b 100644 --- a/src/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs +++ b/src/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs @@ -87,7 +87,7 @@ public void Clock() } } - private class Saw + private sealed class Saw { private readonly Action SendDiff; public Saw(Action SendDiff) { this.SendDiff = SendDiff; } @@ -186,7 +186,7 @@ public void Clock() } } - private class Pulse + private sealed class Pulse { private readonly Action SendDiff; public Pulse(Action SendDiff) { this.SendDiff = SendDiff; } diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.ButtonNameOverrides.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.ButtonNameOverrides.cs index a6a8f210b0c..01f7e872895 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.ButtonNameOverrides.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.ButtonNameOverrides.cs @@ -36,9 +36,9 @@ private static bool IsRomanNumeral(string str) private string OverrideButtonName(string original) { // VB hack - if (ButtonNameOverrides.ContainsKey(original)) + if (ButtonNameOverrides.TryGetValue(original, out string vbOverrideName)) { - original = ButtonNameOverrides[original]; + original = vbOverrideName; } original = Regex.Replace(original, @"\s*(↑|↓|←|→)\s*", ""); @@ -48,9 +48,9 @@ private string OverrideButtonName(string original) original = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(original.ToLowerInvariant()); } - if (ButtonNameOverrides.ContainsKey(original)) + if (ButtonNameOverrides.TryGetValue(original, out string overrideName)) { - original = ButtonNameOverrides[original]; + original = overrideName; } // TODO: Add dictionaries or whatever here as needed diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Settings.ComponentModel.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Settings.ComponentModel.cs index 44f1b88b0e0..25cc82dfd29 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Settings.ComponentModel.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Settings.ComponentModel.cs @@ -182,7 +182,7 @@ protected override string ConvertToString(object o) } public override TypeConverter Converter => new MyTypeConverter { Setting = Setting }; - private class MyTypeConverter : TypeConverter + private sealed class MyTypeConverter : TypeConverter { public SettingT Setting { get; set; } // Mednafen includes extra fallback aliases of enums that are nameless, just one way value aliases. @@ -354,7 +354,7 @@ public override bool ShouldSerializeValue(object component) public override TypeConverter Converter => new MyTypeConverter { Port = Port }; - private class MyTypeConverter : TypeConverter + private sealed class MyTypeConverter : TypeConverter { public Port Port { get; set; } diff --git a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs index 4779521bf33..565889ddec4 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs @@ -82,7 +82,7 @@ static WaterboxHost() #endif } - private class ReadWriteWrapper : IDisposable + private sealed class ReadWriteWrapper : IDisposable { private GCHandle _handle; private readonly ISpanStream _backingSpanStream; @@ -313,7 +313,7 @@ public MemoryDomain GetPagesDomain() return new WaterboxPagesDomain(this); } - private class WaterboxPagesDomain : MemoryDomain + private sealed class WaterboxPagesDomain : MemoryDomain { private readonly WaterboxHost _host; diff --git a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxMemoryDomain.cs b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxMemoryDomain.cs index 393fad05489..0fd9c1d0410 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxMemoryDomain.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxMemoryDomain.cs @@ -132,7 +132,7 @@ public abstract class MemoryDomainAccessStub [BizImport(CallingConvention.Cdecl)] public abstract void Access(IntPtr buffer, long address, long count, bool write); - private class StubResolver : IImportResolver + private sealed class StubResolver : IImportResolver { private readonly IntPtr _p; public StubResolver(IntPtr p) diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/A26Schema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/A26Schema.cs index 40a1b063aa0..453c5fe7691 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/A26Schema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/A26Schema.cs @@ -197,7 +197,7 @@ private static PadSchema KeyboardController(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/A78Schema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/A78Schema.cs index fe99ee1e79b..d79eab63c13 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/A78Schema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/A78Schema.cs @@ -105,7 +105,7 @@ private static PadSchema LightGunController(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/ChannelFSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/ChannelFSchema.cs index bf70d98592a..8bfffd3777e 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/ChannelFSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/ChannelFSchema.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores { [Schema(VSystemID.Raw.ChannelF)] - internal class ChannelFSchema : IVirtualPadSchema + internal sealed class ChannelFSchema : IVirtualPadSchema { public IEnumerable GetPadSchemas(IEmulator core, Action showMessageBox) { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/ColecoSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/ColecoSchema.cs index 4aedd0d6241..46c71ee9c3b 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/ColecoSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/ColecoSchema.cs @@ -82,7 +82,7 @@ private static PadSchema SuperActionController(int controller) }; } - private static IEnumerable StandardButtons(int controller) => new ButtonSchema[] + private static ButtonSchema[] StandardButtons(int controller) => new ButtonSchema[] { ButtonSchema.Up(50, 11, controller), ButtonSchema.Down(50, 32, controller), diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/GBASchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/GBASchema.cs index ec9974e202b..cc916338ff9 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/GBASchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/GBASchema.cs @@ -69,7 +69,7 @@ private static PadSchema StandardController() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/GBSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/GBSchema.cs index e370755b4e3..cb6fc726d9a 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/GBSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/GBSchema.cs @@ -48,7 +48,7 @@ private static PadSchema StandardController() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/GenSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/GenSchema.cs index 741a7d669f6..64d7ef42b2c 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/GenSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/GenSchema.cs @@ -90,7 +90,7 @@ private static PadSchema SixButtonController(int controller) }; } - private static IEnumerable ThreeButtons(int controller) + private static ButtonSchema[] ThreeButtons(int controller) { return new[] { @@ -141,7 +141,7 @@ private static PadSchema Mouse(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/IntvSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/IntvSchema.cs index 4a1bd19586e..4c082fa9cb2 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/IntvSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/IntvSchema.cs @@ -85,7 +85,7 @@ private static PadSchema AnalogController(int controller) }; } - private static IEnumerable StandardButtons(int controller) + private static ButtonSchema[] StandardButtons(int controller) { return new[] { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/JaguarSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/JaguarSchema.cs index f206796dbf3..58022454842 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/JaguarSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/JaguarSchema.cs @@ -49,7 +49,7 @@ private static PadSchema StandardController(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/N3DSSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/N3DSSchema.cs index 55b365d126a..107967644d4 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/N3DSSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/N3DSSchema.cs @@ -62,7 +62,7 @@ static AxisSpec MakeSpec() }; } - private static PadSchema Console() + private static ConsoleSchema Console() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/NdsSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/NdsSchema.cs index 1fa64cc111d..45f7968ebec 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/NdsSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/NdsSchema.cs @@ -43,7 +43,7 @@ private static PadSchema Controller() }; } - private static PadSchema Console() + private static ConsoleSchema Console() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/NesSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/NesSchema.cs index f5885d8f23a..cae72291159 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/NesSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/NesSchema.cs @@ -160,7 +160,7 @@ public IEnumerable GetPadSchemas(IEmulator core, Action showM } } - private static PadSchema NesConsoleButtons() + private static ConsoleSchema NesConsoleButtons() { return new ConsoleSchema { @@ -173,7 +173,7 @@ private static PadSchema NesConsoleButtons() }; } - private static PadSchema FdsConsoleButtons(int diskSize) + private static ConsoleSchema FdsConsoleButtons(int diskSize) { var buttons = new List { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/NgpSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/NgpSchema.cs index 16ec03e17dc..387cc402963 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/NgpSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/NgpSchema.cs @@ -32,7 +32,7 @@ private static PadSchema Controller() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/O2Schema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/O2Schema.cs index d47bb90c9f0..098531e4a5d 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/O2Schema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/O2Schema.cs @@ -96,7 +96,7 @@ private static PadSchema KeyboardButtons() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs index c02d6f1d03e..e2ff1b9888f 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs @@ -414,7 +414,7 @@ private static PadSchema NymaDancePad(int controller) }; } - private static PadSchema ConsoleButtons(Octoshock octo) + private static ConsoleSchema ConsoleButtons(Octoshock octo) { return new ConsoleSchema { @@ -427,7 +427,7 @@ private static PadSchema ConsoleButtons(Octoshock octo) }; } - private static PadSchema NymaConsoleButtons(AxisSpec diskRange) + private static ConsoleSchema NymaConsoleButtons(AxisSpec diskRange) { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/PceSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/PceSchema.cs index 29c510c9e4b..bbbf8b0cab5 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/PceSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/PceSchema.cs @@ -159,7 +159,7 @@ private static PadSchema Mouse(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/PcfxSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/PcfxSchema.cs index 0b5b4d22ce5..74b9f249730 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/PcfxSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/PcfxSchema.cs @@ -93,7 +93,7 @@ private static PadSchema Mouse(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs index b751b22de78..c3d21a081d5 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs @@ -275,7 +275,7 @@ private static PadSchema LightGun(int controller) }; } - private static PadSchema ConsoleButtons(AxisSpec diskRange) + private static ConsoleSchema ConsoleButtons(AxisSpec diskRange) { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/SmsSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/SmsSchema.cs index a1624509afb..d0b06aff592 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/SmsSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/SmsSchema.cs @@ -191,7 +191,7 @@ private static PadSchema LightGunController(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/SnesSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/SnesSchema.cs index 89be3c82311..d4ad415ff0a 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/SnesSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/SnesSchema.cs @@ -328,7 +328,7 @@ private static IEnumerable PayLoadButtons(int controller) } } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/TIC80Schema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/TIC80Schema.cs index b6e5b480a9a..5592da42a08 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/TIC80Schema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/TIC80Schema.cs @@ -76,7 +76,7 @@ private static PadSchema Mouse() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/VECSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/VECSchema.cs index ce5c9b8c943..021fdd18874 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/VECSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/VECSchema.cs @@ -83,7 +83,7 @@ private static ButtonSchema Button(int x, int y, int controller, int button) return new ButtonSchema(x, y, controller, $"Button {button}", button.ToString()); } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/VirtualBoySchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/VirtualBoySchema.cs index 33f7901f079..be01bab134a 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/VirtualBoySchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/VirtualBoySchema.cs @@ -39,7 +39,7 @@ private static PadSchema StandardController() }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/WonderSwanSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/WonderSwanSchema.cs index b964b8015f0..3d85027c7e2 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/WonderSwanSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/WonderSwanSchema.cs @@ -61,7 +61,7 @@ private static PadSchema RotatedController(int controller) }; } - private static PadSchema ConsoleButtons() + private static ConsoleSchema ConsoleButtons() { return new ConsoleSchema { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/ZXSpectrumSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/ZXSpectrumSchema.cs index 1ce8fe013fe..66795c3ec97 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/ZXSpectrumSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/ZXSpectrumSchema.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores { [Schema(VSystemID.Raw.ZXSpectrum)] - internal class ZxSpectrumSchema : IVirtualPadSchema + public class ZxSpectrumSchema : IVirtualPadSchema { public IEnumerable GetPadSchemas(IEmulator core, Action showMessageBox) { @@ -34,7 +34,7 @@ private static PadSchema Joystick(int controller) }; } - private class ButtonLayout + private sealed class ButtonLayout { public string Name { get; set; } public string DisName { get; set; } diff --git a/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs b/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs index f7c212bf731..0af50eb3fea 100644 --- a/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs +++ b/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs @@ -35,8 +35,8 @@ public MednaDisc(string pathToDisc) public MednadiscTOC TOC; public MednadiscTOCTrack[] TOCTracks; - [ThreadStatic] private static byte[] buf2442 = new byte[2448]; - [ThreadStatic] private static byte[] buf96 = new byte[96]; + private static byte[] buf2442 = new byte[2448]; + private static byte[] buf96 = new byte[96]; public void Read_2442(int LBA, byte[] buffer, int offset) @@ -145,4 +145,4 @@ public struct MednadiscTOCTrack [DllImport("mednadisc.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void mednadisc_ReadTOC(IntPtr disc, MednadiscTOC* toc, MednadiscTOCTrack* tracks101); } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscDecoding.cs b/src/BizHawk.Emulation.DiscSystem/DiscDecoding.cs index f996c24a9b6..c408dd549a1 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscDecoding.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscDecoding.cs @@ -5,10 +5,10 @@ namespace BizHawk.Emulation.DiscSystem { - internal class AudioDecoder + internal sealed class AudioDecoder { [Serializable] - public class AudioDecoder_Exception : Exception + public sealed class AudioDecoder_Exception : Exception { public AudioDecoder_Exception(string message) : base(message) diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_CHD.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_CHD.cs index 00b6bd05d6a..d8f5b00d537 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_CHD.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_CHD.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.DiscSystem { - internal class Blob_CHD : IBlob + internal sealed class Blob_CHD : IBlob { private IntPtr _chdFile; diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_ECM.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_ECM.cs index ec57572235f..6f3f5ee5a58 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_ECM.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_ECM.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.DiscSystem { - internal class Blob_ECM : IBlob + internal sealed class Blob_ECM : IBlob { private FileStream stream; diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_RawFile.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_RawFile.cs index 8d56d051c38..22808706288 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_RawFile.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_RawFile.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.DiscSystem { - internal class Blob_RawFile : IBlob + internal sealed class Blob_RawFile : IBlob { public string PhysicalPath { diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_WaveFile.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_WaveFile.cs index ec6bad2535a..1ce2ed3a7ea 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_WaveFile.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/Blob_WaveFile.cs @@ -7,10 +7,10 @@ namespace BizHawk.Emulation.DiscSystem /// TODO - double-check that riffmaster is not filling memory at load-time but reading through to the disk /// TODO - clarify stream disposing semantics /// - internal class Blob_WaveFile : IBlob + internal sealed class Blob_WaveFile : IBlob { [Serializable] - public class Blob_WaveFile_Exception : Exception + public sealed class Blob_WaveFile_Exception : Exception { public Blob_WaveFile_Exception(string message) : base(message) diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs index 2c2f6ffa16a..0ca296ab652 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.DiscSystem /// Please be sure to test round-tripping when you make any changes. This architecture is a bit tricky to use, but it works if you're careful. /// TODO - clarify stream disposing semantics /// - internal class RiffMaster : IDisposable + internal sealed class RiffMaster : IDisposable { public RiffMaster() { } @@ -40,7 +40,7 @@ public void Dispose() private static string ReadTag(BinaryReader br) => string.Concat(br.ReadChar(), br.ReadChar(), br.ReadChar(), br.ReadChar()); - protected static void WriteTag(BinaryWriter bw, string tag) + private static void WriteTag(BinaryWriter bw, string tag) { for (var i = 0; i < 4; i++) bw.Write(tag[i]); @@ -115,7 +115,7 @@ public override RiffChunk Morph() } } - public class RiffSubchunk_fmt : RiffSubchunk + public sealed class RiffSubchunk_fmt : RiffSubchunk { public enum FORMAT_TAG : ushort { @@ -231,7 +231,7 @@ public override RiffChunk Morph() } } - public class RiffContainer_INFO : RiffContainer + public sealed class RiffContainer_INFO : RiffContainer { public readonly IDictionary dictionary = new Dictionary(); public RiffContainer_INFO() { type = "INFO"; } @@ -341,4 +341,4 @@ public void LoadStream(Stream s) riff = (RiffContainer)chunk; } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs index 4f67776a518..18d66c5a5d5 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs @@ -159,7 +159,7 @@ public class CCDParseException : Exception public CCDParseException(string message) : base(message) { } } - private class CCDSection : Dictionary + private sealed class CCDSection : Dictionary { public string Name; @@ -204,7 +204,7 @@ private static List ParseSections(Stream stream) var parts = line.Split('='); if (parts.Length != 2) throw new CCDParseException("Malformed or unexpected CCD format: parsing item into two parts"); - if (parts[0].ToUpperInvariant() == "FLAGS") + if (parts[0].Equals("FLAGS", StringComparison.OrdinalIgnoreCase)) { // flags are a space-separated collection of symbolic constants: // https://www.gnu.org/software/ccd2cue/manual/html_node/FLAGS-_0028Compact-Disc-fields_0029.html#FLAGS-_0028Compact-Disc-fields_0029 @@ -448,7 +448,7 @@ public static void Dump(Disc disc, string path) } } - private class SS_CCD : ISectorSynthJob2448 + private sealed class SS_CCD : ISectorSynthJob2448 { public void Synth(SectorSynthJob job) { diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CHD_format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CHD_format.cs index 4bd3d71e202..c258dca59b8 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CHD_format.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CHD_format.cs @@ -516,7 +516,7 @@ public static LoadResults LoadCHDPath(string path) /// /// CHD is dumb and byteswaps audio samples for some reason /// - private class SS_CHD_Audio : SS_Base + private sealed class SS_CHD_Audio : SS_Base { public override void Synth(SectorSynthJob job) { @@ -532,7 +532,7 @@ public override void Synth(SectorSynthJob job) } } - private class SS_CHD_Sub : ISectorSynthJob2448 + private sealed class SS_CHD_Sub : ISectorSynthJob2448 { private readonly SS_Base _baseSynth; private readonly uint _subOffset; @@ -853,7 +853,7 @@ private static ushort CalcCrc16(ReadOnlySpan bytes) return crc16; } - private class ChdHunkMapEntry + private sealed class ChdHunkMapEntry { public uint CompressedLength; public long HunkOffset; diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs index 4d16e0ca222..b4c4bfb43cd 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE { - internal class CompiledCDText + internal sealed class CompiledCDText { public string Songwriter; public string Performer; @@ -68,7 +68,7 @@ public enum CompiledCueFileType DecodeAudio, } - internal class CompiledCueFile + internal sealed class CompiledCueFile { public string FullPath; public CompiledCueFileType Type; @@ -78,13 +78,13 @@ public override string ToString() } } - internal class CompiledSessionInfo + internal sealed class CompiledSessionInfo { public int FirstRecordedTrackNumber, LastRecordedTrackNumber; public SessionFormat SessionFormat; } - internal class CompiledCueTrack + internal sealed class CompiledCueTrack { public int BlobIndex; public int Number; @@ -117,7 +117,7 @@ public override string ToString() } } - internal class CompileCueJob : DiscJob + internal sealed class CompileCueJob : DiscJob { private readonly CUE_File IN_CueFile; @@ -484,4 +484,4 @@ public override void Run() } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs index de22923b818..abb5ac1a6f3 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs @@ -5,7 +5,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE /// /// Represents the contents of a cue file /// - internal class CUE_File + internal sealed class CUE_File { /// /// (here are all the commands we can encounter) @@ -172,7 +172,7 @@ public TRACK(int number, CueTrackType type) /// /// Stuff other than the commands, global for the whole disc /// - public class DiscInfo + public sealed class DiscInfo { public Command.CATALOG? Catalog; public Command.ISRC? ISRC; @@ -189,4 +189,4 @@ public class DiscInfo /// public readonly DiscInfo GlobalDiscInfo = new(); } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs index 80a7ffb89a8..afbf3cd2ce8 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs @@ -28,7 +28,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE /// For this job, virtually all nonsense input is treated as errors, but the process will try to recover as best it can. /// The user should still reject any jobs which generated errors /// - internal class LoadCueJob : DiscJob + internal sealed class LoadCueJob : DiscJob { private readonly CompileCueJob IN_CompileJob; @@ -45,7 +45,7 @@ private enum BurnType Normal, Pregap, Postgap } - private class BlobInfo + private sealed class BlobInfo { public IBlob Blob; public long Length; @@ -424,4 +424,4 @@ public override void Run() //FinishLog(); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs index 1d3de8c1c54..a8da2dc462d 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE /// /// Performs minimum parse processing on a cue file /// - internal class ParseCueJob : DiscJob + internal sealed class ParseCueJob : DiscJob { private readonly string IN_CueString; @@ -33,7 +33,7 @@ public ParseCueJob(string cueString, bool strict = false) /// public CUE_File OUT_CueFile { get; private set; } - private class CueLineParser + private sealed class CueLineParser { private int index; private readonly string str; @@ -133,12 +133,12 @@ private string ReadToken(Mode mode) private void LoadFromString() { - TextReader tr = new StringReader(IN_CueString); + StringReader reader = new(IN_CueString); while (true) { CurrentLine++; - var line = tr.ReadLine()?.Trim(); + var line = reader.ReadLine()?.Trim(); if (line is null) break; if (line == string.Empty) continue; var clp = new CueLineParser(line); diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_SynthExtras.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_SynthExtras.cs index 70d88d32a7f..04fc3796f38 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_SynthExtras.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_SynthExtras.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE /// Represents a Mode2 Form1 2048-byte sector /// Only used by NRG, MDS, and CHD /// - internal class SS_Mode2_Form1_2048 : SS_Base + internal sealed class SS_Mode2_Form1_2048 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -36,7 +36,7 @@ public override void Synth(SectorSynthJob job) /// Represents a Mode2 Form1 2324-byte sector /// Only used by MDS and CHD /// - internal class SS_Mode2_Form2_2324 : SS_Base + internal sealed class SS_Mode2_Form2_2324 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -59,7 +59,7 @@ public override void Synth(SectorSynthJob job) /// Represents a Mode2 Form1 2328-byte sector /// Only used by MDS /// - internal class SS_Mode2_Form2_2328 : SS_Base + internal sealed class SS_Mode2_Form2_2328 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -82,7 +82,7 @@ public override void Synth(SectorSynthJob job) /// Represents a full 2448-byte sector with interleaved subcode /// Only used by MDS, NRG, and CDI /// - internal class SS_2448_Interleaved : SS_Base + internal sealed class SS_2448_Interleaved : SS_Base { public override void Synth(SectorSynthJob job) { @@ -99,7 +99,7 @@ public override void Synth(SectorSynthJob job) /// Represents a 2364-byte (2352 + 12) sector with deinterleaved Q subcode /// Only used by CDI /// - internal class SS_2364_DeinterleavedQ : SS_Base + internal sealed class SS_2364_DeinterleavedQ : SS_Base { public override void Synth(SectorSynthJob job) { @@ -122,4 +122,4 @@ public override void Synth(SectorSynthJob job) SynthUtils.InterleaveSubcodeInplace(job.DestBuffer2448, job.DestOffset + 2352); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs index 6e89618ea44..3b49b2e2e30 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs @@ -47,7 +47,7 @@ protected void SynthSubchannelAsNeed(SectorSynthJob job) /// /// Represents a Mode1 2048-byte sector /// - internal class SS_Mode1_2048 : SS_Base + internal sealed class SS_Mode1_2048 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -76,7 +76,7 @@ public override void Synth(SectorSynthJob job) /// /// Represents a Mode2 2336-byte sector /// - internal class SS_Mode2_2336 : SS_Base + internal sealed class SS_Mode2_2336 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -95,7 +95,7 @@ public override void Synth(SectorSynthJob job) /// /// Represents a 2352-byte sector of any sort /// - internal class SS_2352 : SS_Base + internal sealed class SS_2352 : SS_Base { public override void Synth(SectorSynthJob job) { @@ -111,7 +111,7 @@ public override void Synth(SectorSynthJob job) /// /// Encodes a pre-gap sector /// - internal class SS_Gap : SS_Base + internal sealed class SS_Gap : SS_Base { public CueTrackType TrackType; @@ -177,4 +177,4 @@ public override void Synth(SectorSynthJob job) SynthSubchannelAsNeed(job); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 1b35f404f60..9ce55bdaf82 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -668,20 +668,8 @@ private static Dictionary MountBlobs(AFile mdsf, Disc disc) //mount the file var mdfBlob = new Blob_RawFile { PhysicalPath = file }; - - var dupe = false; - foreach (var re in disc.DisposableResources) - { - if (re.ToString() == mdfBlob.ToString()) - dupe = true; - } - - if (!dupe) - { - // wrap in zeropadadapter - disc.DisposableResources.Add(mdfBlob); - BlobIndex[count++] = mdfBlob; - } + disc.DisposableResources.Add(mdfBlob); + BlobIndex[count++] = mdfBlob; } } diff --git a/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index 783b367bd56..32b3a7ac7d5 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -238,7 +238,7 @@ public DiscType DetectDiscType() return DiscType.Playdia; if (sysId is "CDTV" or "AMIGA" - || iso.Root.Children.Keys.Any(k => k.ToLowerInvariant().Contains("cd32"))) + || iso.Root.Children.Keys.Any(k => k.Contains("cd32", StringComparison.OrdinalIgnoreCase))) { return DiscType.Amiga; } diff --git a/src/BizHawk.Emulation.DiscSystem/DiscMountJob.MednaDisc.cs b/src/BizHawk.Emulation.DiscSystem/DiscMountJob.MednaDisc.cs index 55e0d1099f4..ca462b1c72f 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscMountJob.MednaDisc.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscMountJob.MednaDisc.cs @@ -2,7 +2,7 @@ { public partial class DiscMountJob { - private class SS_MednaDisc : ISectorSynthJob2448 + private sealed class SS_MednaDisc : ISectorSynthJob2448 { public void Synth(SectorSynthJob job) { @@ -117,4 +117,4 @@ private void RunMednaDisc() disc.Session1.RawTOCEntries.Add(new() { QData = qA1 }); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/ApplySBIJob.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/ApplySBIJob.cs index 82474c9d43f..0ca86a1f103 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/ApplySBIJob.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/ApplySBIJob.cs @@ -1,7 +1,7 @@ // TODO - generate correct Q subchannel CRC namespace BizHawk.Emulation.DiscSystem { - internal class ApplySBIJob + internal sealed class ApplySBIJob { /// /// applies an SBI file to the disc diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs index 0a7c67763c4..8b85e565e13 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.DiscSystem.SBI /// /// Loads SBI files into an internal representation. /// - internal class LoadSBIJob : DiscJob + internal sealed class LoadSBIJob : DiscJob { private readonly string IN_Path; @@ -75,4 +75,4 @@ public override void Run() OUT_Data = ret; } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs index a952831941d..bc6bf157a59 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.DiscSystem /// Synthesizes RawTCOEntry A0 A1 A2 from the provided information. /// This might be reused by formats other than CUE later, so it isn't directly associated with that /// - internal class Synthesize_A0A1A2_Job + internal sealed class Synthesize_A0A1A2_Job { private readonly int IN_FirstRecordedTrackNumber; @@ -79,4 +79,4 @@ public void Run(List entries) entries.Insert(2, new() { QData = sq }); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTOC_From_RawTOCEntries_Job.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTOC_From_RawTOCEntries_Job.cs index 81be1d044ea..49177cce906 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTOC_From_RawTOCEntries_Job.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTOC_From_RawTOCEntries_Job.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.DiscSystem /// When a disc drive firmware reads the lead-in area, it builds this TOC from finding q-mode 1 sectors in the Q subchannel of the lead-in area. /// Question: I guess it must ignore q-mode != 1? what else would it do with it? /// - internal class Synthesize_DiscTOC_From_RawTOCEntries_Job + internal sealed class Synthesize_DiscTOC_From_RawTOCEntries_Job { private readonly IReadOnlyList Entries; @@ -102,4 +102,4 @@ public void Run() //} } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTracks_From_DiscTOC_Job.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTracks_From_DiscTOC_Job.cs index 05744a19f8e..44200c45bca 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTracks_From_DiscTOC_Job.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTracks_From_DiscTOC_Job.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.DiscSystem { - internal class Synthesize_DiscTracks_From_DiscTOC_Job + internal sealed class Synthesize_DiscTracks_From_DiscTOC_Job { private readonly Disc IN_Disc; @@ -78,4 +78,4 @@ public void Run() Tracks[0].Mode = Tracks[1].Mode; } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_Leadout_Job.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_Leadout_Job.cs index 10cae531a8a..f9f03c03609 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_Leadout_Job.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_Leadout_Job.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.DiscSystem /// generates lead-out sectors according to very crude approximations /// TODO - this isn't being used right now /// - internal class Synthesize_LeadoutJob + internal sealed class Synthesize_LeadoutJob { private readonly int Length; private readonly Disc Disc; @@ -56,4 +56,4 @@ public void Run() } } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs b/src/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs index 05c295d923a..b200928b7e0 100644 --- a/src/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs +++ b/src/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs @@ -111,7 +111,7 @@ internal interface ISectorSynthJob2448 /// /// Not a proper job? maybe with additional flags, it could be /// - internal class SectorSynthJob + internal sealed class SectorSynthJob { public int LBA; public ESectorSynthPart Parts; @@ -124,7 +124,7 @@ internal class SectorSynthJob /// /// an ISectorSynthProvider that just returns a value from an array of pre-made sectors /// - internal class ArraySectorSynthProvider : ISectorSynthProvider + internal sealed class ArraySectorSynthProvider : ISectorSynthProvider { public List Sectors = new(); public int FirstLBA; @@ -140,7 +140,7 @@ public ISectorSynthJob2448 Get(int lba) /// /// an ISectorSynthProvider that just returns a fixed synthesizer /// - internal class SimpleSectorSynthProvider : ISectorSynthProvider + internal sealed class SimpleSectorSynthProvider : ISectorSynthProvider { public ISectorSynthJob2448 SS; @@ -150,7 +150,7 @@ internal class SimpleSectorSynthProvider : ISectorSynthProvider /// /// Returns 'Patch' synth if the provided condition is met /// - internal class ConditionalSectorSynthProvider : ISectorSynthProvider + internal sealed class ConditionalSectorSynthProvider : ISectorSynthProvider { private Func Condition; private ISectorSynthJob2448 Patch; @@ -193,7 +193,7 @@ internal struct SectorSynthParams } - internal class SS_PatchQ : ISectorSynthJob2448 + internal sealed class SS_PatchQ : ISectorSynthJob2448 { public ISectorSynthJob2448 Original; public readonly byte[] Buffer_SubQ = new byte[12]; @@ -211,7 +211,7 @@ public void Synth(SectorSynthJob job) } } - internal class SS_Leadout : ISectorSynthJob2448 + internal sealed class SS_Leadout : ISectorSynthJob2448 { public int SessionNumber; public DiscMountPolicy Policy; @@ -271,4 +271,4 @@ public void Synth(SectorSynthJob job) } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Tests/Client.Common/Api/MemoryApiTests.cs b/src/BizHawk.Tests/Client.Common/Api/MemoryApiTests.cs index 8e2e10df8c0..c437c02cebc 100644 --- a/src/BizHawk.Tests/Client.Common/Api/MemoryApiTests.cs +++ b/src/BizHawk.Tests/Client.Common/Api/MemoryApiTests.cs @@ -20,7 +20,7 @@ private static void AssertAreSequenceEqual(IReadOnlyList expected, IReadOn Assert.Fail(message); } - private IMemoryApi CreateDummyApi(byte[] memDomainContents) + private MemoryApi CreateDummyApi(byte[] memDomainContents) => new MemoryApi(Console.WriteLine) //TODO capture and check for error messages? { MemoryDomainCore = new MemoryDomainList(new MemoryDomain[] diff --git a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs index 2730b89648f..311de3ad6ee 100644 --- a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs +++ b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs @@ -54,7 +54,7 @@ private ZwinderStateManager CreateSmallZwinder(IStatable ss) return zw; } - private IStatable CreateStateSource() => new StateSource {PaddingData = new byte[1000]}; + private StateSource CreateStateSource() => new StateSource {PaddingData = new byte[1000]}; [TestMethod] public void SaveCreateRoundTrip() @@ -595,7 +595,7 @@ public void BufferStressTest() } } - private class StateSource : IStatable + private sealed class StateSource : IStatable { public int Frame { get; set; } public byte[] PaddingData { get; set; } = Array.Empty(); diff --git a/src/BizHawk.Tests/Client.Common/config/SerializationStabilityTests.cs b/src/BizHawk.Tests/Client.Common/config/SerializationStabilityTests.cs index 2e41605caa9..d285fdf8f0a 100644 --- a/src/BizHawk.Tests/Client.Common/config/SerializationStabilityTests.cs +++ b/src/BizHawk.Tests/Client.Common/config/SerializationStabilityTests.cs @@ -22,7 +22,7 @@ public sealed class SerializationStabilityTests #if NET5_0_OR_GREATER private static readonly IReadOnlySet KnownGoodFromStdlib = new HashSet #else - private static readonly ICollection KnownGoodFromStdlib = new HashSet + private static readonly HashSet KnownGoodFromStdlib = new HashSet #endif { typeof(bool), diff --git a/src/BizHawk.Tests/Common/CollectionExtensions/CollectionExtensionTests.cs b/src/BizHawk.Tests/Common/CollectionExtensions/CollectionExtensionTests.cs index a9eec1cc26c..44059330165 100644 --- a/src/BizHawk.Tests/Common/CollectionExtensions/CollectionExtensionTests.cs +++ b/src/BizHawk.Tests/Common/CollectionExtensions/CollectionExtensionTests.cs @@ -14,7 +14,7 @@ public class CollectionExtensionTests /// there isn't really an implementor which isn't and isn't immutable... so I made one private readonly struct ListImpl : IList { - private readonly IList _wrapped; + private readonly List _wrapped; public int Count => _wrapped.Count; diff --git a/src/BizHawk.Tests/Emulation.Common/Database/FirmwareDatabaseTests.cs b/src/BizHawk.Tests/Emulation.Common/Database/FirmwareDatabaseTests.cs index abd76e040ea..9dd6665788d 100644 --- a/src/BizHawk.Tests/Emulation.Common/Database/FirmwareDatabaseTests.cs +++ b/src/BizHawk.Tests/Emulation.Common/Database/FirmwareDatabaseTests.cs @@ -16,7 +16,9 @@ public void CheckFilesInOptions() public void CheckFormatOfHashes() { static void CustomAssert(string hash) +#pragma warning disable CA1862 // incorrect detection, see https://github.com/dotnet/roslyn-analyzers/issues/7074 => Assert.IsTrue(hash.Length == 40 && hash == hash.ToUpperInvariant() && hash.IsHex(), $"incorrectly formatted: {hash}"); +#pragma warning restore CA1862 foreach (var hash in FirmwareDatabase.FirmwareFilesByHash.Keys) CustomAssert(hash); foreach (var fo in FirmwareDatabase.FirmwareOptions) CustomAssert(fo.Hash); }