Decompiled source of Avalonia BepInEx Console Server v0.2.0

BepInEx/core/AvaloniaBepInExConsole.Server/com.sigurd.avalonia_bepinex_console.server.dll

Decompiled 4 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.CompilerServices;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using NetMQ;
using NetMQ.Sockets;
using OdinSerializer;
using Sigurd.AvaloniaBepInExConsole.Common;
using Sigurd.AvaloniaBepInExConsole.Extensions;
using Sigurd.AvaloniaBepInExConsole.LogService;
using UnityEngine;
using UnityEngine.LowLevel;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sigurd Team")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+939cd5d6b2954fa604003884e60e61e9ada4f267")]
[assembly: AssemblyProduct("Avalonia Console Server")]
[assembly: AssemblyTitle("com.sigurd.avalonia_bepinex_console.server")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/lc-sigurd/avalonia-bepinex-console")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace Sigurd.AvaloniaBepInExConsole
{
	internal static class Bootstrap
	{
		[UsedImplicitly]
		private static void Start()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();
			PlayerLoopHelper.Initialize(ref currentPlayerLoop, (InjectPlayerLoopTimings)65535);
			new Harmony("com.sigurd.avalonia_bepinex_console.server").PatchAll(typeof(ChainloaderPatches));
			GameObject val = new GameObject("AvaloniaConsole")
			{
				hideFlags = (HideFlags)61
			};
			val.AddComponent<Manager>();
			Object.DontDestroyOnLoad((Object)val);
		}
	}
	[HarmonyPatch(typeof(Chainloader))]
	public static class ChainloaderPatches
	{
		private static UniTaskCompletionSource _chainloaderInitializedCompletionSource = new UniTaskCompletionSource();

		public static UniTask ChainloaderInitialized => _chainloaderInitializedCompletionSource.Task;

		[HarmonyPatch("Initialize")]
		[HarmonyPostfix]
		public static void OnChainloaderInitialized()
		{
			_chainloaderInitializedCompletionSource.TrySetResult();
		}
	}
	public sealed class Manager : MonoBehaviour
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <<Awake>g__RunProcessor|5_3>d : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public Manager <>4__this;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Manager manager = <>4__this;
				try
				{
					Awaiter awaiter;
					UniTask val;
					if (num != 0)
					{
						if (num == 1)
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter);
							num = (<>1__state = -1);
							goto IL_00e9;
						}
						val = manager._processorService.StartAsync(manager._cts.Token);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <<Awake>g__RunProcessor|5_3>d>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
					val = manager._processorService.StopAsync(default(CancellationToken));
					awaiter = ((UniTask)(ref val)).GetAwaiter();
					if (!((Awaiter)(ref awaiter)).IsCompleted)
					{
						num = (<>1__state = 1);
						<>u__1 = awaiter;
						((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <<Awake>g__RunProcessor|5_3>d>(ref awaiter, ref this);
						return;
					}
					goto IL_00e9;
					IL_00e9:
					((Awaiter)(ref awaiter)).GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <<Awake>g__SubmitStartGameEventToQueue|5_2>d : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public Manager <>4__this;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Manager manager = <>4__this;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						ILogMessageQueue? queue = manager._queue;
						GameLifetimeEvent val = new GameLifetimeEvent();
						val.set_Type((GameLifetimeEventType)0);
						UniTask val2 = queue.QueueAsync((IConsoleEvent)val, manager._cts.Token);
						awaiter = ((UniTask)(ref val2)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <<Awake>g__SubmitStartGameEventToQueue|5_2>d>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private ManualLogSource? _logger;

		private ILogMessageQueue? _queue;

		private IHostedService? _processorService;

		private AvaloniaLogListener? _listener;

		private CancellationTokenSource? _cts;

		private void Awake()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			_logger = Logger.CreateLogSource("Avalonia Console Server");
			ManualLogSource logger = Logger.CreateLogSource("Avalonia Console Server/Internal");
			_cts = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { UniTaskCancellationExtensions.GetCancellationTokenOnDestroy((MonoBehaviour)(object)this) });
			_queue = new DefaultLogMessageQueue(32);
			_processorService = new LogQueueProcessor(_queue, logger);
			_listener = new AvaloniaLogListener(_queue, logger, _cts.Token);
			UniTaskExtensions.Forget(UniTask.RunOnThreadPool((Func<UniTask>)SubmitStartGameEventToQueue, true, _cts.Token), (Action<Exception>)delegate(Exception exc)
			{
				_logger.LogError((object)$"Uncaught exception occurred during submission of the 'start game' event\n{exc}");
			}, false);
			Logger.Listeners.Add((ILogListener)(object)_listener);
			_logger.LogInfo((object)"Listener initialised");
			UniTaskExtensions.Forget(UniTask.RunOnThreadPool((Func<UniTask>)RunProcessor, true, default(CancellationToken)), (Action<Exception>)delegate(Exception exc)
			{
				_logger.LogError((object)$"Uncaught exception occurred in the processor thread\n{exc}");
			}, false);
			_logger.LogInfo((object)"Processor start requested");
			[AsyncStateMachine(typeof(<<Awake>g__RunProcessor|5_3>d))]
			UniTask RunProcessor()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				<<Awake>g__RunProcessor|5_3>d <<Awake>g__RunProcessor|5_3>d = default(<<Awake>g__RunProcessor|5_3>d);
				<<Awake>g__RunProcessor|5_3>d.<>t__builder = AsyncUniTaskMethodBuilder.Create();
				<<Awake>g__RunProcessor|5_3>d.<>4__this = this;
				<<Awake>g__RunProcessor|5_3>d.<>1__state = -1;
				((AsyncUniTaskMethodBuilder)(ref <<Awake>g__RunProcessor|5_3>d.<>t__builder)).Start<<<Awake>g__RunProcessor|5_3>d>(ref <<Awake>g__RunProcessor|5_3>d);
				return ((AsyncUniTaskMethodBuilder)(ref <<Awake>g__RunProcessor|5_3>d.<>t__builder)).Task;
			}
			[AsyncStateMachine(typeof(<<Awake>g__SubmitStartGameEventToQueue|5_2>d))]
			UniTask SubmitStartGameEventToQueue()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				<<Awake>g__SubmitStartGameEventToQueue|5_2>d <<Awake>g__SubmitStartGameEventToQueue|5_2>d = default(<<Awake>g__SubmitStartGameEventToQueue|5_2>d);
				<<Awake>g__SubmitStartGameEventToQueue|5_2>d.<>t__builder = AsyncUniTaskMethodBuilder.Create();
				<<Awake>g__SubmitStartGameEventToQueue|5_2>d.<>4__this = this;
				<<Awake>g__SubmitStartGameEventToQueue|5_2>d.<>1__state = -1;
				((AsyncUniTaskMethodBuilder)(ref <<Awake>g__SubmitStartGameEventToQueue|5_2>d.<>t__builder)).Start<<<Awake>g__SubmitStartGameEventToQueue|5_2>d>(ref <<Awake>g__SubmitStartGameEventToQueue|5_2>d);
				return ((AsyncUniTaskMethodBuilder)(ref <<Awake>g__SubmitStartGameEventToQueue|5_2>d.<>t__builder)).Task;
			}
		}

		private void OnDestroy()
		{
			NetMQConfig.Cleanup(true);
			CancellationTokenSource cts = _cts;
			if (cts != null && !cts.IsCancellationRequested)
			{
				_cts.Cancel();
			}
		}
	}
	internal static class ConsoleServerInfo
	{
		public const string PRODUCT_GUID = "com.sigurd.avalonia_bepinex_console.server";

		public const string PRODUCT_NAME = "Avalonia Console Server";

		public const string PRODUCT_VERSION = "0.2.0";
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.sigurd.avalonia_bepinex_console.server";

		public const string PLUGIN_NAME = "Avalonia Console Server";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace Sigurd.AvaloniaBepInExConsole.LogService
{
	public class AvaloniaLogListener : ILogListener, IDisposable
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <SubmitLogEventToQueue>d__5 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public CancellationToken cancellationToken;

			public AvaloniaLogListener <>4__this;

			public LogEventArgs eventArgs;

			private CancellationTokenSource <cts>5__2;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				AvaloniaLogListener avaloniaLogListener = <>4__this;
				try
				{
					if (num != 0)
					{
						<cts>5__2 = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { cancellationToken });
					}
					try
					{
						Awaiter awaiter;
						if (num != 0)
						{
							<cts>5__2.CancelAfter(5000);
							UniTask val = avaloniaLogListener._taskQueue.QueueAsync((IConsoleEvent)(object)eventArgs.ToAvaloniaBepInExConsoleLogEvent(), <cts>5__2.Token);
							awaiter = ((UniTask)(ref val)).GetAwaiter();
							if (!((Awaiter)(ref awaiter)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <SubmitLogEventToQueue>d__5>(ref awaiter, ref this);
								return;
							}
						}
						else
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter);
							num = (<>1__state = -1);
						}
						((Awaiter)(ref awaiter)).GetResult();
					}
					catch (OperationCanceledException arg)
					{
						avaloniaLogListener._logger.LogError((object)$"Timed out queueing message.\n{arg}");
					}
					finally
					{
						if (num < 0 && <cts>5__2 != null)
						{
							((IDisposable)<cts>5__2).Dispose();
						}
					}
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<cts>5__2 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<cts>5__2 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private readonly ILogMessageQueue _taskQueue;

		private readonly ManualLogSource _logger;

		private readonly CancellationToken _cancellationToken;

		public AvaloniaLogListener(ILogMessageQueue taskQueue, ManualLogSource logger, CancellationToken token)
		{
			_taskQueue = taskQueue;
			_logger = logger;
			_cancellationToken = token;
		}

		public void LogEvent(object sender, LogEventArgs eventArgs)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			LogEventArgs eventArgs2 = eventArgs;
			if (eventArgs2.Source != _logger)
			{
				UniTaskExtensions.Forget(UniTask.RunOnThreadPool((Func<UniTask>)(() => SubmitLogEventToQueue(eventArgs2, _cancellationToken)), true, _cancellationToken), (Action<Exception>)delegate(Exception exc)
				{
					_logger.LogError((object)$"Exception occurred during submission of a log event\n{exc}");
				}, false);
			}
		}

		[AsyncStateMachine(typeof(<SubmitLogEventToQueue>d__5))]
		private UniTask SubmitLogEventToQueue(LogEventArgs eventArgs, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			<SubmitLogEventToQueue>d__5 <SubmitLogEventToQueue>d__ = default(<SubmitLogEventToQueue>d__5);
			<SubmitLogEventToQueue>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<SubmitLogEventToQueue>d__.<>4__this = this;
			<SubmitLogEventToQueue>d__.eventArgs = eventArgs;
			<SubmitLogEventToQueue>d__.cancellationToken = cancellationToken;
			<SubmitLogEventToQueue>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <SubmitLogEventToQueue>d__.<>t__builder)).Start<<SubmitLogEventToQueue>d__5>(ref <SubmitLogEventToQueue>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <SubmitLogEventToQueue>d__.<>t__builder)).Task;
		}

		public void Dispose()
		{
		}
	}
	public abstract class BackgroundService : IHostedService, IDisposable
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <StopAsync>d__6 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public BackgroundService <>4__this;

			public CancellationToken cancellationToken;

			private object <>7__wrap1;

			private int <>7__wrap2;

			private CancellationTokenRegistration <registration>5__4;

			private object <>7__wrap4;

			private int <>7__wrap5;

			private Awaiter<int> <>u__1;

			private ValueTaskAwaiter <>u__2;

			private void MoveNext()
			{
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				BackgroundService backgroundService = <>4__this;
				try
				{
					if (num == 0)
					{
						goto IL_009e;
					}
					ValueTaskAwaiter awaiter;
					if (num == 1)
					{
						awaiter = <>u__2;
						<>u__2 = default(ValueTaskAwaiter);
						num = (<>1__state = -1);
						goto IL_01ad;
					}
					UniTaskCompletionSource<object> val = default(UniTaskCompletionSource<object>);
					if (backgroundService._executeTask.HasValue)
					{
						<>7__wrap1 = null;
						<>7__wrap2 = 0;
						try
						{
							backgroundService._stoppingCts?.Cancel();
						}
						catch (object obj)
						{
							<>7__wrap1 = obj;
						}
						val = new UniTaskCompletionSource<object>();
						<registration>5__4 = cancellationToken.Register(delegate(object s)
						{
							((TaskCompletionSource<object>)s).SetCanceled();
						}, val);
						<>7__wrap4 = null;
						<>7__wrap5 = 0;
						goto IL_009e;
					}
					goto end_IL_000e;
					IL_009e:
					try
					{
						Awaiter<int> awaiter2;
						if (num != 0)
						{
							awaiter2 = UniTask.WhenAny((UniTask[])(object)new UniTask[2]
							{
								(UniTask)(((??)backgroundService._executeTask) ?? UniTask.CompletedTask),
								UniTask<object>.op_Implicit(val.Task)
							}).GetAwaiter();
							if (!awaiter2.IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter2;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<int>, <StopAsync>d__6>(ref awaiter2, ref this);
								return;
							}
						}
						else
						{
							awaiter2 = <>u__1;
							<>u__1 = default(Awaiter<int>);
							num = (<>1__state = -1);
						}
						awaiter2.GetResult();
					}
					catch (object obj)
					{
						<>7__wrap4 = obj;
					}
					awaiter = <registration>5__4.DisposeAsync().GetAwaiter();
					if (!awaiter.IsCompleted)
					{
						num = (<>1__state = 1);
						<>u__2 = awaiter;
						((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ValueTaskAwaiter, <StopAsync>d__6>(ref awaiter, ref this);
						return;
					}
					goto IL_01ad;
					IL_01ad:
					awaiter.GetResult();
					object obj2 = <>7__wrap4;
					if (obj2 != null)
					{
						ExceptionDispatchInfo.Capture((obj2 as Exception) ?? throw obj2).Throw();
					}
					<>7__wrap4 = null;
					<registration>5__4 = default(CancellationTokenRegistration);
					obj2 = <>7__wrap1;
					if (obj2 != null)
					{
						ExceptionDispatchInfo.Capture((obj2 as Exception) ?? throw obj2).Throw();
					}
					<>7__wrap1 = null;
					end_IL_000e:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private UniTask? _executeTask;

		private CancellationTokenSource? _stoppingCts;

		public virtual UniTask? ExecuteTask => _executeTask;

		protected abstract UniTask ExecuteAsync(CancellationToken stoppingToken);

		public virtual UniTask StartAsync(CancellationToken cancellationToken)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			_stoppingCts = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { cancellationToken });
			_executeTask = ExecuteAsync(_stoppingCts.Token);
			UniTask? executeTask = _executeTask;
			if (executeTask.HasValue)
			{
				UniTask valueOrDefault = executeTask.GetValueOrDefault();
				if ((int)((UniTask)(ref valueOrDefault)).Status == 1)
				{
					return UniTask.CompletedTask;
				}
			}
			return _executeTask.Value;
		}

		[AsyncStateMachine(typeof(<StopAsync>d__6))]
		public virtual UniTask StopAsync(CancellationToken cancellationToken)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<StopAsync>d__6 <StopAsync>d__ = default(<StopAsync>d__6);
			<StopAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<StopAsync>d__.<>4__this = this;
			<StopAsync>d__.cancellationToken = cancellationToken;
			<StopAsync>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <StopAsync>d__.<>t__builder)).Start<<StopAsync>d__6>(ref <StopAsync>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <StopAsync>d__.<>t__builder)).Task;
		}

		public virtual void Dispose()
		{
			_stoppingCts?.Cancel();
		}
	}
	public class DefaultLogMessageQueue : ILogMessageQueue
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <DequeueAsync>d__3 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<IConsoleEvent> <>t__builder;

			public DefaultLogMessageQueue <>4__this;

			public CancellationToken cancellationToken;

			private ValueTaskAwaiter<IConsoleEvent> <>u__1;

			private void MoveNext()
			{
				int num = <>1__state;
				DefaultLogMessageQueue defaultLogMessageQueue = <>4__this;
				IConsoleEvent result;
				try
				{
					ValueTaskAwaiter<IConsoleEvent> awaiter;
					if (num != 0)
					{
						awaiter = defaultLogMessageQueue._queue.Reader.ReadAsync(cancellationToken).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<>t__builder.AwaitUnsafeOnCompleted<ValueTaskAwaiter<IConsoleEvent>, <DequeueAsync>d__3>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(ValueTaskAwaiter<IConsoleEvent>);
						num = (<>1__state = -1);
					}
					result = awaiter.GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>t__builder.SetException(exception);
					return;
				}
				<>1__state = -2;
				<>t__builder.SetResult(result);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				<>t__builder.SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <QueueAsync>d__2 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public IConsoleEvent workItem;

			public DefaultLogMessageQueue <>4__this;

			public CancellationToken cancellationToken;

			private ValueTaskAwaiter <>u__1;

			private void MoveNext()
			{
				int num = <>1__state;
				DefaultLogMessageQueue defaultLogMessageQueue = <>4__this;
				try
				{
					ValueTaskAwaiter awaiter;
					if (num != 0)
					{
						if (workItem == null)
						{
							throw new ArgumentNullException("workItem");
						}
						awaiter = defaultLogMessageQueue._queue.Writer.WriteAsync(workItem, cancellationToken).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ValueTaskAwaiter, <QueueAsync>d__2>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(ValueTaskAwaiter);
						num = (<>1__state = -1);
					}
					awaiter.GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private readonly Channel<IConsoleEvent> _queue;

		public bool HasQueuedLogMessages => _queue.Reader.Count > 0;

		public DefaultLogMessageQueue(int capacity)
		{
			BoundedChannelOptions options = new BoundedChannelOptions(capacity)
			{
				FullMode = BoundedChannelFullMode.Wait
			};
			_queue = Channel.CreateBounded<IConsoleEvent>(options);
		}

		[AsyncStateMachine(typeof(<QueueAsync>d__2))]
		public UniTask QueueAsync(IConsoleEvent workItem, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			<QueueAsync>d__2 <QueueAsync>d__ = default(<QueueAsync>d__2);
			<QueueAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<QueueAsync>d__.<>4__this = this;
			<QueueAsync>d__.workItem = workItem;
			<QueueAsync>d__.cancellationToken = cancellationToken;
			<QueueAsync>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <QueueAsync>d__.<>t__builder)).Start<<QueueAsync>d__2>(ref <QueueAsync>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <QueueAsync>d__.<>t__builder)).Task;
		}

		[AsyncStateMachine(typeof(<DequeueAsync>d__3))]
		public UniTask<IConsoleEvent> DequeueAsync(CancellationToken cancellationToken)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<DequeueAsync>d__3 <DequeueAsync>d__ = default(<DequeueAsync>d__3);
			<DequeueAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder<IConsoleEvent>.Create();
			<DequeueAsync>d__.<>4__this = this;
			<DequeueAsync>d__.cancellationToken = cancellationToken;
			<DequeueAsync>d__.<>1__state = -1;
			<DequeueAsync>d__.<>t__builder.Start<<DequeueAsync>d__3>(ref <DequeueAsync>d__);
			return <DequeueAsync>d__.<>t__builder.Task;
		}
	}
	public interface IHostedService
	{
		UniTask StartAsync(CancellationToken cancellationToken);

		UniTask StopAsync(CancellationToken cancellationToken);
	}
	public interface ILogMessageQueue
	{
		bool HasQueuedLogMessages { get; }

		UniTask QueueAsync(IConsoleEvent workItem, CancellationToken cancellationToken = default(CancellationToken));

		UniTask<IConsoleEvent> DequeueAsync(CancellationToken cancellationToken);
	}
	public class LogQueueProcessor : BackgroundService
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <ExecuteAsync>d__4 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public LogQueueProcessor <>4__this;

			public CancellationToken stoppingToken;

			private TaskAwaiter <>u__1;

			private Awaiter <>u__2;

			private void MoveNext()
			{
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				LogQueueProcessor logQueueProcessor = <>4__this;
				try
				{
					Awaiter awaiter;
					TaskAwaiter awaiter2;
					if (num != 0)
					{
						if (num == 1)
						{
							awaiter = <>u__2;
							<>u__2 = default(Awaiter);
							num = (<>1__state = -1);
							goto IL_00e8;
						}
						logQueueProcessor._publisherSocket = new PublisherSocket(">tcp://localhost:38554");
						awaiter2 = Task.Delay(500, stoppingToken).GetAwaiter();
						if (!awaiter2.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter2;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<TaskAwaiter, <ExecuteAsync>d__4>(ref awaiter2, ref this);
							return;
						}
					}
					else
					{
						awaiter2 = <>u__1;
						<>u__1 = default(TaskAwaiter);
						num = (<>1__state = -1);
					}
					awaiter2.GetResult();
					UniTask val = logQueueProcessor.ProcessLogQueueAsync(stoppingToken);
					awaiter = ((UniTask)(ref val)).GetAwaiter();
					if (!((Awaiter)(ref awaiter)).IsCompleted)
					{
						num = (<>1__state = 1);
						<>u__2 = awaiter;
						((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <ExecuteAsync>d__4>(ref awaiter, ref this);
						return;
					}
					goto IL_00e8;
					IL_00e8:
					((Awaiter)(ref awaiter)).GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <ProcessLogQueueAsync>d__6 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public LogQueueProcessor <>4__this;

			public CancellationToken cancellationToken;

			private Awaiter<IConsoleEvent> <>u__1;

			private void MoveNext()
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				LogQueueProcessor logQueueProcessor = <>4__this;
				try
				{
					if (num == 0)
					{
						goto IL_0027;
					}
					logQueueProcessor.<logger>P.LogInfo((object)"Entering queue processing loop");
					goto IL_0117;
					IL_0117:
					if (!cancellationToken.IsCancellationRequested)
					{
						goto IL_0027;
					}
					logQueueProcessor.<logger>P.LogInfo((object)"Exited queue processing loop");
					goto end_IL_000e;
					IL_0027:
					try
					{
						Awaiter<IConsoleEvent> awaiter;
						if (num != 0)
						{
							awaiter = logQueueProcessor.<logQueue>P.DequeueAsync(cancellationToken).GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<IConsoleEvent>, <ProcessLogQueueAsync>d__6>(ref awaiter, ref this);
								return;
							}
						}
						else
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter<IConsoleEvent>);
							num = (<>1__state = -1);
						}
						IConsoleEvent result = awaiter.GetResult();
						LogEvent val = (LogEvent)(object)((result is LogEvent) ? result : null);
						if (val == null)
						{
							GameLifetimeEvent val2 = (GameLifetimeEvent)(object)((result is GameLifetimeEvent) ? result : null);
							if (val2 == null)
							{
								throw new ArgumentOutOfRangeException("consoleEvent");
							}
							logQueueProcessor.PublishGameLifetimeMessage(val2);
						}
						else
						{
							logQueueProcessor.PublishLogMessage(val);
						}
					}
					catch (Exception ex) when (ex is OperationCanceledException)
					{
						logQueueProcessor.<logger>P.LogInfo((object)"Caught cancellation exception");
					}
					catch (Exception arg)
					{
						logQueueProcessor.<logger>P.LogError((object)$"Encountered exception while trying to publish a message\n{arg}");
					}
					goto IL_0117;
					end_IL_000e:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <StopAsync>d__5 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public LogQueueProcessor <>4__this;

			public CancellationToken cancellationToken;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				LogQueueProcessor logQueueProcessor = <>4__this;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						if (logQueueProcessor.SocketAlive)
						{
							((NetMQSocket)logQueueProcessor._publisherSocket).Dispose();
							logQueueProcessor._publisherSocket = null;
						}
						UniTask val = ((BackgroundService)logQueueProcessor).StopAsync(cancellationToken);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <StopAsync>d__5>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[CompilerGenerated]
		private ILogMessageQueue <logQueue>P;

		[CompilerGenerated]
		private ManualLogSource <logger>P;

		private PublisherSocket? _publisherSocket;

		[MemberNotNullWhen(true, "_publisherSocket")]
		private bool SocketAlive
		{
			[MemberNotNullWhen(true, "_publisherSocket")]
			get
			{
				PublisherSocket publisherSocket = _publisherSocket;
				if (publisherSocket != null)
				{
					return !((NetMQSocket)publisherSocket).IsDisposed;
				}
				return false;
			}
		}

		public LogQueueProcessor(ILogMessageQueue logQueue, ManualLogSource logger)
		{
			<logQueue>P = logQueue;
			<logger>P = logger;
			base..ctor();
		}

		[AsyncStateMachine(typeof(<ExecuteAsync>d__4))]
		protected override UniTask ExecuteAsync(CancellationToken stoppingToken)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<ExecuteAsync>d__4 <ExecuteAsync>d__ = default(<ExecuteAsync>d__4);
			<ExecuteAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<ExecuteAsync>d__.<>4__this = this;
			<ExecuteAsync>d__.stoppingToken = stoppingToken;
			<ExecuteAsync>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <ExecuteAsync>d__.<>t__builder)).Start<<ExecuteAsync>d__4>(ref <ExecuteAsync>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <ExecuteAsync>d__.<>t__builder)).Task;
		}

		[AsyncStateMachine(typeof(<StopAsync>d__5))]
		public override UniTask StopAsync(CancellationToken cancellationToken)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<StopAsync>d__5 <StopAsync>d__ = default(<StopAsync>d__5);
			<StopAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<StopAsync>d__.<>4__this = this;
			<StopAsync>d__.cancellationToken = cancellationToken;
			<StopAsync>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <StopAsync>d__.<>t__builder)).Start<<StopAsync>d__5>(ref <StopAsync>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <StopAsync>d__.<>t__builder)).Task;
		}

		[AsyncStateMachine(typeof(<ProcessLogQueueAsync>d__6))]
		private UniTask ProcessLogQueueAsync(CancellationToken cancellationToken)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			<ProcessLogQueueAsync>d__6 <ProcessLogQueueAsync>d__ = default(<ProcessLogQueueAsync>d__6);
			<ProcessLogQueueAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<ProcessLogQueueAsync>d__.<>4__this = this;
			<ProcessLogQueueAsync>d__.cancellationToken = cancellationToken;
			<ProcessLogQueueAsync>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <ProcessLogQueueAsync>d__.<>t__builder)).Start<<ProcessLogQueueAsync>d__6>(ref <ProcessLogQueueAsync>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <ProcessLogQueueAsync>d__.<>t__builder)).Task;
		}

		private void PublishLogMessage(LogEvent logEvent)
		{
			EnsureSocketAlive();
			byte[] array = SerializationUtility.SerializeValue<LogEvent>(logEvent, (DataFormat)0, (SerializationContext)null);
			OutgoingSocketExtensions.SendFrame(OutgoingSocketExtensions.SendMoreFrame((IOutgoingSocket)(object)_publisherSocket, "logMessage"), array, false);
		}

		private void PublishGameLifetimeMessage(GameLifetimeEvent gameLifetimeEvent)
		{
			EnsureSocketAlive();
			byte[] array = SerializationUtility.SerializeValue<GameLifetimeEvent>(gameLifetimeEvent, (DataFormat)0, (SerializationContext)null);
			OutgoingSocketExtensions.SendFrame(OutgoingSocketExtensions.SendMoreFrame((IOutgoingSocket)(object)_publisherSocket, "gameLifetime"), array, false);
		}

		[MemberNotNull("_publisherSocket")]
		private void EnsureSocketAlive()
		{
			if (SocketAlive)
			{
				return;
			}
			throw new InvalidOperationException("Publisher socket is uninitialized or has been disposed.");
		}
	}
}
namespace Sigurd.AvaloniaBepInExConsole.Extensions
{
	public static class LogEventArgsExtensions
	{
		public static LogEvent ToAvaloniaBepInExConsoleLogEvent(this LogEventArgs logEventArgs)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			LogEvent val = new LogEvent();
			val.set_Content((object)logEventArgs.GetContent());
			val.set_Level(logEventArgs.Level.ToAvaloniaBepInExConsoleLogLevel());
			val.set_SourceName(logEventArgs.Source.SourceName);
			return val;
		}

		private static string GetContent(this LogEventArgs logEventArgs)
		{
			IAnsiFormattable val = (IAnsiFormattable)(object)((logEventArgs is IAnsiFormattable) ? logEventArgs : null);
			if (val != null)
			{
				return val.ToAnsiFormattedString();
			}
			return ((object)logEventArgs).ToString();
		}
	}
	public static class LogLevelExtensions
	{
		public static BepInExLogLevel ToAvaloniaBepInExConsoleLogLevel(this LogLevel logLevel)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected I4, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)logLevel <= 8)
			{
				switch (logLevel - 1)
				{
				default:
					if ((int)logLevel != 8)
					{
						break;
					}
					return (BepInExLogLevel)2;
				case 0:
					return (BepInExLogLevel)5;
				case 1:
					return (BepInExLogLevel)4;
				case 3:
					return (BepInExLogLevel)3;
				case 2:
					break;
				}
			}
			else
			{
				if ((int)logLevel == 16)
				{
					return (BepInExLogLevel)1;
				}
				if ((int)logLevel == 32)
				{
					return (BepInExLogLevel)0;
				}
			}
			throw new ArgumentOutOfRangeException("logLevel", logLevel, null);
		}
	}
}

BepInEx/patchers/AvaloniaBepInExConsole.Patcher/com.sigurd.avalonia_bepinex_console.patcher.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Preloader;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("BepInEx.Preloader")]
[assembly: AssemblyCompany("Sigurd Team")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+939cd5d6b2954fa604003884e60e61e9ada4f267")]
[assembly: AssemblyProduct("com.sigurd.avalonia_bepinex_console.patcher")]
[assembly: AssemblyTitle("com.sigurd.avalonia_bepinex_console.patcher")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/lc-sigurd/avalonia-bepinex-console")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Sigurd.AvaloniaBepInExConsole.Patcher
{
	public static class AvaloniaBepInExPatcher
	{
		private const string AvaloniaConsoleServerAssemblyName = "com.sigurd.avalonia_bepinex_console.server.dll";

		private static readonly IEnumerable<string> AvaloniaConsoleServerAssemblySearchPaths = new <>z__ReadOnlyArray<string>(new string[3]
		{
			Path.Combine(Paths.BepInExAssemblyDirectory, "Sigurd-Avalonia_BepInEx_Console_Server", "AvaloniaBepInExConsole.Server"),
			Path.Combine(Paths.BepInExAssemblyDirectory, "AvaloniaBepInExConsole.Server"),
			Paths.BepInExAssemblyDirectory
		});

		private static string? _avaloniaConsoleServerAssemblyPath;

		private static string? AvaloniaConsoleServerAssemblyPath => _avaloniaConsoleServerAssemblyPath ?? (_avaloniaConsoleServerAssemblyPath = AvaloniaConsoleServerAssemblySearchPaths.Select((string directoryPath) => Path.Combine(directoryPath, "com.sigurd.avalonia_bepinex_console.server.dll")).FirstOrDefault(File.Exists));

		public static IEnumerable<string> TargetDLLs => new <>z__ReadOnlyArray<string>(new string[1] { Preloader.ConfigEntrypointAssembly.Value });

		public static void Patch(AssemblyDefinition assembly)
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			if (AvaloniaConsoleServerAssemblyPath == null)
			{
				throw new InvalidOperationException("AvaloniaBepInExConsole.Server assembly could not be found. It should be in the BepInEx/core/ directory.");
			}
			string entrypointType = Preloader.ConfigEntrypointType.Value;
			string entrypointMethod = Preloader.ConfigEntrypointMethod.Value;
			bool flag = Utility.IsNullOrWhiteSpace(entrypointMethod) || entrypointMethod == ".cctor";
			TypeDefinition val = ((IEnumerable<TypeDefinition>)assembly.MainModule.Types).FirstOrDefault((Func<TypeDefinition, bool>)((TypeDefinition x) => ((MemberReference)x).Name == entrypointType));
			if (val == null)
			{
				return;
			}
			AssemblyDefinition val2 = AssemblyDefinition.ReadAssembly(AvaloniaConsoleServerAssemblyPath);
			try
			{
				MethodDefinition val3 = ((IEnumerable<MethodDefinition>)((IEnumerable<TypeDefinition>)val2.MainModule.Types).First((TypeDefinition x) => ((MemberReference)x).Name == "Bootstrap").Methods).First((MethodDefinition x) => ((MemberReference)x).Name == "Start");
				MethodReference val4 = assembly.MainModule.ImportReference((MethodReference)(object)val3);
				List<MethodDefinition> list = new List<MethodDefinition>();
				if (flag)
				{
					MethodDefinition val5 = ((IEnumerable<MethodDefinition>)val.Methods).FirstOrDefault((Func<MethodDefinition, bool>)((MethodDefinition m) => m.IsConstructor && m.IsStatic));
					if (val5 == null)
					{
						val5 = new MethodDefinition(".cctor", (MethodAttributes)6289, assembly.MainModule.ImportReference(typeof(void)));
						val.Methods.Add(val5);
						ILProcessor iLProcessor = val5.Body.GetILProcessor();
						iLProcessor.Append(iLProcessor.Create(OpCodes.Ret));
					}
					list.Add(val5);
				}
				else
				{
					list.AddRange(((IEnumerable<MethodDefinition>)val.Methods).Where((MethodDefinition x) => ((MemberReference)x).Name == entrypointMethod));
				}
				if (!list.Any())
				{
					return;
				}
				foreach (MethodDefinition item in list)
				{
					ILProcessor iLProcessor2 = item.Body.GetILProcessor();
					Instruction val6 = ((IEnumerable<Instruction>)iLProcessor2.Body.Instructions).First();
					iLProcessor2.InsertBefore(val6, iLProcessor2.Create(OpCodes.Call, val4));
				}
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}

BepInEx/core/AvaloniaBepInExConsole.Common/com.sigurd.avalonia_bepinex_console.common.dll

Decompiled 4 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using OdinSerializer;
using Sigurd.AvaloniaBepInExConsole.Common.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sigurd Team")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+939cd5d6b2954fa604003884e60e61e9ada4f267")]
[assembly: AssemblyProduct("com.sigurd.avalonia_bepinex_console.common")]
[assembly: AssemblyTitle("com.sigurd.avalonia_bepinex_console.common")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/lc-sigurd/avalonia-bepinex-console")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace Sigurd.AvaloniaBepInExConsole.Common
{
	public enum BepInExLogLevel
	{
		Debug,
		Info,
		Message,
		Warning,
		Error,
		Fatal
	}
	public record GameLifetimeEvent : IConsoleEvent
	{
		[OdinSerialize]
		public required GameLifetimeEventType Type { get; init; }

		[CompilerGenerated]
		[SetsRequiredMembers]
		protected GameLifetimeEvent(GameLifetimeEvent original)
		{
			Type = original.Type;
		}

		public GameLifetimeEvent()
		{
		}
	}
	public enum GameLifetimeEventType
	{
		Start
	}
	public interface IAnsiFormattable
	{
		string ToAnsiFormattedString();
	}
	public interface IConsoleEvent
	{
	}
	public record LogEvent : IConsoleEvent, IAnsiFormattable
	{
		[OdinSerialize]
		public required object Content { get; init; }

		[OdinSerialize]
		public required BepInExLogLevel Level { get; init; }

		[OdinSerialize]
		public required string SourceName { get; init; }

		public string AnsiFormattedContent => ToAnsiFormattedString();

		public override string ToString()
		{
			return $"{Content}";
		}

		public string ToStringLine()
		{
			return $"{this}{Environment.NewLine}";
		}

		public string ToAnsiFormattedString()
		{
			return $"{Level.GetLevelAnsiReset()}{this}\u001b[0m";
		}

		[CompilerGenerated]
		[SetsRequiredMembers]
		protected LogEvent(LogEvent original)
		{
			Content = original.Content;
			Level = original.Level;
			SourceName = original.SourceName;
		}

		public LogEvent()
		{
		}
	}
}
namespace Sigurd.AvaloniaBepInExConsole.Common.Extensions
{
	public static class BepInExLogLevelExtensions
	{
		public static string GetLevelAnsiReset(this BepInExLogLevel level)
		{
			return level switch
			{
				BepInExLogLevel.Debug => "\u001b[0;38;5;8m", 
				BepInExLogLevel.Info => "\u001b[0;38;5;7m", 
				BepInExLogLevel.Message => "\u001b[m", 
				BepInExLogLevel.Warning => "\u001b[0;38;5;11m", 
				BepInExLogLevel.Error => "\u001b[0;1;38;5;1m", 
				BepInExLogLevel.Fatal => "\u001b[0;1;38;5;9m", 
				_ => "\u001b[m", 
			};
		}
	}
}