From dd3b35a9fe32e29e14a1b134616f9a4ce8711d55 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 15 Feb 2020 12:22:16 -0600 Subject: [PATCH] cleanup BizHawk.Emulation.Common/Extensions --- BizHawk.Emulation.Common/Extensions.cs | 42 +++----------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index d732222a88..29ca2fe57c 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -20,12 +20,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions public static bool HasVideoProvider(this IEmulator core) { - if (core == null) - { - return false; - } - - return core.ServiceProvider.HasService(); + return core != null && core.ServiceProvider.HasService(); } public static IVideoProvider AsVideoProvider(this IEmulator core) @@ -208,23 +203,12 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions public static bool CanPoke(this MemoryDomain d) { - if (!d.Writable) - { - return false; - } - - // once upon a time, we did a try { poke(peek) } here, but that was before Writable was added. the poke(peek) is not acceptable. If there are further problems, make sure Writable is correct. - return true; + return d.Writable; } public static bool HasRegions(this IEmulator core) { - if (core == null) - { - return false; - } - - return core.ServiceProvider.HasService(); + return core != null && core.ServiceProvider.HasService(); } public static IRegionable AsRegionable(this IEmulator core) @@ -297,26 +281,8 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions return core.VsyncNumerator() / (double)core.VsyncDenominator(); } - // TODO: a better place for these + // TODO: a better place for this public static bool IsImplemented(this MethodInfo info) - { - // If a method is marked as Not implemented, it is not implemented no matter what the body is - if (info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute)) - { - return false; - } - - // adelikat: we can't rely on this anymore - // Some methods throw an exception by design, such as ISoundProvider.GetSamplesAsync() - // If async is not provided by the implementation this method will throw an exception - // We need to figure out a reliable way to check specifically for a NotImplementedException, then maybe this method will be more useful - // If a method is not marked but all it does is throw an exception, consider it not implemented - ////return !info.ThrowsError(); - - return true; - } - - public static bool IsImplemented(this PropertyInfo info) { return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute); }