private static void ProcessDll(string dllPath) { var watch = Stopwatch.StartNew(); if (TryToOpenFile(dllPath, FileMode.Open, FileAccess.ReadWrite, WaitMillisecondsForFileHandle, out var stream)) { try { var pdbPath = Path.ChangeExtension(Path.GetFullPath(stream.Name), ".pdb"); if (CodeWeaver.WeaveDllStream(stream, File.Exists(pdbPath))) { watch.Stop(); Debug.Log($"Processed {dllPath} in {watch.Elapsed.TotalMilliseconds} milliseconds."); } } finally { stream.Close(); } } else { throw new Exception(dllPath + " was used by other process and could not be prepared for serialization."); } }
static InstanceMethodCallProcessor() { CodeWeaver.AddProcessor(new InstanceMethodCallProcessor()); }