splitting up ProcessEvents function (#2174)

This commit is contained in:
James Frowen 2020-08-18 17:56:21 +01:00 committed by GitHub
parent e4d9304478
commit 7294c42798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,33 +118,38 @@ public static void ProcessEvents(TypeDefinition td, List<EventDefinition> 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<EventDefinition> events, List<MethodDefinition> 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);
}
}
}