private static void PatchTest() { var targetPath = @"..\..\..\Patchwork.Tests.Target\bin\debug\Patchwork.Tests.Target.dll";; var dir = Path.GetDirectoryName(targetPath); var fn = Path.GetFileNameWithoutExtension(targetPath); var ext = Path.GetExtension(targetPath); var newFileName = string.Format("{0}.patched{1}", fn, ext); var newTarget = Path.Combine(dir, newFileName); File.Copy(targetPath, newTarget, true); var patcher = new AssemblyPatcher(newTarget, log: Log); var patchPath = typeof(Patchwork.Tests.Patch.TestClass).Assembly.Location; var maker = new ManifestCreator(); var manifest = maker.CreateManifest(patchPath); patcher.PatchManifest(manifest, null); patcher.WriteTo(newTarget); Log.Information("Loading assembly into memory..."); var loaded = Assembly.LoadFrom(newTarget); Log.Information("Invoking method"); var module = loaded.GetModules()[0]; var types = module.FindTypes((typ, o) => typ.Name.Contains("EntryPoint"), null); var foundType = types.Single(); var method = foundType.GetMethod("StandardTests"); try { var ret = method.Invoke(null, null); Log.Information("Result: {@Result}", ret); } catch (TargetInvocationException ex) { throw ex.InnerException; } Console.ReadKey(); }
/// <exception cref="T:Patchwork.Engine.PatchDeclerationException">The patch did not have a PatchInfo class.</exception> public static PatchingManifest TryGetManifest(string assemblyPath) { PatchingManifest patchingManifest = ManifestCreator.CreateManifest(assemblyPath); if (patchingManifest.PatchInfo == null) { throw new PatchDeclerationException("The patch did not have a PatchInfo class."); } return(patchingManifest); }