diff --git a/Mirror/Weaver/Resolvers.cs b/Mirror/Weaver/Resolvers.cs index f1d0ed098..b360c3c9c 100644 --- a/Mirror/Weaver/Resolvers.cs +++ b/Mirror/Weaver/Resolvers.cs @@ -84,5 +84,19 @@ public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDef { return ResolveMethodWithArg(tr, scriptDef, name, argType.FullName); } + + public static MethodDefinition ResolveDefaultPublicCtor(TypeReference variable) + { + foreach (MethodDefinition methodRef in variable.Resolve().Methods) + { + if (methodRef.Name == ".ctor" && + methodRef.Resolve().IsPublic && + methodRef.Parameters.Count == 0) + { + return methodRef; + } + } + return null; + } } } \ No newline at end of file diff --git a/Mirror/Weaver/Weaver.cs b/Mirror/Weaver/Weaver.cs index 572d82d66..41efb5b22 100644 --- a/Mirror/Weaver/Weaver.cs +++ b/Mirror/Weaver/Weaver.cs @@ -660,7 +660,7 @@ static MethodDefinition GenerateReadFunction(TypeReference variable) { // classes are created with their constructor - var ctor = ResolveDefaultPublicCtor(variable); + MethodDefinition ctor = Resolvers.ResolveDefaultPublicCtor(variable); if (ctor == null) { Log.Error("The class " + variable.Name + " has no default constructor or it's private, aborting."); @@ -1034,20 +1034,6 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td) return false; } - static MethodDefinition ResolveDefaultPublicCtor(TypeReference variable) - { - foreach (MethodDefinition methodRef in variable.Resolve().Methods) - { - if (methodRef.Name == ".ctor" && - methodRef.Resolve().IsPublic && - methodRef.Parameters.Count == 0) - { - return methodRef; - } - } - return null; - } - static GenericInstanceMethod ResolveMethodGeneric(TypeReference t, string name, TypeReference genericType) { foreach (var methodRef in t.Resolve().Methods)