diff --git a/Assets/Mirror/Editor/Weaver/Processors/SyncEventProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/SyncEventProcessor.cs index f8871f45d..cbc84b8b5 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/SyncEventProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/SyncEventProcessor.cs @@ -118,33 +118,38 @@ public static void ProcessEvents(TypeDefinition td, List events if (syncEventAttr != null) { - if (ed.EventType.Resolve().HasGenericParameters) - { - Weaver.Error($"{ed.Name} must not have generic parameters. Consider creating a new class that inherits from {ed.EventType} instead", ed); - return; - } - - events.Add(ed); - MethodDefinition eventFunc = ProcessEventInvoke(td, ed); - if (eventFunc == null) - { - return; - } - - td.Methods.Add(eventFunc); - eventInvocationFuncs.Add(eventFunc); - - Weaver.DLog(td, "ProcessEvent " + ed); - - MethodDefinition eventCallFunc = ProcessEventCall(td, ed, syncEventAttr); - td.Methods.Add(eventCallFunc); - - // original weaver compares .Name, not EventDefinition. - Weaver.WeaveLists.replaceEvents[ed.FullName] = eventCallFunc; - - Weaver.DLog(td, " Event: " + ed.Name); + ProcessEvent(td, events, eventInvocationFuncs, ed, syncEventAttr); } } } + + static void ProcessEvent(TypeDefinition td, List events, List eventInvocationFuncs, EventDefinition ed, CustomAttribute syncEventAttr) + { + if (ed.EventType.Resolve().HasGenericParameters) + { + Weaver.Error($"{ed.Name} must not have generic parameters. Consider creating a new class that inherits from {ed.EventType} instead", ed); + return; + } + + events.Add(ed); + MethodDefinition eventFunc = ProcessEventInvoke(td, ed); + if (eventFunc == null) + { + return; + } + + td.Methods.Add(eventFunc); + eventInvocationFuncs.Add(eventFunc); + + Weaver.DLog(td, "ProcessEvent " + ed); + + MethodDefinition eventCallFunc = ProcessEventCall(td, ed, syncEventAttr); + td.Methods.Add(eventCallFunc); + + // original weaver compares .Name, not EventDefinition. + Weaver.WeaveLists.replaceEvents[ed.FullName] = eventCallFunc; + + Weaver.DLog(td, " Event: " + ed.Name); + } } }