Simplify guard check

This commit is contained in:
Paul Pacheco 2020-09-21 16:57:22 -05:00
parent 65f6e42b53
commit ca418457e8

View File

@ -64,33 +64,18 @@ public static bool HasServerClientAttribute(MethodDefinition md)
public static bool ProcessMethodAttributes(TypeDefinition td, MethodDefinition md) public static bool ProcessMethodAttributes(TypeDefinition td, MethodDefinition md)
{ {
bool modified = false; if (md.HasCustomAttribute<Mirror.ServerAttribute>())
foreach (CustomAttribute attr in md.CustomAttributes) InjectServerGuard(md, true);
{ else if (md.HasCustomAttribute<Mirror.ServerCallbackAttribute>())
switch (attr.Constructor.DeclaringType.ToString()) InjectServerGuard(md, false);
{ else if (md.HasCustomAttribute<Mirror.ClientAttribute>())
case "Mirror.ServerAttribute": InjectClientGuard(md, true);
InjectServerGuard(md, true); else if (md.HasCustomAttribute<Mirror.ClientCallbackAttribute>())
modified = true; InjectClientGuard(md, false);
break; else
case "Mirror.ServerCallbackAttribute": return false;
InjectServerGuard(md, false);
modified = true;
break;
case "Mirror.ClientAttribute":
InjectClientGuard(md, true);
modified = true;
break;
case "Mirror.ClientCallbackAttribute":
InjectClientGuard(md, false);
modified = true;
break;
default:
break;
}
}
return modified; return true;
} }
static void InjectServerGuard(MethodDefinition md, bool logWarning) static void InjectServerGuard(MethodDefinition md, bool logWarning)