diff --git a/Mirror/Weaver/Processors/NetworkBehaviourProcessor.cs b/Mirror/Weaver/Processors/NetworkBehaviourProcessor.cs index 21f346ead..ddd953f2b 100644 --- a/Mirror/Weaver/Processors/NetworkBehaviourProcessor.cs +++ b/Mirror/Weaver/Processors/NetworkBehaviourProcessor.cs @@ -330,7 +330,7 @@ void GenerateSerialization() VariableDefinition dirtyLocal = new VariableDefinition(Weaver.boolType); serialize.Body.Variables.Add(dirtyLocal); - MethodReference baseSerialize = Weaver.ResolveMethodInParents(m_td.BaseType, "OnSerialize"); + MethodReference baseSerialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.scriptDef, "OnSerialize"); if (baseSerialize != null) { serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base @@ -527,7 +527,7 @@ void GenerateDeSerialization() serialize.Parameters.Add(new ParameterDefinition("initialState", ParameterAttributes.None, Weaver.boolType)); ILProcessor serWorker = serialize.Body.GetILProcessor(); - MethodReference baseDeserialize = Weaver.ResolveMethodInParents(m_td.BaseType, "OnDeserialize"); + MethodReference baseDeserialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.scriptDef, "OnDeserialize"); if (baseDeserialize != null) { serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base diff --git a/Mirror/Weaver/Resolvers.cs b/Mirror/Weaver/Resolvers.cs index baf82e2e8..edb9d7e71 100644 --- a/Mirror/Weaver/Resolvers.cs +++ b/Mirror/Weaver/Resolvers.cs @@ -37,5 +37,24 @@ public static MethodReference ResolveMethod(TypeReference tr, AssemblyDefinition Weaver.fail = true; return null; } + + public static MethodReference ResolveMethodInParents(TypeReference tr, AssemblyDefinition scriptDef, string name) + { + if (tr == null) + { + Log.Error("Type missing for " + name); + Weaver.fail = true; + return null; + } + foreach (MethodDefinition methodRef in tr.Resolve().Methods) + { + if (methodRef.Name == name) + { + return scriptDef.MainModule.ImportReference(methodRef); + } + } + // Could not find the method in this class, try the parent + return ResolveMethodInParents(tr.Resolve().BaseType, scriptDef, name); + } } } \ No newline at end of file diff --git a/Mirror/Weaver/Weaver.cs b/Mirror/Weaver/Weaver.cs index 6e6b29c9d..4120a6431 100644 --- a/Mirror/Weaver/Weaver.cs +++ b/Mirror/Weaver/Weaver.cs @@ -1033,24 +1033,6 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td) } return false; } - public static MethodReference ResolveMethodInParents(TypeReference t, string name) - { - if (t == null) - { - Log.Error("Type missing for " + name); - fail = true; - return null; - } - foreach (var methodRef in t.Resolve().Methods) - { - if (methodRef.Name == name) - { - return scriptDef.MainModule.ImportReference(methodRef); - } - } - // Could not find the method in this class, try the parent - return ResolveMethodInParents(t.Resolve().BaseType, name); - } static MethodReference ResolveMethodWithArg(TypeReference t, string name, TypeReference argType) {