From 7320cd8a2f76b58acb779bf0d10d8989bc1053dc Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 19 Aug 2021 22:47:30 +0800 Subject: [PATCH] Writers: remove static Log references --- .../Editor/Weaver/Processors/ReaderWriterProcessor.cs | 2 +- Assets/Mirror/Editor/Weaver/Writers.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs index bca7f8a63..c5c32e236 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/ReaderWriterProcessor.cs @@ -21,7 +21,7 @@ public static bool Process(AssemblyDefinition CurrentAssembly, WeaverTypes weave // otherwise we would get // "System.ArgumentException: Member ... is declared in another module and needs to be imported" // errors when still using the previous module's reader/writer funcs. - writers = new Writers(CurrentAssembly, weaverTypes); + writers = new Writers(CurrentAssembly, weaverTypes, Log); readers = new Readers(CurrentAssembly, weaverTypes, Log); foreach (Assembly unityAsm in CompilationPipeline.GetAssemblies()) diff --git a/Assets/Mirror/Editor/Weaver/Writers.cs b/Assets/Mirror/Editor/Weaver/Writers.cs index bd11e8823..ace3acd42 100644 --- a/Assets/Mirror/Editor/Weaver/Writers.cs +++ b/Assets/Mirror/Editor/Weaver/Writers.cs @@ -13,16 +13,17 @@ public class Writers // can't be used from another assembly, otherwise we will get: // "System.ArgumentException: Member ... is declared in another module and needs to be imported" AssemblyDefinition assembly; - WeaverTypes weaverTypes; + Logger Log; Dictionary writeFuncs = new Dictionary(new TypeReferenceComparer()); - public Writers(AssemblyDefinition assembly, WeaverTypes weaverTypes) + public Writers(AssemblyDefinition assembly, WeaverTypes weaverTypes, Logger Log) { this.assembly = assembly; this.weaverTypes = weaverTypes; + this.Log = Log; } public void Register(TypeReference dataType, MethodReference methodReference) @@ -64,7 +65,7 @@ public MethodReference GetWriteFunc(TypeReference variable) } catch (GenerateWriterException e) { - Weaver.Log.Error(e.Message, e.MemberReference); + Log.Error(e.Message, e.MemberReference); Weaver.WeavingFailed = true; return null; } @@ -279,7 +280,7 @@ MethodDefinition GenerateCollectionWriter(TypeReference variable, TypeReference // need this null check till later PR when GetWriteFunc throws exception instead if (elementWriteFunc == null) { - Weaver.Log.Error($"Cannot generate writer for {variable}. Use a supported type or provide a custom writer", variable); + Log.Error($"Cannot generate writer for {variable}. Use a supported type or provide a custom writer", variable); Weaver.WeavingFailed = true; return writerFunc; }