mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver follow on pr to 490 (#519)
* removed workaround from previous cecil version that now causes sharing violation console warning * fixed language feature error -- null prop op is C#4 but .sln target is net35 * separated editor logging (required) from console logging (optional) * fix issue introduced by flipping boolean property meaning in9895bff
* added updated weaver assembly * updated to release assembly - wrong assembly inef0c903
* commenting weave target debug log to retain prev behaviour (oops)
This commit is contained in:
parent
400382be76
commit
92596de38a
Binary file not shown.
@ -25,25 +25,26 @@ public class CompilationFinishedHook
|
||||
static void HandleMessage(string msg)
|
||||
{
|
||||
if (UnityLogEnabled) Debug.Log(msg);
|
||||
OnWeaverMessage?.Invoke(msg);
|
||||
if (OnWeaverMessage != null) OnWeaverMessage.Invoke(msg);
|
||||
}
|
||||
|
||||
// warning message handler that also calls OnWarningMethod delegate
|
||||
static void HandleWarning(string msg)
|
||||
{
|
||||
if (UnityLogEnabled) Debug.LogWarning(msg);
|
||||
OnWeaverWarning?.Invoke(msg);
|
||||
if (OnWeaverWarning != null) OnWeaverWarning.Invoke(msg);
|
||||
}
|
||||
|
||||
// error message handler that also calls OnErrorMethod delegate
|
||||
static void HandleError(string msg)
|
||||
{
|
||||
if (UnityLogEnabled) Debug.LogError(msg);
|
||||
OnWeaverError?.Invoke(msg);
|
||||
if (OnWeaverError != null) OnWeaverError.Invoke(msg);
|
||||
}
|
||||
|
||||
static CompilationFinishedHook()
|
||||
{
|
||||
UnityLogEnabled = true;
|
||||
// assemblyPath: Library/ScriptAssemblies/Assembly-CSharp.dll/
|
||||
// assemblyPath: Library/ScriptAssemblies/Assembly-CSharp-Editor.dll
|
||||
CompilationPipeline.assemblyCompilationFinished += (assemblyPath, messages) =>
|
||||
@ -85,7 +86,8 @@ static CompilationFinishedHook()
|
||||
bool buildingForEditor = assemblyPath.EndsWith("Editor.dll");
|
||||
if (!buildingForEditor)
|
||||
{
|
||||
if (UnityLogEnabled) Console.WriteLine("Weaving: " + assemblyPath);
|
||||
//if (UnityLogEnabled) Debug.Log("Weaving: " + assemblyPath); // uncomment to easily observe weave targets
|
||||
Console.WriteLine("Weaving: " + assemblyPath);
|
||||
// assemblyResolver: unity uses this by default:
|
||||
// ICompilationExtension compilationExtension = GetCompilationExtension();
|
||||
// IAssemblyResolver assemblyResolver = compilationExtension.GetAssemblyResolver(editor, file, null);
|
||||
|
@ -1466,31 +1466,6 @@ static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyRes
|
||||
//Console.WriteLine ("Output:" + dest);
|
||||
|
||||
WriterParameters writeParams = Helpers.GetWriterParameters(readParams);
|
||||
|
||||
// PdbWriterProvider uses ISymUnmanagedWriter2 COM interface but Mono can't invoke a method on it and crashes (actually it first throws the following exception and then crashes).
|
||||
// One solution would be to convert UNetWeaver to exe file and run it on .NET on Windows (I have tested that and it works).
|
||||
// However it's much more simple to just write mdb file.
|
||||
// System.NullReferenceException: Object reference not set to an instance of an object
|
||||
// at(wrapper cominterop - invoke) Mono.Cecil.Pdb.ISymUnmanagedWriter2:DefineDocument(string, System.Guid &, System.Guid &, System.Guid &, Mono.Cecil.Pdb.ISymUnmanagedDocumentWriter &)
|
||||
// at Mono.Cecil.Pdb.SymWriter.DefineDocument(System.String url, Guid language, Guid languageVendor, Guid documentType)[0x00000] in < filename unknown >:0
|
||||
if (writeParams.SymbolWriterProvider is PdbWriterProvider)
|
||||
{
|
||||
writeParams.SymbolWriterProvider = new MdbWriterProvider();
|
||||
// old pdb file is out of date so delete it. symbols will be stored in mdb
|
||||
string pdb = Path.ChangeExtension(assName, ".pdb");
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(pdb);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// workaround until Unity fixes C#7 compiler compability with the UNET weaver
|
||||
// un-comment it if you want lot of noise
|
||||
//UnityEngine.Debug.LogWarning(string.Format("Unable to delete file {0}: {1}", pdb, ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
CurrentAssembly.Write(dest, writeParams);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user