From ad107e3b8478de5e0276df814f840b49bbbd344a Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 22 Aug 2021 21:33:19 +0800 Subject: [PATCH] comments on why reflection is used --- .../Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs index d82e6c964..5092965ab 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs @@ -128,6 +128,8 @@ static bool IsEditorAssembly(AssemblyDefinition currentAssembly) // helper function to add [RuntimeInitializeOnLoad] attribute to method // TODO avoid reflection if possible + // reflection is used because according paul, 'weaving Mirror.dll caused + // unity to rebuild all dlls but in wrong order, which breaks rewired' static void AddRuntimeInitializeOnLoadAttribute(AssemblyDefinition assembly, WeaverTypes weaverTypes, MethodDefinition method) { System.Reflection.ConstructorInfo attributeconstructor = typeof(RuntimeInitializeOnLoadMethodAttribute).GetConstructor(new[] { typeof(RuntimeInitializeLoadType) }); @@ -139,6 +141,8 @@ static void AddRuntimeInitializeOnLoadAttribute(AssemblyDefinition assembly, Wea // helper function to add [InitializeOnLoad] attribute to method // (only works in Editor assemblies. check IsEditorAssembly first.) // TODO avoid reflection if possible + // reflection is used because according paul, 'weaving Mirror.dll caused + // unity to rebuild all dlls but in wrong order, which breaks rewired' static void AddInitializeOnLoadAttribute(AssemblyDefinition assembly, MethodDefinition method) { System.Reflection.ConstructorInfo initializeOnLoadConstructor = typeof(InitializeOnLoadMethodAttribute).GetConstructor(new Type[0]);