From 3f410a771c33ad541cb88b3e302647cb57167551 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 27 Oct 2013 17:07:37 +0000 Subject: [PATCH] small code cleanups and deal with some warnings --- BizHawk.Client.Common/BinarySaveStates.cs | 37 ++++++++++++++----- BizHawk.Client.Common/HawkFile.cs | 2 +- BizHawk.Client.Common/movie/Movie.cs | 1 - .../Chips/Internals/Vic.Graphics.cs | 3 ++ .../Chips/Internals/Vic.Internal.cs | 3 ++ .../Chips/Internals/Vic.Registers.cs | 2 + .../Chips/Internals/Vic.Sprite.cs | 2 + .../Chips/Internals/Vic.Timing.cs | 3 ++ .../Chips/Internals/Vic.VideoProvider.cs | 2 + .../Computers/Commodore64/MOS/Sid.cs | 4 ++ .../Consoles/Nintendo/Gameboy/Gambatte.cs | 2 +- BizHawk.Emulation/Consoles/PSX/Octoshock.cs | 2 + BizHawk.MultiClient/CustomControls/Win32.cs | 2 +- 13 files changed, 52 insertions(+), 13 deletions(-) diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs index dea072e45b..e583c532d3 100644 --- a/BizHawk.Client.Common/BinarySaveStates.cs +++ b/BizHawk.Client.Common/BinarySaveStates.cs @@ -18,13 +18,23 @@ namespace BizHawk.Client.Common public class BinaryStateLoader : IDisposable { - bool disposed = false; + private bool isDisposed = false; public void Dispose() { - if (!disposed) + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!isDisposed) { - disposed = true; - zip.Close(); + isDisposed = true; + + if (disposing) + { + zip.Close(); + } } } @@ -95,8 +105,6 @@ namespace BizHawk.Client.Common { ZipOutputStream zip; - bool disposed = false; - /// /// /// @@ -135,12 +143,23 @@ namespace BizHawk.Client.Common PutFileByName(BinaryStateFileNames.input, callback); } + private bool isDisposed = false; public void Dispose() { - if (!disposed) + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (!isDisposed) { - disposed = true; - zip.Dispose(); + isDisposed = true; + + if (disposing) + { + zip.Close(); + } } } diff --git a/BizHawk.Client.Common/HawkFile.cs b/BizHawk.Client.Common/HawkFile.cs index 46e08b91c5..d5bd1bd373 100644 --- a/BizHawk.Client.Common/HawkFile.cs +++ b/BizHawk.Client.Common/HawkFile.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.Common //split into "bind" and "open (the bound thing)" //scan archive to flatten interior directories down to a path (maintain our own archive item list) - public class HawkFile : IDisposable + public sealed class HawkFile : IDisposable { public static bool ExistsAt(string path) { diff --git a/BizHawk.Client.Common/movie/Movie.cs b/BizHawk.Client.Common/movie/Movie.cs index 293701dff6..f8f42f01df 100644 --- a/BizHawk.Client.Common/movie/Movie.cs +++ b/BizHawk.Client.Common/movie/Movie.cs @@ -436,7 +436,6 @@ namespace BizHawk.Client.Common Header.Comments.Add(str); } } - sr.Close(); } return true; diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs index 991052c6b4..8ce8b6ed03 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Graphics.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete +#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public partial class Vic diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs index 5a6354f06a..b2f52f7b6b 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Internal.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete +#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public partial class Vic diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs index f0bbda45ef..28d8e4d4df 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Registers.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public partial class Vic diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs index 00ad5c24b4..3cd96b6b08 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Sprite.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public partial class Vic diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs index cac3182bbc..34ecf16865 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.Timing.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete +#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public class VicColumnState diff --git a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs index 95bbd35994..c6bf80ab7a 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Experimental/Chips/Internals/Vic.VideoProvider.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals { sealed public partial class Vic : IVideoProvider diff --git a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs index 51032e556e..5ec2a5a6b5 100644 --- a/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs +++ b/BizHawk.Emulation/Computers/Commodore64/MOS/Sid.cs @@ -1,5 +1,9 @@ using System; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete +#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete +#pragma warning disable 219 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Computers.Commodore64.MOS { sealed public partial class Sid diff --git a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs index f5fc2c0380..a2c04b889f 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Consoles.GB /// /// RTC time when emulation begins. /// - long zerotime; + long zerotime = 0; LibGambatte.RTCCallback TimeCallback; diff --git a/BizHawk.Emulation/Consoles/PSX/Octoshock.cs b/BizHawk.Emulation/Consoles/PSX/Octoshock.cs index 30bb41185b..15605d6727 100644 --- a/BizHawk.Emulation/Consoles/PSX/Octoshock.cs +++ b/BizHawk.Emulation/Consoles/PSX/Octoshock.cs @@ -3,6 +3,8 @@ using System.Runtime.InteropServices; using System.IO; using System.Collections.Generic; +#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete + namespace BizHawk.Emulation.Consoles.PSX { public unsafe class Octoshock : IEmulator, IVideoProvider, ISoundProvider diff --git a/BizHawk.MultiClient/CustomControls/Win32.cs b/BizHawk.MultiClient/CustomControls/Win32.cs index ccefefb97a..715acea454 100644 --- a/BizHawk.MultiClient/CustomControls/Win32.cs +++ b/BizHawk.MultiClient/CustomControls/Win32.cs @@ -491,7 +491,7 @@ namespace BizHawk /// File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via various file I/O APIs. /// [Flags] - [CLSCompliant(false)] + //[CLSCompliant(false)] public enum FileAttributes : uint { ///