diff --git a/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index f16247b3fb..436b34f9ff 100644 --- a/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -876,8 +876,7 @@ namespace BizHawk.Client.EmuHawk } // (TODO - inefficient- build directly in a buffer) - int bytes_written; - AVIWriterImports.AVIStreamWrite(pAviRawAudioStream, outStatus.audio_samples, todo_realsamples, buf, todo_realsamples * 4, 0, IntPtr.Zero, out 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; @@ -925,8 +924,7 @@ namespace BizHawk.Client.EmuHawk bp += pitch_add; } - int bytes_written; - int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo, AVIIF_KEYFRAME, IntPtr.Zero, out bytes_written); + int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo, AVIIF_KEYFRAME, IntPtr.Zero, out var bytes_written); outStatus.video_bytes += bytes_written; outStatus.video_frames++; } @@ -957,8 +955,7 @@ namespace BizHawk.Client.EmuHawk idx -= w * 2; } - int bytes_written; - int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo * 3, AVIIF_KEYFRAME, IntPtr.Zero, out bytes_written); + int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo * 3, AVIIF_KEYFRAME, IntPtr.Zero, out var bytes_written); outStatus.video_bytes += bytes_written; outStatus.video_frames++; } diff --git a/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs b/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs index e1c0d76984..3fa8d447f5 100644 --- a/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs +++ b/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs @@ -47,7 +47,7 @@ namespace BizHawk.Client.EmuHawk //NOTE: this throws EGL exceptions anyway. I'm going to ignore it and whine about it later } - public string API { get { return "OPENGL"; } } + public string API => "OPENGL"; public int Version { @@ -252,9 +252,8 @@ namespace BizHawk.Client.EmuHawk if (required) throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}"); else success = false; - - int linkStatus; - GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus); + + GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out var linkStatus); if (linkStatus == 0) if (required) throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}"); @@ -286,8 +285,7 @@ namespace BizHawk.Client.EmuHawk //get all the attributes (not needed) List attributes = new List(); - int nAttributes; - GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes); + GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out var nAttributes); for (int i = 0; i < nAttributes; i++) { int size, length; @@ -299,16 +297,14 @@ namespace BizHawk.Client.EmuHawk //get all the uniforms List uniforms = new List(); - int nUniforms; - GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out nUniforms); + GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out var nUniforms); List samplers = new List(); for (int i = 0; i < nUniforms; i++) { int size, length; - ActiveUniformType type; string name = new System.Text.StringBuilder(1024).ToString(); - GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, out name); + GL.GetActiveUniform(pid, i, 1024, out length, out size, out var type, out name); errcode = GL.GetError(); int loc = GL.GetUniformLocation(pid, name); @@ -758,8 +754,7 @@ namespace BizHawk.Client.EmuHawk } } - int n; - GL.GetShader(sid, ShaderParameter.CompileStatus, out n); + GL.GetShader(sid, ShaderParameter.CompileStatus, out var n); if (n == 0) if (required) diff --git a/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs index 37d3d277ea..a96add0aca 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs @@ -129,8 +129,7 @@ namespace BizHawk.Client.EmuHawk private int GetSource(ALGetSourcei param) { - int value; - AL.GetSource(_sourceID, param, out value); + AL.GetSource(_sourceID, param, out var value); return value; } diff --git a/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs b/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs index 5bd78d85d0..a5a4b94758 100644 --- a/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs +++ b/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs @@ -210,14 +210,11 @@ namespace BizHawk.Client.EmuHawk private void GetSamplesFromBase(ref double scaleFactor) { - short[] samples; - int count; - if (BaseSoundProvider.SyncMode != SyncSoundMode.Sync) { throw new InvalidOperationException("Base sound provider must be in sync mode."); } - BaseSoundProvider.GetSamplesSync(out samples, out count); + BaseSoundProvider.GetSamplesSync(out var samples, out var count); bool correctedEmptyFrame = false; if (count == 0) diff --git a/BizHawk.Client.EmuHawk/UpdateChecker.cs b/BizHawk.Client.EmuHawk/UpdateChecker.cs index 8ac33be3f1..713164639c 100644 --- a/BizHawk.Client.EmuHawk/UpdateChecker.cs +++ b/BizHawk.Client.EmuHawk/UpdateChecker.cs @@ -113,8 +113,7 @@ namespace BizHawk.Client.EmuHawk ulong version = 0; for (int i = 0; i < split.Length; i++) { - ushort versionPart; - if (!UInt16.TryParse(split[i], out versionPart)) return 0; + if (!UInt16.TryParse(split[i], out var versionPart)) return 0; version |= (ulong)versionPart << (48 - (i * 16)); } return version; diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index c86f93f188..883ac778f1 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -56,8 +56,7 @@ namespace BizHawk.Client.EmuHawk uint a = _currentDisassemblerAddress; for (int i = 0; i <= lineCount; ++i) { - int advance; - string line = Disassembler.Disassemble(MemoryDomains.SystemBus, a, out advance); + string line = Disassembler.Disassemble(MemoryDomains.SystemBus, a, out var advance); _disassemblyLines.Add(new DisasmOp(a, advance, line)); a += (uint)advance; if (a > BusMaxValue) @@ -107,8 +106,7 @@ namespace BizHawk.Client.EmuHawk while (true) { - int bytestoadvance; - Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out bytestoadvance); + Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out var bytestoadvance); if (newaddress + bytestoadvance == _currentDisassemblerAddress) { break; diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.cs b/BizHawk.Client.EmuHawk/tools/GameShark.cs index 3f9a7f1977..9c21b689d3 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.cs @@ -2474,8 +2474,7 @@ namespace BizHawk.Client.EmuHawk foreach (var t in code) { hexcode <<= 5; - long y; - _GENgameGenieTable.TryGetValue(t, out y); + _GENgameGenieTable.TryGetValue(t, out var y); hexcode |= y; } long decoded = (hexcode & 0xFF00000000) >> 32; diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index f94440cb41..56dffb1c4c 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -1182,8 +1182,7 @@ namespace BizHawk.Client.EmuHawk private void paletteViewer_MouseMove(object sender, MouseEventArgs e) { - Point pt; - bool valid = TranslatePaletteCoord(e.Location, out pt); + bool valid = TranslatePaletteCoord(e.Location, out var pt); if (!valid) return; lastColorNum = pt.Y * 16 + pt.X; UpdateColorDetails(); diff --git a/BizHawk.Common/AWEMemoryStream.cs b/BizHawk.Common/AWEMemoryStream.cs index 6b44fa6f9d..33b7c365a7 100644 --- a/BizHawk.Common/AWEMemoryStream.cs +++ b/BizHawk.Common/AWEMemoryStream.cs @@ -335,8 +335,7 @@ namespace BizHawk.Common return false; } var tkp = new TOKEN_PRIVILEGES { PrivilegeCount = 1, Privileges = new LUID_AND_ATTRIBUTES[1] }; - LUID luid; - if (!LookupPrivilegeValue(null, PrivilegeName, out luid)) + if (!LookupPrivilegeValue(null, PrivilegeName, out var luid)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); return false; diff --git a/BizHawk.Common/BinaryQuickSerializer.cs b/BizHawk.Common/BinaryQuickSerializer.cs index 411be9d938..1121d97380 100644 --- a/BizHawk.Common/BinaryQuickSerializer.cs +++ b/BizHawk.Common/BinaryQuickSerializer.cs @@ -128,8 +128,7 @@ namespace BizHawk.Common { il.Emit(OpCodes.Ldloc, target); il.Emit(OpCodes.Ldarg_1); - MethodInfo m; - if (!Readhandlers.TryGetValue(field.FieldType, out m)) + if (!Readhandlers.TryGetValue(field.FieldType, out var m)) { throw new InvalidOperationException($"(R) Can't handle nested type {field.FieldType}"); } @@ -153,8 +152,7 @@ namespace BizHawk.Common il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Ldloc, target); il.Emit(OpCodes.Ldfld, field); - MethodInfo m; - if (!Writehandlers.TryGetValue(field.FieldType, out m)) + if (!Writehandlers.TryGetValue(field.FieldType, out var m)) { throw new InvalidOperationException($"(W) Can't handle nested type {field.FieldType}"); } @@ -180,8 +178,7 @@ namespace BizHawk.Common private static SerializationFactory GetFactory(Type t) { - SerializationFactory f; - if (!Serializers.TryGetValue(t, out f)) + if (!Serializers.TryGetValue(t, out var f)) { f = CreateFactory(t); Serializers[t] = f; diff --git a/BizHawk.Common/SettingsUtil.cs b/BizHawk.Common/SettingsUtil.cs index 68f4aead44..a795d3ab57 100644 --- a/BizHawk.Common/SettingsUtil.cs +++ b/BizHawk.Common/SettingsUtil.cs @@ -26,8 +26,7 @@ namespace BizHawk.Common /// the obj to act on public static void SetDefaultValues(T obj) { - DefaultValueSetter f; - if (!DefaultValueSetters.TryGetValue(typeof(T), out f)) + if (!DefaultValueSetters.TryGetValue(typeof(T), out var f)) { f = CreateSetter(typeof(T)); DefaultValueSetters[typeof(T)] = f; diff --git a/BizHawk.Emulation.Common/Sound/Utilities/Metaspu.cs b/BizHawk.Emulation.Common/Sound/Utilities/Metaspu.cs index 1cf62afeda..f5c5518963 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/Metaspu.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/Metaspu.cs @@ -37,10 +37,8 @@ namespace BizHawk.Emulation.Common public void GetSamplesAsync(short[] samples) { - short[] sampin; - int numsamp; - _input.GetSamplesSync(out sampin, out numsamp); - _buffer.EnqueueSamples(sampin, numsamp); + _input.GetSamplesSync(out var sampIn, out var numSamp); + _buffer.EnqueueSamples(sampIn, numSamp); _buffer.OutputSamples(samples, samples.Length / 2); } diff --git a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs index 4754b555e5..49a287b957 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs @@ -425,9 +425,7 @@ namespace BizHawk.Emulation.Common { if (_input != null) { - short[] sampin; - int nsampin; - _input.GetSamplesSync(out sampin, out nsampin); + _input.GetSamplesSync(out var sampin, out int nsampin); EnqueueSamples(sampin, nsampin); } diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs index f0f72b705d..dabfdc5490 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs @@ -171,8 +171,7 @@ namespace BizHawk.Emulation.DiscSystem /// not found in public int FetchOrFail(string key) { - int ret; - if(!TryGetValue(key, out ret)) + if(!TryGetValue(key, out var ret)) throw new CCDParseException($"Malformed or unexpected CCD format: missing required [Entry] key: {key}"); return ret; } diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs index 4ec9b7b19d..e5121bac77 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs @@ -250,8 +250,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE break; } string strindexnum = clp.ReadToken(); - int indexnum; - if (!int.TryParse(strindexnum, out indexnum) || indexnum < 0 || indexnum > 99) + if (!int.TryParse(strindexnum, out var indexnum) || indexnum < 0 || indexnum > 99) { job.Error($"Invalid INDEX number: {strindexnum}"); break; @@ -331,15 +330,15 @@ namespace BizHawk.Emulation.DiscSystem.CUE job.Error("Incomplete TRACK command"); break; } + string str_tracknum = clp.ReadToken(); - int tracknum; - if (!int.TryParse(str_tracknum, out tracknum) || tracknum < 1 || tracknum > 99) + if (!int.TryParse(str_tracknum, out int tracknum) || tracknum < 1 || tracknum > 99) { job.Error($"Invalid TRACK number: {str_tracknum}"); break; } - //TODO - check sequentiality? maybe as a warning + // TODO - check sequentiality? maybe as a warning CueTrackType tt; var str_trackType = clp.ReadToken(); diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index f3045a207c..856297fd0a 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -504,15 +504,13 @@ namespace BizHawk.Emulation.DiscSystem foreach (var s in aSessions.Values) { Session session = new Session(); - ATrack startTrack; - ATrack endTrack; - if (!aTracks.TryGetValue(s.FirstTrack, out startTrack)) + if (!aTracks.TryGetValue(s.FirstTrack, out var startTrack)) { break; } - if (!aTracks.TryGetValue(s.LastTrack, out endTrack)) + if (!aTracks.TryGetValue(s.LastTrack, out var endTrack)) { break; } diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index 98486527eb..fffb108d72 100644 --- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -341,8 +341,7 @@ namespace BizHawk.Emulation.DiscSystem //read it if we dont have it cached //we wont be caching very much here, it's no big deal //identification is not something we want to take a long time - byte[] data; - if (!_sectorCache.TryGetValue(lba, out data)) + if (!_sectorCache.TryGetValue(lba, out var data)) { data = new byte[2048]; int read = _dsr.ReadLBA_2048(lba, data, 0); diff --git a/BizHawk.Emulation.DiscSystem/DiscTypes.cs b/BizHawk.Emulation.DiscSystem/DiscTypes.cs index cbd96a3808..8248d61cc3 100644 --- a/BizHawk.Emulation.DiscSystem/DiscTypes.cs +++ b/BizHawk.Emulation.DiscSystem/DiscTypes.cs @@ -63,15 +63,13 @@ namespace BizHawk.Emulation.DiscSystem public static int BCDToInt(byte n) { - var bcd = new BCD2(); - bcd.BCDValue = n; + var bcd = new BCD2 { BCDValue = n }; return bcd.DecimalValue; } public static byte IntToBCD(int n) { - int ones; - int tens = Math.DivRem(n, 10, out ones); + int tens = Math.DivRem(n, 10, out var ones); return (byte)((tens << 4) | ones); } diff --git a/BizHawk.Emulation.DiscSystem/DiscUtils.cs b/BizHawk.Emulation.DiscSystem/DiscUtils.cs index 857d0e22f6..74b8c3f581 100644 --- a/BizHawk.Emulation.DiscSystem/DiscUtils.cs +++ b/BizHawk.Emulation.DiscSystem/DiscUtils.cs @@ -6,8 +6,7 @@ namespace BizHawk.Emulation.DiscSystem { static byte IntToBCD(int n) { - int ones; - int tens = Math.DivRem(n, 10, out ones); + int tens = Math.DivRem(n, 10, out var ones); return (byte)((tens << 4) | ones); } @@ -37,7 +36,5 @@ namespace BizHawk.Emulation.DiscSystem { return f + (s * 75) + (m * 75 * 60) - 150; } - } - } \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs index 6a34b8d788..702e983c8e 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.IO; - +using Cyotek.Drawing.BitmapFont; using sd=System.Drawing; namespace BizHawk.Bizware.BizwareGL @@ -61,8 +61,7 @@ namespace BizHawk.Bizware.BizwareGL continue; } - Cyotek.Drawing.BitmapFont.Character bfc; - if (!FontInfo.Characters.TryGetValue((char)c, out bfc)) + if (!FontInfo.Characters.TryGetValue((char)c, out var bfc)) bfc = FontInfo.Characters[unchecked((char)-1)]; x += bfc.XAdvance; @@ -98,8 +97,7 @@ namespace BizHawk.Bizware.BizwareGL continue; } - Cyotek.Drawing.BitmapFont.Character bfc; - if (!FontInfo.Characters.TryGetValue((char)c, out bfc)) + if (!FontInfo.Characters.TryGetValue((char)c, out var bfc)) bfc = FontInfo.Characters[unchecked((char)-1)]; // calculate texcoords (we shouldve already had this cached, but im speedcoding now)