forked from pardeike/Harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First (rough) implementation, not tested yet
- Loading branch information
u0035718
committed
Apr 18, 2019
1 parent
60cb59e
commit 4c7f7c7
Showing
6 changed files
with
164 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Harmony; | ||
using HarmonyTests.Assets; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace HarmonyTests | ||
{ | ||
[TestFixture] | ||
public class FinalizerPatches | ||
{ | ||
[Test] | ||
public void TestSimpleFinalizer() | ||
{ | ||
var originalClass = typeof(SimpleFinalizerClass); | ||
Assert.IsNotNull(originalClass); | ||
var originalMethod = originalClass.GetMethod("Method"); | ||
Assert.IsNotNull(originalMethod); | ||
|
||
var patchClass = typeof(SimpleFinalizerPatch); | ||
var finalizer = patchClass.GetMethod("Finalizer"); | ||
Assert.IsNotNull(finalizer); | ||
|
||
var instance = HarmonyInstance.Create("test"); | ||
Assert.IsNotNull(instance); | ||
var patcher = new PatchProcessor(instance, new List<MethodBase> { originalMethod }, null, null, null, new HarmonyMethod(finalizer)); | ||
Assert.IsNotNull(patcher); | ||
patcher.Patch(); | ||
|
||
new SimpleFinalizerClass().Method(); | ||
Assert.IsTrue(SimpleFinalizerPatch.finalized); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters