Skip to content

Commit 66847b9

Browse files
authored
Fix #21 : patching unsupported methods breaks the whole patching process (#22)
Try-catch the actual patching to prevent attempting to patch unsupported methods (ususally generics...) from breaking the whole patching process.
1 parent f6a1855 commit 66847b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Source/Shabby.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ private void Start()
236236
if (callSite == mInfo_ShaderFind_Replacement)
237237
continue;
238238

239-
Log.Debug(
240-
$"Patching call site : {callSite.DeclaringType.Assembly.GetName().Name}::{callSite.DeclaringType}.{callSite.Name}");
241-
harmony.Patch(callSite, null, null, new HarmonyMethod(callSiteTranspiler));
239+
try {
240+
harmony.Patch(callSite, null, null, new HarmonyMethod(callSiteTranspiler));
241+
Log.Debug($"Patching call site : {callSite.DeclaringType.Assembly.GetName().Name}::{callSite.DeclaringType}.{callSite.Name}");
242+
} catch (Exception e) {
243+
Log.Warning($"Failed to patch call site : {callSite.DeclaringType.Assembly.GetName().Name}::{callSite.DeclaringType}.{callSite.Name}\n{e.Message}\n{e.StackTrace}");
244+
}
242245
}
243246
}
244247

0 commit comments

Comments
 (0)