Files
se-launcher/CringeLauncher/Utils/MethodTools.cs
zznty e5c4f0c07c
Some checks failed
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m12s
Build / Build Nuget package (NuGet) (push) Successful in 1m55s
Build / Build Nuget package (SharedCringe) (push) Has been cancelled
Build / Build Nuget package (CringePlugins) (push) Has been cancelled
Build / Build Launcher (push) Has been cancelled
first
2024-10-28 05:15:13 +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");
}
}