From b8a072012146078f7af247152a3be1e3913e6ffb Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 17 Jan 2021 23:44:34 +1000 Subject: [PATCH] Remove old ext. tool attributes and the code using them it just detected old tools and displayed a specialised error message --- .../Api/BizHawkExternalToolAttribute.cs | 24 ------------------- .../Api/ExternalToolAttributes.cs | 10 +------- .../tools/ExternalToolManager.cs | 8 ++----- 3 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 src/BizHawk.Client.Common/Api/BizHawkExternalToolAttribute.cs diff --git a/src/BizHawk.Client.Common/Api/BizHawkExternalToolAttribute.cs b/src/BizHawk.Client.Common/Api/BizHawkExternalToolAttribute.cs deleted file mode 100644 index 5a73324930..0000000000 --- a/src/BizHawk.Client.Common/Api/BizHawkExternalToolAttribute.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace BizHawk.Client.Common -{ - /// This class needs to be in the assembly or old tools will throw on load instead of being recognized as old. - [AttributeUsage(AttributeTargets.Assembly)] - [Obsolete("last used in 2.4, use [ExternalTool] instead")] - public sealed class BizHawkExternalToolAttribute : Attribute - { - public BizHawkExternalToolAttribute(string name, string description, string iconResourceName) {} - public BizHawkExternalToolAttribute(string name, string description) {} - public BizHawkExternalToolAttribute(string name) {} - } - - /// - [AttributeUsage(AttributeTargets.Assembly)] - [Obsolete("last used in 2.4, use [ExternalToolApplicability.*] instead")] - public sealed class BizHawkExternalToolUsageAttribute : Attribute - { - public BizHawkExternalToolUsageAttribute(BizHawkExternalToolUsage usage, CoreSystem system, string gameHash) {} - public BizHawkExternalToolUsageAttribute(BizHawkExternalToolUsage usage, CoreSystem system) {} - public BizHawkExternalToolUsageAttribute() {} - } -} diff --git a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs index 6151de41b5..adbbf6652d 100644 --- a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs +++ b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs @@ -107,15 +107,7 @@ namespace BizHawk.Client.Common Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name; } - public class MissingException : Exception - { - public readonly bool OldAttributeFound; - - public MissingException(bool oldAttributeFound) - { - OldAttributeFound = oldAttributeFound; - } - } + public class MissingException : Exception {} } [AttributeUsage(AttributeTargets.Class)] diff --git a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs index 1ee41b185f..bf07bd45ac 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs @@ -74,9 +74,7 @@ namespace BizHawk.Client.EmuHawk var externalToolFile = Assembly.LoadFrom(fileName); var entryPoint = externalToolFile.GetTypes() .SingleOrDefault(t => typeof(IExternalToolForm).IsAssignableFrom(t) && t.GetCustomAttributes().OfType().Any()); -#pragma warning disable CS0618 - if (entryPoint == null) throw new ExternalToolAttribute.MissingException(externalToolFile.GetCustomAttributes().OfType().Any()); -#pragma warning restore CS0618 + if (entryPoint == null) throw new ExternalToolAttribute.MissingException(); var allAttrs = entryPoint.GetCustomAttributes().ToList(); var applicabilityAttrs = allAttrs.OfType().ToList(); @@ -128,9 +126,7 @@ namespace BizHawk.Client.EmuHawk { BadImageFormatException => "This assembly can't be loaded, probably because it's corrupt or targets an incompatible .NET runtime.", ExternalToolApplicabilityAttributeBase.DuplicateException => "The IExternalToolForm has conflicting applicability attributes.", - ExternalToolAttribute.MissingException e1 => e1.OldAttributeFound - ? "The assembly doesn't contain a class implementing IExternalToolForm and annotated with [ExternalTool].\nHowever, the assembly itself is annotated with [BizHawkExternalTool], which is now deprecated. Has the tool been updated since BizHawk 2.4?" - : "The assembly doesn't contain a class implementing IExternalToolForm and annotated with [ExternalTool].", + ExternalToolAttribute.MissingException => "The assembly doesn't contain a class implementing IExternalToolForm and annotated with [ExternalTool].", ReflectionTypeLoadException => "Something went wrong while trying to load the assembly.", _ => $"An exception of type {e.GetType().FullName} was thrown while trying to load the assembly and look for an IExternalToolForm:\n{e.Message}" };