Files
se-launcher/CringeLauncher/Utils/MethodTools.cs
zznty fbf02ad716
All checks were successful
Build / Build Launcher (push) Successful in 2m17s
move client mods updates to actual steam api
2024-05-31 17:56:24 +07:00

19 lines
705 B
C#

using System.Reflection;
using HarmonyLib;
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.FullDescription()} does not contain a valid async state machine");
return AccessTools.Method(localVar.LocalType, "MoveNext") ??
throw new InvalidOperationException(
$"Async State machine of method {method.FullDescription()} does not contain a valid MoveNext method");
}
}