diff --git a/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs b/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs index 61c58cce6c6..1c4d601bede 100644 --- a/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs +++ b/src/BizHawk.Client.Common/Api/ClientWebSocketWrapper.cs @@ -38,7 +38,7 @@ public readonly Task Receive(ArraySegment buffer, ?? throw new ObjectDisposedException(nameof(_w)); /// calls - public string Receive(int bufferCap, CancellationToken? cancellationToken = null) + public readonly string Receive(int bufferCap, CancellationToken? cancellationToken = null) { if (_w == null) throw new ObjectDisposedException(nameof(_w)); var buffer = new byte[bufferCap]; @@ -52,7 +52,7 @@ public readonly Task Send(ArraySegment buffer, WebSocketMessageType messag ?? throw new ObjectDisposedException(nameof(_w)); /// calls - public Task Send(string message, bool endOfMessage, CancellationToken? cancellationToken = null) + public readonly Task Send(string message, bool endOfMessage, CancellationToken? cancellationToken = null) { if (_w == null) throw new ObjectDisposedException(nameof(_w)); return Send( diff --git a/src/BizHawk.Client.Common/tools/Watch/Watch.cs b/src/BizHawk.Client.Common/tools/Watch/Watch.cs index 44689faf01d..a823371abb1 100644 --- a/src/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/src/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -150,7 +150,7 @@ public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize s /// True if both watch are equals; otherwise, false public static bool operator ==(Watch a, Watch b) { - if (ReferenceEquals(a, null) || ReferenceEquals(b, null)) + if (a is null || b is null) { return false; } @@ -171,7 +171,7 @@ public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize s /// True if they are equals; otherwise, false public static bool operator ==(Watch a, Cheat b) { - if (ReferenceEquals(a, null) || ReferenceEquals(b, null)) + if (a is null || b is null) { return false; } @@ -325,7 +325,7 @@ public void ClearChangeCount() /// True if both object are equals; otherwise, false public bool Equals(Watch other) { - if (ReferenceEquals(other, null)) + if (other is null) { return false; } @@ -342,7 +342,7 @@ public bool Equals(Watch other) /// True if both object are equals; otherwise, false public bool Equals(Cheat other) { - return !ReferenceEquals(other, null) + return other is not null && _domain == other.Domain && Address == other.Address && Size == other.Size; diff --git a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs index 4b3140f47ad..ac93363e229 100644 --- a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs +++ b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchEqualityComparer.cs @@ -18,12 +18,12 @@ private class WatchEqualityComparer : IEqualityComparer /// True if are equal; otherwise, false public bool Equals(Watch x, Watch y) { - if (ReferenceEquals(x, null)) + if (x is null) { - return ReferenceEquals(y, null); + return y is null; } - if (ReferenceEquals(y, null)) + if (y is null) { return false; } diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs index 7d850c28c17..ce631c8a30f 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/Cell.cs @@ -37,7 +37,7 @@ public override int GetHashCode() public static bool operator ==(Cell a, Cell b) { - return a?.Equals(b) ?? ReferenceEquals(b, null); + return a?.Equals(b) ?? b is null; } public static bool operator !=(Cell a, Cell b) diff --git a/src/BizHawk.Common/EndiannessUtils.cs b/src/BizHawk.Common/EndiannessUtils.cs index 6065b00ec46..6924f40ef2c 100644 --- a/src/BizHawk.Common/EndiannessUtils.cs +++ b/src/BizHawk.Common/EndiannessUtils.cs @@ -31,10 +31,8 @@ public static void MutatingByteSwap32(Span a) fixed (byte* p = &a[0]) for (var i = 0; i < l; i += 4) { (p[i + 3], p[i]) = (p[i], p[i + 3]); - var b = p[i + 1]; - p[i + 1] = p[i + 2]; - p[i + 2] = b; - } + (p[i + 2], p[i + 1]) = (p[i + 1], p[i + 2]); + } #else Debug.Assert(a.Length % 4 == 0); var ints = MemoryMarshal.Cast(a); diff --git a/src/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs b/src/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs index b4c28df0e8f..eb2c172d5f1 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs @@ -651,9 +651,7 @@ public void ADDS_Func(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) public void EXCH_16_Func(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { (Regs[src_l], Regs[dest_l]) = (Regs[dest_l], Regs[src_l]); - var temp = Regs[dest_h]; - Regs[dest_h] = Regs[src_h]; - Regs[src_h] = temp; + (Regs[src_h], Regs[dest_h]) = (Regs[dest_h], Regs[src_h]); } public void SBC_16_Func(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Timing.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Timing.cs index 0161c69332a..ca262c336e4 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Timing.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Timing.cs @@ -28,10 +28,10 @@ private long CurrentCPUCycle } #pragma warning restore IDE0051 - /// - /// The last CPU cycle when the FDC accepted an IO read/write - /// - private long LastCPUCycle; + /// + /// The last CPU cycle when the FDC accepted an IO read/write + /// + private long LastCPUCycle; /// /// The current delay figure (in Z80 t-states) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs index 1b49049dd2d..887ca48b688 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs @@ -346,7 +346,7 @@ private struct CommStruct //utilities //TODO: make internal, wrap on the API instead of the comm - public string GetAscii() => _getAscii(str); + public readonly string GetAscii() => _getAscii(str); public readonly bool GetBool() { return value != 0; } private readonly string _getAscii(sbyte* ptr) diff --git a/src/BizHawk.Emulation.DiscSystem/DiscSubQ.cs b/src/BizHawk.Emulation.DiscSystem/DiscSubQ.cs index 25ca67fc499..060cec3d1da 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscSubQ.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscSubQ.cs @@ -91,7 +91,7 @@ public struct SubchannelQ /// Retrieves the initial set of timestamps (min,sec,frac) as a convenient Timestamp /// public int Timestamp { - get => MSF.ToInt(min.DecimalValue, sec.DecimalValue, frame.DecimalValue); + readonly get => MSF.ToInt(min.DecimalValue, sec.DecimalValue, frame.DecimalValue); set { var ts = new Timestamp(value); min.DecimalValue = ts.MIN; sec.DecimalValue = ts.SEC; frame.DecimalValue = ts.FRAC; @@ -103,7 +103,7 @@ public int Timestamp { /// TODO - rename everything AP here, it's nonsense. (the P is) /// public int AP_Timestamp { - get => MSF.ToInt(ap_min.DecimalValue, ap_sec.DecimalValue, ap_frame.DecimalValue); + readonly get => MSF.ToInt(ap_min.DecimalValue, ap_sec.DecimalValue, ap_frame.DecimalValue); set { var ts = new Timestamp(value); ap_min.DecimalValue = ts.MIN; ap_sec.DecimalValue = ts.SEC; ap_frame.DecimalValue = ts.FRAC; diff --git a/src/BizHawk.Emulation.DiscSystem/DiscTypes.cs b/src/BizHawk.Emulation.DiscSystem/DiscTypes.cs index 4ed21a213de..7566faf9d1a 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscTypes.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscTypes.cs @@ -34,7 +34,7 @@ public readonly bool Equals(BCD2 other) return BCDValue == other.BCDValue; } - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { return obj is BCD2 other && Equals(other); }