diff --git a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs index d476239779..4303d6fcd2 100644 --- a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs +++ b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs @@ -279,10 +279,9 @@ namespace BizHawk.BizInvoke private static void VerifyParameter(Type type) { - if (type == typeof(float) || type == typeof(double) || - type == typeof(void) || type.IsPrimitive || type.IsEnum || - type.IsPointer || typeof(Delegate).IsAssignableFrom(type) || - type.IsByRef || type.IsClass) + if (type.IsPrimitive || type.IsEnum || type.IsPointer || type.IsByRef || type.IsClass + || type == typeof(float) || type == typeof(double) || type == typeof(void) //TODO aren't these covered by IsPrimitive? --yoshi + || typeof(Delegate).IsAssignableFrom(type)) { return; } diff --git a/src/BizHawk.Bizware.Audio/DirectSoundSoundOutput.cs b/src/BizHawk.Bizware.Audio/DirectSoundSoundOutput.cs index 6dec20ea26..ac2303d9f9 100644 --- a/src/BizHawk.Bizware.Audio/DirectSoundSoundOutput.cs +++ b/src/BizHawk.Bizware.Audio/DirectSoundSoundOutput.cs @@ -88,8 +88,7 @@ namespace BizHawk.Bizware.Audio try { var status = (BufferStatus)_deviceBuffer.Status; - return (status & BufferStatus.BufferLost) == 0 && - (status & BufferStatus.Playing) == BufferStatus.Playing; + return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing; } catch (SharpDXException) { @@ -290,8 +289,7 @@ namespace BizHawk.Bizware.Audio } var status = (BufferStatus)_wavDeviceBuffer.Status; - return (status & BufferStatus.BufferLost) == 0 && - (status & BufferStatus.Playing) == BufferStatus.Playing; + return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing; } } diff --git a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs index 73c7ffedbd..202351851c 100644 --- a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs +++ b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs @@ -32,11 +32,11 @@ namespace BizHawk.Bizware.Graphics // set some sensible defaults SDL_GL_ResetAttributes(); - if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) != 0 || - SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) != 0 || - SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) != 0 || - SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) != 0 || - SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) != 0) + if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) is not 0) { throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}"); } diff --git a/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs b/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs index 9c0ce9c8b3..59f07dcaf9 100644 --- a/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs +++ b/src/BizHawk.Bizware.Input/DirectX/DKeyInput.cs @@ -56,9 +56,7 @@ namespace BizHawk.Bizware.Input lock (_lockObj) { - if (_keyboard == null || - _keyboard.Acquire().Failure || - _keyboard.Poll().Failure) + if (_keyboard is null || _keyboard.Acquire().Failure || _keyboard.Poll().Failure) { return Enumerable.Empty(); } diff --git a/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs b/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs index 821028ebb2..e5b651e4ed 100644 --- a/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs +++ b/src/BizHawk.Bizware.Input/KeyInput/RawKeyInput.cs @@ -85,8 +85,8 @@ namespace BizHawk.Bizware.Input return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - if (input->header.dwType == RAWINPUTHEADER.RIM_TYPE.KEYBOARD && - (input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) == 0) + if (input->header.dwType is RAWINPUTHEADER.RIM_TYPE.KEYBOARD + && (input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) is 0) { var handle = GCHandle.FromIntPtr(ud); var rawKeyInput = (RawKeyInput)handle.Target; diff --git a/src/BizHawk.Client.Common/DisplayManager/FilterManager.cs b/src/BizHawk.Client.Common/DisplayManager/FilterManager.cs index 903e1d936a..b2cea63311 100644 --- a/src/BizHawk.Client.Common/DisplayManager/FilterManager.cs +++ b/src/BizHawk.Client.Common/DisplayManager/FilterManager.cs @@ -238,8 +238,8 @@ namespace BizHawk.Client.Common.FilterManager { newTarget = true; } - else if (currState.SurfaceDisposition == SurfaceDisposition.Texture && - iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget) + else if (currState.SurfaceDisposition is SurfaceDisposition.Texture + && iosi.SurfaceDisposition is SurfaceDisposition.RenderTarget) { newTarget = true; } diff --git a/src/BizHawk.Client.Common/RomGame.cs b/src/BizHawk.Client.Common/RomGame.cs index 1b25517809..f7e75d2102 100644 --- a/src/BizHawk.Client.Common/RomGame.cs +++ b/src/BizHawk.Client.Common/RomGame.cs @@ -105,8 +105,7 @@ namespace BizHawk.Client.Common { RomData = FileData; } - else if (file.Extension == ".dsk" || file.Extension == ".tap" || file.Extension == ".tzx" || - file.Extension == ".pzx" || file.Extension == ".csw" || file.Extension == ".wav" || file.Extension == ".cdt") + else if (file.Extension is ".cdt" or ".csw" or ".dsk" or ".pzx" or ".tap" or ".tzx" or ".wav") { // these are not roms. unfortunately if treated as such there are certain edge-cases // where a header offset is detected. This should mitigate this issue until a cleaner solution is found diff --git a/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs b/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs index 7c5b06bd25..d46e901eb8 100644 --- a/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs +++ b/src/BizHawk.Client.Common/Sound/Utilities/SoundOutputProvider.cs @@ -239,8 +239,8 @@ namespace BizHawk.Client.Common UpdateHistory(_baseSamplesPerFrame, count, BaseSampleRateMaxHistoryLength); - if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength && - !_baseEmptyFrameCorrectionHistory.Any(n => n)) + if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength + && !_baseEmptyFrameCorrectionHistory.Contains(true)) { double baseAverageSamplesPerFrame = _baseSamplesPerFrame.Average(); if (baseAverageSamplesPerFrame != 0.0) diff --git a/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs b/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs index 0dc0d63687..4c5226fd4a 100644 --- a/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs +++ b/src/BizHawk.Client.Common/lua/LuaHelperLibs/EventsLuaLibrary.cs @@ -115,8 +115,9 @@ namespace BizHawk.Client.Common { try { - if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() && - DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) + if (DebuggableCore is not null + && DebuggableCore.MemoryCallbacksAvailable() + && DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) { if (!HasScope(scope)) { diff --git a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs index 2207629451..8ac7c1f822 100644 --- a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs +++ b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs @@ -160,12 +160,14 @@ namespace BizHawk.Client.Common { long targetSize = settings.BufferSize * 1024 * 1024; long size = 1L << (int)Math.Floor(Math.Log(targetSize, 2)); - return Size == size && - _useCompression == settings.UseCompression && - _fixedRewindInterval == settings.UseFixedRewindInterval && - (_fixedRewindInterval ? _targetRewindInterval == settings.TargetRewindInterval : _targetFrameLength == settings.TargetFrameLength) && - _allowOutOfOrderStates == settings.AllowOutOfOrderStates && - _backingStoreType == settings.BackingStore; + return Size == size + && _useCompression == settings.UseCompression + && _fixedRewindInterval == settings.UseFixedRewindInterval + && (_fixedRewindInterval + ? _targetRewindInterval == settings.TargetRewindInterval + : _targetFrameLength == settings.TargetFrameLength) + && _allowOutOfOrderStates == settings.AllowOutOfOrderStates + && _backingStoreType == settings.BackingStore; } private bool ShouldCaptureForFrameDiff(int frameDiff) diff --git a/src/BizHawk.Client.Common/tools/Cheat.cs b/src/BizHawk.Client.Common/tools/Cheat.cs index 40f4b6a83b..e91f720b02 100644 --- a/src/BizHawk.Client.Common/tools/Cheat.cs +++ b/src/BizHawk.Client.Common/tools/Cheat.cs @@ -224,8 +224,7 @@ namespace BizHawk.Client.Common case WatchSize.Word: return addr == _watch.Address || addr == _watch.Address + 1; case WatchSize.DWord: - return addr == _watch.Address || addr == _watch.Address + 1 || - addr == _watch.Address + 2 || addr == _watch.Address + 3; + return addr >= _watch.Address && addr <= _watch.Address + 3; } } diff --git a/src/BizHawk.Client.Common/tools/Watch/Watch.cs b/src/BizHawk.Client.Common/tools/Watch/Watch.cs index a823371abb..a43a2f64c3 100644 --- a/src/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/src/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -324,16 +324,8 @@ namespace BizHawk.Client.Common /// The to compare /// True if both object are equals; otherwise, false public bool Equals(Watch other) - { - if (other is null) - { - return false; - } - - return _domain == other._domain && - Address == other.Address && - Size == other.Size; - } + => other is not null + && _domain == other._domain && Address == other.Address && Size == other.Size; /// /// Determines if this is equals to an instance of diff --git a/src/BizHawk.Common/Extensions/CollectionExtensions.cs b/src/BizHawk.Common/Extensions/CollectionExtensions.cs index 4d6a6891cb..90c2696aae 100644 --- a/src/BizHawk.Common/Extensions/CollectionExtensions.cs +++ b/src/BizHawk.Common/Extensions/CollectionExtensions.cs @@ -89,13 +89,7 @@ namespace BizHawk.Common.CollectionExtensions return midItem; } } - - if (min == max && - keySelector(list[min]).CompareTo(key) == 0) - { - return list[min]; - } - + if (min == max && keySelector(list[min]).CompareTo(key) is 0) return list[min]; throw new InvalidOperationException("Item not found"); } diff --git a/src/BizHawk.Emulation.Common/DSKIdentifier.cs b/src/BizHawk.Emulation.Common/DSKIdentifier.cs index 153eae1396..743545e78e 100644 --- a/src/BizHawk.Emulation.Common/DSKIdentifier.cs +++ b/src/BizHawk.Emulation.Common/DSKIdentifier.cs @@ -207,9 +207,9 @@ namespace BizHawk.Emulation.Common } } - if (trk.Sectors[0].SectorData[7] == 3 && - trk.Sectors[0].SectorData[9] == 23 && - trk.Sectors[0].SectorData[2] == 40) + if (trk.Sectors[0].SectorData[7] is 3 + && trk.Sectors[0].SectorData[9] is 23 + && trk.Sectors[0].SectorData[2] is 40) { IdentifiedSystem = VSystemID.Raw.ZXSpectrum; return; diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 496d1514e4..b8a4b70133 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -481,8 +481,8 @@ namespace BizHawk.Emulation.DiscSystem var (dir, fileNoExt, _) = aFile.MDSPath.SplitPathToDirFileAndExt(); - if (f.FilenameOffset == 0 || - string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase)) + if (f.FilenameOffset is 0 + || string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase)) { fileName = $@"{dir}\{fileNoExt}.mdf"; } diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/NRG_format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/NRG_format.cs index 22c9abb9fc..b7eda98fcf 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/NRG_format.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/NRG_format.cs @@ -415,9 +415,7 @@ namespace BizHawk.Emulation.DiscSystem var v2 = chunkID == "DAOX"; var ntracks = ret.LastTrack - ret.FirstTrack + 1; - if (ntracks <= 0 || - ret.FirstTrack is < 0 or > 99 || - ret.LastTrack is < 0 or > 99) + if (ntracks <= 0 || ret.FirstTrack is < 0 or > 99 || ret.LastTrack is < 0 or > 99) { throw new NRGParseException("Malformed NRG format: Corrupt track numbers in DAO chunk!"); } @@ -443,9 +441,7 @@ namespace BizHawk.Emulation.DiscSystem track.TrackStartFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 26, sizeof(long))); track.TrackEndFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 34, sizeof(long))); - if (track.PregapFileOffset < 0 || - track.TrackStartFileOffset < 0 || - track.TrackEndFileOffset < 0) + if (track.PregapFileOffset < 0 || track.TrackStartFileOffset < 0 || track.TrackEndFileOffset < 0) { throw new NRGParseException("Malformed NRG format: Negative file offsets in DAOX chunk!"); } @@ -849,9 +845,7 @@ namespace BizHawk.Emulation.DiscSystem if (nrgf.DAOTrackInfos.Count > 0) { - if (nrgf.TAOTrackInfos.Count > 0 || - nrgf.RELOs.Count > 0 || - nrgf.TOCTs.Count > 0) + if (nrgf.TAOTrackInfos.Count is not 0 || nrgf.RELOs.Count is not 0 || nrgf.TOCTs.Count is not 0) { throw new NRGParseException("Malformed NRG format: DAO and TAO chunks both present on file!"); }