/// <summary>Mark block after</summary> /// <param name="il"> The il</param> /// <param name="block">The block</param> /// public static void MarkBlockAfter(ILGenerator il, ExceptionBlock block) { if (block.blockType == ExceptionBlockType.EndExceptionBlock) { if (HarmonyInstance.DEBUG) { // fake log a LEAVE code since BeginCatchBlock() does add it LogIL(il, OpCodes.Leave, new LeaveTry()); FileLog.ChangeIndent(-1); FileLog.LogBuffered("} // end handler"); } il.EndExceptionBlock(); } }
/// <summary>Mark block before</summary> /// <param name="il"> The il</param> /// <param name="block">The block</param> /// <param name="label">[out] The label</param> /// public static void MarkBlockBefore(ILGenerator il, ExceptionBlock block, out Label?label) { label = null; switch (block.blockType) { case ExceptionBlockType.BeginExceptionBlock: if (HarmonyInstance.DEBUG) { FileLog.LogBuffered(".try"); FileLog.LogBuffered("{"); FileLog.ChangeIndent(1); } label = il.BeginExceptionBlock(); return; case ExceptionBlockType.BeginCatchBlock: if (HarmonyInstance.DEBUG) { // fake log a LEAVE code since BeginCatchBlock() does add it LogIL(il, OpCodes.Leave, new LeaveTry()); FileLog.ChangeIndent(-1); FileLog.LogBuffered("} // end try"); FileLog.LogBuffered(".catch " + block.catchType); FileLog.LogBuffered("{"); FileLog.ChangeIndent(1); } il.BeginCatchBlock(block.catchType); return; case ExceptionBlockType.BeginExceptFilterBlock: if (HarmonyInstance.DEBUG) { // fake log a LEAVE code since BeginCatchBlock() does add it LogIL(il, OpCodes.Leave, new LeaveTry()); FileLog.ChangeIndent(-1); FileLog.LogBuffered("} // end try"); FileLog.LogBuffered(".filter"); FileLog.LogBuffered("{"); FileLog.ChangeIndent(1); } il.BeginExceptFilterBlock(); return; case ExceptionBlockType.BeginFaultBlock: if (HarmonyInstance.DEBUG) { // fake log a LEAVE code since BeginCatchBlock() does add it LogIL(il, OpCodes.Leave, new LeaveTry()); FileLog.ChangeIndent(-1); FileLog.LogBuffered("} // end try"); FileLog.LogBuffered(".fault"); FileLog.LogBuffered("{"); FileLog.ChangeIndent(1); } il.BeginFaultBlock(); return; case ExceptionBlockType.BeginFinallyBlock: if (HarmonyInstance.DEBUG) { // fake log a LEAVE code since BeginCatchBlock() does add it LogIL(il, OpCodes.Leave, new LeaveTry()); FileLog.ChangeIndent(-1); FileLog.LogBuffered("} // end try"); FileLog.LogBuffered(".finally"); FileLog.LogBuffered("{"); FileLog.ChangeIndent(1); } il.BeginFinallyBlock(); return; } }