ReaderWriterProcessor: ProcessMirrorAssemblyReaderWriterExtensions helper function for cleaner code

This commit is contained in:
vis2k 2021-08-22 16:58:44 +08:00
parent 2420a6d18b
commit 265a6384e1

View File

@ -15,6 +15,16 @@ public static bool Process(AssemblyDefinition CurrentAssembly, Writers writers,
{ {
// find readers/writers from Mirror.dll first // find readers/writers from Mirror.dll first
// which are the ones in NetworkReader/WriterExtensions class. // which are the ones in NetworkReader/WriterExtensions class.
ProcessMirrorAssemblyReaderWriterExtensions(CurrentAssembly, writers, readers, ref WeavingFailed);
// find readers/writers in the assembly we are in right now.
return ProcessAssemblyClasses(CurrentAssembly, CurrentAssembly, writers, readers, ref WeavingFailed);
}
static void ProcessMirrorAssemblyReaderWriterExtensions(AssemblyDefinition CurrentAssembly, Writers writers, Readers readers, ref bool WeavingFailed)
{
// we search all assemblies to find Mirror.dll.
// then find all NetworkReader/WriterExtensions.
foreach (Assembly unityAsm in CompilationPipeline.GetAssemblies()) foreach (Assembly unityAsm in CompilationPipeline.GetAssemblies())
{ {
if (unityAsm.name == "Mirror") if (unityAsm.name == "Mirror")
@ -26,9 +36,6 @@ public static bool Process(AssemblyDefinition CurrentAssembly, Writers writers,
} }
} }
} }
// find readers/writers in the assembly we are in right now.
return ProcessAssemblyClasses(CurrentAssembly, CurrentAssembly, writers, readers, ref WeavingFailed);
} }
static bool ProcessAssemblyClasses(AssemblyDefinition CurrentAssembly, AssemblyDefinition assembly, Writers writers, Readers readers, ref bool WeavingFailed) static bool ProcessAssemblyClasses(AssemblyDefinition CurrentAssembly, AssemblyDefinition assembly, Writers writers, Readers readers, ref bool WeavingFailed)