add unloading for mod assemblies
This commit is contained in:
20
CringeLauncher/Utils/MethodTools.cs
Normal file
20
CringeLauncher/Utils/MethodTools.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using MonoMod.Utils;
|
||||
|
||||
namespace CringeLauncher.Utils;
|
||||
|
||||
public static class MethodTools
|
||||
{
|
||||
public static MethodInfo AsyncMethodBody(MethodInfo method)
|
||||
{
|
||||
var (_, operand) = PatchProcessor.ReadMethodBody(method).First();
|
||||
|
||||
if (operand is not LocalVariableInfo localVar)
|
||||
throw new InvalidOperationException($"Method {method.GetID()} does not contain a valid async state machine");
|
||||
|
||||
return AccessTools.Method(localVar.LocalType, "MoveNext") ??
|
||||
throw new InvalidOperationException(
|
||||
$"Async State machine of method {method.GetID()} does not contain a valid MoveNext method");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user