diff --git a/Common.ruleset b/Common.ruleset index 88727c35db..bf97cebb1b 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -239,7 +239,7 @@ - + diff --git a/src/BizHawk.BizInvoke/BizInvokeUtilities.cs b/src/BizHawk.BizInvoke/BizInvokeUtilities.cs index 75c7553589..bf9196b803 100644 --- a/src/BizHawk.BizInvoke/BizInvokeUtilities.cs +++ b/src/BizHawk.BizInvoke/BizInvokeUtilities.cs @@ -82,7 +82,7 @@ namespace BizHawk.BizInvoke var t = o.GetType(); if (t == typeof(OutAttribute) || t == typeof(InAttribute)) { - return new CustomAttributeBuilder(t.GetConstructor(Type.EmptyTypes)!, new object[0]); + return new CustomAttributeBuilder(t.GetConstructor(Type.EmptyTypes)!, Array.Empty()); } throw new InvalidOperationException($"Unknown parameter attribute {t.Name}"); diff --git a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs index 070dda8165..e2bd0b02d2 100644 --- a/src/BizHawk.BizInvoke/BizInvokerUtilities.cs +++ b/src/BizHawk.BizInvoke/BizInvokerUtilities.cs @@ -61,7 +61,7 @@ namespace BizHawk.BizInvoke /// public static int ComputeStringOffset() { - var s = new string(new char[0]); + var s = new string(Array.Empty()); int ret; fixed(char* fx = s) { diff --git a/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs b/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs index d1b131184b..e594dab7c1 100644 --- a/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs +++ b/src/BizHawk.Client.Common/DisplayManager/DisplayManagerBase.cs @@ -535,7 +535,8 @@ namespace BizHawk.Client.Common private class FakeVideoProvider : IVideoProvider { - public int[] GetVideoBuffer() => new int[] {}; + public int[] GetVideoBuffer() + => Array.Empty(); public int VirtualWidth { get; set; } public int VirtualHeight { get; set; } diff --git a/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs b/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs index f7f1818203..6a044f6bb7 100644 --- a/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs +++ b/src/BizHawk.Client.Common/DisplayManager/Filters/Retro.cs @@ -105,7 +105,7 @@ namespace BizHawk.Client.Common.Filters public readonly string Errors; public readonly IGL Owner; public readonly RetroShaderPreset Preset; - public readonly RetroShader[] Shaders = new RetroShader[0]; + public readonly IReadOnlyList Shaders = Array.Empty(); public readonly RetroShaderPreset.ShaderPass[] Passes; private bool _isDisposed; diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 176ee60719..7412453353 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -817,7 +817,7 @@ namespace BizHawk.Client.Common public static readonly IReadOnlyCollection ZXSpectrum = new[] { "tzx", "tap", "dsk", "pzx" }; - public static readonly IReadOnlyCollection AutoloadFromArchive = new string[0] + public static readonly IReadOnlyCollection AutoloadFromArchive = Array.Empty() .Concat(A26) .Concat(A78) .Concat(AppleII) @@ -848,12 +848,12 @@ namespace BizHawk.Client.Common /// TODO add and handle (you can drag-and-drop scripts and there are already non-rom things in this list, so why not?) private static readonly FilesystemFilterSet RomFSFilterSet = new FilesystemFilterSet( - new FilesystemFilter("Music Files", new string[0], devBuildExtraExts: new[] { "psf", "minipsf", "sid", "nsf" }), + new FilesystemFilter("Music Files", Array.Empty(), devBuildExtraExts: new[] { "psf", "minipsf", "sid", "nsf" }), new FilesystemFilter("Disc Images", new[] { "cue", "ccd", "mds", "m3u" }), new FilesystemFilter("NES", RomFileExtensions.NES.Concat(new[] { "nsf" }).ToList(), addArchiveExts: true), new FilesystemFilter("Super NES", RomFileExtensions.SNES, addArchiveExts: true), new FilesystemFilter("PlayStation", new[] { "cue", "ccd", "mds", "m3u" }), - new FilesystemFilter("PSX Executables (experimental)", new string[0], devBuildExtraExts: new[] { "exe" }), + new FilesystemFilter("PSX Executables (experimental)", Array.Empty(), devBuildExtraExts: new[] { "exe" }), new FilesystemFilter("PSF Playstation Sound File", new[] { "psf", "minipsf" }), new FilesystemFilter("Nintendo 64", RomFileExtensions.N64), new FilesystemFilter("Gameboy", RomFileExtensions.GB, addArchiveExts: true), @@ -869,13 +869,13 @@ namespace BizHawk.Client.Common new FilesystemFilter("TI-83", RomFileExtensions.TI83, addArchiveExts: true), FilesystemFilter.Archives, new FilesystemFilter("Genesis", RomFileExtensions.GEN.Concat(new[] { "bin", "cue", "ccd" }).ToList(), addArchiveExts: true), - new FilesystemFilter("SID Commodore 64 Music File", new string[0], devBuildExtraExts: new[] { "sid" }, devBuildAddArchiveExts: true), + new FilesystemFilter("SID Commodore 64 Music File", Array.Empty(), devBuildExtraExts: new[] { "sid" }, devBuildAddArchiveExts: true), new FilesystemFilter("WonderSwan", RomFileExtensions.WSWAN, addArchiveExts: true), new FilesystemFilter("Apple II", RomFileExtensions.AppleII, addArchiveExts: true), new FilesystemFilter("Virtual Boy", RomFileExtensions.VB, addArchiveExts: true), new FilesystemFilter("Neo Geo Pocket", RomFileExtensions.NGP, addArchiveExts: true), new FilesystemFilter("Commodore 64", RomFileExtensions.C64, addArchiveExts: true), - new FilesystemFilter("Amstrad CPC", new string[0], devBuildExtraExts: new[] { "cdt", "dsk" }, devBuildAddArchiveExts: true), + new FilesystemFilter("Amstrad CPC", Array.Empty(), devBuildExtraExts: new[] { "cdt", "dsk" }, devBuildAddArchiveExts: true), new FilesystemFilter("Sinclair ZX Spectrum", RomFileExtensions.ZXSpectrum.Concat(new[] { "csw", "wav" }).ToList(), addArchiveExts: true), new FilesystemFilter("Odyssey 2", RomFileExtensions.O2), new FilesystemFilter("Uzebox", RomFileExtensions.UZE), diff --git a/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs b/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs index 970a036c21..7c5b06bd25 100644 --- a/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs +++ b/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs @@ -47,9 +47,9 @@ namespace BizHawk.Client.Common private double _lastAdvertisedSamplesPerFrame; private readonly Queue _baseSamplesPerFrame = new Queue(); - private short[] _outputBuffer = new short[0]; + private short[] _outputBuffer = Array.Empty(); - private short[] _resampleBuffer = new short[0]; + private short[] _resampleBuffer = Array.Empty(); private double _resampleLengthRoundingError; public SoundOutputProvider(Func getCoreVsyncRateCallback, bool standaloneMode = false) @@ -90,8 +90,8 @@ namespace BizHawk.Client.Common _baseEmptyFrameCorrectionHistory.Clear(); _lastAdvertisedSamplesPerFrame = 0.0; _baseSamplesPerFrame.Clear(); - _outputBuffer = new short[0]; - _resampleBuffer = new short[0]; + _outputBuffer = Array.Empty(); + _resampleBuffer = Array.Empty(); _resampleLengthRoundingError = 0.0; BaseSoundProvider?.DiscardSamples(); diff --git a/src/BizHawk.Client.Common/movie/import/MovieImport.cs b/src/BizHawk.Client.Common/movie/import/MovieImport.cs index 041bfe4916..ec1960fc6f 100644 --- a/src/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/src/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -47,13 +47,10 @@ namespace BizHawk.Client.Common } // Create a new instance of the importer class using the no-argument constructor - IMovieImport importer = (IMovieImport)importerType - .GetConstructor(new Type[] { }) - ?.Invoke(new object[] { }); - return importer == null - ? ImportResult.Error($"No importer found for file type {ext}") - : importer.Import(dialogParent, session, emulator, path, config); + return importerType.GetConstructor(Array.Empty())?.Invoke(Array.Empty()) is IMovieImport importer + ? importer.Import(dialogParent, session, emulator, path, config) + : ImportResult.Error($"No importer found for file type {ext}"); } private static Type ImporterForExtension(string ext) diff --git a/src/BizHawk.Client.Common/movie/tasproj/ZwinderStateManager.cs b/src/BizHawk.Client.Common/movie/tasproj/ZwinderStateManager.cs index 29652d4ce4..7a0f5bbe4a 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/ZwinderStateManager.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/ZwinderStateManager.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.Common { public class ZwinderStateManager : IStateManager, IDisposable { - private static readonly byte[] NonState = new byte[0]; + private static readonly byte[] NonState = Array.Empty(); private readonly Func _reserveCallback; internal readonly SortedList StateCache = new SortedList(); diff --git a/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs b/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs index dfe2ecf412..5bc3187df8 100644 --- a/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs +++ b/src/BizHawk.Client.Common/rewind/ZeldaWinder.cs @@ -17,10 +17,10 @@ namespace BizHawk.Client.Common private readonly ZwinderBuffer _buffer; private readonly IStatable _stateSource; - private byte[] _master = new byte[0]; + private byte[] _master = Array.Empty(); private int _masterFrame = -1; private int _masterLength = 0; - private byte[] _scratch = new byte[0]; + private byte[] _scratch = Array.Empty(); private int _count; private Task _activeTask = null; diff --git a/src/BizHawk.Client.EmuHawk/AVOut/AVSync.cs b/src/BizHawk.Client.EmuHawk/AVOut/AVSync.cs index e9e681f264..51a509095d 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/AVSync.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/AVSync.cs @@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk W = w; } - private short[] _samples = new short[0]; + private short[] _samples = Array.Empty(); // how many extra audio samples there are (* fpsNum) private long _exAudioNum; diff --git a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index 2055050249..d30aa6a785 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -420,8 +420,8 @@ namespace BizHawk.Client.EmuHawk private CodecToken() { } private AVIWriterImports.AVICOMPRESSOPTIONS _comprOptions; public string codec; - public byte[] Format = new byte[0]; - public byte[] Parms = new byte[0]; + public byte[] Format = Array.Empty(); + public byte[] Parms = Array.Empty(); private static string Decode_mmioFOURCC(int code) { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs b/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs index e84877247a..e8d18e4449 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs @@ -390,7 +390,7 @@ namespace BizHawk.Client.EmuHawk WriteVarU(1, header); // max_pts_distance WriteVarU(0, header); // decode_delay WriteVarU(1, header); // stream_flags = FLAG_FIXED_FPS - WriteBytes(new byte[0], header); // codec_specific_data + WriteBytes(Array.Empty(), header); // codec_specific_data // stream_class = video WriteVarU(_avParams.Width, header); // width @@ -414,7 +414,7 @@ namespace BizHawk.Client.EmuHawk WriteVarU(_avParams.Samplerate, header); // max_pts_distance WriteVarU(0, header); // decode_delay WriteVarU(0, header); // stream_flags = none; no FIXED_FPS because we aren't guaranteeing same-size audio chunks - WriteBytes(new byte[0], header); // codec_specific_data + WriteBytes(Array.Empty(), header); // codec_specific_data // stream_class = audio WriteVarU(_avParams.Samplerate, header); // samplerate_num @@ -649,12 +649,12 @@ namespace BizHawk.Client.EmuHawk { if (!_videoDone) { - WriteVideoFrame(new int[0]); + WriteVideoFrame(Array.Empty()); } if (!_audioDone) { - WriteAudioFrame(new short[0]); + WriteAudioFrame(Array.Empty()); } // flush any remaining queued packets diff --git a/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs b/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs index 331d0e6d17..9ef09281c6 100644 --- a/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs +++ b/src/BizHawk.Client.EmuHawk/ArchiveChooser.cs @@ -234,8 +234,7 @@ namespace BizHawk.Client.EmuHawk { return new SimpleMatcher { - Keys = searchKey.ToLower().Split(new char[0], - StringSplitOptions.RemoveEmptyEntries) + Keys = searchKey.ToLower().Split(Array.Empty(), StringSplitOptions.RemoveEmptyEntries) // splits on all whitespace chars }; } else diff --git a/src/BizHawk.Client.EmuHawk/movie/RecordMovie.cs b/src/BizHawk.Client.EmuHawk/movie/RecordMovie.cs index 3db2c35df2..f1bf59ff1d 100644 --- a/src/BizHawk.Client.EmuHawk/movie/RecordMovie.cs +++ b/src/BizHawk.Client.EmuHawk/movie/RecordMovie.cs @@ -134,7 +134,7 @@ namespace BizHawk.Client.EmuHawk } // TODO: do we want to support optionally not saving this? - movieToRecord.SavestateFramebuffer = new int[0]; + movieToRecord.SavestateFramebuffer = Array.Empty(); if (_emulator.HasVideoProvider()) { movieToRecord.SavestateFramebuffer = (int[])_emulator.AsVideoProvider().GetVideoBuffer().Clone(); diff --git a/src/BizHawk.Client.EmuHawk/tools/CDL.cs b/src/BizHawk.Client.EmuHawk/tools/CDL.cs index 1f334740c5..de33795bd8 100644 --- a/src/BizHawk.Client.EmuHawk/tools/CDL.cs +++ b/src/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -116,7 +116,7 @@ namespace BizHawk.Client.EmuHawk tsbLoggingActive.Checked = value; } - private string[][] _listContents = new string[0][]; + private string[][] _listContents = Array.Empty(); private unsafe void UpdateDisplay(bool force) { diff --git a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 9551ceba51..c63b31e416 100644 --- a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -363,9 +363,7 @@ namespace BizHawk.Client.EmuHawk private byte[] ConvertHexStringToByteArray(string str) { - if (string.IsNullOrWhiteSpace(str)) { - return new byte[0]; - } + if (string.IsNullOrWhiteSpace(str)) return Array.Empty(); // TODO: Better method of handling this? if (str.Length % 2 == 1) diff --git a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 8e1439730f..8509c5b0b4 100644 --- a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -421,7 +421,7 @@ namespace BizHawk.Client.EmuHawk int bgnum = (int)selection; var bg = si.BG[bgnum]; - map = new SNESGraphicsDecoder.TileEntry[0]; + map = Array.Empty(); viewBgMode = bg.BGMode; //bool handled = false; diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 1fb394ec91..d5863c1ad8 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -394,10 +394,8 @@ namespace BizHawk.Client.EmuHawk RefreshSettings(form, dest, settings, idx); form.Size = oldSize; - form.GetType() - .GetMethodsWithAttrib(typeof(RestoreDefaultsAttribute)) - .FirstOrDefault() - ?.Invoke(form, new object[0]); + form.GetType().GetMethodsWithAttrib(typeof(RestoreDefaultsAttribute)) + .FirstOrDefault()?.Invoke(form, Array.Empty()); }; } diff --git a/src/BizHawk.Common/Serializer.cs b/src/BizHawk.Common/Serializer.cs index 0616b8b572..5fb100b498 100644 --- a/src/BizHawk.Common/Serializer.cs +++ b/src/BizHawk.Common/Serializer.cs @@ -197,7 +197,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new byte[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.BytesToHexString()); } } @@ -213,7 +213,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToBoolBuffer(); if (val == null && !useNull) { - val = new bool[0]; + val = Array.Empty(); } } else @@ -239,7 +239,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new bool[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -254,7 +254,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToShortBuffer(); if (val == null && !useNull) { - val = new short[0]; + val = Array.Empty(); } } else @@ -274,7 +274,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToUShortBuffer(); if (val == null && !useNull) { - val = new ushort[0]; + val = Array.Empty(); } } else @@ -300,7 +300,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new short[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -322,7 +322,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new ushort[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -338,7 +338,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToIntBuffer(); if (val == null && !useNull) { - val = new int[0]; + val = Array.Empty(); } } else @@ -364,7 +364,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new int[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -380,7 +380,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToUIntBuffer(); if (val == null && !useNull) { - val = new uint[0]; + val = Array.Empty(); } } else @@ -406,7 +406,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new uint[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -422,7 +422,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToFloatBuffer(); if (val == null && !useNull) { - val = new float[0]; + val = Array.Empty(); } } else @@ -448,7 +448,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new float[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } @@ -464,7 +464,7 @@ namespace BizHawk.Common val = _br.ReadByteBuffer(false).ToDoubleBuffer(); if (val == null && !useNull) { - val = new double[0]; + val = Array.Empty(); } } else @@ -490,7 +490,7 @@ namespace BizHawk.Common } else { - var temp = val ?? new double[0]; + var temp = val ?? Array.Empty(); _tw.WriteLine("{0} {1}", name, temp.ToUByteBuffer().BytesToHexString()); } } diff --git a/src/BizHawk.Common/SpanStream.cs b/src/BizHawk.Common/SpanStream.cs index 08401cdca2..8052ea3a95 100644 --- a/src/BizHawk.Common/SpanStream.cs +++ b/src/BizHawk.Common/SpanStream.cs @@ -30,7 +30,7 @@ namespace BizHawk.Common { _stream = stream; } - private byte[] _buffer = new byte[0]; + private byte[] _buffer = Array.Empty(); private readonly Stream _stream; public unsafe int Read(Span buffer) { diff --git a/src/BizHawk.Emulation.Common/Base Implementations/NullSound.cs b/src/BizHawk.Emulation.Common/Base Implementations/NullSound.cs index 685f16358c..dfc8c57181 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/NullSound.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/NullSound.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Common private readonly long _spfNumerator; private readonly long _spfDenominator; private long _remainder; - private short[] _buff = new short[0]; + private short[] _buff = Array.Empty(); private NullSound() { diff --git a/src/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs b/src/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs index 9fa040d2b4..08f1f0966e 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Common.Base_Implementations /// public class SimpleSyncSoundProvider : ISoundProvider { - private short[] _buffer = new short[0]; + private short[] _buffer = Array.Empty(); private int _nsamp; public bool CanProvideAsync => false; diff --git a/src/BizHawk.Emulation.Common/DSKIdentifier.cs b/src/BizHawk.Emulation.Common/DSKIdentifier.cs index e68f7287f0..98176c4796 100644 --- a/src/BizHawk.Emulation.Common/DSKIdentifier.cs +++ b/src/BizHawk.Emulation.Common/DSKIdentifier.cs @@ -1,5 +1,6 @@ #nullable disable +using System; using System.Linq; using System.Text; @@ -238,7 +239,7 @@ namespace BizHawk.Emulation.Common { if (TrackSizes[i] == 0) { - Tracks[i] = new Track { Sectors = new Sector[0] }; + Tracks[i] = new() { Sectors = Array.Empty() }; continue; } int p = pos; @@ -313,7 +314,7 @@ namespace BizHawk.Emulation.Common { if (TrackSizes[i] == 0) { - Tracks[i] = new Track { Sectors = new Sector[0] }; + Tracks[i] = new() { Sectors = Array.Empty() }; continue; } int p = pos; diff --git a/src/BizHawk.Emulation.Common/Interfaces/Services/ISettable.cs b/src/BizHawk.Emulation.Common/Interfaces/Services/ISettable.cs index 06b2702285..61a6291121 100644 --- a/src/BizHawk.Emulation.Common/Interfaces/Services/ISettable.cs +++ b/src/BizHawk.Emulation.Common/Interfaces/Services/ISettable.cs @@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Common public bool HasSyncSettings { get; } private readonly object[] _tempObject = new object[1]; - private static readonly object[] Empty = new object[0]; + private static readonly object[] Empty = Array.Empty(); private readonly MethodInfo _gets; private readonly MethodInfo _puts; diff --git a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index a700c96507..6ffed5ddf1 100644 --- a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -5,7 +5,7 @@ true - $(NoWarn);CA1806;CA2214;SA1100;SA1120;SA1137;SA1205;SA1208;SA1400 + $(NoWarn);CA1806;CA1825;CA2214;SA1100;SA1120;SA1137;SA1205;SA1208;SA1400 disable diff --git a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs index 20646d5bdd..4901f2f1ab 100644 --- a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs +++ b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs @@ -574,7 +574,7 @@ namespace BizHawk.Tests.Client.Common.Movie private class StateSource : IStatable { public int Frame { get; set; } - public byte[] PaddingData { get; set; } = new byte[0]; + public byte[] PaddingData { get; set; } = Array.Empty(); public void LoadStateBinary(BinaryReader reader) { Frame = reader.ReadInt32();