diff --git a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs index bc1276b2..093838d7 100644 --- a/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs +++ b/src/MoonSharp.Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs @@ -13,7 +13,6 @@ namespace MoonSharp.Interpreter.Interop.BasicDescriptors /// public abstract class DispatchingUserDataDescriptor : IUserDataDescriptor, IOptimizableDescriptor { - private int m_ExtMethodsVersion = 0; private Dictionary m_MetaMembers = new Dictionary(); private Dictionary m_Members = new Dictionary(); @@ -236,10 +235,8 @@ public virtual DynValue Index(Script script, object obj, DynValue index, bool is if (v == null) v = TryIndex(script, obj, Camelify(index.String)); if (v == null) v = TryIndex(script, obj, UpperFirstLetter(Camelify(index.String))); - if (v == null && m_ExtMethodsVersion < UserData.GetExtensionMethodsChangeVersion()) + if (v == null) { - m_ExtMethodsVersion = UserData.GetExtensionMethodsChangeVersion(); - v = TryIndexOnExtMethod(script, obj, index.String); if (v == null) v = TryIndexOnExtMethod(script, obj, UpperFirstLetter(index.String)); if (v == null) v = TryIndexOnExtMethod(script, obj, Camelify(index.String)); diff --git a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs index baaf9069..262e76f4 100644 --- a/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs +++ b/src/MoonSharp.Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs @@ -153,17 +153,25 @@ private static MethodInfo InstantiateMethodInfo(MethodInfo mi, Type extensionTyp private static Type GetGenericMatch(Type extensionType, Type extendedType) { - extensionType = extensionType.GetGenericTypeDefinition(); - - foreach (Type t in extendedType.GetAllImplementedTypes()) - { - if (t.IsGenericType && t.GetGenericTypeDefinition() == extensionType) - { - return t; - } - } - - return null; + if (!extensionType.IsGenericParameter) + { + extensionType = extensionType.GetGenericTypeDefinition(); + + foreach (Type t in extendedType.GetAllImplementedTypes()) + { + if (t.IsGenericType && t.GetGenericTypeDefinition() == extensionType) + { + return t; + } + } + } + + /*if (extendedType.IsGenericParameter) + { + return extendedType; + }*/ + + return null; } }