-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds better detection for methods that end in dead code
- Loading branch information
Showing
8 changed files
with
259 additions
and
70 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
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 |
---|---|---|
@@ -1,30 +1,51 @@ | ||
using HarmonyLib; | ||
using HarmonyLibTests.Assets; | ||
using NUnit.Framework; | ||
|
||
namespace HarmonyLibTests.Patching | ||
{ | ||
// TODO: DynamicMethod does not support 'catch .. when' and | ||
// MonoMod.Core has still a bug so for now we cannot enable | ||
|
||
public class TestExceptionFilterBlock | ||
{ | ||
// Filter exceptions are currently not supported in DynamicMethods | ||
// Example: | ||
// catch (Exception e) when (e.Message == "test") { } | ||
[Test] | ||
[Ignore("Filter exceptions are currently not supported in DynamicMethods")] | ||
public void TestExceptionsWithFilter() | ||
{ | ||
var originalClass = typeof(ClassExceptionFilter); | ||
Assert.NotNull(originalClass); | ||
var originalMethod = originalClass.GetMethod("Method1"); | ||
Assert.NotNull(originalMethod); | ||
|
||
var instance = new Harmony("test"); | ||
Assert.NotNull(instance); | ||
|
||
var patcher = new PatchProcessor(instance, originalMethod); | ||
Assert.NotNull(patcher); | ||
_ = patcher.Patch(); | ||
|
||
ClassExceptionFilter.Method1(); | ||
} | ||
|
||
/* | ||
[Test] | ||
[Ignore("Filter exceptions are currently not supported in DynamicMethods")] | ||
public void TestPlainMethodExceptions() | ||
{ | ||
var originalClass = typeof(ClassExceptionFilter); | ||
Assert.NotNull(originalClass); | ||
var originalMethod = originalClass.GetMethod("Method"); | ||
var originalMethod = originalClass.GetMethod("Method2"); | ||
Assert.NotNull(originalMethod); | ||
|
||
var instance = new Harmony("test"); | ||
Assert.NotNull(instance); | ||
|
||
var patcher = new PatchProcessor(instance, originalMethod); | ||
Assert.NotNull(patcher); | ||
patcher.Patch(); | ||
_ = patcher.Patch(); | ||
|
||
var result = ClassExceptionFilter.Method(null); | ||
var result = ClassExceptionFilter.Method2(null); | ||
Assert.AreEqual(100, result); | ||
} | ||
*/ | ||
} | ||
} |
Oops, something went wrong.