mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver: move writing out of Weave()
This commit is contained in:
parent
7088938bb7
commit
e8cf20847d
@ -172,7 +172,15 @@ static bool WeaveFromFile(string assemblyPath, string[] dependencies, string mir
|
|||||||
|
|
||||||
// create weaver with logger
|
// create weaver with logger
|
||||||
weaver = new Weaver(new CompilationFinishedLogger());
|
weaver = new Weaver(new CompilationFinishedLogger());
|
||||||
return weaver.Weave(assembly, asmResolver);
|
if (weaver.Weave(assembly, asmResolver, out bool modified))
|
||||||
|
{
|
||||||
|
// write changes to file if modified
|
||||||
|
if (modified)
|
||||||
|
assembly.Write(new WriterParameters{WriteSymbols = true});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,9 +132,10 @@ void CreateGeneratedCodeClass()
|
|||||||
// would not be guaranteed to be resolve-able because
|
// would not be guaranteed to be resolve-able because
|
||||||
// for ILPostProcessor we can't assume where Mirror.dll
|
// for ILPostProcessor we can't assume where Mirror.dll
|
||||||
// is etc.
|
// is etc.
|
||||||
public bool Weave(AssemblyDefinition assembly, IAssemblyResolver resolver)
|
public bool Weave(AssemblyDefinition assembly, IAssemblyResolver resolver, out bool modified)
|
||||||
{
|
{
|
||||||
WeavingFailed = false;
|
WeavingFailed = false;
|
||||||
|
modified = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Resolver = resolver;
|
Resolver = resolver;
|
||||||
@ -170,7 +171,7 @@ public bool Weave(AssemblyDefinition assembly, IAssemblyResolver resolver)
|
|||||||
|
|
||||||
Stopwatch rwstopwatch = Stopwatch.StartNew();
|
Stopwatch rwstopwatch = Stopwatch.StartNew();
|
||||||
// Need to track modified from ReaderWriterProcessor too because it could find custom read/write functions or create functions for NetworkMessages
|
// Need to track modified from ReaderWriterProcessor too because it could find custom read/write functions or create functions for NetworkMessages
|
||||||
bool modified = ReaderWriterProcessor.Process(CurrentAssembly, resolver, Log, writers, readers, ref WeavingFailed);
|
modified = ReaderWriterProcessor.Process(CurrentAssembly, resolver, Log, writers, readers, ref WeavingFailed);
|
||||||
rwstopwatch.Stop();
|
rwstopwatch.Stop();
|
||||||
Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds");
|
Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds");
|
||||||
|
|
||||||
@ -193,9 +194,11 @@ public bool Weave(AssemblyDefinition assembly, IAssemblyResolver resolver)
|
|||||||
|
|
||||||
ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly, weaverTypes, writers, readers, GeneratedCodeClass);
|
ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly, weaverTypes, writers, readers, GeneratedCodeClass);
|
||||||
|
|
||||||
// write to outputDir if specified, otherwise perform in-place write
|
// DO NOT WRITE here.
|
||||||
WriterParameters writeParams = new WriterParameters { WriteSymbols = true };
|
// CompilationFinishedHook writes to the file.
|
||||||
CurrentAssembly.Write(writeParams);
|
// ILPostProcessor writes to in-memory assembly.
|
||||||
|
// it depends on the caller.
|
||||||
|
//CurrentAssembly.Write(new WriterParameters{ WriteSymbols = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user