From 7d75ad3cf0f83e004b864d45bfc4838d21e5244f Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 25 Mar 2021 12:28:28 +0800 Subject: [PATCH] weaver: making GenerateWriter return MethodReference (#2479) --- Assets/Mirror/Editor/Weaver/Writers.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Writers.cs b/Assets/Mirror/Editor/Weaver/Writers.cs index 113b47bce..dd69277cb 100644 --- a/Assets/Mirror/Editor/Weaver/Writers.cs +++ b/Assets/Mirror/Editor/Weaver/Writers.cs @@ -27,13 +27,15 @@ public static void Register(TypeReference dataType, MethodReference methodRefere writeFuncs[typeName] = methodReference; } - static void RegisterWriteFunc(string name, MethodDefinition newWriterFunc) + static void RegisterWriteFunc(string name, MethodReference newWriterFunc) { - writeFuncs[name] = newWriterFunc; - Weaver.WeaveLists.generatedWriteFunctions.Add(newWriterFunc); + MethodDefinition resolved = newWriterFunc.Resolve(); + + writeFuncs[name] = resolved; + Weaver.WeaveLists.generatedWriteFunctions.Add(resolved); Weaver.ConfirmGeneratedCodeClass(); - Weaver.WeaveLists.generateContainerClass.Methods.Add(newWriterFunc); + Weaver.WeaveLists.generateContainerClass.Methods.Add(resolved); } public static MethodReference GetWriteFunc(TypeReference variable, int recursionCount = 0) @@ -49,7 +51,7 @@ public static MethodReference GetWriteFunc(TypeReference variable, int recursion } else { - MethodDefinition newWriterFunc = GenerateWriter(variable, recursionCount); + MethodReference newWriterFunc = GenerateWriter(variable, recursionCount); if (newWriterFunc != null) { RegisterWriteFunc(variable.FullName, newWriterFunc); @@ -58,7 +60,7 @@ public static MethodReference GetWriteFunc(TypeReference variable, int recursion } } - static MethodDefinition GenerateWriter(TypeReference variableReference, int recursionCount = 0) + static MethodReference GenerateWriter(TypeReference variableReference, int recursionCount = 0) { // TODO: do we need this check? do we ever receieve types that are "ByReference"s if (variableReference.IsByReference)