diff --git a/BizHawk.Common/EnumHelper.cs b/BizHawk.Common/EnumHelper.cs deleted file mode 100644 index 03a6dd2e3d..0000000000 --- a/BizHawk.Common/EnumHelper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ComponentModel; -using System.Reflection; - -using BizHawk.Common.ReflectionExtensions; - -namespace BizHawk.Common -{ - public static class EnumHelper - { - public static IEnumerable GetDescriptions() - { - var vals = Enum.GetValues(typeof(T)); - - foreach (var v in vals) - { - yield return v.GetDescription(); - } - } - } -} \ No newline at end of file diff --git a/BizHawk.Common/Extensions/Extensions.cs b/BizHawk.Common/Extensions/Extensions.cs index dfc19ada04..2b7ffe726f 100644 --- a/BizHawk.Common/Extensions/Extensions.cs +++ b/BizHawk.Common/Extensions/Extensions.cs @@ -64,13 +64,22 @@ namespace BizHawk.Common //we didnt find it. return something corresponding to lower_bound semantics if (mid == list.Count) - return max; //had to go all the way to max before giving up; lower bound is max + { + return max; // had to go all the way to max before giving up; lower bound is max + } + if (mid == 0) - return -1; //had to go all the way to min before giving up; lower bound is min + { + return -1; // had to go all the way to min before giving up; lower bound is min + } midKey = keySelector(list[mid]); - if (midKey.CompareTo(key) >= 0) return mid - 1; - else return mid; + if (midKey.CompareTo(key) >= 0) + { + return mid - 1; + } + + return mid; } // http://stackoverflow.com/questions/1766328/can-linq-use-binary-search-when-the-collection-is-ordered diff --git a/BizHawk.Common/Extensions/ReflectionExtensions.cs b/BizHawk.Common/Extensions/ReflectionExtensions.cs index fe79331e02..1c131b8c99 100644 --- a/BizHawk.Common/Extensions/ReflectionExtensions.cs +++ b/BizHawk.Common/Extensions/ReflectionExtensions.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Reflection; -using System.Text; namespace BizHawk.Common.ReflectionExtensions { @@ -17,15 +14,15 @@ namespace BizHawk.Common.ReflectionExtensions /// public static string GetDescription(this object obj) { - Type type = obj.GetType(); + var type = obj.GetType(); var memInfo = type.GetMember(obj.ToString()); - if (memInfo != null && memInfo.Length > 0) + if (memInfo.Length > 0) { - object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); + var attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); - if (attrs != null && attrs.Length > 0) + if (attrs.Length > 0) { return ((DescriptionAttribute)attrs[0]).Description; } @@ -69,12 +66,16 @@ namespace BizHawk.Common.ReflectionExtensions if (attribute != null) { if (attribute.Description == description) + { return (T)field.GetValue(null); + } } else { if (field.Name == description) + { return (T)field.GetValue(null); + } } } diff --git a/BizHawk.Common/Extensions/StringExtensions.cs b/BizHawk.Common/Extensions/StringExtensions.cs index fe56405c15..42559db846 100644 --- a/BizHawk.Common/Extensions/StringExtensions.cs +++ b/BizHawk.Common/Extensions/StringExtensions.cs @@ -329,7 +329,7 @@ namespace BizHawk.Common.StringExtensions var output = new StringBuilder(); - bool usedDot = false; + var usedDot = false; foreach (var chr in raw) { if (chr == '.') @@ -338,10 +338,8 @@ namespace BizHawk.Common.StringExtensions { continue; } - else - { - usedDot = true; - } + + usedDot = true; } if (IsFixedPoint(chr)) @@ -366,8 +364,8 @@ namespace BizHawk.Common.StringExtensions var output = new StringBuilder(); - bool usedDot = false; - int count = 0; + var usedDot = false; + var count = 0; foreach (var chr in raw) { if (count == 0 && chr == '-') @@ -382,10 +380,8 @@ namespace BizHawk.Common.StringExtensions { continue; } - else - { - usedDot = true; - } + + usedDot = true; } if (IsFixedPoint(chr)) @@ -393,9 +389,10 @@ namespace BizHawk.Common.StringExtensions output.Append(chr); } } + + count++; } - count++; return output.ToString(); } diff --git a/BizHawk.Common/HawkFile.cs b/BizHawk.Common/HawkFile.cs index 4c45e4ef74..03d43924fe 100644 --- a/BizHawk.Common/HawkFile.cs +++ b/BizHawk.Common/HawkFile.cs @@ -159,7 +159,7 @@ namespace BizHawk.Common /// /// these extensions won't even be tried as archives (removes spurious archive detects since some of the signatures are pretty damn weak) /// - public string[] NonArchiveExtensions = new string[] { }; + public string[] NonArchiveExtensions = { }; public void Open(string path) { diff --git a/BizHawk.Common/IPC/IPCRingBuffer.cs b/BizHawk.Common/IPC/IPCRingBuffer.cs index f25afcda7a..40df4140b0 100644 --- a/BizHawk.Common/IPC/IPCRingBuffer.cs +++ b/BizHawk.Common/IPC/IPCRingBuffer.cs @@ -179,7 +179,7 @@ namespace BizHawk.Common public class Tester { - Queue shazam = new Queue(); + private readonly Queue shazam = new Queue(); string bufid; unsafe void a() @@ -247,11 +247,13 @@ namespace BizHawk.Common /// public unsafe class IPCRingBufferStream : Stream { + private readonly IPCRingBuffer buf; + public IPCRingBufferStream(IPCRingBuffer buf) { this.buf = buf; } - IPCRingBuffer buf; + public override bool CanRead { get { return true; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return true; } } diff --git a/BizHawk.Common/Properties/AssemblyInfo.cs b/BizHawk.Common/Properties/AssemblyInfo.cs index 4a67d3042b..50892a59fb 100644 --- a/BizHawk.Common/Properties/AssemblyInfo.cs +++ b/BizHawk.Common/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/BizHawk.Common/Serializer.cs b/BizHawk.Common/Serializer.cs index 9acd9e2f8a..44e79decc9 100644 --- a/BizHawk.Common/Serializer.cs +++ b/BizHawk.Common/Serializer.cs @@ -1128,9 +1128,9 @@ namespace BizHawk.Common _tw.WriteLine("{0} {1}", name, val); } - private class Section : Dictionary + private sealed class Section : Dictionary { - public string Name = String.Empty; + public string Name = string.Empty; public readonly Dictionary Items = new Dictionary(); } diff --git a/BizHawk.Common/SettingsUtil.cs b/BizHawk.Common/SettingsUtil.cs index f7fcb31354..71b6b55dec 100644 --- a/BizHawk.Common/SettingsUtil.cs +++ b/BizHawk.Common/SettingsUtil.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Reflection; using System.Reflection.Emit; using System.Collections.Concurrent; @@ -11,10 +9,9 @@ namespace BizHawk.Common { public class SettingsUtil { - private class DefaultValueSetter + private sealed class DefaultValueSetter { public Action SetDefaultValues; - public Type Type; public object[] DefaultValues; } @@ -74,7 +71,6 @@ namespace BizHawk.Common return new DefaultValueSetter { SetDefaultValues = (Action)dyn.CreateDelegate(typeof(Action)), - Type = t, DefaultValues = DefaultValues.ToArray() }; } diff --git a/BizHawk.Common/Util.cs b/BizHawk.Common/Util.cs index 1cbccb0f83..b091aa6d84 100644 --- a/BizHawk.Common/Util.cs +++ b/BizHawk.Common/Util.cs @@ -359,7 +359,7 @@ namespace BizHawk.Common const int BUFF_SIZE = 4096; var buffer = new byte[BUFF_SIZE]; - int bytesRead = 0; + int bytesRead; var inStream = new BufferedStream(stream); var outStream = new MemoryStream(); diff --git a/VersionInfo.cs b/VersionInfo.cs index c19484a00a..6aa9b00d60 100644 --- a/VersionInfo.cs +++ b/VersionInfo.cs @@ -1,5 +1,3 @@ -using System; - static class VersionInfo { public const string MAINVERSION = "1.7.0";