diff --git a/Mirror/Weaver/Resolvers.cs b/Mirror/Weaver/Resolvers.cs index b360c3c9c..8ffaaead8 100644 --- a/Mirror/Weaver/Resolvers.cs +++ b/Mirror/Weaver/Resolvers.cs @@ -98,5 +98,32 @@ public static MethodDefinition ResolveDefaultPublicCtor(TypeReference variable) } return null; } + + public static GenericInstanceMethod ResolveMethodGeneric(TypeReference t, AssemblyDefinition scriptDef, string name, TypeReference genericType) + { + foreach (MethodDefinition methodRef in t.Resolve().Methods) + { + if (methodRef.Name == name) + { + if (methodRef.Parameters.Count == 0) + { + if (methodRef.GenericParameters.Count == 1) + { + MethodReference tmp = scriptDef.MainModule.ImportReference(methodRef); + GenericInstanceMethod gm = new GenericInstanceMethod(tmp); + gm.GenericArguments.Add(genericType); + if (gm.GenericArguments[0].FullName == genericType.FullName) + { + return gm; + } + } + } + } + } + + Log.Error("ResolveMethodGeneric failed " + t.Name + "::" + name + " " + genericType); + Weaver.fail = true; + return null; + } } } \ No newline at end of file diff --git a/Mirror/Weaver/Weaver.cs b/Mirror/Weaver/Weaver.cs index 41efb5b22..3772f7feb 100644 --- a/Mirror/Weaver/Weaver.cs +++ b/Mirror/Weaver/Weaver.cs @@ -1034,33 +1034,6 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td) return false; } - static GenericInstanceMethod ResolveMethodGeneric(TypeReference t, string name, TypeReference genericType) - { - foreach (var methodRef in t.Resolve().Methods) - { - if (methodRef.Name == name) - { - if (methodRef.Parameters.Count == 0) - { - if (methodRef.GenericParameters.Count == 1) - { - MethodReference tmp = scriptDef.MainModule.ImportReference(methodRef); - GenericInstanceMethod gm = new GenericInstanceMethod(tmp); - gm.GenericArguments.Add(genericType); - if (gm.GenericArguments[0].FullName == genericType.FullName) - { - return gm; - } - } - } - } - } - - Log.Error("ResolveMethodGeneric failed " + t.Name + "::" + name + " " + genericType); - fail = true; - return null; - } - public static FieldReference ResolveField(TypeReference t, string name) { foreach (FieldDefinition fd in t.Resolve().Fields) @@ -1217,7 +1190,7 @@ static void SetupTargetTypes() ReadyConnectionReference = Resolvers.ResolveMethod(ClientSceneType, scriptDef, "get_readyConnection"); // get specialized GetComponent() - getComponentReference = ResolveMethodGeneric(ComponentType, "GetComponent", NetworkIdentityType); + getComponentReference = Resolvers.ResolveMethodGeneric(ComponentType, scriptDef, "GetComponent", NetworkIdentityType); getUNetIdReference = Resolvers.ResolveMethod(unetViewTmp, scriptDef, "get_netId");