public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca) { const string targetPrefix = "Target"; int prefixLen = targetPrefix.Length; if (md.Name.Length > prefixLen && md.Name.Substring(0, prefixLen) != targetPrefix) { Weaver.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Target' prefix"); return(false); } if (md.IsStatic) { Weaver.Error("TargetRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method"); return(false); } if (!NetworkBehaviourProcessor.ProcessMethodsValidateFunction(td, md, "Target Rpc")) { return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Target Rpc")); }
public static bool ProcessMethodsValidateCommand(MethodDefinition md) { if (md.IsStatic) { Weaver.Error($"{md.Name} cannot be static", md); return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateFunction(md) && NetworkBehaviourProcessor.ProcessMethodsValidateParameters(md, RemoteCallType.Command)); }
public static bool ProcessMethodsValidateTargetRpc(MethodDefinition md) { if (md.IsStatic) { Weaver.Error($"{md.Name} must not be static", md); return(false); } if (!NetworkBehaviourProcessor.ProcessMethodsValidateFunction(md)) { return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateParameters(md, RemoteCallType.TargetRpc)); }
public static bool ProcessMethodsValidateRpc(MethodDefinition md, CustomAttribute ca) { if (!md.Name.StartsWith("Rpc")) { Weaver.Error($"{md.Name} must start with Rpc. Consider renaming it to Rpc{md.Name}", md); return(false); } if (md.IsStatic) { Weaver.Error($"{md.Name} must not be static", md); return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateFunction(md) && NetworkBehaviourProcessor.ProcessMethodsValidateParameters(md, ca)); }
public static bool ProcessMethodsValidateCommand(MethodDefinition md, CustomAttribute commandAttr) { if (!md.Name.StartsWith("Cmd")) { Weaver.Error($"{md.Name} must start with Cmd. Consider renaming it to Cmd{md.Name}", md); return(false); } if (md.IsStatic) { Weaver.Error($"{md.Name} cannot be static", md); return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateFunction(md) && NetworkBehaviourProcessor.ProcessMethodsValidateParameters(md, commandAttr)); }
public static bool ProcessMethodsValidateRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca) { if (!md.Name.StartsWith("Rpc")) { Weaver.Error("Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Rpc' prefix"); return(false); } if (md.IsStatic) { Weaver.Error("ClientRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method"); return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateFunction(td, md, "Rpc") && NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Rpc")); }
public static bool ProcessMethodsValidateCommand(TypeDefinition td, MethodDefinition md, CustomAttribute ca) { if (md.Name.Length > 2 && md.Name.Substring(0, 3) != "Cmd") { Weaver.Error("Command function [" + td.FullName + ":" + md.Name + "] doesnt have 'Cmd' prefix"); return(false); } if (md.IsStatic) { Weaver.Error("Command function [" + td.FullName + ":" + md.Name + "] cant be a static method"); return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateFunction(td, md, "Command") && NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Command")); }
public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca) { const string targetPrefix = "Target"; int prefixLen = targetPrefix.Length; if (md.Name.Length > prefixLen && md.Name.Substring(0, prefixLen) != targetPrefix) { Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Target' prefix"); Weaver.fail = true; return(false); } if (md.IsStatic) { Log.Error("TargetRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method"); Weaver.fail = true; return(false); } if (!NetworkBehaviourProcessor.ProcessMethodsValidateFunction(td, md, "Target Rpc")) { return(false); } if (md.Parameters.Count < 1) { Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] must have a NetworkConnection as the first parameter"); Weaver.fail = true; return(false); } if (md.Parameters[0].ParameterType.FullName != Weaver.NetworkConnectionType.FullName) { Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] first parameter must be a NetworkConnection"); Weaver.fail = true; return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Target Rpc")); }
public static bool ProcessMethodsValidateTargetRpc(MethodDefinition md) { if (!md.Name.StartsWith("Target")) { Weaver.Error($"{md.Name} must start with Target. Consider renaming it to Target{md.Name}", md); return(false); } if (md.IsStatic) { Weaver.Error($"{md.Name} must not be static", md); return(false); } if (!NetworkBehaviourProcessor.ProcessMethodsValidateFunction(md)) { return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateParameters(md, RemoteCallType.TargetRpc)); }
public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefinition md, CustomAttribute ca) { if (!md.Name.StartsWith("Target")) { Weaver.Error($"{md} must start with Target. Consider renaming it to Target{md.Name}"); return(false); } if (md.IsStatic) { Weaver.Error($"{md} must not be static"); return(false); } if (!NetworkBehaviourProcessor.ProcessMethodsValidateFunction(td, md, "Target Rpc")) { return(false); } // validate return(NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Target Rpc")); }