mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver.ResolveMethodGeneric moved to Resolvers
This commit is contained in:
parent
ee618ad8f6
commit
abdc6b8e56
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NetworkIdentity>()
|
||||
getComponentReference = ResolveMethodGeneric(ComponentType, "GetComponent", NetworkIdentityType);
|
||||
getComponentReference = Resolvers.ResolveMethodGeneric(ComponentType, scriptDef, "GetComponent", NetworkIdentityType);
|
||||
|
||||
getUNetIdReference = Resolvers.ResolveMethod(unetViewTmp, scriptDef, "get_netId");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user