Added options to disable launcher/plugin auto updates
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 4m4s
Build / Build Nuget package (NuGet) (push) Successful in 4m7s
Build / Build Nuget package (SharedCringe) (push) Successful in 4m5s
Build / Build Nuget package (CringePlugins) (push) Successful in 4m25s
Build / Build Launcher (push) Successful in 5m12s

Also ran cleanup
This commit is contained in:
2025-06-06 01:35:09 -04:00
parent bc88f0c28a
commit 94fc8a55c0
48 changed files with 381 additions and 267 deletions

View File

@@ -66,7 +66,7 @@ internal sealed class ImGuiHandler : IGuiHandler, IDisposable
ImGui_ImplWin32_Init(windowHandle);
ImGui_ImplDX11_Init(device.NativePointer, deviceContext.NativePointer);
_init = true;
_imageService.Initialize();
}
@@ -123,7 +123,7 @@ internal sealed class ImGuiHandler : IGuiHandler, IDisposable
UpdatePlatformWindows();
RenderPlatformWindowsDefault();
_imageService.Update();
}

View File

@@ -1,9 +1,4 @@
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using CringeBootstrap.Abstractions;
using CringeBootstrap.Abstractions;
using CringeLauncher.Utils;
using CringePlugins.Config;
using CringePlugins.Loader;
@@ -25,6 +20,12 @@ using Sandbox.Game;
using SpaceEngineers.Game;
using SpaceEngineers.Game.Achievements;
using SpaceEngineers.Game.GUI;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using System.Text.Json;
using Velopack;
using VRage;
using VRage.Audio;
@@ -58,7 +59,7 @@ public class Launcher : ICorePlugin
{
if (Type.GetType("GameAnalyticsSDK.Net.Logging.GALogger, GameAnalytics.Mono") is { } gaLoggerType)
RuntimeHelpers.RunClassConstructor(gaLoggerType.TypeHandle);
LogManager.Setup()
.LoadConfigurationFromFile()
.SetupExtensions(s =>
@@ -75,19 +76,21 @@ public class Launcher : ICorePlugin
var logger = LogManager.GetLogger("CringeBootstrap");
logger.Info("Bootstrapping");
//environment variable for viktor's plugins
Environment.SetEnvironmentVariable("SE_PLUGIN_DISABLE_METHOD_VERIFICATION", "True");
#if !DEBUG
CheckUpdates(args, logger).GetAwaiter().GetResult();
#else
logger.Info("Updates disabled: {Flag}", CheckUpdatesDisabledAsync(logger).GetAwaiter().GetResult());
#endif
// hook up steam as we ship it inside base context as an override
if (AssemblyLoadContext.GetLoadContext(typeof(Launcher).Assembly) is ICoreLoadContext coreLoadContext)
NativeLibrary.SetDllImportResolver(typeof(Steamworks.Constants).Assembly, (name, _, _) => coreLoadContext.ResolveUnmanagedDll(name));
NativeLibrary.SetDllImportResolver(typeof(EosService).Assembly, (name, _, _) => NativeLibrary.Load(Path.Join(AppContext.BaseDirectory, name)));
_harmony.PatchAll(typeof(Launcher).Assembly);
MyFileSystem.ExePath = Path.GetDirectoryName(args.ElementAtOrDefault(0) ?? Assembly.GetExecutingAssembly().Location)!;
@@ -105,12 +108,12 @@ public class Launcher : ICorePlugin
MyShaderCompiler.Init(MyShaderCompiler.TargetPlatform.PC, false);
MyVRageWindows.Init(MyPerGameSettings.BasicGameInfo.ApplicationName, MySandboxGame.Log,
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
MyPerGameSettings.BasicGameInfo.ApplicationName),
MyPerGameSettings.BasicGameInfo.ApplicationName),
false, false);
MyPlatformGameSettings.SAVE_TO_CLOUD_OPTION_AVAILABLE = true;
MyXAudio2.DEVICE_DETAILS_SUPPORTED = false;
if (MyVRage.Platform.System.SimulationQuality == SimulationQuality.Normal)
{
MyPlatformGameSettings.SIMPLIFIED_SIMULATION_OVERRIDE = false;
@@ -133,17 +136,17 @@ public class Launcher : ICorePlugin
_renderComponent = new();
_renderComponent.Start(new(), () => InitEarlyWindow(splash), MyVideoSettingsManager.Initialize(), MyPerGameSettings.MaxFrameRate);
_renderComponent.RenderThread.BeforeDraw += MyFpsManager.Update;
// this technically should wait for render thread init, but who cares
splash.ExecuteLoadingStages();
InitUgc();
MyFileSystem.InitUserSpecific(MyGameService.UserId.ToString());
_lifetime.RegisterLifetime();
WaitForDevice();
_game = new(args)
{
GameRenderComponent = _renderComponent,
@@ -164,14 +167,14 @@ public class Launcher : ICorePlugin
var retryPolicy = HttpPolicyExtensions.HandleTransientHttpError()
.WaitAndRetryAsync(5, _ => TimeSpan.FromSeconds(1));
services.AddHttpClient<PluginsLifetime>()
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
AutomaticDecompression = DecompressionMethods.All
})
.AddPolicyHandler(retryPolicy);
services.AddHttpClient<ImGuiImageService>()
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
@@ -208,25 +211,55 @@ public class Launcher : ICorePlugin
private IVRageWindow InitEarlyWindow(Splash splash)
{
ImGuiHandler.Instance = new(_configDir);
RenderHandler.Current.RegisterComponent(splash);
MyVRage.Platform.Windows.CreateWindow("Cringe Launcher", MyPerGameSettings.GameIcon, null);
MyVRage.Platform.Windows.Window.OnExit += MySandboxGame.ExitThreadSafe;
MyRenderProxy.RenderThread = _renderComponent!.RenderThread;
MyVRage.Platform.Windows.Window.ShowAndFocus();
return MyVRage.Platform.Windows.Window;
}
private async Task<bool> CheckUpdatesDisabledAsync(Logger logger)
{
var path = Path.Join(_configDir.FullName, "launcher.json");
if (!File.Exists(path))
return false;
try
{
await using var stream = File.OpenRead(path);
var conf = await JsonSerializer.DeserializeAsync<LauncherConfig>(stream, ConfigHandler.SerializerOptions);
return conf?.DisableLauncherUpdates ?? false;
}
catch (Exception ex)
{
logger.Error(ex, "Error reading launcher config");
}
return false;
}
private async Task CheckUpdates(string[] args, Logger logger)
{
if (await CheckUpdatesDisabledAsync(logger))
{
logger.Warn("Updates Disabled (may break from keen update)");
return;
}
logger.Info("Checking for updates...");
var mgr = new UpdateManager("https://dl.zznty.ru/CringeLauncher/");
// check for new version
var newVersion = await mgr.CheckForUpdatesAsync();
if (newVersion == null)
@@ -234,7 +267,7 @@ public class Launcher : ICorePlugin
logger.Info("Up to date");
return; // no update available
}
// print update info
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"New version available: {mgr.CurrentVersion} -> {newVersion.TargetFullRelease.Version}");
@@ -250,7 +283,7 @@ public class Launcher : ICorePlugin
// download new version
await mgr.DownloadUpdatesAsync(newVersion);
logger.Info("Done! Restarting...");
// install new version and restart app
@@ -278,11 +311,11 @@ public class Launcher : ICorePlugin
var textsPath = Path.Combine(MyFileSystem.RootPath, @"Content\Data\Localization\CoreTexts");
var hashSet = new HashSet<MyLanguagesEnum>();
MyTexts.LoadSupportedLanguages(textsPath, hashSet);
if (!MyTexts.Languages.TryGetValue(MyLanguage.Instance.GetOsLanguageCurrentOfficial(), out var description) &&
!MyTexts.Languages.TryGetValue(MyLanguagesEnum.English, out description))
return;
MyTexts.LoadTexts(textsPath, description.CultureName, description.SubcultureName);
}
@@ -290,20 +323,20 @@ public class Launcher : ICorePlugin
{
var steamGameService = MySteamGameService.Create(false, AppId);
MyServiceManager.Instance.AddService(steamGameService);
var aggregator = new MyServerDiscoveryAggregator();
MySteamGameService.InitNetworking(false, steamGameService, MyPerGameSettings.GameName, aggregator);
EosService.InitNetworking(false, false, MyPerGameSettings.GameName, steamGameService, "xyza7891964JhtVD93nm3nZp8t1MbnhC",
"AKGM16qoFtct0IIIA8RCqEIYG4d4gXPPDNpzGuvlhLA", "24b1cd652a18461fa9b3d533ac8d6b5b",
"1958fe26c66d4151a327ec162e4d49c8", "07c169b3b641401496d352cad1c905d6",
"https://retail.epicgames.com/", EosService.CreatePlatform(),
MyPlatformGameSettings.VERBOSE_NETWORK_LOGGING, ArraySegment<string>.Empty, aggregator,
MyPlatformGameSettings.VERBOSE_NETWORK_LOGGING, [], aggregator,
MyMultiplayer.Channels);
MyServiceManager.Instance.AddService<IMyServerDiscovery>(aggregator);
MyServiceManager.Instance.AddService(MySteamGameService.CreateMicrophone());
MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(AppId, steamGameService));
var modUgc = MyModIoService.Create(MyServiceManager.Instance.GetService<IMyGameService>(), "spaceengineers",
@@ -313,7 +346,7 @@ public class Launcher : ICorePlugin
MyPlatformGameSettings.MODIO_PORTAL);
modUgc.IsConsentGiven = MySandboxGame.Config.ModIoConsent;
MyGameService.WorkshopService.AddAggregate(modUgc);
MySpaceEngineersAchievements.Initialize();
}
@@ -321,13 +354,13 @@ public class Launcher : ICorePlugin
{
var renderQualityHint = MyVRage.Platform.Render.GetRenderQualityHint();
var preset = MyGuiScreenOptionsGraphics.GetPreset(renderQualityHint);
MyRenderProxy.Settings.User = MyVideoSettingsManager
.GetGraphicsSettingsFromConfig(ref preset, renderQualityHint > MyRenderPresetEnum.CUSTOM)
.PerformanceSettings.RenderSettings;
MyRenderProxy.Settings.EnableAnsel = MyPlatformGameSettings.ENABLE_ANSEL;
MyRenderProxy.Settings.EnableAnselWithSprites = MyPlatformGameSettings.ENABLE_ANSEL_WITH_SPRITES;
var graphicsRenderer = MySandboxGame.Config.GraphicsRenderer;
MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;

View File

@@ -16,15 +16,15 @@ public static class EosInitPatch
var ins = instructions.ToList();
var stIndex = ins.FindIndex(b => b.opcode == OpCodes.Stloc_1);
ins.InsertRange(stIndex, new []
{
ins.InsertRange(stIndex,
[
new CodeInstruction(OpCodes.Dup),
new(OpCodes.Ldc_I4_2), // PlatformFlags.DisableOverlay
new(OpCodes.Conv_I8),
CodeInstruction.Call("Epic.OnlineServices.Platform.Options:set_Flags"),
});
CodeInstruction.Call("Epic.OnlineServices.Platform.Options:set_Flags"),
]);
return ins;
}
}

View File

@@ -42,23 +42,26 @@ public static class IntrospectionPatches
//mods need to look for specific derived types
Debug.WriteLine($"Getting special types for {__instance.FullName}");
var module = __instance.GetMainModule();
__result = IntrospectionContext.Global.CollectDerivedTypes<MyObjectBuilder_Base>(module)
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyStatLogic>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyObjectBuilderDefinitionAttribute>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyComponentBase>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyComponentBuilderAttribute>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyTextSurfaceScript>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyUseObject>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyHudStat>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MySessionComponentDescriptor>(module))
.ToArray();
__result =
[
.. IntrospectionContext.Global.CollectDerivedTypes<MyObjectBuilder_Base>(module)
,
.. IntrospectionContext.Global.CollectDerivedTypes<MyStatLogic>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MyObjectBuilderDefinitionAttribute>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<MyComponentBase>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MyComponentBuilderAttribute>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyTextSurfaceScript>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyUseObject>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyHudStat>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MySessionComponentDescriptor>(module),
];
return false;
}
Debug.WriteLine($"Blocking GetTypes for {__instance.FullName}");
__result = [];
return false;
}
@@ -74,10 +77,9 @@ public static class IntrospectionPatches
__result = [];
return false;
}
// static classes are abstract
__result = IntrospectionContext.Global.CollectAttributedTypes<HarmonyAttribute>(assembly.GetMainModule(), true)
.ToArray();
__result = [.. IntrospectionContext.Global.CollectAttributedTypes<HarmonyAttribute>(assembly.GetMainModule(), true)];
return false;
}
@@ -101,13 +103,13 @@ public static class IntrospectionPatches
.Concat(PluginsLifetime.Contexts.SelectMany(x => x.Assemblies)) ?? [];
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(MySession), "PrepareBaseSession", typeof(MyObjectBuilder_Checkpoint), typeof(MyObjectBuilder_Sector))]
private static void PrepareSessionPrefix()
{
// i hate keen for that in MyUseObjectFactory..cctor
// MyUseObjectFactory.RegisterAssemblyTypes(Assembly.LoadFrom(Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll")));
MyUseObjectFactory.RegisterAssemblyTypes(MyPlugins.SandboxGameAssembly);
}
@@ -117,10 +119,10 @@ public static class IntrospectionPatches
foreach (var type in assemblies.SelectMany(b => IntrospectionContext.Global.CollectDerivedTypes<IPlugin>(b.GetMainModule())))
{
var instance = Activator.CreateInstance(type);
if (instance is IPlugin plugin)
___m_plugins.Add(plugin);
if (instance is IHandleInputPlugin handleInputPlugin)
___m_handleInputPlugins.Add(handleInputPlugin);
}
@@ -138,22 +140,22 @@ public static class IntrospectionPatches
if (assembly?.GetType($"Microsoft.Xml.Serialization.GeneratedAssembly.{typeName}Serializer") is not { } type)
return false;
__result = Activator.CreateInstance(type) as XmlSerializer;
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(MyXmlSerializerManager), nameof(MyXmlSerializerManager.RegisterFromAssembly))]
private static bool XmlManagerRegisterPrefix(Assembly assembly) => AssemblyLoadContext.GetLoadContext(assembly) is ICoreLoadContext;
[HarmonyPatch]
private static class GameAssembliesPatch
{
private static IEnumerable<MethodInfo> TargetMethods()
{
return AccessTools.GetDeclaredMethods(typeof(MyPlugins))
.Where(b => b.Name.StartsWith("Register") &&
.Where(b => b.Name.StartsWith("Register") &&
b.GetParameters() is [var param] && param.ParameterType == typeof(string));
}

View File

@@ -13,7 +13,7 @@ public static class PluginNamePatch
// to be just $"Plugin Init: {plugin}"
// so you could override .ToString
// doesn't change default behavior since base .ToString is .GetType().ToString()
return new CodeMatcher(instructions)
.SearchForward(b => b.Is(OpCodes.Ldstr, "Plugin Init: "))
.Advance(2)

View File

@@ -10,7 +10,7 @@ namespace CringeLauncher.Patches;
public static class ScriptCompilationSettingsPatch
{
private static readonly CSharpParseOptions Options = new(LanguageVersion.Latest, DocumentationMode.None);
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var field = AccessTools.Field(typeof(MyScriptCompiler), nameof(MyScriptCompiler.m_conditionalParseOptions));

View File

@@ -14,7 +14,7 @@ public static class ScriptCompilerInitializationPatch
return AccessTools.Method(Type.GetType("VRage.Scripting.MyVRageScriptingInternal, VRage.Scripting", true),
"Initialize");
}
private static bool Prefix(Thread updateThread, Type[] referencedTypes, string[] symbols)
{
MyModWatchdog.Init(updateThread);

View File

@@ -18,10 +18,10 @@ public static class SwapChainPatch
WindowHandle = windowHandle;
MyPlatformRender.DisposeSwapChain();
MyPlatformRender.Log.WriteLine("CreateDeviceInternal create swapchain");
if (MyPlatformRender.m_swapchain != null)
return false;
var chainDescription = new SwapChainDescription
{
BufferCount = 2,
@@ -39,7 +39,7 @@ public static class SwapChainPatch
Usage = Usage.ShaderInput | Usage.RenderTargetOutput,
SwapEffect = SwapEffect.Discard
};
var factory = MyPlatformRender.GetFactory();
try
{
@@ -62,7 +62,7 @@ public static class SwapChainPatch
{
ImGuiHandler.Instance?.Init(WindowHandle, MyRender11.DeviceInstance, MyRender11.RC.DeviceContext);
}
[HarmonyPrefix, HarmonyPatch(typeof(MyBackbuffer), MethodType.Constructor, typeof(SharpDX.Direct3D11.Resource))]
private static bool SwapChainBBPrefix(MyBackbuffer __instance, SharpDX.Direct3D11.Resource swapChainBB)
{
@@ -73,13 +73,13 @@ public static class SwapChainPatch
Dimension = RenderTargetViewDimension.Texture2D,
});
__instance.m_srv = new ShaderResourceView(MyRender11.DeviceInstance, swapChainBB);
ImGuiHandler.Rtv = new RenderTargetView(MyRender11.DeviceInstance, swapChainBB, new()
{
Format = Format.R8G8B8A8_UNorm,
Dimension = RenderTargetViewDimension.Texture2D,
});
return false;
}
@@ -87,7 +87,7 @@ public static class SwapChainPatch
private static void SwapChainBBReleasePrefix(MyBackbuffer __instance)
{
if (ImGuiHandler.Rtv is null) return;
ImGuiHandler.Rtv.Dispose();
ImGuiHandler.Rtv = null;
}

View File

@@ -10,7 +10,7 @@ public static class WhitelistAllowPatch
private static void Prefix(ref MemberInfo[] members)
{
if (members.Any(b => b is null))
members = members.Where(b => b is { }).ToArray();
members = [.. members.Where(b => b is { })];
}
private static Exception? Finalizer(Exception __exception)

View File

@@ -14,7 +14,7 @@ public static class WhitelistPatch
private static void Prefix(MyScriptCompiler scriptCompiler)
{
var baseDir = new FileInfo(typeof(Type).Assembly.Location).DirectoryName!;
scriptCompiler.AddReferencedAssemblies(
typeof(Type).Assembly.Location,
typeof(LinkedList<>).Assembly.Location,

View File

@@ -9,7 +9,7 @@ public static class WhitelistTypeResolutionPatch
{
[HarmonyReversePatch]
private static INamedTypeSymbol ResolveTypeSymbol(MyScriptWhitelist.Batch batch, Type type) => throw null!;
// cant be assed to write a transpiler so heres a prefix
private static bool Prefix(MyScriptWhitelist.Batch __instance, Type type, ref INamedTypeSymbol __result)
{
@@ -26,18 +26,18 @@ public static class WhitelistTypeResolutionPatch
// if type is not generic or constructed generic, run regular lookup
if (!type.IsGenericType || !type.IsConstructedGenericType)
return ResolveTypeSymbol(batch, type);
var unconstructedSymbol = ResolveTypeSymbol(batch, type.GetGenericTypeDefinition());
var typeArguments = type.GetGenericArguments();
var typeSymbolArguments = new ITypeSymbol[typeArguments.Length];
for (var i = 0; i < typeArguments.Length; i++)
{
// recursively resolve (possibly) generic arguments
typeSymbolArguments[i] = ResolveGenericTypeSymbol(batch, typeArguments[i]);
}
return unconstructedSymbol.Construct(typeSymbolArguments);
}
}

View File

@@ -11,26 +11,26 @@ public static class XmlRootWriterPatch
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var ins = instructions.ToList();
var index = ins.FindIndex(b =>
b.opcode == OpCodes.Ldstr && b.operand is "xsi:type");
ins[index].operand = "xsi";
ins.InsertRange(index + 1, new[]
{
ins.InsertRange(index + 1,
[
new CodeInstruction(OpCodes.Ldstr, "type"),
new CodeInstruction(OpCodes.Ldstr, "http://www.w3.org/2001/XMLSchema-instance")
});
]);
var instruction = ins[ins.FindIndex(b => b.opcode == OpCodes.Callvirt)];
instruction.operand = AccessTools.Method(typeof(XmlWriter), "WriteAttributeString", new[]
{
instruction.operand = AccessTools.Method(typeof(XmlWriter), "WriteAttributeString",
[
typeof(string),
typeof(string),
typeof(string),
typeof(string)
});
]);
return ins;
}
}

View File

@@ -9,11 +9,11 @@ namespace CringeLauncher.Utils;
public static class ExceptionFormatter
{
private static readonly AccessTools.FieldRef<Exception, string> StackTraceField = AccessTools.FieldRefAccess<Exception, string>("_remoteStackTraceString");
public static void FormatStackTrace(this Exception exception)
{
var stackTrace = new StackTrace(exception, true);
var sb = new StringBuilder();
var i = 0;
@@ -22,12 +22,12 @@ public static class ExceptionFormatter
var method = frame.GetMethod();
if (method is null)
continue;
sb.Append("at ");
if (method.DeclaringType is { } declaringType &&
AssemblyLoadContext.GetLoadContext(declaringType.Assembly) is { } assemblyLoadContext)
sb.Append(assemblyLoadContext).Append("//");
if (method.IsStatic)
sb.Append("static ");
@@ -35,7 +35,7 @@ public static class ExceptionFormatter
sb.Append(methodInfo.ReturnType, false);
else
sb.Append("new");
sb.Append(' ');
if (method.DeclaringType is null)
@@ -48,7 +48,7 @@ public static class ExceptionFormatter
sb.Append('.');
sb.Append(method.Name);
}
if (method.ContainsGenericParameters)
sb.Append(method.GetGenericArguments(), false);
@@ -63,7 +63,7 @@ public static class ExceptionFormatter
if (j < parameters.Length - 1)
sb.Append(", ");
}
sb.Append(')');
if (frame.GetFileName() is { } fileName)
@@ -75,7 +75,7 @@ public static class ExceptionFormatter
}
ref var stackTraceString = ref StackTraceField(exception);
stackTraceString = sb.ToString();
}
@@ -84,9 +84,9 @@ public static class ExceptionFormatter
if (fullName && !string.IsNullOrEmpty(type.Namespace))
sb.Append(type.Namespace).Append('.');
sb.Append(type.Name);
if (type.ContainsGenericParameters)
if (type.ContainsGenericParameters)
sb.Append(type.GetGenericArguments(), fullName);
return sb;
}

View File

@@ -8,7 +8,7 @@ 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");