diff --git a/IPA.Loader/Config/Stores/Attributes.cs b/IPA.Loader/Config/Stores/Attributes.cs
index d2708b30..d9361054 100644
--- a/IPA.Loader/Config/Stores/Attributes.cs
+++ b/IPA.Loader/Config/Stores/Attributes.cs
@@ -31,14 +31,12 @@ namespace IPA.Config.Stores.Attributes
///
/// Gets the type of the converter to use.
///
- public Type ConverterType { get; private set; }
+ public Type ConverterType { get; }
///
/// Gets the target type of the converter if it is avaliable at instantiation time, otherwise
/// .
///
- public Type ConverterTargetType => ConverterType.BaseType.IsGenericType ?
- ConverterType.BaseType.GetGenericArguments()[0] :
- null;
+ public Type ConverterTargetType { get; }
///
/// Gets whether or not this converter is a generic .
@@ -53,10 +51,16 @@ namespace IPA.Config.Stores.Attributes
{
ConverterType = converterType;
+ var baseT = ConverterType.BaseType;
+ while (baseT != null && baseT != typeof(object) &&
+ (!baseT.IsGenericType || baseT.GetGenericTypeDefinition() != typeof(ValueConverter<>)))
+ baseT = baseT.BaseType;
+ if (baseT == typeof(object)) ConverterTargetType = null;
+ else ConverterTargetType = baseT.GetGenericArguments()[0];
+
var implInterface = ConverterType.GetInterfaces().Contains(typeof(IValueConverter));
- var inheritGeneric = ConverterType.BaseType.IsGenericType &&
- ConverterType.BaseType.GetGenericTypeDefinition() == typeof(ValueConverter<>);
- if (!implInterface && !inheritGeneric) throw new ArgumentException("Type is not a value converter!");
+
+ if (ConverterTargetType == null && !implInterface) throw new ArgumentException("Type is not a value converter!");
}
}