Remove old ext. tool attributes and the code using them

it just detected old tools and displayed a specialised error message
This commit is contained in:
YoshiRulz 2021-01-17 23:44:34 +10:00
parent db7150642a
commit b8a0720121
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 3 additions and 39 deletions

View File

@ -1,24 +0,0 @@
using System;
namespace BizHawk.Client.Common
{
/// <remarks>This class needs to be in the assembly or old tools will throw on load instead of being recognized as old.</remarks>
[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) {}
}
/// <inheritdoc cref="BizHawkExternalToolAttribute"/>
[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() {}
}
}

View File

@ -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)]

View File

@ -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<ExternalToolAttribute>().Any());
#pragma warning disable CS0618
if (entryPoint == null) throw new ExternalToolAttribute.MissingException(externalToolFile.GetCustomAttributes().OfType<BizHawkExternalToolAttribute>().Any());
#pragma warning restore CS0618
if (entryPoint == null) throw new ExternalToolAttribute.MissingException();
var allAttrs = entryPoint.GetCustomAttributes().ToList();
var applicabilityAttrs = allAttrs.OfType<ExternalToolApplicabilityAttributeBase>().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}"
};