diff --git a/Common.ruleset b/Common.ruleset index 1d8f1d9a49..88727c35db 100644 --- a/Common.ruleset +++ b/Common.ruleset @@ -209,7 +209,7 @@ - + diff --git a/src/BizHawk.BizInvoke/MemoryBlockLinuxPal.cs b/src/BizHawk.BizInvoke/MemoryBlockLinuxPal.cs index a38aca0e01..1a4ac74c8b 100644 --- a/src/BizHawk.BizInvoke/MemoryBlockLinuxPal.cs +++ b/src/BizHawk.BizInvoke/MemoryBlockLinuxPal.cs @@ -31,7 +31,7 @@ namespace BizHawk.BizInvoke { if (_disposed) return; - munmap(Z.US(Start), Z.UU(_size)); + _ = munmap(Z.US(Start), Z.UU(_size)); _disposed = true; GC.SuppressFinalize(this); } diff --git a/src/BizHawk.Client.Common/ArgParser.cs b/src/BizHawk.Client.Common/ArgParser.cs index 749b6cd525..bd5a56b6b7 100644 --- a/src/BizHawk.Client.Common/ArgParser.cs +++ b/src/BizHawk.Client.Common/ArgParser.cs @@ -98,7 +98,7 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWith("--dump-length=")) { - int.TryParse(argDowncased.Substring(argDowncased.IndexOf('=') + 1), out var len); + var len = int.TryParse(argDowncased.Substring(argDowncased.IndexOf('=') + 1), out var i1) ? i1 : default; autoDumpLength = len; } else if (argDowncased.StartsWith("--dump-close")) @@ -125,7 +125,7 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWith("--socket_port=")) { - int.TryParse(argDowncased.Substring(argDowncased.IndexOf('=') + 1), out var port); + var port = int.TryParse(argDowncased.Substring(argDowncased.IndexOf('=') + 1), out var i1) ? i1 : default; if (port > 0) socketPort = port; } else if (argDowncased.StartsWith("--socket_ip=")) diff --git a/src/BizHawk.Client.Common/movie/import/DsmImport.cs b/src/BizHawk.Client.Common/movie/import/DsmImport.cs index 4c0a9b694a..e28e39b45b 100644 --- a/src/BizHawk.Client.Common/movie/import/DsmImport.cs +++ b/src/BizHawk.Client.Common/movie/import/DsmImport.cs @@ -40,8 +40,7 @@ namespace BizHawk.Client.Common } else if (line.StartsWith("rerecordCount")) { - int.TryParse(ParseHeader(line, "rerecordCount"), out var rerecordCount); - Result.Movie.Rerecords = (ulong)rerecordCount; + Result.Movie.Rerecords = (ulong) (int.TryParse(ParseHeader(line, "rerecordCount"), out var rerecordCount) ? rerecordCount : default); } else if (line.StartsWith("firmNickname")) { diff --git a/src/BizHawk.Client.Common/movie/import/Fm2Import.cs b/src/BizHawk.Client.Common/movie/import/Fm2Import.cs index bd7c0bc759..b7562df451 100644 --- a/src/BizHawk.Client.Common/movie/import/Fm2Import.cs +++ b/src/BizHawk.Client.Common/movie/import/Fm2Import.cs @@ -97,8 +97,7 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("rerecordcount")) { - int.TryParse(ParseHeader(line, "rerecordCount"), out var rerecordCount); - Result.Movie.Rerecords = (ulong)rerecordCount; + Result.Movie.Rerecords = (ulong) (int.TryParse(ParseHeader(line, "rerecordCount"), out var rerecordCount) ? rerecordCount : default); } else if (line.ToLower().StartsWith("guid")) { diff --git a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs index ee30050003..eeb48e269f 100644 --- a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs +++ b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchValueComparer.cs @@ -26,26 +26,13 @@ namespace BizHawk.Client.Common /// 0 for equality, 1 if x comes first; -1 if y comes first public int Compare(Watch x, Watch y) { - int xValue; - int yValue; + var xValue = x.Type is not WatchDisplayType.Signed + ? x.Value + : int.TryParse(x.ValueString, out var i) ? i : default; - if (x.Type == WatchDisplayType.Signed) - { - int.TryParse(x.ValueString, out xValue); - } - else - { - xValue = x.Value; - } - - if (y.Type == WatchDisplayType.Signed) - { - int.TryParse(y.ValueString, out yValue); - } - else - { - yValue = y.Value; - } + var yValue = y.Type is not WatchDisplayType.Signed + ? y.Value + : int.TryParse(y.ValueString, out var i1) ? i1 : default; if (Equals(x, y)) { diff --git a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index 690db00c05..2055050249 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -808,19 +808,19 @@ namespace BizHawk.Client.EmuHawk CloseStreams(); if (_pAviRawAudioStream != IntPtr.Zero) { - AVIWriterImports.AVIStreamRelease(_pAviRawAudioStream); + _ = AVIWriterImports.AVIStreamRelease(_pAviRawAudioStream); _pAviRawAudioStream = IntPtr.Zero; } if (_pAviRawVideoStream != IntPtr.Zero) { - AVIWriterImports.AVIStreamRelease(_pAviRawVideoStream); + _ = AVIWriterImports.AVIStreamRelease(_pAviRawVideoStream); _pAviRawVideoStream = IntPtr.Zero; } if (_pAviFile != IntPtr.Zero) { - AVIWriterImports.AVIFileRelease(_pAviFile); + _ = AVIWriterImports.AVIFileRelease(_pAviFile); _pAviFile = IntPtr.Zero; } @@ -844,7 +844,7 @@ namespace BizHawk.Client.EmuHawk if (_pAviCompressedVideoStream != IntPtr.Zero) { - AVIWriterImports.AVIStreamRelease(_pAviCompressedVideoStream); + _ = AVIWriterImports.AVIStreamRelease(_pAviCompressedVideoStream); _pAviCompressedVideoStream = IntPtr.Zero; } } @@ -884,7 +884,7 @@ namespace BizHawk.Client.EmuHawk } // (TODO - inefficient- build directly in a buffer) - AVIWriterImports.AVIStreamWrite(_pAviRawAudioStream, _outStatus.audio_samples, todo_realsamples, buf, todo_realsamples * 4, 0, IntPtr.Zero, out var bytes_written); + _ = AVIWriterImports.AVIStreamWrite(_pAviRawAudioStream, _outStatus.audio_samples, todo_realsamples, buf, todo_realsamples * 4, 0, IntPtr.Zero, out var bytes_written); _outStatus.audio_samples += todo_realsamples; _outStatus.audio_bytes += bytes_written; _outStatus.audio_buffered_shorts = 0; diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/FolderBrowserDialogEx.cs b/src/BizHawk.Client.EmuHawk/CustomControls/FolderBrowserDialogEx.cs index 4a0026c890..9c1f3d45ea 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/FolderBrowserDialogEx.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/FolderBrowserDialogEx.cs @@ -45,7 +45,7 @@ namespace BizHawk.Client.EmuHawk } var hWndOwner = owner?.Handle ?? Win32Imports.GetActiveWindow(); - Win32Imports.SHGetSpecialFolderLocation(hWndOwner, startLocation, out var pidlRoot); + _ = Win32Imports.SHGetSpecialFolderLocation(hWndOwner, startLocation, out var pidlRoot); if (pidlRoot == IntPtr.Zero) return DialogResult.Cancel; var mergedOptions = publicOptions | privateOptions; if ((mergedOptions & Win32Imports.BROWSEINFO.FLAGS.NewDialogStyle) != 0 && ApartmentState.MTA == Application.OleRequired()) @@ -75,7 +75,7 @@ namespace BizHawk.Client.EmuHawk } finally { - Win32Imports.SHGetMalloc(out var malloc); + _ = Win32Imports.SHGetMalloc(out var malloc); malloc.Free(pidlRoot); if (pidlRet != IntPtr.Zero) malloc.Free(pidlRet); } diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index 4b9a789b03..2c13af0547 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk // this will look in subdirectory "dll" to load pinvoked stuff var dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - SetDllDirectory(dllDir); + _ = SetDllDirectory(dllDir); //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; @@ -226,7 +226,7 @@ namespace BizHawk.Client.EmuHawk //note: this is pasted instead of being put in a static method due to this initialization code being sensitive to things like that, and not wanting to cause it to break //pasting should be safe (not affecting the jit order of things) var dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - SetDllDirectory(dllDir); + _ = SetDllDirectory(dllDir); } Util.DebugWriteLine(EmuHawkUtil.CLRHostHasElevatedPrivileges ? "running as Superuser/Administrator" : "running as unprivileged user"); diff --git a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 0b40657828..a700c96507 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);CA2214;SA1100;SA1120;SA1137;SA1205;SA1208;SA1400 + $(NoWarn);CA1806;CA2214;SA1100;SA1120;SA1137;SA1205;SA1208;SA1400 disable diff --git a/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs b/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs index 4861442c24..4ada99f9b2 100644 --- a/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs +++ b/src/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs @@ -44,7 +44,7 @@ namespace BizHawk.Emulation.DiscSystem { //read directly into the target buffer fixed(byte* pBuffer = &buffer[0]) - mednadisc_ReadSector(handle, LBA, pBuffer + offset); + _ = mednadisc_ReadSector(handle, LBA, pBuffer + offset); } #if false