mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver.ResolveMethodInParents moved to Resolvers
This commit is contained in:
parent
feb6a9e01d
commit
6252201f21
@ -330,7 +330,7 @@ void GenerateSerialization()
|
|||||||
VariableDefinition dirtyLocal = new VariableDefinition(Weaver.boolType);
|
VariableDefinition dirtyLocal = new VariableDefinition(Weaver.boolType);
|
||||||
serialize.Body.Variables.Add(dirtyLocal);
|
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)
|
if (baseSerialize != null)
|
||||||
{
|
{
|
||||||
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
|
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
|
||||||
@ -527,7 +527,7 @@ void GenerateDeSerialization()
|
|||||||
serialize.Parameters.Add(new ParameterDefinition("initialState", ParameterAttributes.None, Weaver.boolType));
|
serialize.Parameters.Add(new ParameterDefinition("initialState", ParameterAttributes.None, Weaver.boolType));
|
||||||
ILProcessor serWorker = serialize.Body.GetILProcessor();
|
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)
|
if (baseDeserialize != null)
|
||||||
{
|
{
|
||||||
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
|
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
|
||||||
|
@ -37,5 +37,24 @@ public static MethodReference ResolveMethod(TypeReference tr, AssemblyDefinition
|
|||||||
Weaver.fail = true;
|
Weaver.fail = true;
|
||||||
return null;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1033,24 +1033,6 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td)
|
|||||||
}
|
}
|
||||||
return false;
|
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)
|
static MethodReference ResolveMethodWithArg(TypeReference t, string name, TypeReference argType)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user