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:
parent
db7150642a
commit
b8a0720121
|
@ -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() {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -107,15 +107,7 @@ namespace BizHawk.Client.Common
|
||||||
Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name;
|
Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MissingException : Exception
|
public class MissingException : Exception {}
|
||||||
{
|
|
||||||
public readonly bool OldAttributeFound;
|
|
||||||
|
|
||||||
public MissingException(bool oldAttributeFound)
|
|
||||||
{
|
|
||||||
OldAttributeFound = oldAttributeFound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
|
|
@ -74,9 +74,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var externalToolFile = Assembly.LoadFrom(fileName);
|
var externalToolFile = Assembly.LoadFrom(fileName);
|
||||||
var entryPoint = externalToolFile.GetTypes()
|
var entryPoint = externalToolFile.GetTypes()
|
||||||
.SingleOrDefault(t => typeof(IExternalToolForm).IsAssignableFrom(t) && t.GetCustomAttributes().OfType<ExternalToolAttribute>().Any());
|
.SingleOrDefault(t => typeof(IExternalToolForm).IsAssignableFrom(t) && t.GetCustomAttributes().OfType<ExternalToolAttribute>().Any());
|
||||||
#pragma warning disable CS0618
|
if (entryPoint == null) throw new ExternalToolAttribute.MissingException();
|
||||||
if (entryPoint == null) throw new ExternalToolAttribute.MissingException(externalToolFile.GetCustomAttributes().OfType<BizHawkExternalToolAttribute>().Any());
|
|
||||||
#pragma warning restore CS0618
|
|
||||||
|
|
||||||
var allAttrs = entryPoint.GetCustomAttributes().ToList();
|
var allAttrs = entryPoint.GetCustomAttributes().ToList();
|
||||||
var applicabilityAttrs = allAttrs.OfType<ExternalToolApplicabilityAttributeBase>().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.",
|
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.",
|
ExternalToolApplicabilityAttributeBase.DuplicateException => "The IExternalToolForm has conflicting applicability attributes.",
|
||||||
ExternalToolAttribute.MissingException e1 => e1.OldAttributeFound
|
ExternalToolAttribute.MissingException => "The assembly doesn't contain a class implementing IExternalToolForm and annotated with [ExternalTool].",
|
||||||
? "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].",
|
|
||||||
ReflectionTypeLoadException => "Something went wrong while trying to load the assembly.",
|
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}"
|
_ => $"An exception of type {e.GetType().FullName} was thrown while trying to load the assembly and look for an IExternalToolForm:\n{e.Message}"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue