mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MethodProcessor: remove static Log references
This commit is contained in:
parent
b430e29e8b
commit
f0747c5418
@ -29,9 +29,9 @@ and replaces the body of the original method with the send message code.
|
||||
This way we do not need to modify the code anywhere else, and this works
|
||||
correctly in dependent assemblies
|
||||
*/
|
||||
public static MethodDefinition ProcessCommandCall(WeaverTypes weaverTypes, TypeDefinition td, MethodDefinition md, CustomAttribute commandAttr)
|
||||
public static MethodDefinition ProcessCommandCall(WeaverTypes weaverTypes, Logger Log, TypeDefinition td, MethodDefinition md, CustomAttribute commandAttr)
|
||||
{
|
||||
MethodDefinition cmd = MethodProcessor.SubstituteMethod(td, md);
|
||||
MethodDefinition cmd = MethodProcessor.SubstituteMethod(Log, td, md);
|
||||
|
||||
ILProcessor worker = md.Body.GetILProcessor();
|
||||
|
||||
|
@ -30,7 +30,7 @@ public static class MethodProcessor
|
||||
//
|
||||
// the original method definition loses all code
|
||||
// this returns the newly created method with all the user provided code
|
||||
public static MethodDefinition SubstituteMethod(TypeDefinition td, MethodDefinition md)
|
||||
public static MethodDefinition SubstituteMethod(Logger Log, TypeDefinition td, MethodDefinition md)
|
||||
{
|
||||
string newName = RpcPrefix + md.Name;
|
||||
MethodDefinition cmd = new MethodDefinition(newName, md.Attributes, md.ReturnType);
|
||||
@ -66,13 +66,13 @@ public static MethodDefinition SubstituteMethod(TypeDefinition td, MethodDefinit
|
||||
|
||||
td.Methods.Add(cmd);
|
||||
|
||||
FixRemoteCallToBaseMethod(td, cmd);
|
||||
FixRemoteCallToBaseMethod(Log, td, cmd);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// Finds and fixes call to base methods within remote calls
|
||||
//For example, changes `base.CmdDoSomething` to `base.CallCmdDoSomething` within `this.CallCmdDoSomething`
|
||||
public static void FixRemoteCallToBaseMethod(TypeDefinition type, MethodDefinition method)
|
||||
public static void FixRemoteCallToBaseMethod(Logger Log, TypeDefinition type, MethodDefinition method)
|
||||
{
|
||||
string callName = method.Name;
|
||||
|
||||
@ -95,14 +95,14 @@ public static void FixRemoteCallToBaseMethod(TypeDefinition type, MethodDefiniti
|
||||
|
||||
if (baseMethod == null)
|
||||
{
|
||||
Weaver.Log.Error($"Could not find base method for {callName}", method);
|
||||
Log.Error($"Could not find base method for {callName}", method);
|
||||
Weaver.WeavingFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!baseMethod.IsVirtual)
|
||||
{
|
||||
Weaver.Log.Error($"Could not find base method that was virutal {callName}", method);
|
||||
Log.Error($"Could not find base method that was virutal {callName}", method);
|
||||
Weaver.WeavingFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -1117,7 +1117,7 @@ void ProcessClientRpc(HashSet<string> names, MethodDefinition md, CustomAttribut
|
||||
includeOwner = includeOwner
|
||||
});
|
||||
|
||||
MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(weaverTypes, netBehaviourSubclass, md, clientRpcAttr);
|
||||
MethodDefinition rpcCallFunc = RpcProcessor.ProcessRpcCall(weaverTypes, Log, netBehaviourSubclass, md, clientRpcAttr);
|
||||
// need null check here because ProcessRpcCall returns null if it can't write all the args
|
||||
if (rpcCallFunc == null) { return; }
|
||||
|
||||
@ -1149,7 +1149,7 @@ void ProcessTargetRpc(HashSet<string> names, MethodDefinition md, CustomAttribut
|
||||
names.Add(md.Name);
|
||||
targetRpcs.Add(md);
|
||||
|
||||
MethodDefinition rpcCallFunc = TargetRpcProcessor.ProcessTargetRpcCall(weaverTypes, netBehaviourSubclass, md, targetRpcAttr);
|
||||
MethodDefinition rpcCallFunc = TargetRpcProcessor.ProcessTargetRpcCall(weaverTypes, Log, netBehaviourSubclass, md, targetRpcAttr);
|
||||
|
||||
MethodDefinition rpcFunc = TargetRpcProcessor.ProcessTargetRpcInvoke(weaverTypes, netBehaviourSubclass, md, rpcCallFunc);
|
||||
if (rpcFunc != null)
|
||||
@ -1186,7 +1186,7 @@ void ProcessCommand(HashSet<string> names, MethodDefinition md, CustomAttribute
|
||||
requiresAuthority = requiresAuthority
|
||||
});
|
||||
|
||||
MethodDefinition cmdCallFunc = CommandProcessor.ProcessCommandCall(weaverTypes, netBehaviourSubclass, md, commandAttr);
|
||||
MethodDefinition cmdCallFunc = CommandProcessor.ProcessCommandCall(weaverTypes, Log, netBehaviourSubclass, md, commandAttr);
|
||||
|
||||
MethodDefinition cmdFunc = CommandProcessor.ProcessCommandInvoke(weaverTypes, netBehaviourSubclass, md, cmdCallFunc);
|
||||
if (cmdFunc != null)
|
||||
|
@ -56,9 +56,9 @@ and replaces the body of the original method with the send message code.
|
||||
This way we do not need to modify the code anywhere else, and this works
|
||||
correctly in dependent assemblies
|
||||
*/
|
||||
public static MethodDefinition ProcessRpcCall(WeaverTypes weaverTypes, TypeDefinition td, MethodDefinition md, CustomAttribute clientRpcAttr)
|
||||
public static MethodDefinition ProcessRpcCall(WeaverTypes weaverTypes, Logger Log, TypeDefinition td, MethodDefinition md, CustomAttribute clientRpcAttr)
|
||||
{
|
||||
MethodDefinition rpc = MethodProcessor.SubstituteMethod(td, md);
|
||||
MethodDefinition rpc = MethodProcessor.SubstituteMethod(Log, td, md);
|
||||
|
||||
ILProcessor worker = md.Body.GetILProcessor();
|
||||
|
||||
|
@ -90,9 +90,9 @@ and replaces the body of the original method with the send message code.
|
||||
correctly in dependent assemblies
|
||||
|
||||
*/
|
||||
public static MethodDefinition ProcessTargetRpcCall(WeaverTypes weaverTypes, TypeDefinition td, MethodDefinition md, CustomAttribute targetRpcAttr)
|
||||
public static MethodDefinition ProcessTargetRpcCall(WeaverTypes weaverTypes, Logger Log, TypeDefinition td, MethodDefinition md, CustomAttribute targetRpcAttr)
|
||||
{
|
||||
MethodDefinition rpc = MethodProcessor.SubstituteMethod(td, md);
|
||||
MethodDefinition rpc = MethodProcessor.SubstituteMethod(Log, td, md);
|
||||
|
||||
ILProcessor worker = md.Body.GetILProcessor();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user