Skip to content

Commit

Permalink
Make ZenjectLifecycleUnasserter slightly more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Nov 15, 2024
1 parent f08a03c commit 43a7696
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions SiraUtil/Tweaks/ZenjectLifecycleUnasserter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ class ZenjectLifecycleUnasserter

public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
CodeMatcher codeMatcher = new(instructions, generator);
codeMatcher
return new CodeMatcher(instructions, generator)
.MatchForward(false, new CodeMatch(OpCodes.Call, _rootMethod), new CodeMatch(OpCodes.Throw))
.ThrowIfInvalid($"Call to {nameof(ModestTree.Assert.CreateException)} & throw not found");

List<ExceptionBlock> blocks = codeMatcher.InstructionAt(1).blocks;
codeMatcher
.RemoveInstructions(2)
.Insert(new CodeInstruction(OpCodes.Call, _newFail) { blocks = blocks });

return codeMatcher.InstructionEnumeration();
.ThrowIfInvalid($"Call to {nameof(ModestTree.Assert.CreateException)} & throw not found")
.RemoveInstruction()
.SetAndAdvance(OpCodes.Call, _newFail)
.InstructionEnumeration();
}

public static IEnumerable<MethodInfo> TargetMethods()
Expand Down

0 comments on commit 43a7696

Please sign in to comment.