From ca418457e889734977fb9c78d665e40c01539eb1 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Mon, 21 Sep 2020 16:57:22 -0500 Subject: [PATCH] Simplify guard check --- .../ServerClientAttributeProcessor.cs | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Processors/ServerClientAttributeProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/ServerClientAttributeProcessor.cs index 989ce1aea..f13131310 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/ServerClientAttributeProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/ServerClientAttributeProcessor.cs @@ -64,33 +64,18 @@ public static bool HasServerClientAttribute(MethodDefinition md) public static bool ProcessMethodAttributes(TypeDefinition td, MethodDefinition md) { - bool modified = false; - foreach (CustomAttribute attr in md.CustomAttributes) - { - switch (attr.Constructor.DeclaringType.ToString()) - { - case "Mirror.ServerAttribute": - InjectServerGuard(md, true); - modified = true; - break; - case "Mirror.ServerCallbackAttribute": - 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; - } - } + if (md.HasCustomAttribute()) + InjectServerGuard(md, true); + else if (md.HasCustomAttribute()) + InjectServerGuard(md, false); + else if (md.HasCustomAttribute()) + InjectClientGuard(md, true); + else if (md.HasCustomAttribute()) + InjectClientGuard(md, false); + else + return false; - return modified; + return true; } static void InjectServerGuard(MethodDefinition md, bool logWarning)