Decompiled source of RuntimeUnityEditor v5.5.1

plugins/MonoMod.Backports.dll

Decompiled a month ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Threading;
using Microsoft.CodeAnalysis;
using MonoMod;
using MonoMod.Backports.ILHelpers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = ".NET Framework 4.5.2")]
[assembly: AssemblyCompany("0x0ade, DaNike")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2024 0x0ade, DaNike")]
[assembly: AssemblyDescription("A set of backports of new BCL features to all frameworks which MonoMod supports.")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+a1b82852b")]
[assembly: AssemblyProduct("MonoMod.Backports")]
[assembly: AssemblyTitle("MonoMod.Backports")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoMod/MonoMod.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: TypeForwardedTo(typeof(ConcurrentBag<>))]
[assembly: TypeForwardedTo(typeof(ConcurrentDictionary<, >))]
[assembly: TypeForwardedTo(typeof(ConcurrentQueue<>))]
[assembly: TypeForwardedTo(typeof(ConcurrentStack<>))]
[assembly: TypeForwardedTo(typeof(EnumerablePartitionerOptions))]
[assembly: TypeForwardedTo(typeof(IProducerConsumerCollection<>))]
[assembly: TypeForwardedTo(typeof(OrderablePartitioner<>))]
[assembly: TypeForwardedTo(typeof(Partitioner))]
[assembly: TypeForwardedTo(typeof(Partitioner<>))]
[assembly: TypeForwardedTo(typeof(IReadOnlyCollection<>))]
[assembly: TypeForwardedTo(typeof(IReadOnlyList<>))]
[assembly: TypeForwardedTo(typeof(IStructuralComparable))]
[assembly: TypeForwardedTo(typeof(IStructuralEquatable))]
[assembly: TypeForwardedTo(typeof(IntrospectionExtensions))]
[assembly: TypeForwardedTo(typeof(IReflectableType))]
[assembly: TypeForwardedTo(typeof(TypeDelegator))]
[assembly: TypeForwardedTo(typeof(TypeInfo))]
[assembly: TypeForwardedTo(typeof(CallerFilePathAttribute))]
[assembly: TypeForwardedTo(typeof(CallerLineNumberAttribute))]
[assembly: TypeForwardedTo(typeof(CallerMemberNameAttribute))]
[assembly: TypeForwardedTo(typeof(ConditionalWeakTable<, >))]
[assembly: TypeForwardedTo(typeof(TupleElementNamesAttribute))]
[assembly: TypeForwardedTo(typeof(DefaultDllImportSearchPathsAttribute))]
[assembly: TypeForwardedTo(typeof(DllImportSearchPath))]
[assembly: TypeForwardedTo(typeof(SpinLock))]
[assembly: TypeForwardedTo(typeof(SpinWait))]
[assembly: TypeForwardedTo(typeof(ThreadLocal<>))]
[assembly: TypeForwardedTo(typeof(Volatile))]
[assembly: TypeForwardedTo(typeof(Tuple))]
[assembly: TypeForwardedTo(typeof(Tuple<>))]
[assembly: TypeForwardedTo(typeof(Tuple<, >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , , >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , , , >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , , , , >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , , , , , >))]
[assembly: TypeForwardedTo(typeof(Tuple<, , , , , , , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple))]
[assembly: TypeForwardedTo(typeof(ValueTuple<>))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , , , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , , , , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , , , , , >))]
[assembly: TypeForwardedTo(typeof(ValueTuple<, , , , , , , >))]
[assembly: TypeForwardedTo(typeof(WeakReference<>))]
[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]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = 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;
		}
	}
}
internal static class AssemblyInfo
{
	public const string AssemblyName = "MonoMod.Backports";

	public const string AssemblyVersion = "1.1.2";
}
namespace MonoMod.SourceGen.Attributes
{
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class EmitILOverloadsAttribute : Attribute
	{
		public EmitILOverloadsAttribute(string filename, string kind)
		{
		}
	}
	internal static class ILOverloadKind
	{
		public const string Cursor = "ILCursor";

		public const string Matcher = "ILMatcher";
	}
}
namespace MonoMod.Backports
{
	public static class MethodImplOptionsEx
	{
		public const MethodImplOptions Unmanaged = MethodImplOptions.Unmanaged;

		public const MethodImplOptions NoInlining = MethodImplOptions.NoInlining;

		public const MethodImplOptions ForwardRef = MethodImplOptions.ForwardRef;

		public const MethodImplOptions Synchronized = MethodImplOptions.Synchronized;

		public const MethodImplOptions NoOptimization = MethodImplOptions.NoOptimization;

		public const MethodImplOptions PreserveSig = MethodImplOptions.PreserveSig;

		public const MethodImplOptions AggressiveInlining = MethodImplOptions.AggressiveInlining;

		public const MethodImplOptions AggressiveOptimization = MethodImplOptions.AggressiveOptimization;

		public const MethodImplOptions InternalCall = MethodImplOptions.InternalCall;
	}
}
namespace System
{
	public static class ArrayEx
	{
		private static class TypeHolder<T>
		{
			public static readonly T[] Empty = new T[0];
		}

		public static int MaxLength => 1879048191;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static T[] Empty<T>()
		{
			return TypeHolder<T>.Empty;
		}
	}
	public readonly struct SequencePosition : IEquatable<SequencePosition>
	{
		private readonly object? _object;

		private readonly int _integer;

		public SequencePosition(object? @object, int integer)
		{
			_object = @object;
			_integer = integer;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public object? GetObject()
		{
			return _object;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public int GetInteger()
		{
			return _integer;
		}

		public bool Equals(SequencePosition other)
		{
			if (_integer == other._integer)
			{
				return object.Equals(_object, other._object);
			}
			return false;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			if (obj is SequencePosition other)
			{
				return Equals(other);
			}
			return false;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			return HashCode.Combine(_object, _integer);
		}
	}
	public static class EnvironmentEx
	{
		public static int CurrentManagedThreadId => Environment.CurrentManagedThreadId;
	}
	public sealed class Gen2GcCallback : CriticalFinalizerObject
	{
		private readonly Func<bool>? _callback0;

		private readonly Func<object, bool>? _callback1;

		private GCHandle _weakTargetObj;

		private Gen2GcCallback(Func<bool> callback)
		{
			_callback0 = callback;
		}

		private Gen2GcCallback(Func<object, bool> callback, object targetObj)
		{
			_callback1 = callback;
			_weakTargetObj = GCHandle.Alloc(targetObj, GCHandleType.Weak);
		}

		public static void Register(Func<bool> callback)
		{
			new Gen2GcCallback(callback);
		}

		public static void Register(Func<object, bool> callback, object targetObj)
		{
			new Gen2GcCallback(callback, targetObj);
		}

		~Gen2GcCallback()
		{
			if (_weakTargetObj.IsAllocated)
			{
				object target = _weakTargetObj.Target;
				if (target == null)
				{
					_weakTargetObj.Free();
					return;
				}
				try
				{
					if (!_callback1(target))
					{
						_weakTargetObj.Free();
						return;
					}
				}
				catch
				{
				}
			}
			else
			{
				try
				{
					if (!_callback0())
					{
						return;
					}
				}
				catch
				{
				}
			}
			GC.ReRegisterForFinalize(this);
		}
	}
	public struct HashCode
	{
		private static readonly uint s_seed = GenerateGlobalSeed();

		private const uint Prime1 = 2654435761u;

		private const uint Prime2 = 2246822519u;

		private const uint Prime3 = 3266489917u;

		private const uint Prime4 = 668265263u;

		private const uint Prime5 = 374761393u;

		private uint _v1;

		private uint _v2;

		private uint _v3;

		private uint _v4;

		private uint _queue1;

		private uint _queue2;

		private uint _queue3;

		private uint _length;

		private static uint GenerateGlobalSeed()
		{
			Span<byte> destination = stackalloc byte[4];
			using (RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create())
			{
				byte[] array = new byte[destination.Length];
				randomNumberGenerator.GetBytes(array);
				MemoryExtensions.AsSpan(array).CopyTo(destination);
			}
			return Unsafe.ReadUnaligned<uint>(ref destination[0]);
		}

		public static int Combine<T1>(T1 value1)
		{
			uint queuedValue = (uint)(value1?.GetHashCode() ?? 0);
			return (int)MixFinal(QueueRound(MixEmptyState() + 4, queuedValue));
		}

		public static int Combine<T1, T2>(T1 value1, T2 value2)
		{
			uint queuedValue = (uint)(value1?.GetHashCode() ?? 0);
			uint queuedValue2 = (uint)(value2?.GetHashCode() ?? 0);
			return (int)MixFinal(QueueRound(QueueRound(MixEmptyState() + 8, queuedValue), queuedValue2));
		}

		public static int Combine<T1, T2, T3>(T1 value1, T2 value2, T3 value3)
		{
			uint queuedValue = (uint)(value1?.GetHashCode() ?? 0);
			uint queuedValue2 = (uint)(value2?.GetHashCode() ?? 0);
			uint queuedValue3 = (uint)(value3?.GetHashCode() ?? 0);
			return (int)MixFinal(QueueRound(QueueRound(QueueRound(MixEmptyState() + 12, queuedValue), queuedValue2), queuedValue3));
		}

		public static int Combine<T1, T2, T3, T4>(T1 value1, T2 value2, T3 value3, T4 value4)
		{
			uint input = (uint)(value1?.GetHashCode() ?? 0);
			uint input2 = (uint)(value2?.GetHashCode() ?? 0);
			uint input3 = (uint)(value3?.GetHashCode() ?? 0);
			uint input4 = (uint)(value4?.GetHashCode() ?? 0);
			Initialize(out var v, out var v2, out var v3, out var v4);
			v = Round(v, input);
			v2 = Round(v2, input2);
			v3 = Round(v3, input3);
			v4 = Round(v4, input4);
			return (int)MixFinal(MixState(v, v2, v3, v4) + 16);
		}

		public static int Combine<T1, T2, T3, T4, T5>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)
		{
			uint input = (uint)(value1?.GetHashCode() ?? 0);
			uint input2 = (uint)(value2?.GetHashCode() ?? 0);
			uint input3 = (uint)(value3?.GetHashCode() ?? 0);
			uint input4 = (uint)(value4?.GetHashCode() ?? 0);
			uint queuedValue = (uint)(value5?.GetHashCode() ?? 0);
			Initialize(out var v, out var v2, out var v3, out var v4);
			v = Round(v, input);
			v2 = Round(v2, input2);
			v3 = Round(v3, input3);
			v4 = Round(v4, input4);
			return (int)MixFinal(QueueRound(MixState(v, v2, v3, v4) + 20, queuedValue));
		}

		public static int Combine<T1, T2, T3, T4, T5, T6>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6)
		{
			uint input = (uint)(value1?.GetHashCode() ?? 0);
			uint input2 = (uint)(value2?.GetHashCode() ?? 0);
			uint input3 = (uint)(value3?.GetHashCode() ?? 0);
			uint input4 = (uint)(value4?.GetHashCode() ?? 0);
			uint queuedValue = (uint)(value5?.GetHashCode() ?? 0);
			uint queuedValue2 = (uint)(value6?.GetHashCode() ?? 0);
			Initialize(out var v, out var v2, out var v3, out var v4);
			v = Round(v, input);
			v2 = Round(v2, input2);
			v3 = Round(v3, input3);
			v4 = Round(v4, input4);
			return (int)MixFinal(QueueRound(QueueRound(MixState(v, v2, v3, v4) + 24, queuedValue), queuedValue2));
		}

		public static int Combine<T1, T2, T3, T4, T5, T6, T7>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7)
		{
			uint input = (uint)(value1?.GetHashCode() ?? 0);
			uint input2 = (uint)(value2?.GetHashCode() ?? 0);
			uint input3 = (uint)(value3?.GetHashCode() ?? 0);
			uint input4 = (uint)(value4?.GetHashCode() ?? 0);
			uint queuedValue = (uint)(value5?.GetHashCode() ?? 0);
			uint queuedValue2 = (uint)(value6?.GetHashCode() ?? 0);
			uint queuedValue3 = (uint)(value7?.GetHashCode() ?? 0);
			Initialize(out var v, out var v2, out var v3, out var v4);
			v = Round(v, input);
			v2 = Round(v2, input2);
			v3 = Round(v3, input3);
			v4 = Round(v4, input4);
			return (int)MixFinal(QueueRound(QueueRound(QueueRound(MixState(v, v2, v3, v4) + 28, queuedValue), queuedValue2), queuedValue3));
		}

		public static int Combine<T1, T2, T3, T4, T5, T6, T7, T8>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8)
		{
			uint input = (uint)(value1?.GetHashCode() ?? 0);
			uint input2 = (uint)(value2?.GetHashCode() ?? 0);
			uint input3 = (uint)(value3?.GetHashCode() ?? 0);
			uint input4 = (uint)(value4?.GetHashCode() ?? 0);
			uint input5 = (uint)(value5?.GetHashCode() ?? 0);
			uint input6 = (uint)(value6?.GetHashCode() ?? 0);
			uint input7 = (uint)(value7?.GetHashCode() ?? 0);
			uint input8 = (uint)(value8?.GetHashCode() ?? 0);
			Initialize(out var v, out var v2, out var v3, out var v4);
			v = Round(v, input);
			v2 = Round(v2, input2);
			v3 = Round(v3, input3);
			v4 = Round(v4, input4);
			v = Round(v, input5);
			v2 = Round(v2, input6);
			v3 = Round(v3, input7);
			v4 = Round(v4, input8);
			return (int)MixFinal(MixState(v, v2, v3, v4) + 32);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void Initialize(out uint v1, out uint v2, out uint v3, out uint v4)
		{
			v1 = (uint)((int)s_seed + -1640531535 + -2048144777);
			v2 = s_seed + 2246822519u;
			v3 = s_seed;
			v4 = s_seed - 2654435761u;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static uint Round(uint hash, uint input)
		{
			return BitOperations.RotateLeft(hash + (uint)((int)input * -2048144777), 13) * 2654435761u;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static uint QueueRound(uint hash, uint queuedValue)
		{
			return BitOperations.RotateLeft(hash + (uint)((int)queuedValue * -1028477379), 17) * 668265263;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static uint MixState(uint v1, uint v2, uint v3, uint v4)
		{
			return BitOperations.RotateLeft(v1, 1) + BitOperations.RotateLeft(v2, 7) + BitOperations.RotateLeft(v3, 12) + BitOperations.RotateLeft(v4, 18);
		}

		private static uint MixEmptyState()
		{
			return s_seed + 374761393;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static uint MixFinal(uint hash)
		{
			hash ^= hash >> 15;
			hash *= 2246822519u;
			hash ^= hash >> 13;
			hash *= 3266489917u;
			hash ^= hash >> 16;
			return hash;
		}

		public void Add<T>(T value)
		{
			Add(value?.GetHashCode() ?? 0);
		}

		public void Add<T>(T value, IEqualityComparer<T>? comparer)
		{
			Add((value != null) ? (comparer?.GetHashCode(value) ?? value.GetHashCode()) : 0);
		}

		public void AddBytes(ReadOnlySpan<byte> value)
		{
			ref byte reference = ref MemoryMarshal.GetReference(value);
			ref byte reference2 = ref Unsafe.Add(ref reference, value.Length);
			while (Unsafe.ByteOffset(ref reference, ref reference2) >= 4)
			{
				Add(Unsafe.ReadUnaligned<int>(ref reference));
				reference = ref Unsafe.Add(ref reference, 4);
			}
			while (Unsafe.IsAddressLessThan(ref reference, ref reference2))
			{
				Add((int)reference);
				reference = ref Unsafe.Add(ref reference, 1);
			}
		}

		private void Add(int value)
		{
			uint num = _length++;
			switch (num % 4)
			{
			case 0u:
				_queue1 = (uint)value;
				return;
			case 1u:
				_queue2 = (uint)value;
				return;
			case 2u:
				_queue3 = (uint)value;
				return;
			}
			if (num == 3)
			{
				Initialize(out _v1, out _v2, out _v3, out _v4);
			}
			_v1 = Round(_v1, _queue1);
			_v2 = Round(_v2, _queue2);
			_v3 = Round(_v3, _queue3);
			_v4 = Round(_v4, (uint)value);
		}

		public int ToHashCode()
		{
			uint length = _length;
			uint num = length % 4;
			uint num2 = ((length < 4) ? MixEmptyState() : MixState(_v1, _v2, _v3, _v4));
			num2 += length * 4;
			if (num != 0)
			{
				num2 = QueueRound(num2, _queue1);
				if (num > 1)
				{
					num2 = QueueRound(num2, _queue2);
					if (num > 2)
					{
						num2 = QueueRound(num2, _queue3);
					}
				}
			}
			return (int)MixFinal(num2);
		}

		[Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code.", true)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			throw new NotSupportedException("GetHashCode on HashCode is not supported");
		}

		[Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes.", true)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			throw new NotSupportedException("Equals on HashCode is not supported");
		}
	}
	public static class MathEx
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static byte Clamp(byte value, byte min, byte max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static decimal Clamp(decimal value, decimal min, decimal max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static double Clamp(double value, double min, double max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static short Clamp(short value, short min, short max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int Clamp(int value, int min, int max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static long Clamp(long value, long min, long max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static nint Clamp(nint value, nint min, nint max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public static sbyte Clamp(sbyte value, sbyte min, sbyte max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Clamp(float value, float min, float max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public static ushort Clamp(ushort value, ushort min, ushort max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public static uint Clamp(uint value, uint min, uint max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public static ulong Clamp(ulong value, ulong min, ulong max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public static nuint Clamp(nuint value, nuint min, nuint max)
		{
			if (min > max)
			{
				ThrowMinMaxException(min, max);
			}
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		[DoesNotReturn]
		private static void ThrowMinMaxException<T>(T min, T max)
		{
			throw new ArgumentException($"Minimum {min} is less than maximum {max}");
		}
	}
	[DebuggerTypeProxy(typeof(System.MemoryDebugView<>))]
	[DebuggerDisplay("{ToString(),raw}")]
	public readonly struct Memory<T>
	{
		private readonly object? _object;

		private readonly int _index;

		private readonly int _length;

		private const int RemoveFlagsBitMask = int.MaxValue;

		public static Memory<T> Empty => default(Memory<T>);

		public int Length => _length & 0x7FFFFFFF;

		public bool IsEmpty => (_length & 0x7FFFFFFF) == 0;

		public Span<T> Span
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				Span<T> result;
				if (_index < 0)
				{
					result = ((MemoryManager<T>)_object).GetSpan();
					return result.Slice(_index & 0x7FFFFFFF, _length);
				}
				if (typeof(T) == typeof(char) && _object is string text)
				{
					result = new Span<T>(text, (IntPtr)RuntimeHelpers.OffsetToStringData, text.Length);
					return result.Slice(_index, _length);
				}
				if (_object != null)
				{
					return new Span<T>((T[])_object, _index, _length & 0x7FFFFFFF);
				}
				result = default(Span<T>);
				return result;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Memory(T[]? array)
		{
			if (array == null)
			{
				this = default(Memory<T>);
				return;
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			_object = array;
			_index = 0;
			_length = array.Length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal Memory(T[]? array, int start)
		{
			if (array == null)
			{
				if (start != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException();
				}
				this = default(Memory<T>);
				return;
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			if ((uint)start > (uint)array.Length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			_object = array;
			_index = start;
			_length = array.Length - start;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Memory(T[]? array, int start, int length)
		{
			if (array == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException();
				}
				this = default(Memory<T>);
				return;
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			_object = array;
			_index = start;
			_length = length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal Memory(MemoryManager<T> manager, int length)
		{
			if (length < 0)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			_object = manager;
			_index = int.MinValue;
			_length = length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal Memory(MemoryManager<T> manager, int start, int length)
		{
			if (length < 0 || start < 0)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			_object = manager;
			_index = start | int.MinValue;
			_length = length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal Memory(object? obj, int start, int length)
		{
			_object = obj;
			_index = start;
			_length = length;
		}

		public static implicit operator Memory<T>(T[]? array)
		{
			return new Memory<T>(array);
		}

		public static implicit operator Memory<T>(ArraySegment<T> segment)
		{
			return new Memory<T>(segment.Array, segment.Offset, segment.Count);
		}

		public static implicit operator ReadOnlyMemory<T>(Memory<T> memory)
		{
			return Unsafe.As<Memory<T>, ReadOnlyMemory<T>>(ref memory);
		}

		public override string ToString()
		{
			if (typeof(T) == typeof(char))
			{
				if (!(_object is string text))
				{
					return Span.ToString();
				}
				return text.Substring(_index, _length & 0x7FFFFFFF);
			}
			return $"System.Memory<{typeof(T).Name}>[{_length & 0x7FFFFFFF}]";
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Memory<T> Slice(int start)
		{
			int length = _length;
			int num = length & 0x7FFFFFFF;
			if ((uint)start > (uint)num)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new Memory<T>(_object, _index + start, length - start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Memory<T> Slice(int start, int length)
		{
			int length2 = _length;
			int num = length2 & 0x7FFFFFFF;
			if ((uint)start > (uint)num || (uint)length > (uint)(num - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			return new Memory<T>(_object, _index + start, length | (length2 & int.MinValue));
		}

		public void CopyTo(Memory<T> destination)
		{
			Span.CopyTo(destination.Span);
		}

		public bool TryCopyTo(Memory<T> destination)
		{
			return Span.TryCopyTo(destination.Span);
		}

		public unsafe MemoryHandle Pin()
		{
			if (_index < 0)
			{
				return ((MemoryManager<T>)_object).Pin(_index & 0x7FFFFFFF);
			}
			if (typeof(T) == typeof(char) && _object is string value)
			{
				GCHandle handle = GCHandle.Alloc(value, GCHandleType.Pinned);
				return new MemoryHandle(Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index), handle);
			}
			if (_object is T[] array)
			{
				if (_length < 0)
				{
					return new MemoryHandle(Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index));
				}
				GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned);
				return new MemoryHandle(Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index), handle2);
			}
			return default(MemoryHandle);
		}

		public T[] ToArray()
		{
			return Span.ToArray();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			if (obj is ReadOnlyMemory<T> readOnlyMemory)
			{
				return readOnlyMemory.Equals(this);
			}
			if (obj is Memory<T> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Memory<T> other)
		{
			if (_object == other._object && _index == other._index)
			{
				return _length == other._length;
			}
			return false;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			if (_object == null)
			{
				return 0;
			}
			return HashCode.Combine(_object, _index, _length);
		}
	}
	internal sealed class MemoryDebugView<T>
	{
		private readonly ReadOnlyMemory<T> _memory;

		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
		public T[] Items => _memory.ToArray();

		public MemoryDebugView(Memory<T> memory)
		{
			_memory = memory;
		}

		public MemoryDebugView(ReadOnlyMemory<T> memory)
		{
			_memory = memory;
		}
	}
	public static class MemoryExtensions
	{
		public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span)
		{
			return span.TrimStart().TrimEnd();
		}

		public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span)
		{
			int i;
			for (i = 0; i < span.Length && char.IsWhiteSpace(span[i]); i++)
			{
			}
			return span.Slice(i);
		}

		public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span)
		{
			int num = span.Length - 1;
			while (num >= 0 && char.IsWhiteSpace(span[num]))
			{
				num--;
			}
			return span.Slice(0, num + 1);
		}

		public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, char trimChar)
		{
			return span.TrimStart(trimChar).TrimEnd(trimChar);
		}

		public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, char trimChar)
		{
			int i;
			for (i = 0; i < span.Length && span[i] == trimChar; i++)
			{
			}
			return span.Slice(i);
		}

		public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, char trimChar)
		{
			int num = span.Length - 1;
			while (num >= 0 && span[num] == trimChar)
			{
				num--;
			}
			return span.Slice(0, num + 1);
		}

		public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)
		{
			return span.TrimStart(trimChars).TrimEnd(trimChars);
		}

		public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)
		{
			if (trimChars.IsEmpty)
			{
				return span.TrimStart();
			}
			int i;
			for (i = 0; i < span.Length; i++)
			{
				int num = 0;
				while (num < trimChars.Length)
				{
					if (span[i] != trimChars[num])
					{
						num++;
						continue;
					}
					goto IL_003c;
				}
				break;
				IL_003c:;
			}
			return span.Slice(i);
		}

		public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)
		{
			if (trimChars.IsEmpty)
			{
				return span.TrimEnd();
			}
			int num;
			for (num = span.Length - 1; num >= 0; num--)
			{
				int num2 = 0;
				while (num2 < trimChars.Length)
				{
					if (span[num] != trimChars[num2])
					{
						num2++;
						continue;
					}
					goto IL_0044;
				}
				break;
				IL_0044:;
			}
			return span.Slice(0, num + 1);
		}

		public static bool IsWhiteSpace(this ReadOnlySpan<char> span)
		{
			for (int i = 0; i < span.Length; i++)
			{
				if (!char.IsWhiteSpace(span[i]))
				{
					return false;
				}
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
			}
			return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
			}
			return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
			}
			return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
			}
			return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool SequenceEqual<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>
		{
			int length = span.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length == other.Length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (nuint)length * size);
				}
				return false;
			}
			if (length == other.Length)
			{
				return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length);
			}
			return false;
		}

		public static int SequenceCompareTo<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IComparable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length);
			}
			return System.SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
			}
			return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
			}
			return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
			}
			return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
			}
			return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length);
			}
			return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length);
			}
			return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool SequenceEqual<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>
		{
			int length = span.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length == other.Length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (nuint)length * size);
				}
				return false;
			}
			if (length == other.Length)
			{
				return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length);
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int SequenceCompareTo<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IComparable<T>
		{
			if (typeof(T) == typeof(byte))
			{
				return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length);
			}
			if (typeof(T) == typeof(char))
			{
				return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length);
			}
			return System.SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			int length = value.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length <= span.Length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (nuint)length * size);
				}
				return false;
			}
			if (length <= span.Length)
			{
				return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length);
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			int length = value.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length <= span.Length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (nuint)length * size);
				}
				return false;
			}
			if (length <= span.Length)
			{
				return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length);
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool EndsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			int length = span.Length;
			int length2 = value.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length2 <= length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (nuint)length2 * size);
				}
				return false;
			}
			if (length2 <= length)
			{
				return System.SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2), ref MemoryMarshal.GetReference(value), length2);
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool EndsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>
		{
			int length = span.Length;
			int length2 = value.Length;
			if (default(T) != null && IsTypeComparableAsBytes<T>(out var size))
			{
				if (length2 <= length)
				{
					return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (nuint)length2 * size);
				}
				return false;
			}
			if (length2 <= length)
			{
				return System.SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2), ref MemoryMarshal.GetReference(value), length2);
			}
			return false;
		}

		public static void Reverse<T>(this Span<T> span)
		{
			if (span.Length > 1)
			{
				ref T reference = ref MemoryMarshal.GetReference(span);
				ref T reference2 = ref Unsafe.Add(ref Unsafe.Add(ref reference, span.Length), -1);
				do
				{
					T val = reference;
					reference = reference2;
					reference2 = val;
					reference = ref Unsafe.Add(ref reference, 1);
					reference2 = ref Unsafe.Add(ref reference2, -1);
				}
				while (Unsafe.IsAddressLessThan(ref reference, ref reference2));
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Span<T> AsSpan<T>(this T[]? array)
		{
			return new Span<T>(array);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Span<T> AsSpan<T>(this T[]? array, int start, int length)
		{
			return new Span<T>(array, start, length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Span<T> AsSpan<T>(this ArraySegment<T> segment)
		{
			return new Span<T>(segment.Array, segment.Offset, segment.Count);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start)
		{
			if ((uint)start > segment.Count)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new Span<T>(segment.Array, segment.Offset + start, segment.Count - start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start, int length)
		{
			if ((uint)start > segment.Count)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			if ((uint)length > segment.Count - start)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.length);
			}
			return new Span<T>(segment.Array, segment.Offset + start, length);
		}

		public static Memory<T> AsMemory<T>(this T[]? array)
		{
			return new Memory<T>(array);
		}

		public static Memory<T> AsMemory<T>(this T[]? array, int start)
		{
			return new Memory<T>(array, start);
		}

		public static Memory<T> AsMemory<T>(this T[]? array, int start, int length)
		{
			return new Memory<T>(array, start, length);
		}

		public static Memory<T> AsMemory<T>(this ArraySegment<T> segment)
		{
			return new Memory<T>(segment.Array, segment.Offset, segment.Count);
		}

		public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start)
		{
			if ((uint)start > segment.Count)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new Memory<T>(segment.Array, segment.Offset + start, segment.Count - start);
		}

		public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start, int length)
		{
			if ((uint)start > segment.Count)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			if ((uint)length > segment.Count - start)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.length);
			}
			return new Memory<T>(segment.Array, segment.Offset + start, length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void CopyTo<T>(this T[]? source, Span<T> destination)
		{
			new ReadOnlySpan<T>(source).CopyTo(destination);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void CopyTo<T>(this T[]? source, Memory<T> destination)
		{
			source.CopyTo(destination.Span);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other)
		{
			return ((ReadOnlySpan<T>)span).Overlaps(other);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other, out int elementOffset)
		{
			return ((ReadOnlySpan<T>)span).Overlaps(other, out elementOffset);
		}

		public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other)
		{
			if (span.IsEmpty || other.IsEmpty)
			{
				return false;
			}
			nint num = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
			if (Unsafe.SizeOf<IntPtr>() == 4)
			{
				if ((uint)(int)(IntPtr)num >= (uint)(span.Length * Unsafe.SizeOf<T>()))
				{
					return (uint)(int)(IntPtr)num > (uint)(-(other.Length * Unsafe.SizeOf<T>()));
				}
				return true;
			}
			if ((ulong)(long)(IntPtr)num >= (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()))
			{
				return (ulong)(long)(IntPtr)num > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>()));
			}
			return true;
		}

		public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other, out int elementOffset)
		{
			if (span.IsEmpty || other.IsEmpty)
			{
				elementOffset = 0;
				return false;
			}
			nint num = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
			if (Unsafe.SizeOf<IntPtr>() == 4)
			{
				if ((uint)(int)(IntPtr)num < (uint)(span.Length * Unsafe.SizeOf<T>()) || (uint)(int)(IntPtr)num > (uint)(-(other.Length * Unsafe.SizeOf<T>())))
				{
					if ((int)(IntPtr)num % Unsafe.SizeOf<T>() != 0)
					{
						System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch();
					}
					elementOffset = (int)(IntPtr)num / Unsafe.SizeOf<T>();
					return true;
				}
				elementOffset = 0;
				return false;
			}
			if ((ulong)(long)(IntPtr)num < (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()) || (ulong)(long)(IntPtr)num > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>())))
			{
				if ((long)(IntPtr)num % Unsafe.SizeOf<T>() != 0L)
				{
					System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch();
				}
				elementOffset = (int)((long)(IntPtr)num / Unsafe.SizeOf<T>());
				return true;
			}
			elementOffset = 0;
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T>(this Span<T> span, IComparable<T> comparable)
		{
			return span.BinarySearch<T, IComparable<T>>(comparable);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T, TComparable>(this Span<T> span, TComparable comparable) where TComparable : IComparable<T>
		{
			return BinarySearch((ReadOnlySpan<T>)span, comparable);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T, TComparer>(this Span<T> span, T value, TComparer comparer) where TComparer : IComparer<T>
		{
			return ((ReadOnlySpan<T>)span).BinarySearch(value, comparer);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T>(this ReadOnlySpan<T> span, IComparable<T> comparable)
		{
			return MemoryExtensions.BinarySearch<T, IComparable<T>>(span, comparable);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T>
		{
			return System.SpanHelpers.BinarySearch(span, comparable);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T, TComparer>(this ReadOnlySpan<T> span, T value, TComparer comparer) where TComparer : IComparer<T>
		{
			if (comparer == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.comparer);
			}
			System.SpanHelpers.ComparerComparable<T, TComparer> comparable = new System.SpanHelpers.ComparerComparable<T, TComparer>(value, comparer);
			return BinarySearch(span, comparable);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static bool IsTypeComparableAsBytes<T>(out nuint size)
		{
			if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
			{
				size = 1u;
				return true;
			}
			if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort))
			{
				size = 2u;
				return true;
			}
			if (typeof(T) == typeof(int) || typeof(T) == typeof(uint))
			{
				size = 4u;
				return true;
			}
			if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong))
			{
				size = 8u;
				return true;
			}
			size = 0u;
			return false;
		}

		public static Span<T> AsSpan<T>(this T[]? array, int start)
		{
			return Span<T>.Create(array, start);
		}

		public static bool Contains(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
		{
			return span.IndexOf(value, comparisonType) >= 0;
		}

		public static bool Equals(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType)
		{
			switch (comparisonType)
			{
			case StringComparison.Ordinal:
				return span.SequenceEqual(other);
			case StringComparison.OrdinalIgnoreCase:
				if (span.Length != other.Length)
				{
					return false;
				}
				return EqualsOrdinalIgnoreCase(span, other);
			default:
				return span.ToString().Equals(other.ToString(), comparisonType);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static bool EqualsOrdinalIgnoreCase(ReadOnlySpan<char> span, ReadOnlySpan<char> other)
		{
			if (other.Length == 0)
			{
				return true;
			}
			return CompareToOrdinalIgnoreCase(span, other) == 0;
		}

		public static int CompareTo(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType)
		{
			return comparisonType switch
			{
				StringComparison.Ordinal => span.SequenceCompareTo(other), 
				StringComparison.OrdinalIgnoreCase => CompareToOrdinalIgnoreCase(span, other), 
				_ => string.Compare(span.ToString(), other.ToString(), comparisonType), 
			};
		}

		private unsafe static int CompareToOrdinalIgnoreCase(ReadOnlySpan<char> strA, ReadOnlySpan<char> strB)
		{
			int num = Math.Min(strA.Length, strB.Length);
			int num2 = num;
			fixed (char* ptr = &MemoryMarshal.GetReference(strA))
			{
				fixed (char* ptr3 = &MemoryMarshal.GetReference(strB))
				{
					char* ptr2 = ptr;
					char* ptr4 = ptr3;
					while (num != 0 && *ptr2 <= '\u007f' && *ptr4 <= '\u007f')
					{
						int num3 = *ptr2;
						int num4 = *ptr4;
						if (num3 == num4)
						{
							ptr2++;
							ptr4++;
							num--;
							continue;
						}
						if ((uint)(num3 - 97) <= 25u)
						{
							num3 -= 32;
						}
						if ((uint)(num4 - 97) <= 25u)
						{
							num4 -= 32;
						}
						if (num3 != num4)
						{
							return num3 - num4;
						}
						ptr2++;
						ptr4++;
						num--;
					}
					if (num == 0)
					{
						return strA.Length - strB.Length;
					}
					num2 -= num;
					return string.Compare(strA.Slice(num2).ToString(), strB.Slice(num2).ToString(), StringComparison.OrdinalIgnoreCase);
				}
			}
		}

		public static int IndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
		{
			if (comparisonType == StringComparison.Ordinal)
			{
				return span.IndexOf(value);
			}
			return span.ToString().IndexOf(value.ToString(), comparisonType);
		}

		public static int ToLower(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo culture)
		{
			System.ThrowHelper.ThrowIfArgumentNull(culture, System.ExceptionArgument.culture);
			if (destination.Length < source.Length)
			{
				return -1;
			}
			string str = source.ToString();
			AsSpan(culture.TextInfo.ToLower(str)).CopyTo(destination);
			return source.Length;
		}

		public static int ToLowerInvariant(this ReadOnlySpan<char> source, Span<char> destination)
		{
			return source.ToLower(destination, CultureInfo.InvariantCulture);
		}

		public static int ToUpper(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo culture)
		{
			System.ThrowHelper.ThrowIfArgumentNull(culture, System.ExceptionArgument.culture);
			if (destination.Length < source.Length)
			{
				return -1;
			}
			string str = source.ToString();
			AsSpan(culture.TextInfo.ToUpper(str)).CopyTo(destination);
			return source.Length;
		}

		public static int ToUpperInvariant(this ReadOnlySpan<char> source, Span<char> destination)
		{
			return source.ToUpper(destination, CultureInfo.InvariantCulture);
		}

		public static bool EndsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
		{
			switch (comparisonType)
			{
			case StringComparison.Ordinal:
				return span.EndsWith(value);
			case StringComparison.OrdinalIgnoreCase:
				if (value.Length <= span.Length)
				{
					return EqualsOrdinalIgnoreCase(span.Slice(span.Length - value.Length), value);
				}
				return false;
			default:
			{
				string text = span.ToString();
				string value2 = value.ToString();
				return text.EndsWith(value2, comparisonType);
			}
			}
		}

		public static bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)
		{
			switch (comparisonType)
			{
			case StringComparison.Ordinal:
				return span.StartsWith(value);
			case StringComparison.OrdinalIgnoreCase:
				if (value.Length <= span.Length)
				{
					return EqualsOrdinalIgnoreCase(span.Slice(0, value.Length), value);
				}
				return false;
			default:
			{
				string text = span.ToString();
				string value2 = value.ToString();
				return text.StartsWith(value2, comparisonType);
			}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static ReadOnlySpan<char> AsSpan(this string? text)
		{
			if (text == null)
			{
				return default(ReadOnlySpan<char>);
			}
			return new ReadOnlySpan<char>(text, (IntPtr)RuntimeHelpers.OffsetToStringData, text.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static ReadOnlySpan<char> AsSpan(this string? text, int start)
		{
			if (text == null)
			{
				if (start != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				return default(ReadOnlySpan<char>);
			}
			if ((uint)start > (uint)text.Length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlySpan<char>(text, (nint)RuntimeHelpers.OffsetToStringData + (nint)(start * 2), text.Length - start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static ReadOnlySpan<char> AsSpan(this string? text, int start, int length)
		{
			if (text == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				return default(ReadOnlySpan<char>);
			}
			if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlySpan<char>(text, (nint)RuntimeHelpers.OffsetToStringData + (nint)(start * 2), length);
		}

		public static ReadOnlyMemory<char> AsMemory(this string? text)
		{
			if (text == null)
			{
				return default(ReadOnlyMemory<char>);
			}
			return new ReadOnlyMemory<char>(text, 0, text.Length);
		}

		public static ReadOnlyMemory<char> AsMemory(this string? text, int start)
		{
			if (text == null)
			{
				if (start != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				return default(ReadOnlyMemory<char>);
			}
			if ((uint)start > (uint)text.Length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlyMemory<char>(text, start, text.Length - start);
		}

		public static ReadOnlyMemory<char> AsMemory(this string? text, int start, int length)
		{
			if (text == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				return default(ReadOnlyMemory<char>);
			}
			if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlyMemory<char>(text, start, length);
		}
	}
	[DebuggerTypeProxy(typeof(System.MemoryDebugView<>))]
	[DebuggerDisplay("{ToString(),raw}")]
	public readonly struct ReadOnlyMemory<T>
	{
		private readonly object? _object;

		private readonly int _index;

		private readonly int _length;

		internal const int RemoveFlagsBitMask = int.MaxValue;

		public static ReadOnlyMemory<T> Empty => default(ReadOnlyMemory<T>);

		public int Length => _length & 0x7FFFFFFF;

		public bool IsEmpty => (_length & 0x7FFFFFFF) == 0;

		public ReadOnlySpan<T> Span
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if (_index < 0)
				{
					return ((MemoryManager<T>)_object).GetSpan().Slice(_index & 0x7FFFFFFF, _length);
				}
				ReadOnlySpan<T> result;
				if (typeof(T) == typeof(char) && _object is string text)
				{
					result = new ReadOnlySpan<T>(text, (IntPtr)RuntimeHelpers.OffsetToStringData, text.Length);
					return result.Slice(_index, _length);
				}
				if (_object != null)
				{
					return new ReadOnlySpan<T>((T[])_object, _index, _length & 0x7FFFFFFF);
				}
				result = default(ReadOnlySpan<T>);
				return result;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlyMemory(T[]? array)
		{
			if (array == null)
			{
				this = default(ReadOnlyMemory<T>);
				return;
			}
			_object = array;
			_index = 0;
			_length = array.Length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlyMemory(T[]? array, int start, int length)
		{
			if (array == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException();
				}
				this = default(ReadOnlyMemory<T>);
				return;
			}
			if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException();
			}
			_object = array;
			_index = start;
			_length = length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ReadOnlyMemory(object? obj, int start, int length)
		{
			_object = obj;
			_index = start;
			_length = length;
		}

		public static implicit operator ReadOnlyMemory<T>(T[]? array)
		{
			return new ReadOnlyMemory<T>(array);
		}

		public static implicit operator ReadOnlyMemory<T>(ArraySegment<T> segment)
		{
			return new ReadOnlyMemory<T>(segment.Array, segment.Offset, segment.Count);
		}

		public override string ToString()
		{
			if (typeof(T) == typeof(char))
			{
				if (!(_object is string text))
				{
					return Span.ToString();
				}
				return text.Substring(_index, _length & 0x7FFFFFFF);
			}
			return $"System.ReadOnlyMemory<{typeof(T).Name}>[{_length & 0x7FFFFFFF}]";
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlyMemory<T> Slice(int start)
		{
			int length = _length;
			int num = length & 0x7FFFFFFF;
			if ((uint)start > (uint)num)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlyMemory<T>(_object, _index + start, length - start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlyMemory<T> Slice(int start, int length)
		{
			int length2 = _length;
			int num = _length & 0x7FFFFFFF;
			if ((uint)start > (uint)num || (uint)length > (uint)(num - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return new ReadOnlyMemory<T>(_object, _index + start, length | (length2 & int.MinValue));
		}

		public void CopyTo(Memory<T> destination)
		{
			Span.CopyTo(destination.Span);
		}

		public bool TryCopyTo(Memory<T> destination)
		{
			return Span.TryCopyTo(destination.Span);
		}

		public unsafe MemoryHandle Pin()
		{
			if (_index < 0)
			{
				return ((MemoryManager<T>)_object).Pin(_index & 0x7FFFFFFF);
			}
			if (typeof(T) == typeof(char) && _object is string value)
			{
				GCHandle handle = GCHandle.Alloc(value, GCHandleType.Pinned);
				return new MemoryHandle(Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index), handle);
			}
			if (_object is T[] array)
			{
				if (_length < 0)
				{
					return new MemoryHandle(Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index));
				}
				GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned);
				return new MemoryHandle(Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index), handle2);
			}
			return default(MemoryHandle);
		}

		public T[] ToArray()
		{
			return Span.ToArray();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			if (obj is ReadOnlyMemory<T> other)
			{
				return Equals(other);
			}
			if (obj is Memory<T> memory)
			{
				return Equals(memory);
			}
			return false;
		}

		public bool Equals(ReadOnlyMemory<T> other)
		{
			if (_object == other._object && _index == other._index)
			{
				return _length == other._length;
			}
			return false;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			if (_object == null)
			{
				return 0;
			}
			return HashCode.Combine(_object, _index, _length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal object? GetObjectStartLength(out int start, out int length)
		{
			start = _index;
			length = _length;
			return _object;
		}
	}
	[DebuggerTypeProxy(typeof(System.SpanDebugView<>))]
	[DebuggerDisplay("{ToString(),raw}")]
	public readonly ref struct ReadOnlySpan<T>
	{
		public ref struct Enumerator
		{
			private readonly ReadOnlySpan<T> _span;

			private int _index;

			public ref readonly T Current
			{
				[MethodImpl(MethodImplOptions.AggressiveInlining)]
				get
				{
					return ref _span[_index];
				}
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			internal Enumerator(ReadOnlySpan<T> span)
			{
				_span = span;
				_index = -1;
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public bool MoveNext()
			{
				int num = _index + 1;
				if (num < _span.Length)
				{
					_index = num;
					return true;
				}
				return false;
			}
		}

		private readonly object? _pinnable;

		private readonly IntPtr _byteOffset;

		private readonly int _length;

		public int Length => _length;

		public bool IsEmpty => _length == 0;

		public static ReadOnlySpan<T> Empty => default(ReadOnlySpan<T>);

		public ref readonly T this[int index]
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if ((uint)index >= (uint)_length)
				{
					System.ThrowHelper.ThrowIndexOutOfRangeException();
				}
				return ref Unsafe.Add(ref DangerousGetPinnableReference(), index);
			}
		}

		internal object? Pinnable => _pinnable;

		internal IntPtr ByteOffset => _byteOffset;

		public static bool operator !=(ReadOnlySpan<T> left, ReadOnlySpan<T> right)
		{
			return !(left == right);
		}

		[Obsolete("Equals() on ReadOnlySpan will always throw an exception. Use == instead.")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			throw new NotSupportedException("Cannot call Equals on Span");
		}

		[Obsolete("GetHashCode() on ReadOnlySpan will always throw an exception.")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			throw new NotSupportedException("Cannot call GetHashCodee on Span");
		}

		public static implicit operator ReadOnlySpan<T>(T[]? array)
		{
			return new ReadOnlySpan<T>(array);
		}

		public static implicit operator ReadOnlySpan<T>(ArraySegment<T> segment)
		{
			return new ReadOnlySpan<T>(segment.Array ?? throw new ArgumentNullException("segment"), segment.Offset, segment.Count);
		}

		public Enumerator GetEnumerator()
		{
			return new Enumerator(this);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlySpan(T[]? array)
		{
			if (array == null)
			{
				this = default(ReadOnlySpan<T>);
				return;
			}
			_length = array.Length;
			_pinnable = array;
			_byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlySpan(T[]? array, int start, int length)
		{
			if (array == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				this = default(ReadOnlySpan<T>);
				return;
			}
			if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			_length = length;
			_pinnable = array;
			_byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public unsafe ReadOnlySpan(void* pointer, int length)
		{
			if (System.SpanHelpers.IsReferenceOrContainsReferences<T>())
			{
				System.ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
			}
			if (length < 0)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			_length = length;
			_pinnable = null;
			_byteOffset = new IntPtr(pointer);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ReadOnlySpan(object? pinnable, IntPtr byteOffset, int length)
		{
			_length = length;
			_pinnable = pinnable;
			_byteOffset = byteOffset;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public unsafe ref readonly T GetPinnableReference()
		{
			if (_length != 0)
			{
				return ref DangerousGetPinnableReference();
			}
			return ref Unsafe.AsRef<T>(null);
		}

		public void CopyTo(Span<T> destination)
		{
			if (!TryCopyTo(destination))
			{
				System.ThrowHelper.ThrowArgumentException_DestinationTooShort();
			}
		}

		public bool TryCopyTo(Span<T> destination)
		{
			int length = _length;
			int length2 = destination.Length;
			if (length == 0)
			{
				return true;
			}
			if ((uint)length > (uint)length2)
			{
				return false;
			}
			ref T src = ref DangerousGetPinnableReference();
			System.SpanHelpers.CopyTo(ref destination.DangerousGetPinnableReference(), length2, ref src, length);
			return true;
		}

		public static bool operator ==(ReadOnlySpan<T> left, ReadOnlySpan<T> right)
		{
			if (left._length == right._length)
			{
				return Unsafe.AreSame(ref left.DangerousGetPinnableReference(), ref right.DangerousGetPinnableReference());
			}
			return false;
		}

		public unsafe override string ToString()
		{
			if (typeof(T) == typeof(char))
			{
				if (_byteOffset == (IntPtr)RuntimeHelpers.OffsetToStringData && Unsafe.As<object>(_pinnable) is string text && _length == text.Length)
				{
					return text;
				}
				fixed (char* value = &Unsafe.As<T, char>(ref DangerousGetPinnableReference()))
				{
					return new string(value, 0, _length);
				}
			}
			return $"System.ReadOnlySpan<{typeof(T).Name}>[{_length}]";
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlySpan<T> Slice(int start)
		{
			if ((uint)start > (uint)_length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			IntPtr byteOffset = _byteOffset.Add<T>(start);
			int length = _length - start;
			return new ReadOnlySpan<T>(_pinnable, byteOffset, length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ReadOnlySpan<T> Slice(int start, int length)
		{
			if ((uint)start > (uint)_length || (uint)length > (uint)(_length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			IntPtr byteOffset = _byteOffset.Add<T>(start);
			return new ReadOnlySpan<T>(_pinnable, byteOffset, length);
		}

		public T[] ToArray()
		{
			if (_length == 0)
			{
				return System.SpanHelpers.PerTypeValues<T>.EmptyArray;
			}
			T[] array = new T[_length];
			CopyTo(array);
			return array;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ref T DangerousGetPinnableReference()
		{
			return ref Unsafe.AddByteOffset(ref ILHelpers.ObjectAsRef<T>(_pinnable), _byteOffset);
		}
	}
	[DebuggerTypeProxy(typeof(System.SpanDebugView<>))]
	[DebuggerDisplay("{ToString(),raw}")]
	public readonly ref struct Span<T>
	{
		public ref struct Enumerator
		{
			private readonly Span<T> _span;

			private int _index;

			public ref T Current
			{
				[MethodImpl(MethodImplOptions.AggressiveInlining)]
				get
				{
					return ref _span[_index];
				}
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			internal Enumerator(Span<T> span)
			{
				_span = span;
				_index = -1;
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public bool MoveNext()
			{
				int num = _index + 1;
				if (num < _span.Length)
				{
					_index = num;
					return true;
				}
				return false;
			}
		}

		private readonly object? _pinnable;

		private readonly IntPtr _byteOffset;

		private readonly int _length;

		public int Length => _length;

		public bool IsEmpty => _length == 0;

		public static Span<T> Empty => default(Span<T>);

		public ref T this[int index]
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if ((uint)index >= (uint)_length)
				{
					System.ThrowHelper.ThrowIndexOutOfRangeException();
				}
				return ref Unsafe.Add(ref DangerousGetPinnableReference(), index);
			}
		}

		internal object? Pinnable => _pinnable;

		internal IntPtr ByteOffset => _byteOffset;

		public static bool operator !=(Span<T> left, Span<T> right)
		{
			return !(left == right);
		}

		[Obsolete("Equals() on Span will always throw an exception. Use == instead.")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool Equals(object? obj)
		{
			throw new NotSupportedException("Cannot call Equals on Span");
		}

		[Obsolete("GetHashCode() on Span will always throw an exception.")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			throw new NotSupportedException("Cannot call GetHashCode on Span");
		}

		public static implicit operator Span<T>(T[]? array)
		{
			return new Span<T>(array);
		}

		public static implicit operator Span<T>(ArraySegment<T> segment)
		{
			return new Span<T>(segment.Array, segment.Offset, segment.Count);
		}

		public Enumerator GetEnumerator()
		{
			return new Enumerator(this);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span(T[]? array)
		{
			if (array == null)
			{
				this = default(Span<T>);
				return;
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			_length = array.Length;
			_pinnable = array;
			_byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static Span<T> Create(T[]? array, int start)
		{
			if (array == null)
			{
				if (start != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				return default(Span<T>);
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			if ((uint)start > (uint)array.Length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			IntPtr byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start);
			int length = array.Length - start;
			return new Span<T>(array, byteOffset, length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span(T[]? array, int start, int length)
		{
			if (array == null)
			{
				if (start != 0 || length != 0)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
				}
				this = default(Span<T>);
				return;
			}
			if (default(T) == null && array.GetType() != typeof(T[]))
			{
				System.ThrowHelper.ThrowArrayTypeMismatchException();
			}
			if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			_length = length;
			_pinnable = array;
			_byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[CLSCompliant(false)]
		public unsafe Span(void* pointer, int length)
		{
			if (System.SpanHelpers.IsReferenceOrContainsReferences<T>())
			{
				System.ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
			}
			if (length < 0)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			_length = length;
			_pinnable = null;
			_byteOffset = new IntPtr(pointer);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal Span(object? pinnable, IntPtr byteOffset, int length)
		{
			_length = length;
			_pinnable = pinnable;
			_byteOffset = byteOffset;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public ref T GetPinnableReference()
		{
			if (_length != 0)
			{
				return ref DangerousGetPinnableReference();
			}
			return ref Unsafe.NullRef<T>();
		}

		public unsafe void Clear()
		{
			int length = _length;
			if (length == 0)
			{
				return;
			}
			nuint byteLength = (UIntPtr)(ulong)((uint)length * Unsafe.SizeOf<T>());
			if ((Unsafe.SizeOf<T>() & (sizeof(IntPtr) - 1)) != 0)
			{
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					byte* ptr = (byte*)byteOffset.ToPointer();
					System.SpanHelpers.ClearLessThanPointerSized(ptr, byteLength);
				}
				else
				{
					System.SpanHelpers.ClearLessThanPointerSized(ref Unsafe.As<T, byte>(ref DangerousGetPinnableReference()), byteLength);
				}
			}
			else if (System.SpanHelpers.IsReferenceOrContainsReferences<T>())
			{
				nuint pointerSizeLength = (UIntPtr)(ulong)(length * Unsafe.SizeOf<T>() / sizeof(IntPtr));
				System.SpanHelpers.ClearPointerSizedWithReferences(ref Unsafe.As<T, IntPtr>(ref DangerousGetPinnableReference()), pointerSizeLength);
			}
			else
			{
				System.SpanHelpers.ClearPointerSizedWithoutReferences(ref Unsafe.As<T, byte>(ref DangerousGetPinnableReference()), byteLength);
			}
		}

		public void Fill(T value)
		{
			int length = _length;
			if (length == 0)
			{
				return;
			}
			if (Unsafe.SizeOf<T>() == 1)
			{
				byte value2 = Unsafe.As<T, byte>(ref value);
				Unsafe.InitBlockUnaligned(ref Unsafe.As<T, byte>(ref DangerousGetPinnableReference()), value2, (uint)length);
				return;
			}
			ref T source = ref DangerousGetPinnableReference();
			int i;
			for (i = 0; i < (length & -8); i += 8)
			{
				Unsafe.Add(ref source, i) = value;
				Unsafe.Add(ref source, i + 1) = value;
				Unsafe.Add(ref source, i + 2) = value;
				Unsafe.Add(ref source, i + 3) = value;
				Unsafe.Add(ref source, i + 4) = value;
				Unsafe.Add(ref source, i + 5) = value;
				Unsafe.Add(ref source, i + 6) = value;
				Unsafe.Add(ref source, i + 7) = value;
			}
			if (i < (length & -4))
			{
				Unsafe.Add(ref source, i) = value;
				Unsafe.Add(ref source, i + 1) = value;
				Unsafe.Add(ref source, i + 2) = value;
				Unsafe.Add(ref source, i + 3) = value;
				i += 4;
			}
			for (; i < length; i++)
			{
				Unsafe.Add(ref source, i) = value;
			}
		}

		public void CopyTo(Span<T> destination)
		{
			if (!TryCopyTo(destination))
			{
				System.ThrowHelper.ThrowArgumentException_DestinationTooShort();
			}
		}

		public bool TryCopyTo(Span<T> destination)
		{
			int length = _length;
			int length2 = destination._length;
			if (length == 0)
			{
				return true;
			}
			if ((uint)length > (uint)length2)
			{
				return false;
			}
			ref T src = ref DangerousGetPinnableReference();
			System.SpanHelpers.CopyTo(ref destination.DangerousGetPinnableReference(), length2, ref src, length);
			return true;
		}

		public static bool operator ==(Span<T> left, Span<T> right)
		{
			if (left._length == right._length)
			{
				return Unsafe.AreSame(ref left.DangerousGetPinnableReference(), ref right.DangerousGetPinnableReference());
			}
			return false;
		}

		public static implicit operator ReadOnlySpan<T>(Span<T> span)
		{
			return new ReadOnlySpan<T>(span._pinnable, span._byteOffset, span._length);
		}

		public unsafe override string ToString()
		{
			if (typeof(T) == typeof(char))
			{
				fixed (char* value = &Unsafe.As<T, char>(ref DangerousGetPinnableReference()))
				{
					return new string(value, 0, _length);
				}
			}
			return $"System.Span<{typeof(T).Name}>[{_length}]";
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span<T> Slice(int start)
		{
			if ((uint)start > (uint)_length)
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			IntPtr byteOffset = _byteOffset.Add<T>(start);
			int length = _length - start;
			return new Span<T>(_pinnable, byteOffset, length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span<T> Slice(int start, int length)
		{
			if ((uint)start > (uint)_length || (uint)length > (uint)(_length - start))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			IntPtr byteOffset = _byteOffset.Add<T>(start);
			return new Span<T>(_pinnable, byteOffset, length);
		}

		public T[] ToArray()
		{
			if (_length == 0)
			{
				return System.SpanHelpers.PerTypeValues<T>.EmptyArray;
			}
			T[] array = new T[_length];
			CopyTo(array);
			return array;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ref T DangerousGetPinnableReference()
		{
			return ref Unsafe.AddByteOffset(ref ILHelpers.ObjectAsRef<T>(_pinnable), _byteOffset);
		}
	}
	internal sealed class SpanDebugView<T>
	{
		private readonly T[] _array;

		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
		public T[] Items => _array;

		public SpanDebugView(Span<T> span)
		{
			_array = span.ToArray();
		}

		public SpanDebugView(ReadOnlySpan<T> span)
		{
			_array = span.ToArray();
		}
	}
	internal static class SpanHelpers
	{
		internal struct ComparerComparable<T, TComparer> : IComparable<T> where TComparer : IComparer<T>
		{
			private readonly T _value;

			private readonly TComparer _comparer;

			public ComparerComparable(T value, TComparer comparer)
			{
				_value = value;
				_comparer = comparer;
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public int CompareTo(T? other)
			{
				return _comparer.Compare(_value, other);
			}
		}

		[StructLayout(LayoutKind.Sequential, Size = 64)]
		private struct Reg64
		{
		}

		[StructLayout(LayoutKind.Sequential, Size = 32)]
		private struct Reg32
		{
		}

		[StructLayout(LayoutKind.Sequential, Size = 16)]
		private struct Reg16
		{
		}

		public static class PerTypeValues<T>
		{
			public static readonly bool IsReferenceOrContainsReferences = IsReferenceOrContainsReferencesCore(typeof(T));

			public static readonly T[] EmptyArray = ArrayEx.Empty<T>();

			public static readonly IntPtr ArrayAdjustment = MeasureArrayAdjustment();

			private static IntPtr MeasureArrayAdjustment()
			{
				T[] array = new T[1];
				return Unsafe.ByteOffset(ref ILHelpers.ObjectAsRef<T>((object)array), ref array[0]);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T>
		{
			if (comparable == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.comparable);
			}
			return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable);
		}

		public static int BinarySearch<T, TComparable>(ref T spanStart, int length, TComparable comparable) where TComparable : IComparable<T>
		{
			int num = 0;
			int num2 = length - 1;
			while (num <= num2)
			{
				int num3 = num2 + num >>> 1;
				ref TComparable reference = ref comparable;
				TComparable val = default(TComparable);
				if (val == null)
				{
					val = reference;
					reference = ref val;
				}
				int num4 = reference.CompareTo(Unsafe.Add(ref spanStart, num3));
				if (num4 == 0)
				{
					return num3;
				}
				if (num4 > 0)
				{
					num = num3 + 1;
				}
				else
				{
					num2 = num3 - 1;
				}
			}
			return ~num;
		}

		public static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
		{
			if (valueLength == 0)
			{
				return 0;
			}
			byte value2 = value;
			ref byte second = ref Unsafe.Add(ref value, 1);
			int num = valueLength - 1;
			int num2 = 0;
			while (true)
			{
				int num3 = searchSpaceLength - num2 - num;
				if (num3 <= 0)
				{
					break;
				}
				int num4 = IndexOf(ref Unsafe.Add(ref searchSpace, num2), value2, num3);
				if (num4 == -1)
				{
					break;
				}
				num2 += num4;
				if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num2 + 1), ref second, num))
				{
					return num2;
				}
				num2++;
			}
			return -1;
		}

		public static int IndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
		{
			if (valueLength == 0)
			{
				return 0;
			}
			int num = -1;
			for (int i = 0; i < valueLength; i++)
			{
				int num2 = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength);
				if ((uint)num2 < (uint)num)
				{
					num = num2;
					searchSpaceLength = num2;
					if (num == 0)
					{
						break;
					}
				}
			}
			return num;
		}

		public static int LastIndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
		{
			if (valueLength == 0)
			{
				return 0;
			}
			int num = -1;
			for (int i = 0; i < valueLength; i++)
			{
				int num2 = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength);
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		public static int IndexOf(ref byte searchSpace, byte value, int length)
		{
			nint num = 0;
			nint num2 = length;
			while (true)
			{
				if ((nuint)num2 >= (nuint)8u)
				{
					num2 -= 8;
					if (value != Unsafe.AddByteOffset(ref searchSpace, num))
					{
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
						{
							goto IL_0109;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
						{
							goto IL_010f;
						}
						if (value != Unsafe.AddByteOffset(ref searchSpace, num + 3))
						{
							if (value != Unsafe.AddByteOffset(ref searchSpace, num + 4))
							{
								if (value != Unsafe.AddByteOffset(ref searchSpace, num + 5))
								{
									if (value != Unsafe.AddByteOffset(ref searchSpace, num + 6))
									{
										if (value == Unsafe.AddByteOffset(ref searchSpace, num + 7))
										{
											break;
										}
										num += 8;
										continue;
									}
									return (int)(num + 6);
								}
								return (int)(num + 5);
							}
							return (int)(num + 4);
						}
						goto IL_0115;
					}
				}
				else
				{
					if ((nuint)num2 >= (nuint)4u)
					{
						num2 -= 4;
						if (value == Unsafe.AddByteOffset(ref searchSpace, num))
						{
							goto IL_0106;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
						{
							goto IL_0109;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
						{
							goto IL_010f;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
						{
							goto IL_0115;
						}
						num += 4;
					}
					while (true)
					{
						if (num2 != 0)
						{
							num2--;
							if (value == Unsafe.AddByteOffset(ref searchSpace, num))
							{
								break;
							}
							num++;
							continue;
						}
						return -1;
					}
				}
				goto IL_0106;
				IL_010f:
				return (int)(num + 2);
				IL_0106:
				return (int)num;
				IL_0109:
				return (int)(num + 1);
				IL_0115:
				return (int)(num + 3);
			}
			return (int)(num + 7);
		}

		public static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
		{
			if (valueLength == 0)
			{
				return 0;
			}
			byte value2 = value;
			ref byte second = ref Unsafe.Add(ref value, 1);
			int num = valueLength - 1;
			int num2 = 0;
			while (true)
			{
				int num3 = searchSpaceLength - num2 - num;
				if (num3 <= 0)
				{
					break;
				}
				int num4 = LastIndexOf(ref searchSpace, value2, num3);
				if (num4 == -1)
				{
					break;
				}
				if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num4 + 1), ref second, num))
				{
					return num4;
				}
				num2 += num3 - num4;
			}
			return -1;
		}

		public static int LastIndexOf(ref byte searchSpace, byte value, int length)
		{
			nint num = length;
			nint num2 = length;
			while (true)
			{
				if ((nuint)num2 >= (nuint)8u)
				{
					num2 -= 8;
					num -= 8;
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 7))
					{
						break;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 6))
					{
						return (int)(num + 6);
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 5))
					{
						return (int)(num + 5);
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 4))
					{
						return (int)(num + 4);
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
					{
						goto IL_010f;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
					{
						goto IL_0109;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
					{
						goto IL_0103;
					}
					if (value != Unsafe.AddByteOffset(ref searchSpace, num))
					{
						continue;
					}
				}
				else
				{
					if ((nuint)num2 >= (nuint)4u)
					{
						num2 -= 4;
						num -= 4;
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 3))
						{
							goto IL_010f;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 2))
						{
							goto IL_0109;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num + 1))
						{
							goto IL_0103;
						}
						if (value == Unsafe.AddByteOffset(ref searchSpace, num))
						{
							goto IL_0100;
						}
					}
					do
					{
						if (num2 != 0)
						{
							num2--;
							num--;
							continue;
						}
						return -1;
					}
					while (value != Unsafe.AddByteOffset(ref searchSpace, num));
				}
				goto IL_0100;
				IL_0109:
				return (int)(num + 2);
				IL_010f:
				return (int)(num + 3);
				IL_0103:
				return (int)(num + 1);
				IL_0100:
				return (int)num;
			}
			return (int)(num + 7);
		}

		public static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
		{
			nint num = 0;
			nint num2 = length;
			while (true)
			{
				if ((nuint)num2 >= (nuint)8u)
				{
					num2 -= 8;
					uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
					if (value0 != num3 && value1 != num3)
					{
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_019b;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_01a1;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
						if (value0 != num3 && value1 != num3)
						{
							num3 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
							if (value0 != num3 && value1 != num3)
							{
								num3 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
								if (value0 != num3 && value1 != num3)
								{
									num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
									if (value0 != num3 && value1 != num3)
									{
										num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
										if (value0 == num3 || value1 == num3)
										{
											break;
										}
										num += 8;
										continue;
									}
									return (int)(num + 6);
								}
								return (int)(num + 5);
							}
							return (int)(num + 4);
						}
						goto IL_01a7;
					}
				}
				else
				{
					if ((nuint)num2 >= (nuint)4u)
					{
						num2 -= 4;
						uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_0198;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_019b;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_01a1;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
						if (value0 == num3 || value1 == num3)
						{
							goto IL_01a7;
						}
						num += 4;
					}
					while (true)
					{
						if (num2 != 0)
						{
							num2--;
							uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
							if (value0 == num3 || value1 == num3)
							{
								break;
							}
							num++;
							continue;
						}
						return -1;
					}
				}
				goto IL_0198;
				IL_01a1:
				return (int)(num + 2);
				IL_019b:
				return (int)(num + 1);
				IL_01a7:
				return (int)(num + 3);
				IL_0198:
				return (int)num;
			}
			return (int)(num + 7);
		}

		public static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
		{
			nint num = 0;
			nint num2 = length;
			while (true)
			{
				if ((nuint)num2 >= (nuint)8u)
				{
					num2 -= 8;
					uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
					if (value0 != num3 && value1 != num3 && value2 != num3)
					{
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_020a;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_0210;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
						if (value0 != num3 && value1 != num3 && value2 != num3)
						{
							num3 = Unsafe.AddByteOffset(ref searchSpace, num + 4);
							if (value0 != num3 && value1 != num3 && value2 != num3)
							{
								num3 = Unsafe.AddByteOffset(ref searchSpace, num + 5);
								if (value0 != num3 && value1 != num3 && value2 != num3)
								{
									num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
									if (value0 != num3 && value1 != num3 && value2 != num3)
									{
										num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
										if (value0 == num3 || value1 == num3 || value2 == num3)
										{
											break;
										}
										num += 8;
										continue;
									}
									return (int)(num + 6);
								}
								return (int)(num + 5);
							}
							return (int)(num + 4);
						}
						goto IL_0216;
					}
				}
				else
				{
					if ((nuint)num2 >= (nuint)4u)
					{
						num2 -= 4;
						uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_0207;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 1);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_020a;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 2);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_0210;
						}
						num3 = Unsafe.AddByteOffset(ref searchSpace, num + 3);
						if (value0 == num3 || value1 == num3 || value2 == num3)
						{
							goto IL_0216;
						}
						num += 4;
					}
					while (true)
					{
						if (num2 != 0)
						{
							num2--;
							uint num3 = Unsafe.AddByteOffset(ref searchSpace, num);
							if (value0 == num3 || value1 == num3 || value2 == num3)
							{
								break;
							}
							num++;
							continue;
						}
						return -1;
					}
				}
				goto IL_0207;
				IL_0207:
				return (int)num;
				IL_0210:
				return (int)(num + 2);
				IL_020a:
				return (int)(num + 1);
				IL_0216:
				return (int)(num + 3);
			}
			return (int)(num + 7);
		}

		public static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
		{
			nint num = length;
			nint num2 = length;
			while (true)
			{
				if ((nuint)num2 >= (nuint)8u)
				{
					num2 -= 8;
					num -= 8;
					uint num3 = Unsafe.AddByteOffset(ref searchSpace, num + 7);
					if (value0 == num3 || value1 == num3)
					{
						break;
					}
					num3 = Unsafe.AddByteOffset(ref searchSpace, num + 6);
					if (value0 == num3 || value1 == nu

plugins/MonoMod.Core.dll

Decompiled a month ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using Iced.Intel;
using Microsoft.CodeAnalysis;
using Microsoft.Win32.SafeHandles;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod;
using MonoMod.Core.Interop;
using MonoMod.Core.Interop.Attributes;
using MonoMod.Core.Platforms;
using MonoMod.Core.Platforms.Architectures;
using MonoMod.Core.Platforms.Architectures.AltEntryFactories;
using MonoMod.Core.Platforms.Memory;
using MonoMod.Core.Platforms.Runtimes;
using MonoMod.Core.Platforms.Systems;
using MonoMod.Core.Utils;
using MonoMod.Logs;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]
[assembly: DisableRuntimeMarshalling]
[assembly: CLSCompliant(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = ".NET Framework 4.5.2")]
[assembly: AssemblyCompany("0x0ade, DaNike")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2024 0x0ade, DaNike")]
[assembly: AssemblyDescription("The code functionality for runtime detouring. Use `DetourFactory.Current` to get a DetourFactory capable of installing unique method detours.\n      \n      WARNING: THIS IS A LOW-LEVEL LIBRARY THAT IS DIFFICULT TO USE ON ITS OWN. If possible, use MonoMod.RuntimeDetour instead.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+e79d24413")]
[assembly: AssemblyProduct("MonoMod.Core")]
[assembly: AssemblyTitle("MonoMod.Core")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoMod/MonoMod.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		MMDbgLog.LogVersion();
	}
}
[CompilerGenerated]
internal unsafe delegate CoreCLR.CorJitResult <>f__AnonymousDelegate0(IntPtr arg1, IntPtr arg2, CoreCLR.V21.CORINFO_METHOD_INFO* arg3, uint arg4, byte** arg5, uint* arg6);
[CompilerGenerated]
internal unsafe delegate void <>f__AnonymousDelegate1(IntPtr arg1, CoreCLR.V70.AllocMemArgs* arg2);
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = 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 MonoMod
{
	internal static class MMDbgLog
	{
		[InterpolatedStringHandler]
		internal ref struct DebugLogSpamStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogSpamStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)0, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogTraceStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogTraceStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)1, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogInfoStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogInfoStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)2, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogWarningStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogWarningStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)3, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogErrorStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogErrorStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)4, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		public static bool IsWritingLog => DebugLog.IsWritingLog;

		[ModuleInitializer]
		internal static void LogVersion()
		{
			Info("Version 1.2.1");
		}

		public static void Log(LogLevel level, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DebugLog.Log("MonoMod.Core", level, message);
		}

		public static void Log(LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DebugLog.Log("MonoMod.Core", level, ref message);
		}

		public static void Spam(string message)
		{
			Log((LogLevel)0, message);
		}

		public static void Spam(ref DebugLogSpamStringHandler message)
		{
			Log((LogLevel)0, ref message.handler);
		}

		public static void Trace(string message)
		{
			Log((LogLevel)1, message);
		}

		public static void Trace(ref DebugLogTraceStringHandler message)
		{
			Log((LogLevel)1, ref message.handler);
		}

		public static void Info(string message)
		{
			Log((LogLevel)2, message);
		}

		public static void Info(ref DebugLogInfoStringHandler message)
		{
			Log((LogLevel)2, ref message.handler);
		}

		public static void Warning(string message)
		{
			Log((LogLevel)3, message);
		}

		public static void Warning(ref DebugLogWarningStringHandler message)
		{
			Log((LogLevel)3, ref message.handler);
		}

		public static void Error(string message)
		{
			Log((LogLevel)4, message);
		}

		public static void Error(ref DebugLogErrorStringHandler message)
		{
			Log((LogLevel)4, ref message.handler);
		}
	}
	internal static class MultiTargetShims
	{
		public static TypeReference GetConstraintType(this GenericParameterConstraint constraint)
		{
			return constraint.ConstraintType;
		}
	}
}
namespace MonoMod.SourceGen.Attributes
{
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class EmitILOverloadsAttribute : Attribute
	{
		public EmitILOverloadsAttribute(string filename, string kind)
		{
		}
	}
	internal static class ILOverloadKind
	{
		public const string Cursor = "ILCursor";

		public const string Matcher = "ILMatcher";
	}
}
namespace MonoMod.Core
{
	[CLSCompliant(true)]
	public interface ICoreDetour : ICoreDetourBase, IDisposable
	{
		MethodBase Source { get; }

		MethodBase Target { get; }
	}
	public interface ICoreDetourWithClone : ICoreDetour, ICoreDetourBase, IDisposable
	{
		MethodInfo? SourceMethodClone { get; }

		DynamicMethodDefinition? SourceMethodCloneIL { get; }
	}
	public interface ICoreDetourBase : IDisposable
	{
		bool IsApplied { get; }

		void Apply();

		void Undo();
	}
	public interface ICoreNativeDetour : ICoreDetourBase, IDisposable
	{
		IntPtr Source { get; }

		IntPtr Target { get; }

		bool HasOrigEntrypoint { get; }

		IntPtr OrigEntrypoint { get; }
	}
	[CLSCompliant(true)]
	public interface IDetourFactory
	{
		ICoreDetour CreateDetour(CreateDetourRequest request);

		ICoreNativeDetour CreateNativeDetour(CreateNativeDetourRequest request);
	}
	[CLSCompliant(true)]
	public readonly record struct CreateDetourRequest
	{
		public MethodBase Source { get; init; }

		public MethodBase Target { get; init; }

		public bool ApplyByDefault { get; init; }

		public bool CreateSourceCloneIfNotILClone { get; init; }

		public CreateDetourRequest(MethodBase Source, MethodBase Target)
		{
			CreateSourceCloneIfNotILClone = false;
			this.Source = Source;
			this.Target = Target;
			ApplyByDefault = true;
		}

		[CompilerGenerated]
		public void Deconstruct(out MethodBase Source, out MethodBase Target)
		{
			Source = this.Source;
			Target = this.Target;
		}
	}
	[CLSCompliant(true)]
	public readonly record struct CreateNativeDetourRequest(IntPtr Source, IntPtr Target)
	{
		public bool ApplyByDefault { get; init; } = true;

	}
	[CLSCompliant(true)]
	public static class DetourFactory
	{
		private static PlatformTripleDetourFactory? lazyCurrent;

		private static readonly Func<PlatformTripleDetourFactory> createDefaultFactoryFunc = CreateDefaultFactory;

		public static IDetourFactory Current
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return Helpers.GetOrInit<PlatformTripleDetourFactory>(ref lazyCurrent, createDefaultFactoryFunc);
			}
		}

		private static PlatformTripleDetourFactory CreateDefaultFactory()
		{
			return new PlatformTripleDetourFactory(PlatformTriple.Current);
		}

		public static ICoreDetour CreateDetour(this IDetourFactory factory, MethodBase source, MethodBase target, bool applyByDefault = true)
		{
			Helpers.ThrowIfArgumentNull<IDetourFactory>(factory, "factory");
			return factory.CreateDetour(new CreateDetourRequest(source, target)
			{
				ApplyByDefault = applyByDefault
			});
		}

		public static ICoreNativeDetour CreateNativeDetour(this IDetourFactory factory, IntPtr source, IntPtr target, bool applyByDefault = true)
		{
			Helpers.ThrowIfArgumentNull<IDetourFactory>(factory, "factory");
			return factory.CreateNativeDetour(new CreateNativeDetourRequest(source, target)
			{
				ApplyByDefault = applyByDefault
			});
		}
	}
	internal static class AssemblyInfo
	{
		public const string AssemblyName = "MonoMod.Core";

		public const string AssemblyVersion = "1.2.1";
	}
}
namespace MonoMod.Core.Utils
{
	[Flags]
	public enum AddressKind
	{
		Rel32 = 0,
		Rel64 = 2,
		Abs32 = 1,
		Abs64 = 3,
		PrecodeFixupThunkRel32 = 4,
		PrecodeFixupThunkRel64 = 6,
		PrecodeFixupThunkAbs32 = 5,
		PrecodeFixupThunkAbs64 = 7,
		Indirect = 8
	}
	public static class AddressKindExtensions
	{
		public const AddressKind IsAbsoluteField = AddressKind.Abs32;

		public const AddressKind Is64BitField = AddressKind.Rel64;

		public const AddressKind IsPrecodeFixupField = AddressKind.PrecodeFixupThunkRel32;

		public const AddressKind IsIndirectField = AddressKind.Indirect;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsRelative(this AddressKind value)
		{
			return (value & AddressKind.Abs32) == 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsAbsolute(this AddressKind value)
		{
			return !value.IsRelative();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is32Bit(this AddressKind value)
		{
			return (value & AddressKind.Rel64) == 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is64Bit(this AddressKind value)
		{
			return !value.Is32Bit();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsPrecodeFixup(this AddressKind value)
		{
			return (value & AddressKind.PrecodeFixupThunkRel32) != 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsIndirect(this AddressKind value)
		{
			return (value & AddressKind.Indirect) != 0;
		}

		public static void Validate(this AddressKind value, [CallerArgumentExpression("value")] string argName = "")
		{
			if (((uint)value & 0xFFFFFFF0u) != 0)
			{
				throw new ArgumentOutOfRangeException(argName);
			}
		}

		public static string FastToString(this AddressKind value)
		{
			FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
			((FormatInterpolatedStringHandler)(ref val))..ctor(0, 4);
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(value.IsPrecodeFixup() ? "PrecodeFixupThunk" : "");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(value.IsRelative() ? "Rel" : "Abs");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(value.Is32Bit() ? "32" : "64");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(value.IsIndirect() ? "Indirect" : "");
			return DebugFormatter.Format(ref val);
		}
	}
	public readonly struct AddressMeaning : IEquatable<AddressMeaning>
	{
		public AddressKind Kind { get; }

		public int RelativeToOffset { get; }

		public AddressMeaning(AddressKind kind)
		{
			kind.Validate("kind");
			if (!kind.IsAbsolute())
			{
				throw new ArgumentOutOfRangeException("kind");
			}
			Kind = kind;
			RelativeToOffset = 0;
		}

		public AddressMeaning(AddressKind kind, int relativeOffset)
		{
			kind.Validate("kind");
			if (!kind.IsRelative())
			{
				throw new ArgumentOutOfRangeException("kind");
			}
			if (relativeOffset < 0)
			{
				throw new ArgumentOutOfRangeException("relativeOffset");
			}
			Kind = kind;
			RelativeToOffset = relativeOffset;
		}

		private unsafe static nint DoProcessAddress(AddressKind kind, nint basePtr, int offset, ulong address)
		{
			nint num;
			if (kind.IsAbsolute())
			{
				num = (nint)address;
			}
			else
			{
				long num2 = (kind.Is32Bit() ? System.Runtime.CompilerServices.Unsafe.As<ulong, int>(ref address) : System.Runtime.CompilerServices.Unsafe.As<ulong, long>(ref address));
				num = (nint)(basePtr + offset + num2);
			}
			if (kind.IsIndirect())
			{
				num = *(nint*)num;
			}
			return num;
		}

		public nint ProcessAddress(nint basePtr, int offset, ulong address)
		{
			return DoProcessAddress(Kind, basePtr, offset + RelativeToOffset, address);
		}

		public override bool Equals(object? obj)
		{
			if (obj is AddressMeaning other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(AddressMeaning other)
		{
			if (Kind == other.Kind)
			{
				return RelativeToOffset == other.RelativeToOffset;
			}
			return false;
		}

		public override string ToString()
		{
			FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
			((FormatInterpolatedStringHandler)(ref val))..ctor(26, 2);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("AddressMeaning(");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(Kind.FastToString());
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(", offset: ");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<int>(RelativeToOffset);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(")");
			return DebugFormatter.Format(ref val);
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Kind, RelativeToOffset);
		}

		public static bool operator ==(AddressMeaning left, AddressMeaning right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(AddressMeaning left, AddressMeaning right)
		{
			return !(left == right);
		}
	}
	public sealed class BytePattern
	{
		private enum SegmentKind
		{
			Literal,
			MaskedLiteral,
			Any,
			AnyRepeating,
			Address
		}

		private record struct PatternSegment(int Start, int Length, SegmentKind Kind)
		{
			public ReadOnlySpan<T> SliceOf<T>(ReadOnlySpan<T> span)
			{
				return span.Slice(Start, Length);
			}

			public ReadOnlyMemory<T> SliceOf<T>(ReadOnlyMemory<T> mem)
			{
				return mem.Slice(Start, Length);
			}
		}

		private readonly record struct ComputeSegmentsResult(PatternSegment[] Segments, int MinLen, int AddrBytes);

		private const ushort MaskMask = 65280;

		public const byte BAnyValue = 0;

		public const ushort SAnyValue = 65280;

		public const byte BAnyRepeatingValue = 1;

		public const ushort SAnyRepeatingValue = 65281;

		public const byte BAddressValue = 2;

		public const ushort SAddressValue = 65282;

		private readonly ReadOnlyMemory<byte> pattern;

		private readonly ReadOnlyMemory<byte> bitmask;

		private readonly PatternSegment[] segments;

		private (ReadOnlyMemory<byte> Bytes, int Offset)? lazyFirstLiteralSegment;

		public int AddressBytes { get; }

		public int MinLength { get; }

		public AddressMeaning AddressMeaning { get; }

		public bool MustMatchAtStart { get; }

		public (ReadOnlyMemory<byte> Bytes, int Offset) FirstLiteralSegment
		{
			get
			{
				(ReadOnlyMemory<byte>, int) valueOrDefault = lazyFirstLiteralSegment.GetValueOrDefault();
				if (!lazyFirstLiteralSegment.HasValue)
				{
					valueOrDefault = GetFirstLiteralSegment();
					lazyFirstLiteralSegment = valueOrDefault;
					return valueOrDefault;
				}
				return valueOrDefault;
			}
		}

		public BytePattern(AddressMeaning meaning, params ushort[] pattern)
			: this(meaning, mustMatchAtStart: false, pattern.AsMemory())
		{
		}

		public BytePattern(AddressMeaning meaning, bool mustMatchAtStart, params ushort[] pattern)
			: this(meaning, mustMatchAtStart, pattern.AsMemory())
		{
		}

		public BytePattern(AddressMeaning meaning, ReadOnlyMemory<ushort> pattern)
			: this(meaning, mustMatchAtStart: false, pattern)
		{
		}

		public BytePattern(AddressMeaning meaning, bool mustMatchAtStart, ReadOnlyMemory<ushort> pattern)
		{
			AddressMeaning = meaning;
			MustMatchAtStart = mustMatchAtStart;
			ComputeSegmentsFromShort(pattern).Deconstruct(out PatternSegment[] Segments, out int MinLen, out int AddrBytes);
			segments = Segments;
			MinLength = MinLen;
			AddressBytes = AddrBytes;
			Memory<byte> memory = new byte[pattern.Length * 2].AsMemory();
			Memory<byte> memory2 = memory.Slice(0, pattern.Length);
			Memory<byte> memory3 = memory.Slice(pattern.Length);
			for (int i = 0; i < pattern.Length; i++)
			{
				ushort num = pattern.Span[i];
				byte b = (byte)((num & 0xFF00) >> 8);
				byte b2 = (byte)(num & 0xFFFF00FFu);
				if ((b == 0 || b == byte.MaxValue) ? true : false)
				{
					b = (byte)(~b);
				}
				memory2.Span[i] = (byte)(b2 & b);
				memory3.Span[i] = b;
			}
			this.pattern = memory2;
			bitmask = memory3;
		}

		public BytePattern(AddressMeaning meaning, ReadOnlyMemory<byte> mask, ReadOnlyMemory<byte> pattern)
			: this(meaning, mustMatchAtStart: false, mask, pattern)
		{
		}

		public BytePattern(AddressMeaning meaning, bool mustMatchAtStart, ReadOnlyMemory<byte> mask, ReadOnlyMemory<byte> pattern)
		{
			AddressMeaning = meaning;
			MustMatchAtStart = mustMatchAtStart;
			ComputeSegmentsFromMaskPattern(mask, pattern).Deconstruct(out PatternSegment[] Segments, out int MinLen, out int AddrBytes);
			segments = Segments;
			MinLength = MinLen;
			AddressBytes = AddrBytes;
			this.pattern = pattern;
			bitmask = mask;
		}

		private unsafe static ComputeSegmentsResult ComputeSegmentsFromShort(ReadOnlyMemory<ushort> pattern)
		{
			return ComputeSegmentsCore((delegate*<ReadOnlyMemory<ushort>, int, SegmentKind>)(&KindForShort), pattern.Length, pattern);
			static SegmentKind KindForShort(ReadOnlyMemory<ushort> pattern, int idx)
			{
				ushort num = pattern.Span[idx];
				switch (num & 0xFF00)
				{
				case 0:
					return SegmentKind.Literal;
				case 65280:
				{
					int num2 = num & 0xFF;
					return num2 switch
					{
						0 => SegmentKind.Any, 
						1 => SegmentKind.AnyRepeating, 
						2 => SegmentKind.Address, 
						_ => throw new ArgumentException($"Pattern contained unknown special value {num2:x2}", "pattern"), 
					};
				}
				default:
					return SegmentKind.MaskedLiteral;
				}
			}
		}

		private unsafe static ComputeSegmentsResult ComputeSegmentsFromMaskPattern(ReadOnlyMemory<byte> mask, ReadOnlyMemory<byte> pattern)
		{
			if (mask.Length < pattern.Length)
			{
				throw new ArgumentException("Mask buffer shorter than pattern", "mask");
			}
			return ComputeSegmentsCore((delegate*<(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>), int, SegmentKind>)(&KindForIdx), pattern.Length, (mask, pattern));
			static SegmentKind KindForIdx((ReadOnlyMemory<byte> mask, ReadOnlyMemory<byte> pattern) t, int idx)
			{
				switch (t.mask.Span[idx])
				{
				case 0:
				{
					byte b = t.pattern.Span[idx];
					return b switch
					{
						0 => SegmentKind.Any, 
						1 => SegmentKind.AnyRepeating, 
						2 => SegmentKind.Address, 
						_ => throw new ArgumentException($"Pattern contained unknown special value {b:x2}", "pattern"), 
					};
				}
				case byte.MaxValue:
					return SegmentKind.Literal;
				default:
					return SegmentKind.MaskedLiteral;
				}
			}
		}

		private unsafe static ComputeSegmentsResult ComputeSegmentsCore<TPattern>(delegate*<TPattern, int, SegmentKind> kindForIdx, int patternLength, TPattern pattern)
		{
			if (patternLength == 0)
			{
				throw new ArgumentException("Pattern cannot be empty", "pattern");
			}
			int num = 0;
			SegmentKind segmentKind = SegmentKind.AnyRepeating;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = -1;
			for (int i = 0; i < patternLength; i++)
			{
				SegmentKind segmentKind2 = kindForIdx(pattern, i);
				int num6 = num4;
				num4 = num6 + segmentKind2 switch
				{
					SegmentKind.Literal => 1, 
					SegmentKind.MaskedLiteral => 1, 
					SegmentKind.Any => 1, 
					SegmentKind.AnyRepeating => 0, 
					SegmentKind.Address => 1, 
					_ => 0, 
				};
				if (segmentKind2 != segmentKind)
				{
					if (num5 < 0)
					{
						num5 = i;
					}
					num++;
					num2 = 1;
				}
				else
				{
					num2++;
				}
				if (segmentKind2 == SegmentKind.Address)
				{
					num3++;
				}
				segmentKind = segmentKind2;
			}
			if (num > 0 && segmentKind == SegmentKind.AnyRepeating)
			{
				num--;
			}
			if (num == 0 || num4 <= 0)
			{
				throw new ArgumentException("Pattern has no meaningful segments", "pattern");
			}
			PatternSegment[] array = new PatternSegment[num];
			num = 0;
			segmentKind = SegmentKind.AnyRepeating;
			num2 = 0;
			for (int j = num5; j < patternLength; j++)
			{
				if (num > array.Length)
				{
					break;
				}
				SegmentKind num7 = kindForIdx(pattern, j);
				if (num7 != segmentKind)
				{
					if (num > 0)
					{
						array[num - 1] = new PatternSegment(j - num2, num2, segmentKind);
						if (num > 1 && segmentKind == SegmentKind.Any && array[num - 2].Kind == SegmentKind.AnyRepeating)
						{
							Helpers.Swap<PatternSegment>(ref array[num - 2], ref array[num - 1]);
						}
					}
					num++;
					num2 = 1;
				}
				else
				{
					num2++;
				}
				segmentKind = num7;
			}
			if (segmentKind != SegmentKind.AnyRepeating && num > 0)
			{
				array[num - 1] = new PatternSegment(patternLength - num2, num2, segmentKind);
			}
			return new ComputeSegmentsResult(array, num4, num3);
		}

		public bool TryMatchAt(ReadOnlySpan<byte> data, out ulong address, out int length)
		{
			if (data.Length < MinLength)
			{
				length = 0;
				address = 0uL;
				return false;
			}
			ReadOnlySpan<byte> span = pattern.Span;
			Span<byte> addrBuf = stackalloc byte[8];
			bool result = TryMatchAtImpl(span, data, addrBuf, out length, 0);
			address = System.Runtime.CompilerServices.Unsafe.ReadUnaligned<ulong>(ref addrBuf[0]);
			return result;
		}

		public bool TryMatchAt(ReadOnlySpan<byte> data, Span<byte> addrBuf, out int length)
		{
			if (data.Length < MinLength)
			{
				length = 0;
				return false;
			}
			ReadOnlySpan<byte> span = pattern.Span;
			return TryMatchAtImpl(span, data, addrBuf, out length, 0);
		}

		private bool TryMatchAtImpl(ReadOnlySpan<byte> patternSpan, ReadOnlySpan<byte> data, Span<byte> addrBuf, out int length, int startAtSegment)
		{
			int num = 0;
			int num2 = startAtSegment;
			while (true)
			{
				if (num2 < segments.Length)
				{
					PatternSegment patternSegment = segments[num2];
					switch (patternSegment.Kind)
					{
					case SegmentKind.Literal:
						if (data.Length - num >= patternSegment.Length)
						{
							ReadOnlySpan<byte> span = patternSegment.SliceOf(patternSpan);
							if (span.SequenceEqual(data.Slice(num, span.Length)))
							{
								num += patternSegment.Length;
								goto IL_0192;
							}
						}
						break;
					case SegmentKind.MaskedLiteral:
						if (data.Length - num >= patternSegment.Length)
						{
							ReadOnlySpan<byte> readOnlySpan2 = patternSegment.SliceOf(patternSpan);
							ReadOnlySpan<byte> readOnlySpan3 = patternSegment.SliceOf(bitmask.Span);
							if (Helpers.MaskedSequenceEqual(readOnlySpan2, data.Slice(num, readOnlySpan2.Length), readOnlySpan3))
							{
								num += patternSegment.Length;
								goto IL_0192;
							}
						}
						break;
					case SegmentKind.Any:
						if (data.Length - num >= patternSegment.Length)
						{
							num += patternSegment.Length;
							goto IL_0192;
						}
						break;
					case SegmentKind.Address:
						if (data.Length - num >= patternSegment.Length)
						{
							ReadOnlySpan<byte> readOnlySpan = data.Slice(num, Math.Min(patternSegment.Length, addrBuf.Length));
							readOnlySpan.CopyTo(addrBuf);
							addrBuf = addrBuf.Slice(Math.Min(addrBuf.Length, readOnlySpan.Length));
							num += patternSegment.Length;
							goto IL_0192;
						}
						break;
					case SegmentKind.AnyRepeating:
					{
						int offset;
						int length2;
						bool result = ScanForNextLiteral(patternSpan, data.Slice(num), addrBuf, out offset, out length2, num2);
						length = num + offset + length2;
						return result;
					}
					default:
						throw new InvalidOperationException();
					}
					break;
				}
				length = num;
				return true;
				IL_0192:
				num2++;
			}
			length = 0;
			return false;
		}

		public bool TryFindMatch(ReadOnlySpan<byte> data, out ulong address, out int offset, out int length)
		{
			if (data.Length < MinLength)
			{
				length = (offset = 0);
				address = 0uL;
				return false;
			}
			ReadOnlySpan<byte> span = pattern.Span;
			Span<byte> addrBuf = stackalloc byte[8];
			bool result;
			if (MustMatchAtStart)
			{
				offset = 0;
				result = TryMatchAtImpl(span, data, addrBuf, out length, 0);
			}
			else
			{
				result = ScanForNextLiteral(span, data, addrBuf, out offset, out length, 0);
			}
			address = System.Runtime.CompilerServices.Unsafe.ReadUnaligned<ulong>(ref addrBuf[0]);
			return result;
		}

		public bool TryFindMatch(ReadOnlySpan<byte> data, Span<byte> addrBuf, out int offset, out int length)
		{
			if (data.Length < MinLength)
			{
				length = (offset = 0);
				return false;
			}
			ReadOnlySpan<byte> span = pattern.Span;
			if (MustMatchAtStart)
			{
				offset = 0;
				return TryMatchAtImpl(span, data, addrBuf, out length, 0);
			}
			return ScanForNextLiteral(span, data, addrBuf, out offset, out length, 0);
		}

		private bool ScanForNextLiteral(ReadOnlySpan<byte> patternSpan, ReadOnlySpan<byte> data, Span<byte> addrBuf, out int offset, out int length, int segmentIndex)
		{
			var (patternSegment, num) = GetNextLiteralSegment(segmentIndex);
			if (num + patternSegment.Length > data.Length)
			{
				offset = (length = 0);
				return false;
			}
			int num2 = 0;
			while (true)
			{
				int num3 = data.Slice(num + num2).IndexOf(patternSegment.SliceOf(patternSpan));
				if (num3 < 0)
				{
					offset = (length = 0);
					return false;
				}
				if (TryMatchAtImpl(patternSpan, data.Slice(offset = num2 + num3), addrBuf, out length, segmentIndex))
				{
					break;
				}
				num2 += num3 + 1;
			}
			return true;
		}

		private (ReadOnlyMemory<byte> Bytes, int Offset) GetFirstLiteralSegment()
		{
			var (patternSegment, item) = GetNextLiteralSegment(0);
			return (patternSegment.SliceOf(pattern), item);
		}

		private (PatternSegment Segment, int LiteralOffset) GetNextLiteralSegment(int segmentIndexId)
		{
			if (segmentIndexId < 0 || segmentIndexId >= segments.Length)
			{
				throw new ArgumentOutOfRangeException("segmentIndexId");
			}
			int num = 0;
			while (segmentIndexId < segments.Length)
			{
				PatternSegment item = segments[segmentIndexId];
				if (item.Kind == SegmentKind.Literal)
				{
					return (item, num);
				}
				SegmentKind kind = item.Kind;
				if (((uint)(kind - 1) <= 1u || kind == SegmentKind.Address) ? true : false)
				{
					num += item.Length;
				}
				else if (item.Kind != SegmentKind.AnyRepeating)
				{
					throw new InvalidOperationException("Unknown segment kind");
				}
				segmentIndexId++;
			}
			return (default(PatternSegment), num);
		}
	}
	public sealed class BytePatternCollection : IEnumerable<BytePattern>, IEnumerable
	{
		private struct HomogenousPatternCollection
		{
			public BytePattern[]?[] Lut;

			public readonly int Offset;

			public int MinLength;

			public HomogenousPatternCollection(int offs)
			{
				Offset = offs;
				Lut = null;
				MinLength = int.MaxValue;
			}

			public void AddFirstBytes(ref FirstByteCollection bytes)
			{
				for (int i = 0; i < Lut.Length; i++)
				{
					if (Lut[i] != null)
					{
						bytes.Add((byte)i);
					}
				}
			}
		}

		private ref struct FirstByteCollection
		{
			private Span<byte> firstByteStore;

			private Span<byte> byteIndicies;

			private int firstBytesRecorded;

			public const int SingleAllocationSize = 512;

			public ReadOnlySpan<byte> FirstBytes => firstByteStore.Slice(0, firstBytesRecorded);

			public FirstByteCollection(Span<byte> store)
				: this(store.Slice(0, 256), store.Slice(256, 256))
			{
			}

			public FirstByteCollection(Span<byte> store, Span<byte> indicies)
			{
				firstByteStore = store;
				byteIndicies = indicies;
				firstBytesRecorded = 0;
				byteIndicies.Fill(byte.MaxValue);
			}

			public void Add(byte value)
			{
				ref byte reference = ref byteIndicies[value];
				if (reference == byte.MaxValue)
				{
					reference = (byte)firstBytesRecorded;
					firstByteStore[reference] = value;
					firstBytesRecorded = Math.Min(firstBytesRecorded + 1, 256);
				}
			}
		}

		private readonly HomogenousPatternCollection[] patternCollections;

		private readonly BytePattern[]? emptyPatterns;

		private ReadOnlyMemory<byte>? lazyPossibleFirstBytes;

		public int MinLength { get; }

		public int MaxMinLength { get; }

		public int MaxAddressLength { get; }

		private ReadOnlyMemory<byte> PossibleFirstBytes
		{
			get
			{
				ReadOnlyMemory<byte> valueOrDefault = lazyPossibleFirstBytes.GetValueOrDefault();
				if (!lazyPossibleFirstBytes.HasValue)
				{
					valueOrDefault = GetPossibleFirstBytes();
					lazyPossibleFirstBytes = valueOrDefault;
					return valueOrDefault;
				}
				return valueOrDefault;
			}
		}

		public BytePatternCollection(ReadOnlyMemory<BytePattern?> patterns)
		{
			int minLength;
			int maxMinLength;
			int maxAddrLength;
			(HomogenousPatternCollection[], BytePattern[]) tuple = ComputeLut(patterns, out minLength, out maxMinLength, out maxAddrLength);
			patternCollections = tuple.Item1;
			emptyPatterns = tuple.Item2;
			MinLength = minLength;
			MaxMinLength = maxMinLength;
			MaxAddressLength = maxAddrLength;
			Helpers.Assert(MinLength > 0, (string)null, "MinLength > 0");
		}

		public BytePatternCollection(params BytePattern?[] patterns)
			: this(patterns.AsMemory())
		{
		}

		public IEnumerator<BytePattern> GetEnumerator()
		{
			for (int j = 0; j < patternCollections.Length; j++)
			{
				BytePattern[]?[] coll = patternCollections[j].Lut;
				for (int k = 0; k < coll.Length; k++)
				{
					if (coll[k] != null)
					{
						BytePattern[] array = coll[k];
						for (int l = 0; l < array.Length; l++)
						{
							yield return array[l];
						}
					}
				}
			}
			if (emptyPatterns != null)
			{
				BytePattern[] array = emptyPatterns;
				for (int j = 0; j < array.Length; j++)
				{
					yield return array[j];
				}
			}
		}

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

		private static (HomogenousPatternCollection[], BytePattern[]?) ComputeLut(ReadOnlyMemory<BytePattern?> patterns, out int minLength, out int maxMinLength, out int maxAddrLength)
		{
			if (patterns.Length == 0)
			{
				minLength = 0;
				maxMinLength = 0;
				maxAddrLength = 0;
				return (ArrayEx.Empty<HomogenousPatternCollection>(), null);
			}
			Span<int> span = stackalloc int[256];
			minLength = int.MaxValue;
			maxMinLength = int.MinValue;
			maxAddrLength = 0;
			int[][] array = null;
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < patterns.Length; i++)
			{
				BytePattern bytePattern = patterns.Span[i];
				if (bytePattern == null)
				{
					continue;
				}
				if (bytePattern.MinLength < minLength)
				{
					minLength = bytePattern.MinLength;
				}
				if (bytePattern.MinLength > maxMinLength)
				{
					maxMinLength = bytePattern.MinLength;
				}
				if (bytePattern.AddressBytes > maxAddrLength)
				{
					maxAddrLength = bytePattern.AddressBytes;
				}
				var (readOnlyMemory, num3) = bytePattern.FirstLiteralSegment;
				if (readOnlyMemory.Length == 0)
				{
					num++;
					continue;
				}
				num2 = 1;
				if (num3 == 0)
				{
					span[readOnlyMemory.Span[0]]++;
					continue;
				}
				if (array == null || array.Length < num3)
				{
					Array.Resize(ref array, num3);
				}
				ref int[] reference = ref array[num3 - 1];
				if (reference == null)
				{
					reference = new int[256];
				}
				reference[readOnlyMemory.Span[0]]++;
			}
			if (array != null)
			{
				int[][] array2 = array;
				for (int j = 0; j < array2.Length; j++)
				{
					if (array2[j] != null)
					{
						num2++;
					}
				}
			}
			BytePattern[] array3 = ((num > 0) ? new BytePattern[num] : null);
			int num4 = 0;
			HomogenousPatternCollection[] array4 = new HomogenousPatternCollection[num2];
			int num5 = 1;
			array4[0] = new HomogenousPatternCollection(0);
			for (int k = 0; k < patterns.Length; k++)
			{
				BytePattern bytePattern2 = patterns.Span[k];
				if (bytePattern2 == null)
				{
					continue;
				}
				var (readOnlyMemory2, num6) = bytePattern2.FirstLiteralSegment;
				if (readOnlyMemory2.Length == 0)
				{
					array3[num4++] = bytePattern2;
					continue;
				}
				int num7 = -1;
				for (int l = 0; l < array4.Length; l++)
				{
					if (array4[l].Offset == num6)
					{
						num7 = l;
						break;
					}
				}
				if (num7 == -1)
				{
					num7 = num5++;
					array4[num7] = new HomogenousPatternCollection(num6);
				}
				ReadOnlySpan<int> arrayCounts2 = ((num6 == 0) ? span : array[num6 - 1].AsSpan());
				AddToPatternCollection(ref array4[num7], arrayCounts2, bytePattern2);
				if (num7 > 0 && array4[num7 - 1].Offset > array4[num7].Offset)
				{
					Helpers.Swap<HomogenousPatternCollection>(ref array4[num7 - 1], ref array4[num7]);
				}
			}
			return (array4, array3);
			static void AddToPatternCollection(ref HomogenousPatternCollection collection, ReadOnlySpan<int> arrayCounts, BytePattern pattern)
			{
				ReadOnlyMemory<byte> item = pattern.FirstLiteralSegment.Bytes;
				if (collection.Lut == null)
				{
					BytePattern[][] array5 = new BytePattern[256][];
					for (int m = 0; m < arrayCounts.Length; m++)
					{
						if (arrayCounts[m] > 0)
						{
							array5[m] = new BytePattern[arrayCounts[m]];
						}
					}
					collection.Lut = array5;
				}
				BytePattern[]? obj = collection.Lut[item.Span[0]];
				int num8 = Array.IndexOf(obj, null);
				obj[num8] = pattern;
				if (pattern.MinLength < collection.MinLength)
				{
					collection.MinLength = pattern.MinLength;
				}
			}
		}

		public bool TryMatchAt(ReadOnlySpan<byte> data, out ulong address, [MaybeNullWhen(false)] out BytePattern matchingPattern, out int length)
		{
			if (data.Length < MinLength)
			{
				length = 0;
				address = 0uL;
				matchingPattern = null;
				return false;
			}
			Span<byte> addrBuf = stackalloc byte[8];
			bool result = TryMatchAt(data, addrBuf, out matchingPattern, out length);
			address = System.Runtime.CompilerServices.Unsafe.ReadUnaligned<ulong>(ref addrBuf[0]);
			return result;
		}

		public bool TryMatchAt(ReadOnlySpan<byte> data, Span<byte> addrBuf, [MaybeNullWhen(false)] out BytePattern matchingPattern, out int length)
		{
			if (data.Length < MinLength)
			{
				length = 0;
				matchingPattern = null;
				return false;
			}
			for (int i = 0; i < patternCollections.Length; i++)
			{
				ref HomogenousPatternCollection reference = ref patternCollections[i];
				if (data.Length < reference.Offset + reference.MinLength)
				{
					continue;
				}
				byte b = data[reference.Offset];
				BytePattern[] array = reference.Lut[b];
				if (array == null)
				{
					continue;
				}
				BytePattern[] array2 = array;
				foreach (BytePattern bytePattern in array2)
				{
					if (bytePattern.TryMatchAt(data, addrBuf, out length))
					{
						matchingPattern = bytePattern;
						return true;
					}
				}
			}
			if (emptyPatterns != null)
			{
				BytePattern[] array2 = emptyPatterns;
				foreach (BytePattern bytePattern2 in array2)
				{
					if (bytePattern2.TryMatchAt(data, addrBuf, out length))
					{
						matchingPattern = bytePattern2;
						return true;
					}
				}
			}
			matchingPattern = null;
			length = 0;
			return false;
		}

		public bool TryFindMatch(ReadOnlySpan<byte> data, out ulong address, [MaybeNullWhen(false)] out BytePattern matchingPattern, out int offset, out int length)
		{
			if (data.Length < MinLength)
			{
				length = (offset = 0);
				address = 0uL;
				matchingPattern = null;
				return false;
			}
			Span<byte> addrBuf = stackalloc byte[8];
			bool result = TryFindMatch(data, addrBuf, out matchingPattern, out offset, out length);
			address = System.Runtime.CompilerServices.Unsafe.ReadUnaligned<ulong>(ref addrBuf[0]);
			return result;
		}

		public bool TryFindMatch(ReadOnlySpan<byte> data, Span<byte> addrBuf, [MaybeNullWhen(false)] out BytePattern matchingPattern, out int offset, out int length)
		{
			if (data.Length < MinLength)
			{
				length = (offset = 0);
				matchingPattern = null;
				return false;
			}
			ReadOnlySpan<byte> span = PossibleFirstBytes.Span;
			int num = 0;
			while (true)
			{
				int num2 = data.Slice(num).IndexOfAny(span);
				if (num2 < 0)
				{
					break;
				}
				offset = num + num2;
				byte b = data[offset];
				for (int i = 0; i < patternCollections.Length; i++)
				{
					ref HomogenousPatternCollection reference = ref patternCollections[i];
					if (offset < reference.Offset || data.Length < offset + reference.MinLength)
					{
						continue;
					}
					BytePattern[] array = reference.Lut[b];
					if (array == null)
					{
						continue;
					}
					BytePattern[] array2 = array;
					foreach (BytePattern bytePattern in array2)
					{
						if ((offset == 0 || !bytePattern.MustMatchAtStart) && bytePattern.TryMatchAt(data.Slice(offset - reference.Offset), addrBuf, out length))
						{
							offset -= reference.Offset;
							matchingPattern = bytePattern;
							return true;
						}
					}
				}
				num = offset + 1;
			}
			if (emptyPatterns != null)
			{
				BytePattern[] array2 = emptyPatterns;
				foreach (BytePattern bytePattern2 in array2)
				{
					if (bytePattern2.TryFindMatch(data, addrBuf, out offset, out length))
					{
						matchingPattern = bytePattern2;
						return true;
					}
				}
			}
			matchingPattern = null;
			offset = 0;
			length = 0;
			return false;
		}

		private ReadOnlyMemory<byte> GetPossibleFirstBytes()
		{
			Memory<byte> memory = new byte[512].AsMemory();
			FirstByteCollection bytes = new FirstByteCollection(memory.Span);
			for (int i = 0; i < patternCollections.Length; i++)
			{
				patternCollections[i].AddFirstBytes(ref bytes);
			}
			return memory.Slice(0, bytes.FirstBytes.Length);
		}
	}
	internal static class IcedExtensions
	{
		[Obsolete("This method is not supported.", true)]
		public static string FormatInsns(this IList<Instruction> insns)
		{
			throw new NotSupportedException();
		}

		[Obsolete("This method is not supported.", true)]
		public static string FormatInsns(this InstructionList insns)
		{
			throw new NotSupportedException();
		}
	}
	public interface IInitialize
	{
		void Initialize();
	}
	public interface IInitialize<T>
	{
		void Initialize(T value);
	}
}
namespace MonoMod.Core.Platforms
{
	public enum TypeClassification
	{
		InRegister,
		ByReference,
		OnStack
	}
	public delegate TypeClassification Classifier(Type type, bool isReturn);
	public enum SpecialArgumentKind
	{
		ThisPointer,
		ReturnBuffer,
		GenericContext,
		UserArguments
	}
	public readonly record struct Abi(ReadOnlyMemory<SpecialArgumentKind> ArgumentOrder, Classifier Classifier, bool ReturnsReturnBuffer)
	{
		public TypeClassification Classify(Type type, bool isReturn)
		{
			Helpers.ThrowIfArgumentNull<Type>(type, "type");
			if (type == typeof(void))
			{
				return TypeClassification.InRegister;
			}
			if (!type.IsValueType)
			{
				return TypeClassification.InRegister;
			}
			if (type.IsPointer)
			{
				return TypeClassification.InRegister;
			}
			if (type.IsByRef)
			{
				return TypeClassification.InRegister;
			}
			return Classifier(type, isReturn);
		}
	}
	[Flags]
	public enum ArchitectureFeature
	{
		None = 0,
		FixedInstructionSize = 1,
		Immediate64 = 2,
		CreateAltEntryPoint = 4
	}
	public readonly struct FeatureFlags : IEquatable<FeatureFlags>
	{
		public ArchitectureFeature Architecture { get; }

		public SystemFeature System { get; }

		public RuntimeFeature Runtime { get; }

		public FeatureFlags(ArchitectureFeature archFlags, SystemFeature sysFlags, RuntimeFeature runtimeFlags)
		{
			Runtime = runtimeFlags;
			Architecture = archFlags;
			System = sysFlags;
		}

		public bool Has(RuntimeFeature feature)
		{
			return (Runtime & feature) == feature;
		}

		public bool Has(ArchitectureFeature feature)
		{
			return (Architecture & feature) == feature;
		}

		public bool Has(SystemFeature feature)
		{
			return (System & feature) == feature;
		}

		public override bool Equals(object? obj)
		{
			if (obj is FeatureFlags other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(FeatureFlags other)
		{
			if (Runtime == other.Runtime && Architecture == other.Architecture)
			{
				return System == other.System;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Runtime, Architecture, System);
		}

		public override string ToString()
		{
			return $"({Architecture})({System})({Runtime})";
		}

		public static bool operator ==(FeatureFlags left, FeatureFlags right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(FeatureFlags left, FeatureFlags right)
		{
			return !(left == right);
		}
	}
	public interface IAltEntryFactory
	{
		IntPtr CreateAlternateEntrypoint(IntPtr entrypoint, int minLength, out IDisposable? handle);
	}
	public interface IArchitecture
	{
		ArchitectureKind Target { get; }

		ArchitectureFeature Features { get; }

		BytePatternCollection KnownMethodThunks { get; }

		IAltEntryFactory AltEntryFactory { get; }

		NativeDetourInfo ComputeDetourInfo(IntPtr from, IntPtr target, int maxSizeHint = -1);

		int GetDetourBytes(NativeDetourInfo info, Span<byte> buffer, out IDisposable? allocationHandle);

		NativeDetourInfo ComputeRetargetInfo(NativeDetourInfo detour, IntPtr target, int maxSizeHint = -1);

		int GetRetargetBytes(NativeDetourInfo original, NativeDetourInfo retarget, Span<byte> buffer, out IDisposable? allocationHandle, out bool needsRepatch, out bool disposeOldAlloc);

		ReadOnlyMemory<IAllocatedMemory> CreateNativeVtableProxyStubs(IntPtr vtableBase, int vtableSize);

		IAllocatedMemory CreateSpecialEntryStub(IntPtr target, IntPtr argument);
	}
	public interface INativeDetourKind
	{
		int Size { get; }
	}
	public readonly record struct NativeDetourInfo(IntPtr From, IntPtr To, INativeDetourKind InternalKind, IDisposable? InternalData)
	{
		public int Size => InternalKind.Size;
	}
	public interface IControlFlowGuard
	{
		bool IsSupported { get; }

		int TargetAlignmentRequirement { get; }

		unsafe void RegisterValidIndirectCallTargets(void* memoryRegionStart, nint memoryRegionLength, ReadOnlySpan<nint> validTargetsInMemoryRegion);
	}
	public interface IMemoryAllocator
	{
		int MaxSize { get; }

		bool TryAllocate(AllocationRequest request, [MaybeNullWhen(false)] out IAllocatedMemory allocated);

		bool TryAllocateInRange(PositionedAllocationRequest request, [MaybeNullWhen(false)] out IAllocatedMemory allocated);
	}
	public readonly record struct AllocationRequest
	{
		public int Size { get; init; }

		public int Alignment { get; init; }

		public bool Executable { get; init; }

		public AllocationRequest(int Size)
		{
			Executable = false;
			this.Size = Size;
			Alignment = 8;
		}

		[CompilerGenerated]
		public void Deconstruct(out int Size)
		{
			Size = this.Size;
		}
	}
	public readonly record struct PositionedAllocationRequest(IntPtr Target, IntPtr LowBound, IntPtr HighBound, AllocationRequest Base);
	public interface IAllocatedMemory : IDisposable
	{
		bool IsExecutable { get; }

		IntPtr BaseAddress { get; }

		int Size { get; }

		Span<byte> Memory { get; }
	}
	public interface INativeExceptionHelper
	{
		GetExceptionSlot GetExceptionSlot { get; }

		IntPtr CreateNativeToManagedHelper(IntPtr target, out IDisposable? handle);

		IntPtr CreateManagedToNativeHelper(IntPtr target, out IDisposable? handle);
	}
	public unsafe delegate IntPtr* GetExceptionSlot();
	public interface IRuntime
	{
		RuntimeKind Target { get; }

		RuntimeFeature Features { get; }

		Abi Abi { get; }

		event OnMethodCompiledCallback? OnMethodCompiled;

		MethodBase GetIdentifiable(MethodBase method);

		RuntimeMethodHandle GetMethodHandle(MethodBase method);

		void DisableInlining(MethodBase method);

		IDisposable? PinMethodIfNeeded(MethodBase method);

		IntPtr GetMethodEntryPoint(MethodBase method);

		void Compile(MethodBase method);
	}
	public delegate void OnMethodCompiledCallback(RuntimeMethodHandle methodHandle, MethodBase? method, IntPtr codeStart, IntPtr codeRw, ulong codeSize);
	public interface ISystem
	{
		OSKind Target { get; }

		SystemFeature Features { get; }

		Abi? DefaultAbi { get; }

		IMemoryAllocator MemoryAllocator { get; }

		INativeExceptionHelper? NativeExceptionHelper { get; }

		IEnumerable<string?> EnumerateLoadedModuleFiles();

		nint GetSizeOfReadableMemory(IntPtr start, nint guess);

		void PatchData(PatchTargetKind targetKind, IntPtr patchTarget, ReadOnlySpan<byte> data, Span<byte> backup);
	}
	public enum PatchTargetKind
	{
		Executable,
		ReadOnly
	}
	public sealed class PlatformTriple
	{
		public record struct NativeDetour(SimpleNativeDetour Simple, IntPtr AltEntry, IDisposable? AltHandle)
		{
			public bool HasAltEntry => AltEntry != IntPtr.Zero;
		}

		private static object lazyCurrentLock = new object();

		private static PlatformTriple? lazyCurrent;

		private static readonly Func<PlatformTriple> createCurrentFunc = CreateCurrent;

		private IntPtr ThePreStub = IntPtr.Zero;

		public IArchitecture Architecture { get; }

		public ISystem System { get; }

		public IRuntime Runtime { get; }

		public static PlatformTriple Current => Helpers.GetOrInitWithLock<PlatformTriple>(ref lazyCurrent, lazyCurrentLock, createCurrentFunc);

		public (ArchitectureKind Arch, OSKind OS, RuntimeKind Runtime) HostTriple => (Architecture.Target, System.Target, Runtime.Target);

		public FeatureFlags SupportedFeatures { get; }

		public Abi Abi { get; }

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static IRuntime CreateCurrentRuntime(ISystem system, IArchitecture arch)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected I4, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Helpers.ThrowIfArgumentNull<ISystem>(system, "system");
			Helpers.ThrowIfArgumentNull<IArchitecture>(arch, "arch");
			RuntimeKind runtime = PlatformDetection.Runtime;
			return (runtime - 1) switch
			{
				0 => FxBaseRuntime.CreateForVersion(PlatformDetection.RuntimeVersion, system), 
				1 => CoreBaseRuntime.CreateForVersion(PlatformDetection.RuntimeVersion, system, arch), 
				2 => new MonoRuntime(system), 
				_ => throw new PlatformNotSupportedException($"Runtime kind {runtime} not supported"), 
			};
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static IArchitecture CreateCurrentArchitecture(ISystem system)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0029: Expected I4, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			Helpers.ThrowIfArgumentNull<ISystem>(system, "system");
			ArchitectureKind architecture = PlatformDetection.Architecture;
			return (architecture - 2) switch
			{
				0 => new x86Arch(system), 
				1 => new x86_64Arch(system), 
				2 => throw new NotImplementedException(), 
				3 => throw new NotImplementedException(), 
				_ => throw new PlatformNotSupportedException($"Architecture kind {architecture} not supported"), 
			};
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static ISystem CreateCurrentSystem()
		{
			//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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected I4, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_008c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			OSKind oS = PlatformDetection.OS;
			if ((int)oS <= 17)
			{
				switch (oS - 1)
				{
				case 0:
					throw new NotImplementedException();
				case 4:
					return new MacOSSystem();
				case 1:
					goto IL_006c;
				case 2:
				case 3:
					goto IL_0074;
				}
				if ((int)oS == 9)
				{
					return new LinuxSystem();
				}
				if ((int)oS == 17)
				{
					throw new NotImplementedException();
				}
			}
			else
			{
				if ((int)oS == 34)
				{
					goto IL_006c;
				}
				if ((int)oS == 37)
				{
					throw new NotImplementedException();
				}
				if ((int)oS == 41)
				{
					throw new NotImplementedException();
				}
			}
			goto IL_0074;
			IL_006c:
			return new WindowsSystem();
			IL_0074:
			throw new PlatformNotSupportedException($"OS kind {oS} not supported");
		}

		private static PlatformTriple CreateCurrent()
		{
			ISystem system = CreateCurrentSystem();
			IArchitecture architecture = CreateCurrentArchitecture(system);
			IRuntime runtime = CreateCurrentRuntime(system, architecture);
			return new PlatformTriple(architecture, system, runtime);
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static void SetPlatformTriple(PlatformTriple triple)
		{
			Helpers.ThrowIfArgumentNull<PlatformTriple>(triple, "triple");
			if (lazyCurrent == null)
			{
				ThrowTripleAlreadyExists();
			}
			lock (lazyCurrentLock)
			{
				if (lazyCurrent == null)
				{
					ThrowTripleAlreadyExists();
				}
				lazyCurrent = triple;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void ThrowTripleAlreadyExists()
		{
			throw new InvalidOperationException("The platform triple has already been initialized; cannot set a new one");
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public PlatformTriple(IArchitecture architecture, ISystem system, IRuntime runtime)
		{
			Helpers.ThrowIfArgumentNull<IArchitecture>(architecture, "architecture");
			Helpers.ThrowIfArgumentNull<ISystem>(system, "system");
			Helpers.ThrowIfArgumentNull<IRuntime>(runtime, "runtime");
			Architecture = architecture;
			System = system;
			Runtime = runtime;
			SupportedFeatures = new FeatureFlags(Architecture.Features, System.Features, Runtime.Features);
			InitIfNeeded(Architecture);
			InitIfNeeded(System);
			InitIfNeeded(Runtime);
			Abi = Runtime.Abi;
		}

		private void InitIfNeeded(object obj)
		{
			(obj as IInitialize<ISystem>)?.Initialize(System);
			(obj as IInitialize<IArchitecture>)?.Initialize(Architecture);
			(obj as IInitialize<IRuntime>)?.Initialize(Runtime);
			(obj as IInitialize<PlatformTriple>)?.Initialize(this);
			(obj as IInitialize)?.Initialize();
		}

		public void Compile(MethodBase method)
		{
			Helpers.ThrowIfArgumentNull<MethodBase>(method, "method");
			if (method.IsGenericMethodDefinition)
			{
				throw new ArgumentException("Cannot prepare generic method definition", "method");
			}
			method = GetIdentifiable(method);
			if (SupportedFeatures.Has(RuntimeFeature.RequiresCustomMethodCompile))
			{
				Runtime.Compile(method);
				return;
			}
			RuntimeMethodHandle methodHandle = Runtime.GetMethodHandle(method);
			if (method.IsGenericMethod)
			{
				Type[] genericArguments = method.GetGenericArguments();
				RuntimeTypeHandle[] array = new RuntimeTypeHandle[genericArguments.Length];
				for (int i = 0; i < genericArguments.Length; i++)
				{
					array[i] = genericArguments[i].TypeHandle;
				}
				RuntimeHelpers.PrepareMethod(methodHandle, array);
			}
			else
			{
				RuntimeHelpers.PrepareMethod(methodHandle);
			}
		}

		public MethodBase GetIdentifiable(MethodBase method)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			Helpers.ThrowIfArgumentNull<MethodBase>(method, "method");
			if (SupportedFeatures.Has(RuntimeFeature.RequiresMethodIdentification))
			{
				method = Runtime.GetIdentifiable(method);
			}
			if (method.ReflectedType != method.DeclaringType)
			{
				ParameterInfo[] parameters = method.GetParameters();
				Type[] array = new Type[parameters.Length];
				for (int i = 0; i < parameters.Length; i++)
				{
					array[i] = parameters[i].ParameterType;
				}
				AssertionInterpolatedStringHandler val;
				bool flag2 = default(bool);
				if ((object)method.DeclaringType == null)
				{
					MethodInfo? method2 = method.Module.GetMethod(method.Name, (BindingFlags)(-1), null, method.CallingConvention, array, null);
					bool flag = (object)method2 != null;
					bool num = flag;
					val = new AssertionInterpolatedStringHandler(16, 2, flag, ref flag2);
					if (flag2)
					{
						((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral("orig: ");
						((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(method);
						((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral(", module: ");
						((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<Module>(method.Module);
					}
					Helpers.Assert(num, ref val, "got is not null");
					method = method2;
				}
				else if (method.IsConstructor)
				{
					ConstructorInfo? constructor = method.DeclaringType.GetConstructor((BindingFlags)(-1), null, method.CallingConvention, array, null);
					flag2 = (object)constructor != null;
					bool num2 = flag2;
					bool flag = default(bool);
					val = new AssertionInterpolatedStringHandler(6, 1, flag2, ref flag);
					if (flag)
					{
						((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral("orig: ");
						((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(method);
					}
					Helpers.Assert(num2, ref val, "got is not null");
					method = constructor;
				}
				else
				{
					MethodInfo? method3 = method.DeclaringType.GetMethod(method.Name, (BindingFlags)(-1), null, method.CallingConvention, array, null);
					bool flag = (object)method3 != null;
					bool num3 = flag;
					val = new AssertionInterpolatedStringHandler(6, 1, flag, ref flag2);
					if (flag2)
					{
						((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral("orig: ");
						((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(method);
					}
					Helpers.Assert(num3, ref val, "got is not null");
					method = method3;
				}
			}
			return method;
		}

		public IDisposable? PinMethodIfNeeded(MethodBase method)
		{
			if (SupportedFeatures.Has(RuntimeFeature.RequiresMethodPinning))
			{
				return Runtime.PinMethodIfNeeded(method);
			}
			return null;
		}

		public bool TryDisableInlining(MethodBase method)
		{
			if (SupportedFeatures.Has(RuntimeFeature.DisableInlining))
			{
				Runtime.DisableInlining(method);
				return true;
			}
			return false;
		}

		public SimpleNativeDetour CreateSimpleDetour(IntPtr from, IntPtr to, int detourMaxSize = -1, IntPtr fromRw = default(IntPtr))
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (fromRw == (IntPtr)0)
			{
				fromRw = from;
			}
			bool flag = from != to;
			bool isEnabled = default(bool);
			AssertionInterpolatedStringHandler val = new AssertionInterpolatedStringHandler(48, 2, flag, ref isEnabled);
			if (isEnabled)
			{
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral("Cannot detour a method to itself! (from: ");
				((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<IntPtr>(from);
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral(", to: ");
				((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<IntPtr>(to);
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral(")");
			}
			Helpers.Assert(flag, ref val, "from != to");
			MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(31, 2, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Creating simple detour 0x");
				message.AppendFormatted(from, "x16");
				message.AppendLiteral(" => 0x");
				message.AppendFormatted(to, "x16");
			}
			MMDbgLog.Trace(ref message);
			NativeDetourInfo nativeDetourInfo = Architecture.ComputeDetourInfo(from, to, detourMaxSize);
			Span<byte> span = stackalloc byte[nativeDetourInfo.Size];
			Architecture.GetDetourBytes(nativeDetourInfo, span, out IDisposable allocationHandle);
			byte[] array = new byte[nativeDetourInfo.Size];
			System.PatchData(PatchTargetKind.Executable, fromRw, span, array);
			return new SimpleNativeDetour(this, nativeDetourInfo, array, allocationHandle);
		}

		public NativeDetour CreateNativeDetour(IntPtr from, IntPtr to, int detourMaxSize = -1, IntPtr fromRw = default(IntPtr))
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (fromRw == (IntPtr)0)
			{
				fromRw = from;
			}
			bool flag = from != to;
			bool isEnabled = default(bool);
			AssertionInterpolatedStringHandler val = new AssertionInterpolatedStringHandler(48, 2, flag, ref isEnabled);
			if (isEnabled)
			{
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral("Cannot detour a method to itself! (from: ");
				((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<IntPtr>(from);
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral(", to: ");
				((AssertionInterpolatedStringHandler)(ref val)).AppendFormatted<IntPtr>(to);
				((AssertionInterpolatedStringHandler)(ref val)).AppendLiteral(")");
			}
			Helpers.Assert(flag, ref val, "from != to");
			MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(31, 2, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Creating simple detour 0x");
				message.AppendFormatted(from, "x16");
				message.AppendLiteral(" => 0x");
				message.AppendFormatted(to, "x16");
			}
			MMDbgLog.Trace(ref message);
			NativeDetourInfo nativeDetourInfo = Architecture.ComputeDetourInfo(from, to, detourMaxSize);
			Span<byte> span = stackalloc byte[nativeDetourInfo.Size];
			IDisposable allocationHandle;
			int detourBytes = Architecture.GetDetourBytes(nativeDetourInfo, span, out allocationHandle);
			IntPtr altEntry = IntPtr.Zero;
			IDisposable handle = null;
			if (SupportedFeatures.Has(ArchitectureFeature.CreateAltEntryPoint))
			{
				altEntry = Architecture.AltEntryFactory.CreateAlternateEntrypoint(from, detourBytes, out handle);
			}
			else
			{
				MMDbgLog.DebugLogWarningStringHandler message2 = new MMDbgLog.DebugLogWarningStringHandler(67, 2, out isEnabled);
				if (isEnabled)
				{
					message2.AppendLiteral("Cannot create alternate entry point for native detour (from: ");
					message2.AppendFormatted(from, "x16");
					message2.AppendLiteral(", to: ");
					message2.AppendFormatted(to, "x16");
				}
				MMDbgLog.Warning(ref message2);
			}
			byte[] array = new byte[nativeDetourInfo.Size];
			System.PatchData(PatchTargetKind.Executable, fromRw, span, array);
			return new NativeDetour(new SimpleNativeDetour(this, nativeDetourInfo, array, allocationHandle), altEntry, handle);
		}

		public IntPtr GetNativeMethodBody(MethodBase method)
		{
			if (SupportedFeatures.Has(RuntimeFeature.RequiresBodyThunkWalking))
			{
				return GetNativeMethodBodyWalk(method, reloadPtr: true);
			}
			return GetNativeMethodBodyDirect(method);
		}

		private unsafe IntPtr GetNativeMethodBodyWalk(MethodBase method, bool reloadPtr)
		{
			bool flag = false;
			bool flag2 = false;
			int value = 0;
			BytePatternCollection knownMethodThunks = Architecture.KnownMethodThunks;
			bool isEnabled;
			MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(32, 1, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Performing method body walk for ");
				message.AppendFormatted(method);
			}
			MMDbgLog.Trace(ref message);
			nint num = -1;
			FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
			while (true)
			{
				nint num2 = Runtime.GetMethodEntryPoint(method);
				message = new MMDbgLog.DebugLogTraceStringHandler(25, 1, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Starting entry point = 0x");
					message.AppendFormatted(num2, "x16");
				}
				MMDbgLog.Trace(ref message);
				while (true)
				{
					if (value++ > 20)
					{
						MMDbgLog.DebugLogErrorStringHandler message2 = new MMDbgLog.DebugLogErrorStringHandler(70, 4, out isEnabled);
						if (isEnabled)
						{
							message2.AppendLiteral("Could not get entry point for ");
							message2.AppendFormatted(method);
							message2.AppendLiteral("! (tried ");
							message2.AppendFormatted(value);
							message2.AppendLiteral(" times) entry: 0x");
							message2.AppendFormatted(num2, "x16");
							message2.AppendLiteral(" prevEntry: 0x");
							message2.AppendFormatted(num, "x16");
						}
						MMDbgLog.Error(ref message2);
						((FormatInterpolatedStringHandler)(ref val))..ctor(47, 1);
						((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("Could not get entrypoint for ");
						((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(method);
						((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(" (stuck in a loop)");
						throw new NotSupportedException(DebugFormatter.Format(ref val));
					}
					if (flag2 || num != num2)
					{
						num = num2;
						nint sizeOfReadableMemory = System.GetSizeOfReadableMemory(num2, knownMethodThunks.MaxMinLength);
						if (sizeOfReadableMemory <= 0)
						{
							MMDbgLog.DebugLogWarningStringHandler message3 = new MMDbgLog.DebugLogWarningStringHandler(43, 2, out isEnabled);
							if (isEnabled)
							{
								message3.AppendLiteral("Got zero or negative readable length ");
								message3.AppendFormatted(sizeOfReadableMemory);
								message3.AppendLiteral(" at 0x");
								message3.AppendFormatted(num2, "x16");
							}
							MMDbgLog.Warning(ref message3);
						}
						ReadOnlySpan<byte> data = new ReadOnlySpan<byte>((void*)num2, Math.Min((int)sizeOfReadableMemory, knownMethodThunks.MaxMinLength));
						if (knownMethodThunks.TryFindMatch(data, out ulong address, out BytePattern matchingPattern, out int offset, out int _))
						{
							IntPtr ptrGot = num2;
							flag2 = false;
							AddressMeaning addressMeaning = matchingPattern.AddressMeaning;
							message = new MMDbgLog.DebugLogTraceStringHandler(46, 4, out isEnabled);
							if (isEnabled)
							{
								message.AppendLiteral("Matched thunk with ");
								message.AppendFormatted(addressMeaning);
								message.AppendLiteral(" at 0x");
								message.AppendFormatted(num2, "x16");
								message.AppendLiteral(" (addr: 0x");
								message.AppendFormatted(address, "x8");
								message.AppendLiteral(", offset: ");
								message.AppendFormatted(offset);
								message.AppendLiteral(")");
							}
							MMDbgLog.Trace(ref message);
							if (addressMeaning.Kind.IsPrecodeFixup() && !flag)
							{
								nint num3 = addressMeaning.ProcessAddress(num2, offset, address);
								if (reloadPtr)
								{
									message = new MMDbgLog.DebugLogTraceStringHandler(56, 1, out isEnabled);
									if (isEnabled)
									{
										message.AppendLiteral("Method thunk reset; regenerating (PrecodeFixupThunk: 0x");
										message.AppendFormatted(num3, "X16");
										message.AppendLiteral(")");
									}
									MMDbgLog.Trace(ref message);
									Compile(method);
									flag2 = true;
									break;
								}
								num2 = num3;
							}
							else
							{
								num2 = addressMeaning.ProcessAddress(num2, offset, address);
							}
							message = new MMDbgLog.DebugLogTraceStringHandler(23, 1, out isEnabled);
							if (isEnabled)
							{
								message.AppendLiteral("Got next entry point 0x");
								message.AppendFormatted(num2, "x16");
							}
							MMDbgLog.Trace(ref message);
							num2 = NotThePreStub(ptrGot, num2, out var wasPreStub);
							if (wasPreStub && reloadPtr)
							{
								MMDbgLog.Trace("Matched ThePreStub");
								Compile(method);
								break;
							}
							continue;
						}
					}
					return num2;
				}
			}
		}

		private IntPtr GetNativeMethodBodyDirect(MethodBase method)
		{
			return Runtime.GetMethodEntryPoint(method);
		}

		private IntPtr NotThePreStub(IntPtr ptrGot, IntPtr ptrParsed, out bool wasPreStub)
		{
			if (ThePreStub == IntPtr.Zero)
			{
				ThePreStub = (IntPtr)(-2);
				IntPtr thePreStub = (from m in typeof(HttpWebRequest).Assembly.GetType("System.Net.Connection")?.GetMethods()
					group m by GetNativeMethodBodyWalk(m, reloadPtr: false)).First((IGrouping<IntPtr, MethodInfo> g) => g.Count() > 1).Key ?? ((IntPtr)(-1));
				ThePreStub = thePreStub;
				bool isEnabled;
				MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(14, 1, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("ThePreStub: 0x");
					message.AppendFormatted(ThePreStub, "X16");
				}
				MMDbgLog.Trace(ref message);
			}
			wasPreStub = ptrParsed == ThePreStub;
			if (!wasPreStub)
			{
				return ptrParsed;
			}
			return ptrGot;
		}

		public MethodBase GetRealDetourTarget(MethodBase from, MethodBase to)
		{
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			Helpers.ThrowIfArgumentNull<MethodBase>(from, "from");
			Helpers.ThrowIfArgumentNull<MethodBase>(to, "to");
			to = GetIdentifiable(to);
			if (from is MethodInfo methodInfo && to is MethodInfo && !methodInfo.IsStatic && to.IsStatic)
			{
				Type returnType = methodInfo.ReturnType;
				if (Abi.Classify(returnType, isReturn: true) == TypeClassification.ByReference)
				{
					Type thisParamType = Extensions.GetThisParamType(from);
					Type type = returnType.MakeByRefType();
					Type type2 = (Abi.ReturnsReturnBuffer ? type : typeof(void));
					int num = -1;
					int num2 = -1;
					int num3 = -1;
					ParameterInfo[] parameters = from.GetParameters();
					List<Type> list = new List<Type>();
					ReadOnlySpan<SpecialArgumentKind> span = Abi.ArgumentOrder.Span;
					for (int i = 0; i < span.Length; i++)
					{
						switch (span[i])
						{
						case SpecialArgumentKind.ThisPointer:
							num = list.Count;
							list.Add(thisParamType);
							break;
						case SpecialArgumentKind.ReturnBuffer:
							num2 = list.Count;
							list.Add(type);
							break;
						case SpecialArgumentKind.UserArguments:
							num3 = list.Count;
							list.AddRange(parameters.Select((ParameterInfo p) => p.ParameterType));
							break;
						}
					}
					FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
					((FormatInterpolatedStringHandler)(ref val))..ctor(16, 2);
					((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("Glue:AbiFixup<");
					((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(from);
					((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(",");
					((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(to);
					((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(">");
					DynamicMethodDefinition val2 = new DynamicMethodDefinition(DebugFormatter.Format(ref val), type2, list.ToArray());
					try
					{
						MethodDefinition definition = val2.Definition;
						definition.ImplAttributes = (MethodImplAttributes)(definition.ImplAttributes | 0x208);
						ILProcessor iLProcessor = val2.GetILProcessor();
						iLProcessor.Emit(OpCodes.Ldarg, num2);
						iLProcessor.Emit(OpCodes.Ldarg, num);
						for (int j = 0; j < parameters.Length; j++)
						{
							iLProcessor.Emit(OpCodes.Ldarg, j + num3);
						}
						iLProcessor.Emit(OpCodes.Call, ((MemberReference)iLProcessor.Body.Method).Module.ImportReference(to));
						iLProcessor.Emit(OpCodes.Stobj, ((MemberReference)iLProcessor.Body.Method).Module.ImportReference(returnType));
						if (Abi.ReturnsReturnBuffer)
						{
							iLProcessor.Emit(OpCodes.Ldarg, num2);
						}
						iLProcessor.Emit(OpCodes.Ret);
						return val2.Generate();
					}
					finally
					{
						((IDisposable)val2)?.Dispose();
					}
				}
			}
			return to;
		}
	}
	internal sealed class PlatformTripleDetourFactory : IDetourFactory
	{
		private abstract class DetourBase : ICoreDetourBase, IDisposable
		{
			protected abstract class DetourBoxBase
			{
				public SimpleNativeDetour? Detour;

				protected readonly PlatformTriple Triple;

				protected readonly object Sync = new object();

				private bool applyDetours;

				private bool isApplying;

				public bool IsApplied
				{
					get
					{
						return Volatile.Read(ref applyDetours);
					}
					set
					{
						Volatile.Write(ref applyDetours, value);
						Thread.MemoryBarrier();
					}
				}

				public bool IsApplying
				{
					get
					{
						return Volatile.Read(ref isApplying);
					}
					set
					{
						Volatile.Write(ref isApplying, value);
						Thread.MemoryBarrier();
					}
				}

				protected DetourBoxBase(PlatformTriple triple)
				{
					Triple = triple;
					applyDetours = false;
					isApplying = false;
				}
			}

			protected readonly PlatformTriple Triple;

			protected DetourBoxBase DetourBox;

			private bool disposedValue;

			public bool IsApplied => DetourBox.IsApplied;

			protected DetourBase(PlatformTriple triple)
			{
				Triple = triple;
				DetourBox = null;
			}

			protected TBox GetDetourBox<TBox>() where TBox : DetourBoxBase
			{
				return System.Runtime.CompilerServices.Unsafe.As<TBox>((object)DetourBox);
			}

			protected static void ReplaceDetourInLock(DetourBoxBase nativeDetour, SimpleNativeDetour? newDetour, out SimpleNativeDetour? oldDetour)
			{
				Thread.MemoryBarrier();
				oldDetour = Interlocked.Exchange(ref nativeDetour.Detour, newDetour);
			}

			protected abstract SimpleNativeDetour CreateDetour();

			public void Apply()
			{
				lock (DetourBox)
				{
					if (IsApplied)
					{
						throw new InvalidOperationException("Cannot apply a detour which is already applied");
					}
					try
					{
						DetourBox.IsApplying = true;
						DetourBox.IsApplied = true;
						ReplaceDetourInLock(DetourBox, CreateDetour(), out SimpleNativeDetour _);
					}
					catch
					{
						DetourBox.IsApplied = false;
						throw;
					}
					finally
					{
						DetourBox.IsApplying = false;
					}
				}
			}

			protected abstract void BeforeUndo();

			protected abstract void AfterUndo();

			public void Undo()
			{
				lock (DetourBox)
				{
					if (!IsApplied)
					{
						throw new InvalidOperationException("Cannot undo a detour which is not applied");
					}
					try
					{
						DetourBox.IsApplying = true;
						UndoCore(out SimpleNativeDetour oldDetour);
						oldDetour?.Dispose();
					}
					finally
					{
						DetourBox.IsApplying = false;
					}
				}
			}

			private void UndoCore(out SimpleNativeDetour? oldDetour)
			{
				BeforeUndo();
				DetourBox.IsApplied = false;
				ReplaceDetourInLock(DetourBox, null, out oldDetour);
				AfterUndo();
			}

			protected abstract void BeforeDispose();

			private void Dispose(bool disposing)
			{
				if (!disposedValue)
				{
					BeforeDispose();
					lock (DetourBox)
					{
						UndoCore(out SimpleNativeDetour oldDetour);
						oldDetour?.Dispose();
					}
					disposedValue = true;
				}
			}

			~DetourBase()
			{
				Dispose(disposing: false);
			}

			public void Dispose()
			{
				Dispose(disposing: true);
				GC.SuppressFinalize(this);
			}
		}

		private sealed class Detour : DetourBase, ICoreDetour, ICoreDetourBase, IDisposable
		{
			private sealed class ManagedDetourBox : DetourBoxBase
			{
				private readonly MethodBase src;

				private readonly MethodBase target;

				public ManagedDetourBox(PlatformTriple triple, MethodBase src, MethodBase target)
					: base(triple)
				{
					this.src = src;
					this.target = target;
					Detour = null;
				}

				public void SubscribeCompileMethod()
				{
					AddRelatedDetour(src, this);
				}

				public void UnsubscribeCompileMethod()
				{
					RemoveRelatedDetour(src, this);
				}

				public void OnMethodCompiled(MethodBase method, IntPtr codeStart, IntPtr codeStartRw, ulong codeSize)
				{
					if (!base.IsApplied)
					{
						return;
					}
					method = Triple.GetIdentifiable(method);
					lock (Sync)
					{
						if (!base.IsApplied || base.IsApplying)
						{
							return;
						}
						bool isEnabled;
						MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(43, 4, out isEnabled);
						if (isEnabled)
						{
							message.AppendLiteral("Updating detour from ");
							message.AppendFormatted(src);
							message.AppendLiteral(" to ");
							message.AppendFormatted(target);
							message.AppendLiteral(" (recompiled ");
							message.AppendFormatted(method);
							message.AppendLiteral(" to ");
							message.AppendFormatted(codeStart, "x16");
							message.AppendLiteral(")");
						}
						MMDbgLog.Trace(ref message);
						try
						{
							base.IsApplying = true;
							SimpleNativeDetour detour = Detour;
							IntPtr to;
							IntPtr from;
							IntPtr fromRw;
							if (detour != null)
							{
								_ = detour.Source;
								to = detour.Destination;
								from = codeStart;
								fromRw = codeStartRw;
							}
							else
							{
								from = codeStart;
								fromRw = codeStartRw;
								to = Triple.Runtime.GetMethodHandle(target).GetFunctionPointer();
							}
							SimpleNativeDetour newDetour = Triple.CreateSimpleDetour(from, to, (int)codeSize, fromRw);
							DetourBase.ReplaceDetourInLock(this, newDetour, out SimpleNativeDetour _);
						}
						finally
						{
							base.IsApplying = false;
						}
					}
				}
			}

			private sealed class RelatedDetourBag
			{
				public readonly MethodBase Method;

				public readonly List<ManagedDetourBox> RelatedDetours = new List<ManagedDetourBox>();

				public bool IsValid = true;

				public RelatedDetourBag(MethodBase method)
				{
					Method = method;
				}
			}

			private readonly MethodBase realTarget;

			private static readonly object subLock = new object();

			private static bool hasSubscribed;

			private static readonly ConcurrentDictionary<MethodBase, RelatedDetourBag> relatedDetours = new ConcurrentDictionary<MethodBase, RelatedDetourBag>();

			private IDisposable? srcPin;

			private IDisposable? dstPin;

			private new ManagedDetourBox DetourBox => GetDetourBox<ManagedDetourBox>();

			public MethodBase Source { get; }

			public MethodBase Target { get; }

			public Detour(PlatformTriple triple, MethodBase src, MethodBase dst)
				: base(triple)
			{
				Source = triple.GetIdentifiable(src);
				Target = dst;
				realTarget = triple.GetRealDetourTarget(src, dst);
				base.DetourBox = new ManagedDetourBox(triple, Source, realTarget);
				if (triple.SupportedFeatures.Has(RuntimeFeature.CompileMethodHook))
				{
					EnsureSubscribed(triple);
					DetourBox.SubscribeCompileMethod();
				}
			}

			private static void EnsureSubscribed(PlatformTriple triple)
			{
				if (Volatile.Read(ref hasSubscribed))
				{
					return;
				}
				lock (subLock)
				{
					if (!Volatile.Read(ref hasSubscribed))
					{
						Volatile.Write(ref hasSubscribed, value: true);
						triple.Runtime.OnMethodCompiled += OnMethodCompiled;
					}
				}
			}

			private static void AddRelatedDetour(MethodBase m, ManagedDetourBox cmh)
			{
				while (true)
				{
					RelatedDetourBag orAdd = relatedDetours.GetOrAdd(m, (MethodBase m) => new RelatedDetourBag(m));
					lock (orAdd)
					{
						if (!orAdd.IsValid)
						{
							continue;
						}
						orAdd.RelatedDetours.Add(cmh);
						if (orAdd.RelatedDetours.Count > 1)
						{
							bool isEnabled;
							MMDbgLog.DebugLogWarningStringHandler message = new MMDbgLog.DebugLogWarningStringHandler(115, 1, out isEnabled);
							if (isEnabled)
							{
								message.AppendLiteral("Multiple related detours for method ");
								message.AppendFormatted(m);
								message.AppendLiteral("! This means that the method has been detoured twice. Detour cleanup will fail.");
							}
							MMDbgLog.Warning(ref message);
						}
						break;
					}
				}
			}

			private static void RemoveRelatedDetour(MethodBase m, ManagedDetourBox cmh)
			{
				if (relatedDetours.TryGetValue(m, out RelatedDetourBag value))
				{
					lock (value)
					{
						value.RelatedDetours.Remove(cmh);
						if (value.RelatedDetours.Count == 0)
						{
							value.IsValid = false;
							Helpers.Assert(relatedDetours.TryRemove(value.Method, out RelatedDetourBag _), (string)null, "relatedDetours.TryRemove(related.Method, out _)");
						}
						return;
					}
				}
				bool isEnabled;
				MMDbgLog.DebugLogWarningStringHandler message = new MMDbgLog.DebugLogWarningStringHandler(79, 1, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Attempted to remove a related detour from method ");
					message.AppendFormatted(m);
					message.AppendLiteral(" which has no RelatedDetourBag");
				}
				MMDbgLog.Warning(ref message);
			}

			private static void OnMethodCompiled(RuntimeMethodHandle methodHandle, MethodBase? method, IntPtr codeStart, IntPtr codeStartRw, ulong codeSize)
			{
				if ((object)method == null)
				{
					return;
				}
				method = PlatformTriple.Current.GetIdentifiable(method);
				if (!relatedDetours.TryGetValue(method, out RelatedDetourBag value))
				{
					return;
				}
				lock (value)
				{
					foreach (ManagedDetourBox relatedDetour in value.RelatedDetours)
					{
						relatedDetour.OnMethodCompiled(method, codeStart, codeStartRw, codeSize);
					}
				}
			}

			protected override SimpleNativeDetour CreateDetour()
			{
				bool isEnabled;
				MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(33, 2, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Applying managed detour from ");
					message.AppendFormatted(Source);
					message.AppendLiteral(" to ");
					message.AppendFormatted(realTarget);
				}
				MMDbgLog.Trace(ref message);
				srcPin = Triple.PinMethodIfNeeded(Source);
				dstPin = Triple.PinMethodIfNeeded(realTarget);
				Triple.Compile(Source);
				IntPtr nativeMethodBody = Triple.GetNativeMethodBody(Source);
				Triple.Compile(realTarget);
				IntPtr functionPointer = Triple.Runtime.GetMethodHandle(realTarget).GetFunctionPointer();
				return Triple.CreateSimpleDetour(nativeMethodBody, functionPointer, -1, (IntPtr)0);
			}

			protected override void BeforeUndo()
			{
				bool isEnabled;
				MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(32, 2, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Undoing managed detour from ");
					message.AppendFormatted(Source);
					message.AppendLiteral(" to ");
					message.AppendFormatted(realTarget);
				}
				MMDbgLog.Trace(ref message);
			}

			protected override void AfterUndo()
			{
				Interlocked.Exchange(ref srcPin, null)?.Dispose();
				Interlocked.Exchange(ref dstPin, null)?.Dispose();
			}

			protected override void BeforeDispose()
			{
				if (Triple.SupportedFeatures.Has(RuntimeFeature.CompileMethodHook))
				{
					DetourBox.UnsubscribeCompileMethod();
				}
			}
		}

		private sealed class NativeDetour : DetourBase, ICoreNativeDetour, ICoreDetourBase, IDisposable
		{
			private sealed class NativeDetourBox : DetourBoxBase
			{
				public readonly IntPtr From;

				public readonly IntPtr To;

				public NativeDetourBox(PlatformTriple triple, IntPtr from, IntPtr to)
					: base(triple)
				{
					From = from;
					To = to;
				}
			}

			private IDisposable? origHandle;

			public IntPtr Source => DetourBox.From;

			public IntPtr Target => DetourBox.To;

			public bool HasOrigEntrypoint => OrigEntrypoint != IntPtr.Zero;

			public IntPtr OrigEntrypoint { get; private set; }

			private new NativeDetourBox DetourBox => GetDetourBox<NativeDetourBox>();

			public NativeDetour(PlatformTriple triple, IntPtr from, IntPtr to)
				: base(triple)
			{
				base.DetourBox = new NativeDetourBox(triple, from, to);
			}

			protected override SimpleNativeDetour CreateDetour()
			{
				bool isEnabled;
				MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(32, 2, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Applying native detour from ");
					message.AppendFormatted(Source, "x16");
					message.AppendLiteral(" to ");
					message.AppendFormatted(Target, "x16");
				}
				MMDbgLog.Trace(ref message);
				Triple.CreateNativeDetour(Source, Target, -1, (IntPtr)0).Deconstruct(out SimpleNativeDetour Simple, out IntPtr AltEntry, out IDisposable AltHandle);
				SimpleNativeDetour result = Simple;
				IntPtr origEntrypoint = AltEntry;
				IDisposable disposable = AltHandle;
				IDisposable? disposable2 = origHandle;
				AltHandle = disposable;
				disposable = disposable2;
				origHandle = AltHandle;
				OrigEntrypoint = origEntrypoint;
				return result;
			}

			protected override void BeforeUndo()
			{
				bool isEnabled;
				MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(31, 2, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Undoing native detour from ");
					message.AppendFormatted(Source, "x16");
					message.AppendLiteral(" to ");
					message.AppendFormatted(Target, "x16");
				}
				MMDbgLog.Trace(ref message);
			}

			protected override void AfterUndo()
			{
				OrigEntrypoint = IntPtr.Zero;
				origHandle?.Dispose();
				origHandle = null;
			}

			protected override void BeforeDispose()
			{
			}
		}

		private readonly PlatformTriple triple;

		public PlatformTripleDetourFactory(PlatformTriple triple)
		{
			this.triple = triple;
		}

		public ICoreDetour CreateDetour(CreateDetourRequest request)
		{
			Helpers.ThrowIfArgumentNull<MethodBase>(request.Source, "request.Source");
			Helpers.ThrowIfArgumentNull<MethodBase>(request.Target, "request.Target");
			if (!triple.TryDisableInlining(request.Source))
			{
				bool isEnabled;
				MMDbgLog.DebugLogWarningStringHandler message = new MMDbgLog.DebugLogWarningStringHandler(66, 1, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Could not disable inlining of method ");
					message.AppendFormatted(request.Source);
					message.AppendLiteral("; detours may not be reliable");
				}
				MMDbgLog.Warning(ref message);
			}
			Detour detour = new Detour(triple, request.Source, request.Target);
			if (request.ApplyByDefault)
			{
				detour.Apply();
			}
			return detour;
		}

		public ICoreNativeDetour CreateNativeDetour(CreateNativeDetourRequest request)
		{
			NativeDetour nativeDetour = new NativeDetour(triple, request.Source, request.Target);
			if (request.ApplyByDefault)
			{
				nativeDetour.Apply();
			}
			return nativeDetour;
		}
	}
	[Flags]
	public enum RuntimeFeature
	{
		None = 0,
		PreciseGC = 1,
		CompileMethodHook = 2,
		ILDetour = 4,
		GenericSharing = 8,
		ListGenericInstantiations = 0x40,
		DisableInlining = 0x10,
		Uninlining = 0x20,
		RequiresMethodPinning = 0x80,
		RequiresMethodIdentification = 0x100,
		RequiresBodyThunkWalking = 0x200,
		HasKnownABI = 0x400,
		RequiresCustomMethodCompile = 0x800
	}
	public sealed class SimpleNativeDetour : IDisposable
	{
		private bool disposedValue;

		private readonly PlatformTriple triple;

		private NativeDetourInfo detourInfo;

		private Memory<byte> backup;

		private IDisposable? AllocHandle;

		public ReadOnlyMemory<byte> DetourBackup => backup;

		public IntPtr Source => detourInfo.From;

		public IntPtr Destination => detourInfo.To;

		internal SimpleNativeDetour(PlatformTriple triple, NativeDetourInfo detourInfo, Memory<byte> backup, IDisposable? allocHandle)
		{
			this.triple = triple;
			this.detourInfo = detourInfo;
			this.backup = backup;
			AllocHandle = allocHandle;
		}

		public void ChangeTarget(IntPtr newTarget)
		{
			CheckDisposed();
			bool isEnabled;
			MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(47, 3, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Retargeting simple detour 0x");
				message.AppendFormatted(Source, "x16");
				message.AppendLiteral(" => 0x");
				message.AppendFormatted(Destination, "x16");
				message.AppendLiteral(" to target 0x");
				message.AppendFormatted(newTarget, "x16");
			}
			MMDbgLog.Trace(ref message);
			NativeDetourInfo retarget = triple.Architecture.ComputeRetargetInfo(detourInfo, newTarget, detourInfo.Size);
			Span<byte> span = stackalloc byte[retarget.Size];
			triple.Architecture.GetRetargetBytes

plugins/MonoMod.Iced.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Iced.Intel.BlockEncoderInternal;
using Iced.Intel.DecoderInternal;
using Iced.Intel.EncoderInternal;
using Iced.Intel.Internal;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Iced.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d94ac07d6edc1ac1f306b60544bb88927664f05037602c5e994ea52ca5b0aadc4a242d90522f46730c11af657acc3ff5aadfe19a3030e7dbd67b481635eecd7d738950a7de6a78c92715b797dde11e87d967109da659672957fabe3524cd5f90557cd8ab4927333a0dbd32e7e7246ee18a43327806c6721283fc619acca3f2cb")]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = ".NET Framework 4.5.2")]
[assembly: AssemblyCompany("iced project and contributors <https://github.com/icedland>")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (C) 2018-present iced project and contributors")]
[assembly: AssemblyDescription("x86/x64 disassembler, assembler, instruction decoder")]
[assembly: AssemblyFileVersion("1.21.0.0")]
[assembly: AssemblyInformationalVersion("1.21.0+e79d24413")]
[assembly: AssemblyProduct("Iced")]
[assembly: AssemblyTitle("MonoMod.Iced")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoMod/MonoMod.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.21.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(true)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[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 NullablePublicOnlyAttribute : Attribute
	{
		public readonly bool IncludesInternals;

		public NullablePublicOnlyAttribute(bool P_0)
		{
			IncludesInternals = 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 MonoMod.SourceGen.Attributes
{
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class EmitILOverloadsAttribute : Attribute
	{
		public EmitILOverloadsAttribute(string filename, string kind)
		{
		}
	}
	internal static class ILOverloadKind
	{
		public const string Cursor = "ILCursor";

		public const string Matcher = "ILMatcher";
	}
}
namespace iced
{
	internal static class AssemblyInfo
	{
		public const string AssemblyName = "MonoMod.Iced";

		public const string AssemblyVersion = "1.21.0";
	}
}
namespace Iced.Intel
{
	public enum RelocKind
	{
		Offset64
	}
	public readonly struct RelocInfo
	{
		public readonly ulong Address;

		public readonly RelocKind Kind;

		public RelocInfo(RelocKind kind, ulong address)
		{
			Kind = kind;
			Address = address;
		}
	}
	public readonly struct InstructionBlock
	{
		public readonly CodeWriter CodeWriter;

		public readonly IList<Instruction> Instructions;

		public readonly ulong RIP;

		public InstructionBlock(CodeWriter codeWriter, IList<Instruction> instructions, ulong rip)
		{
			CodeWriter = codeWriter ?? throw new ArgumentNullException("codeWriter");
			Instructions = instructions ?? throw new ArgumentNullException("instructions");
			RIP = rip;
		}
	}
	public readonly struct BlockEncoderResult
	{
		public readonly ulong RIP;

		public readonly List<RelocInfo>? RelocInfos;

		public readonly uint[] NewInstructionOffsets;

		public readonly ConstantOffsets[] ConstantOffsets;

		internal BlockEncoderResult(ulong rip, List<RelocInfo>? relocInfos, uint[]? newInstructionOffsets, ConstantOffsets[]? constantOffsets)
		{
			RIP = rip;
			RelocInfos = relocInfos;
			NewInstructionOffsets = newInstructionOffsets ?? Array2.Empty<uint>();
			ConstantOffsets = constantOffsets ?? Array2.Empty<ConstantOffsets>();
		}
	}
	[Flags]
	public enum BlockEncoderOptions
	{
		None = 0,
		DontFixBranches = 1,
		ReturnRelocInfos = 2,
		ReturnNewInstructionOffsets = 4,
		ReturnConstantOffsets = 8
	}
	public sealed class BlockEncoder
	{
		private sealed class NullCodeWriter : CodeWriter
		{
			public static readonly NullCodeWriter Instance = new NullCodeWriter();

			private NullCodeWriter()
			{
			}

			public override void WriteByte(byte value)
			{
			}
		}

		private readonly int bitness;

		private readonly BlockEncoderOptions options;

		private readonly Block[] blocks;

		private readonly Encoder nullEncoder;

		private readonly Dictionary<ulong, Instr> toInstr;

		internal int Bitness => bitness;

		internal bool FixBranches => (options & BlockEncoderOptions.DontFixBranches) == 0;

		private bool ReturnRelocInfos => (options & BlockEncoderOptions.ReturnRelocInfos) != 0;

		private bool ReturnNewInstructionOffsets => (options & BlockEncoderOptions.ReturnNewInstructionOffsets) != 0;

		private bool ReturnConstantOffsets => (options & BlockEncoderOptions.ReturnConstantOffsets) != 0;

		private BlockEncoder(int bitness, InstructionBlock[] instrBlocks, BlockEncoderOptions options)
		{
			if (bitness != 16 && bitness != 32 && bitness != 64)
			{
				throw new ArgumentOutOfRangeException("bitness");
			}
			if (instrBlocks == null)
			{
				throw new ArgumentNullException("instrBlocks");
			}
			this.bitness = bitness;
			nullEncoder = Encoder.Create(bitness, NullCodeWriter.Instance);
			this.options = options;
			blocks = new Block[instrBlocks.Length];
			int num = 0;
			for (int i = 0; i < instrBlocks.Length; i++)
			{
				IList<Instruction> instructions = instrBlocks[i].Instructions;
				if (instructions == null)
				{
					throw new ArgumentException();
				}
				Block block = new Block(this, instrBlocks[i].CodeWriter, instrBlocks[i].RIP, ReturnRelocInfos ? new List<RelocInfo>() : null);
				blocks[i] = block;
				Instr[] array = new Instr[instructions.Count];
				ulong num2 = instrBlocks[i].RIP;
				for (int j = 0; j < array.Length; j++)
				{
					Instruction instruction = instructions[j];
					Instr instr = Instr.Create(this, block, in instruction);
					instr.IP = num2;
					array[j] = instr;
					num++;
					num2 += instr.Size;
				}
				block.SetInstructions(array);
			}
			Array.Sort(blocks, delegate(Block a, Block b)
			{
				ulong rIP = a.RIP;
				return rIP.CompareTo(b.RIP);
			});
			Dictionary<ulong, Instr> dictionary = (toInstr = new Dictionary<ulong, Instr>(num));
			bool flag = false;
			Block[] array2 = blocks;
			for (int k = 0; k < array2.Length; k++)
			{
				Instr[] instructions2 = array2[k].Instructions;
				foreach (Instr instr2 in instructions2)
				{
					ulong origIP = instr2.OrigIP;
					if (dictionary.TryGetValue(origIP, out var _))
					{
						if (origIP != 0L)
						{
							throw new ArgumentException($"Multiple instructions with the same IP: 0x{origIP:X}");
						}
						flag = true;
					}
					else
					{
						dictionary[origIP] = instr2;
					}
				}
			}
			if (flag)
			{
				dictionary.Remove(0uL);
			}
			array2 = blocks;
			foreach (Block obj in array2)
			{
				ulong num3 = obj.RIP;
				Instr[] instructions2 = obj.Instructions;
				foreach (Instr instr3 in instructions2)
				{
					instr3.IP = num3;
					if (!instr3.Done)
					{
						instr3.Initialize(this);
					}
					num3 += instr3.Size;
				}
			}
		}

		public static bool TryEncode(int bitness, InstructionBlock block, [NotNullWhen(false)] out string? errorMessage, out BlockEncoderResult result, BlockEncoderOptions options = BlockEncoderOptions.None)
		{
			if (TryEncode(bitness, new InstructionBlock[1] { block }, out errorMessage, out BlockEncoderResult[] result2, options))
			{
				result = result2[0];
				return true;
			}
			result = default(BlockEncoderResult);
			return false;
		}

		public static bool TryEncode(int bitness, InstructionBlock[] blocks, [NotNullWhen(false)] out string? errorMessage, [NotNullWhen(true)] out BlockEncoderResult[]? result, BlockEncoderOptions options = BlockEncoderOptions.None)
		{
			return new BlockEncoder(bitness, blocks, options).Encode(out errorMessage, out result);
		}

		private bool Encode([NotNullWhen(false)] out string errorMessage, [NotNullWhen(true)] out BlockEncoderResult[] result)
		{
			Block[] array;
			for (int i = 0; i < 5; i++)
			{
				bool flag = false;
				array = blocks;
				foreach (Block obj in array)
				{
					ulong num = obj.RIP;
					ulong num2 = 0uL;
					Instr[] instructions = obj.Instructions;
					foreach (Instr instr in instructions)
					{
						instr.IP = num;
						if (!instr.Done)
						{
							uint size = instr.Size;
							if (instr.Optimize(num2))
							{
								if (instr.Size > size)
								{
									errorMessage = "Internal error: new size > old size";
									result = null;
									return false;
								}
								if (instr.Size < size)
								{
									num2 += size - instr.Size;
									flag = true;
								}
							}
							else if (instr.Size != size)
							{
								errorMessage = "Internal error: new size != old size";
								result = null;
								return false;
							}
						}
						num += instr.Size;
					}
				}
				if (!flag)
				{
					break;
				}
			}
			array = blocks;
			for (int j = 0; j < array.Length; j++)
			{
				array[j].InitializeData();
			}
			BlockEncoderResult[] array2 = new BlockEncoderResult[blocks.Length];
			for (int l = 0; l < blocks.Length; l++)
			{
				Block block = blocks[l];
				Encoder encoder = Encoder.Create(bitness, block.CodeWriter);
				ulong num3 = block.RIP;
				uint[] array3 = (ReturnNewInstructionOffsets ? new uint[block.Instructions.Length] : null);
				ConstantOffsets[] array4 = (ReturnConstantOffsets ? new ConstantOffsets[block.Instructions.Length] : null);
				Instr[] instructions2 = block.Instructions;
				for (int m = 0; m < instructions2.Length; m++)
				{
					Instr instr2 = instructions2[m];
					uint bytesWritten = block.CodeWriter.BytesWritten;
					bool isOriginalInstruction;
					if (array4 != null)
					{
						errorMessage = instr2.TryEncode(encoder, out array4[m], out isOriginalInstruction);
					}
					else
					{
						errorMessage = instr2.TryEncode(encoder, out var _, out isOriginalInstruction);
					}
					if (errorMessage != null)
					{
						result = null;
						return false;
					}
					uint num4 = block.CodeWriter.BytesWritten - bytesWritten;
					if (num4 != instr2.Size)
					{
						errorMessage = "Internal error: didn't write all bytes";
						result = null;
						return false;
					}
					if (array3 != null)
					{
						if (isOriginalInstruction)
						{
							array3[m] = (uint)(num3 - block.RIP);
						}
						else
						{
							array3[m] = uint.MaxValue;
						}
					}
					num3 += num4;
				}
				array2[l] = new BlockEncoderResult(block.RIP, block.relocInfos, array3, array4);
				block.WriteData();
			}
			errorMessage = null;
			result = array2;
			return true;
		}

		internal TargetInstr GetTarget(ulong address)
		{
			if (toInstr.TryGetValue(address, out var value))
			{
				return new TargetInstr(value);
			}
			return new TargetInstr(address);
		}

		internal uint GetInstructionSize(in Instruction instruction, ulong ip)
		{
			if (!nullEncoder.TryEncode(in instruction, ip, out uint encodedLength, out string _))
			{
				return 15u;
			}
			return encodedLength;
		}
	}
	public sealed class ByteArrayCodeReader : CodeReader
	{
		private readonly byte[] data;

		private int currentPosition;

		private readonly int startPosition;

		private readonly int endPosition;

		public int Position
		{
			get
			{
				return currentPosition - startPosition;
			}
			set
			{
				if ((uint)value > (uint)Count)
				{
					ThrowHelper.ThrowArgumentOutOfRangeException_value();
				}
				currentPosition = startPosition + value;
			}
		}

		public int Count => endPosition - startPosition;

		public bool CanReadByte => currentPosition < endPosition;

		public ByteArrayCodeReader(string hexData)
			: this(HexUtils.ToByteArray(hexData))
		{
		}

		public ByteArrayCodeReader(byte[] data)
		{
			if (data == null)
			{
				ThrowHelper.ThrowArgumentNullException_data();
			}
			this.data = data;
			currentPosition = 0;
			startPosition = 0;
			endPosition = data.Length;
		}

		public ByteArrayCodeReader(byte[] data, int index, int count)
		{
			if (data == null)
			{
				ThrowHelper.ThrowArgumentNullException_data();
			}
			this.data = data;
			if (index < 0)
			{
				ThrowHelper.ThrowArgumentOutOfRangeException_index();
			}
			if (count < 0)
			{
				ThrowHelper.ThrowArgumentOutOfRangeException_count();
			}
			if ((uint)(index + count) > (uint)data.Length)
			{
				ThrowHelper.ThrowArgumentOutOfRangeException_count();
			}
			currentPosition = index;
			startPosition = index;
			endPosition = index + count;
		}

		public ByteArrayCodeReader(ArraySegment<byte> data)
		{
			if (data.Array == null)
			{
				ThrowHelper.ThrowArgumentException();
			}
			this.data = data.Array;
			endPosition = (startPosition = (currentPosition = data.Offset)) + data.Count;
		}

		public override int ReadByte()
		{
			if (currentPosition >= endPosition)
			{
				return -1;
			}
			return data[currentPosition++];
		}
	}
	public enum Code
	{
		INVALID,
		DeclareByte,
		DeclareWord,
		DeclareDword,
		DeclareQword,
		Add_rm8_r8,
		Add_rm16_r16,
		Add_rm32_r32,
		Add_rm64_r64,
		Add_r8_rm8,
		Add_r16_rm16,
		Add_r32_rm32,
		Add_r64_rm64,
		Add_AL_imm8,
		Add_AX_imm16,
		Add_EAX_imm32,
		Add_RAX_imm32,
		Pushw_ES,
		Pushd_ES,
		Popw_ES,
		Popd_ES,
		Or_rm8_r8,
		Or_rm16_r16,
		Or_rm32_r32,
		Or_rm64_r64,
		Or_r8_rm8,
		Or_r16_rm16,
		Or_r32_rm32,
		Or_r64_rm64,
		Or_AL_imm8,
		Or_AX_imm16,
		Or_EAX_imm32,
		Or_RAX_imm32,
		Pushw_CS,
		Pushd_CS,
		Popw_CS,
		Adc_rm8_r8,
		Adc_rm16_r16,
		Adc_rm32_r32,
		Adc_rm64_r64,
		Adc_r8_rm8,
		Adc_r16_rm16,
		Adc_r32_rm32,
		Adc_r64_rm64,
		Adc_AL_imm8,
		Adc_AX_imm16,
		Adc_EAX_imm32,
		Adc_RAX_imm32,
		Pushw_SS,
		Pushd_SS,
		Popw_SS,
		Popd_SS,
		Sbb_rm8_r8,
		Sbb_rm16_r16,
		Sbb_rm32_r32,
		Sbb_rm64_r64,
		Sbb_r8_rm8,
		Sbb_r16_rm16,
		Sbb_r32_rm32,
		Sbb_r64_rm64,
		Sbb_AL_imm8,
		Sbb_AX_imm16,
		Sbb_EAX_imm32,
		Sbb_RAX_imm32,
		Pushw_DS,
		Pushd_DS,
		Popw_DS,
		Popd_DS,
		And_rm8_r8,
		And_rm16_r16,
		And_rm32_r32,
		And_rm64_r64,
		And_r8_rm8,
		And_r16_rm16,
		And_r32_rm32,
		And_r64_rm64,
		And_AL_imm8,
		And_AX_imm16,
		And_EAX_imm32,
		And_RAX_imm32,
		Daa,
		Sub_rm8_r8,
		Sub_rm16_r16,
		Sub_rm32_r32,
		Sub_rm64_r64,
		Sub_r8_rm8,
		Sub_r16_rm16,
		Sub_r32_rm32,
		Sub_r64_rm64,
		Sub_AL_imm8,
		Sub_AX_imm16,
		Sub_EAX_imm32,
		Sub_RAX_imm32,
		Das,
		Xor_rm8_r8,
		Xor_rm16_r16,
		Xor_rm32_r32,
		Xor_rm64_r64,
		Xor_r8_rm8,
		Xor_r16_rm16,
		Xor_r32_rm32,
		Xor_r64_rm64,
		Xor_AL_imm8,
		Xor_AX_imm16,
		Xor_EAX_imm32,
		Xor_RAX_imm32,
		Aaa,
		Cmp_rm8_r8,
		Cmp_rm16_r16,
		Cmp_rm32_r32,
		Cmp_rm64_r64,
		Cmp_r8_rm8,
		Cmp_r16_rm16,
		Cmp_r32_rm32,
		Cmp_r64_rm64,
		Cmp_AL_imm8,
		Cmp_AX_imm16,
		Cmp_EAX_imm32,
		Cmp_RAX_imm32,
		Aas,
		Inc_r16,
		Inc_r32,
		Dec_r16,
		Dec_r32,
		Push_r16,
		Push_r32,
		Push_r64,
		Pop_r16,
		Pop_r32,
		Pop_r64,
		Pushaw,
		Pushad,
		Popaw,
		Popad,
		Bound_r16_m1616,
		Bound_r32_m3232,
		Arpl_rm16_r16,
		Arpl_r32m16_r32,
		Movsxd_r16_rm16,
		Movsxd_r32_rm32,
		Movsxd_r64_rm32,
		Push_imm16,
		Pushd_imm32,
		Pushq_imm32,
		Imul_r16_rm16_imm16,
		Imul_r32_rm32_imm32,
		Imul_r64_rm64_imm32,
		Pushw_imm8,
		Pushd_imm8,
		Pushq_imm8,
		Imul_r16_rm16_imm8,
		Imul_r32_rm32_imm8,
		Imul_r64_rm64_imm8,
		Insb_m8_DX,
		Insw_m16_DX,
		Insd_m32_DX,
		Outsb_DX_m8,
		Outsw_DX_m16,
		Outsd_DX_m32,
		Jo_rel8_16,
		Jo_rel8_32,
		Jo_rel8_64,
		Jno_rel8_16,
		Jno_rel8_32,
		Jno_rel8_64,
		Jb_rel8_16,
		Jb_rel8_32,
		Jb_rel8_64,
		Jae_rel8_16,
		Jae_rel8_32,
		Jae_rel8_64,
		Je_rel8_16,
		Je_rel8_32,
		Je_rel8_64,
		Jne_rel8_16,
		Jne_rel8_32,
		Jne_rel8_64,
		Jbe_rel8_16,
		Jbe_rel8_32,
		Jbe_rel8_64,
		Ja_rel8_16,
		Ja_rel8_32,
		Ja_rel8_64,
		Js_rel8_16,
		Js_rel8_32,
		Js_rel8_64,
		Jns_rel8_16,
		Jns_rel8_32,
		Jns_rel8_64,
		Jp_rel8_16,
		Jp_rel8_32,
		Jp_rel8_64,
		Jnp_rel8_16,
		Jnp_rel8_32,
		Jnp_rel8_64,
		Jl_rel8_16,
		Jl_rel8_32,
		Jl_rel8_64,
		Jge_rel8_16,
		Jge_rel8_32,
		Jge_rel8_64,
		Jle_rel8_16,
		Jle_rel8_32,
		Jle_rel8_64,
		Jg_rel8_16,
		Jg_rel8_32,
		Jg_rel8_64,
		Add_rm8_imm8,
		Or_rm8_imm8,
		Adc_rm8_imm8,
		Sbb_rm8_imm8,
		And_rm8_imm8,
		Sub_rm8_imm8,
		Xor_rm8_imm8,
		Cmp_rm8_imm8,
		Add_rm16_imm16,
		Add_rm32_imm32,
		Add_rm64_imm32,
		Or_rm16_imm16,
		Or_rm32_imm32,
		Or_rm64_imm32,
		Adc_rm16_imm16,
		Adc_rm32_imm32,
		Adc_rm64_imm32,
		Sbb_rm16_imm16,
		Sbb_rm32_imm32,
		Sbb_rm64_imm32,
		And_rm16_imm16,
		And_rm32_imm32,
		And_rm64_imm32,
		Sub_rm16_imm16,
		Sub_rm32_imm32,
		Sub_rm64_imm32,
		Xor_rm16_imm16,
		Xor_rm32_imm32,
		Xor_rm64_imm32,
		Cmp_rm16_imm16,
		Cmp_rm32_imm32,
		Cmp_rm64_imm32,
		Add_rm8_imm8_82,
		Or_rm8_imm8_82,
		Adc_rm8_imm8_82,
		Sbb_rm8_imm8_82,
		And_rm8_imm8_82,
		Sub_rm8_imm8_82,
		Xor_rm8_imm8_82,
		Cmp_rm8_imm8_82,
		Add_rm16_imm8,
		Add_rm32_imm8,
		Add_rm64_imm8,
		Or_rm16_imm8,
		Or_rm32_imm8,
		Or_rm64_imm8,
		Adc_rm16_imm8,
		Adc_rm32_imm8,
		Adc_rm64_imm8,
		Sbb_rm16_imm8,
		Sbb_rm32_imm8,
		Sbb_rm64_imm8,
		And_rm16_imm8,
		And_rm32_imm8,
		And_rm64_imm8,
		Sub_rm16_imm8,
		Sub_rm32_imm8,
		Sub_rm64_imm8,
		Xor_rm16_imm8,
		Xor_rm32_imm8,
		Xor_rm64_imm8,
		Cmp_rm16_imm8,
		Cmp_rm32_imm8,
		Cmp_rm64_imm8,
		Test_rm8_r8,
		Test_rm16_r16,
		Test_rm32_r32,
		Test_rm64_r64,
		Xchg_rm8_r8,
		Xchg_rm16_r16,
		Xchg_rm32_r32,
		Xchg_rm64_r64,
		Mov_rm8_r8,
		Mov_rm16_r16,
		Mov_rm32_r32,
		Mov_rm64_r64,
		Mov_r8_rm8,
		Mov_r16_rm16,
		Mov_r32_rm32,
		Mov_r64_rm64,
		Mov_rm16_Sreg,
		Mov_r32m16_Sreg,
		Mov_r64m16_Sreg,
		Lea_r16_m,
		Lea_r32_m,
		Lea_r64_m,
		Mov_Sreg_rm16,
		Mov_Sreg_r32m16,
		Mov_Sreg_r64m16,
		Pop_rm16,
		Pop_rm32,
		Pop_rm64,
		Nopw,
		Nopd,
		Nopq,
		Xchg_r16_AX,
		Xchg_r32_EAX,
		Xchg_r64_RAX,
		Pause,
		Cbw,
		Cwde,
		Cdqe,
		Cwd,
		Cdq,
		Cqo,
		Call_ptr1616,
		Call_ptr1632,
		Wait,
		Pushfw,
		Pushfd,
		Pushfq,
		Popfw,
		Popfd,
		Popfq,
		Sahf,
		Lahf,
		Mov_AL_moffs8,
		Mov_AX_moffs16,
		Mov_EAX_moffs32,
		Mov_RAX_moffs64,
		Mov_moffs8_AL,
		Mov_moffs16_AX,
		Mov_moffs32_EAX,
		Mov_moffs64_RAX,
		Movsb_m8_m8,
		Movsw_m16_m16,
		Movsd_m32_m32,
		Movsq_m64_m64,
		Cmpsb_m8_m8,
		Cmpsw_m16_m16,
		Cmpsd_m32_m32,
		Cmpsq_m64_m64,
		Test_AL_imm8,
		Test_AX_imm16,
		Test_EAX_imm32,
		Test_RAX_imm32,
		Stosb_m8_AL,
		Stosw_m16_AX,
		Stosd_m32_EAX,
		Stosq_m64_RAX,
		Lodsb_AL_m8,
		Lodsw_AX_m16,
		Lodsd_EAX_m32,
		Lodsq_RAX_m64,
		Scasb_AL_m8,
		Scasw_AX_m16,
		Scasd_EAX_m32,
		Scasq_RAX_m64,
		Mov_r8_imm8,
		Mov_r16_imm16,
		Mov_r32_imm32,
		Mov_r64_imm64,
		Rol_rm8_imm8,
		Ror_rm8_imm8,
		Rcl_rm8_imm8,
		Rcr_rm8_imm8,
		Shl_rm8_imm8,
		Shr_rm8_imm8,
		Sal_rm8_imm8,
		Sar_rm8_imm8,
		Rol_rm16_imm8,
		Rol_rm32_imm8,
		Rol_rm64_imm8,
		Ror_rm16_imm8,
		Ror_rm32_imm8,
		Ror_rm64_imm8,
		Rcl_rm16_imm8,
		Rcl_rm32_imm8,
		Rcl_rm64_imm8,
		Rcr_rm16_imm8,
		Rcr_rm32_imm8,
		Rcr_rm64_imm8,
		Shl_rm16_imm8,
		Shl_rm32_imm8,
		Shl_rm64_imm8,
		Shr_rm16_imm8,
		Shr_rm32_imm8,
		Shr_rm64_imm8,
		Sal_rm16_imm8,
		Sal_rm32_imm8,
		Sal_rm64_imm8,
		Sar_rm16_imm8,
		Sar_rm32_imm8,
		Sar_rm64_imm8,
		Retnw_imm16,
		Retnd_imm16,
		Retnq_imm16,
		Retnw,
		Retnd,
		Retnq,
		Les_r16_m1616,
		Les_r32_m1632,
		Lds_r16_m1616,
		Lds_r32_m1632,
		Mov_rm8_imm8,
		Xabort_imm8,
		Mov_rm16_imm16,
		Mov_rm32_imm32,
		Mov_rm64_imm32,
		Xbegin_rel16,
		Xbegin_rel32,
		Enterw_imm16_imm8,
		Enterd_imm16_imm8,
		Enterq_imm16_imm8,
		Leavew,
		Leaved,
		Leaveq,
		Retfw_imm16,
		Retfd_imm16,
		Retfq_imm16,
		Retfw,
		Retfd,
		Retfq,
		Int3,
		Int_imm8,
		Into,
		Iretw,
		Iretd,
		Iretq,
		Rol_rm8_1,
		Ror_rm8_1,
		Rcl_rm8_1,
		Rcr_rm8_1,
		Shl_rm8_1,
		Shr_rm8_1,
		Sal_rm8_1,
		Sar_rm8_1,
		Rol_rm16_1,
		Rol_rm32_1,
		Rol_rm64_1,
		Ror_rm16_1,
		Ror_rm32_1,
		Ror_rm64_1,
		Rcl_rm16_1,
		Rcl_rm32_1,
		Rcl_rm64_1,
		Rcr_rm16_1,
		Rcr_rm32_1,
		Rcr_rm64_1,
		Shl_rm16_1,
		Shl_rm32_1,
		Shl_rm64_1,
		Shr_rm16_1,
		Shr_rm32_1,
		Shr_rm64_1,
		Sal_rm16_1,
		Sal_rm32_1,
		Sal_rm64_1,
		Sar_rm16_1,
		Sar_rm32_1,
		Sar_rm64_1,
		Rol_rm8_CL,
		Ror_rm8_CL,
		Rcl_rm8_CL,
		Rcr_rm8_CL,
		Shl_rm8_CL,
		Shr_rm8_CL,
		Sal_rm8_CL,
		Sar_rm8_CL,
		Rol_rm16_CL,
		Rol_rm32_CL,
		Rol_rm64_CL,
		Ror_rm16_CL,
		Ror_rm32_CL,
		Ror_rm64_CL,
		Rcl_rm16_CL,
		Rcl_rm32_CL,
		Rcl_rm64_CL,
		Rcr_rm16_CL,
		Rcr_rm32_CL,
		Rcr_rm64_CL,
		Shl_rm16_CL,
		Shl_rm32_CL,
		Shl_rm64_CL,
		Shr_rm16_CL,
		Shr_rm32_CL,
		Shr_rm64_CL,
		Sal_rm16_CL,
		Sal_rm32_CL,
		Sal_rm64_CL,
		Sar_rm16_CL,
		Sar_rm32_CL,
		Sar_rm64_CL,
		Aam_imm8,
		Aad_imm8,
		Salc,
		Xlat_m8,
		Fadd_m32fp,
		Fmul_m32fp,
		Fcom_m32fp,
		Fcomp_m32fp,
		Fsub_m32fp,
		Fsubr_m32fp,
		Fdiv_m32fp,
		Fdivr_m32fp,
		Fadd_st0_sti,
		Fmul_st0_sti,
		Fcom_st0_sti,
		Fcomp_st0_sti,
		Fsub_st0_sti,
		Fsubr_st0_sti,
		Fdiv_st0_sti,
		Fdivr_st0_sti,
		Fld_m32fp,
		Fst_m32fp,
		Fstp_m32fp,
		Fldenv_m14byte,
		Fldenv_m28byte,
		Fldcw_m2byte,
		Fnstenv_m14byte,
		Fstenv_m14byte,
		Fnstenv_m28byte,
		Fstenv_m28byte,
		Fnstcw_m2byte,
		Fstcw_m2byte,
		Fld_sti,
		Fxch_st0_sti,
		Fnop,
		Fstpnce_sti,
		Fchs,
		Fabs,
		Ftst,
		Fxam,
		Fld1,
		Fldl2t,
		Fldl2e,
		Fldpi,
		Fldlg2,
		Fldln2,
		Fldz,
		F2xm1,
		Fyl2x,
		Fptan,
		Fpatan,
		Fxtract,
		Fprem1,
		Fdecstp,
		Fincstp,
		Fprem,
		Fyl2xp1,
		Fsqrt,
		Fsincos,
		Frndint,
		Fscale,
		Fsin,
		Fcos,
		Fiadd_m32int,
		Fimul_m32int,
		Ficom_m32int,
		Ficomp_m32int,
		Fisub_m32int,
		Fisubr_m32int,
		Fidiv_m32int,
		Fidivr_m32int,
		Fcmovb_st0_sti,
		Fcmove_st0_sti,
		Fcmovbe_st0_sti,
		Fcmovu_st0_sti,
		Fucompp,
		Fild_m32int,
		Fisttp_m32int,
		Fist_m32int,
		Fistp_m32int,
		Fld_m80fp,
		Fstp_m80fp,
		Fcmovnb_st0_sti,
		Fcmovne_st0_sti,
		Fcmovnbe_st0_sti,
		Fcmovnu_st0_sti,
		Fneni,
		Feni,
		Fndisi,
		Fdisi,
		Fnclex,
		Fclex,
		Fninit,
		Finit,
		Fnsetpm,
		Fsetpm,
		Frstpm,
		Fucomi_st0_sti,
		Fcomi_st0_sti,
		Fadd_m64fp,
		Fmul_m64fp,
		Fcom_m64fp,
		Fcomp_m64fp,
		Fsub_m64fp,
		Fsubr_m64fp,
		Fdiv_m64fp,
		Fdivr_m64fp,
		Fadd_sti_st0,
		Fmul_sti_st0,
		Fcom_st0_sti_DCD0,
		Fcomp_st0_sti_DCD8,
		Fsubr_sti_st0,
		Fsub_sti_st0,
		Fdivr_sti_st0,
		Fdiv_sti_st0,
		Fld_m64fp,
		Fisttp_m64int,
		Fst_m64fp,
		Fstp_m64fp,
		Frstor_m94byte,
		Frstor_m108byte,
		Fnsave_m94byte,
		Fsave_m94byte,
		Fnsave_m108byte,
		Fsave_m108byte,
		Fnstsw_m2byte,
		Fstsw_m2byte,
		Ffree_sti,
		Fxch_st0_sti_DDC8,
		Fst_sti,
		Fstp_sti,
		Fucom_st0_sti,
		Fucomp_st0_sti,
		Fiadd_m16int,
		Fimul_m16int,
		Ficom_m16int,
		Ficomp_m16int,
		Fisub_m16int,
		Fisubr_m16int,
		Fidiv_m16int,
		Fidivr_m16int,
		Faddp_sti_st0,
		Fmulp_sti_st0,
		Fcomp_st0_sti_DED0,
		Fcompp,
		Fsubrp_sti_st0,
		Fsubp_sti_st0,
		Fdivrp_sti_st0,
		Fdivp_sti_st0,
		Fild_m16int,
		Fisttp_m16int,
		Fist_m16int,
		Fistp_m16int,
		Fbld_m80bcd,
		Fild_m64int,
		Fbstp_m80bcd,
		Fistp_m64int,
		Ffreep_sti,
		Fxch_st0_sti_DFC8,
		Fstp_sti_DFD0,
		Fstp_sti_DFD8,
		Fnstsw_AX,
		Fstsw_AX,
		Fstdw_AX,
		Fstsg_AX,
		Fucomip_st0_sti,
		Fcomip_st0_sti,
		Loopne_rel8_16_CX,
		Loopne_rel8_32_CX,
		Loopne_rel8_16_ECX,
		Loopne_rel8_32_ECX,
		Loopne_rel8_64_ECX,
		Loopne_rel8_16_RCX,
		Loopne_rel8_64_RCX,
		Loope_rel8_16_CX,
		Loope_rel8_32_CX,
		Loope_rel8_16_ECX,
		Loope_rel8_32_ECX,
		Loope_rel8_64_ECX,
		Loope_rel8_16_RCX,
		Loope_rel8_64_RCX,
		Loop_rel8_16_CX,
		Loop_rel8_32_CX,
		Loop_rel8_16_ECX,
		Loop_rel8_32_ECX,
		Loop_rel8_64_ECX,
		Loop_rel8_16_RCX,
		Loop_rel8_64_RCX,
		Jcxz_rel8_16,
		Jcxz_rel8_32,
		Jecxz_rel8_16,
		Jecxz_rel8_32,
		Jecxz_rel8_64,
		Jrcxz_rel8_16,
		Jrcxz_rel8_64,
		In_AL_imm8,
		In_AX_imm8,
		In_EAX_imm8,
		Out_imm8_AL,
		Out_imm8_AX,
		Out_imm8_EAX,
		Call_rel16,
		Call_rel32_32,
		Call_rel32_64,
		Jmp_rel16,
		Jmp_rel32_32,
		Jmp_rel32_64,
		Jmp_ptr1616,
		Jmp_ptr1632,
		Jmp_rel8_16,
		Jmp_rel8_32,
		Jmp_rel8_64,
		In_AL_DX,
		In_AX_DX,
		In_EAX_DX,
		Out_DX_AL,
		Out_DX_AX,
		Out_DX_EAX,
		Int1,
		Hlt,
		Cmc,
		Test_rm8_imm8,
		Test_rm8_imm8_F6r1,
		Not_rm8,
		Neg_rm8,
		Mul_rm8,
		Imul_rm8,
		Div_rm8,
		Idiv_rm8,
		Test_rm16_imm16,
		Test_rm32_imm32,
		Test_rm64_imm32,
		Test_rm16_imm16_F7r1,
		Test_rm32_imm32_F7r1,
		Test_rm64_imm32_F7r1,
		Not_rm16,
		Not_rm32,
		Not_rm64,
		Neg_rm16,
		Neg_rm32,
		Neg_rm64,
		Mul_rm16,
		Mul_rm32,
		Mul_rm64,
		Imul_rm16,
		Imul_rm32,
		Imul_rm64,
		Div_rm16,
		Div_rm32,
		Div_rm64,
		Idiv_rm16,
		Idiv_rm32,
		Idiv_rm64,
		Clc,
		Stc,
		Cli,
		Sti,
		Cld,
		Std,
		Inc_rm8,
		Dec_rm8,
		Inc_rm16,
		Inc_rm32,
		Inc_rm64,
		Dec_rm16,
		Dec_rm32,
		Dec_rm64,
		Call_rm16,
		Call_rm32,
		Call_rm64,
		Call_m1616,
		Call_m1632,
		Call_m1664,
		Jmp_rm16,
		Jmp_rm32,
		Jmp_rm64,
		Jmp_m1616,
		Jmp_m1632,
		Jmp_m1664,
		Push_rm16,
		Push_rm32,
		Push_rm64,
		Sldt_rm16,
		Sldt_r32m16,
		Sldt_r64m16,
		Str_rm16,
		Str_r32m16,
		Str_r64m16,
		Lldt_rm16,
		Lldt_r32m16,
		Lldt_r64m16,
		Ltr_rm16,
		Ltr_r32m16,
		Ltr_r64m16,
		Verr_rm16,
		Verr_r32m16,
		Verr_r64m16,
		Verw_rm16,
		Verw_r32m16,
		Verw_r64m16,
		Jmpe_rm16,
		Jmpe_rm32,
		Sgdt_m1632_16,
		Sgdt_m1632,
		Sgdt_m1664,
		Sidt_m1632_16,
		Sidt_m1632,
		Sidt_m1664,
		Lgdt_m1632_16,
		Lgdt_m1632,
		Lgdt_m1664,
		Lidt_m1632_16,
		Lidt_m1632,
		Lidt_m1664,
		Smsw_rm16,
		Smsw_r32m16,
		Smsw_r64m16,
		Rstorssp_m64,
		Lmsw_rm16,
		Lmsw_r32m16,
		Lmsw_r64m16,
		Invlpg_m,
		Enclv,
		Vmcall,
		Vmlaunch,
		Vmresume,
		Vmxoff,
		Pconfig,
		Monitorw,
		Monitord,
		Monitorq,
		Mwait,
		Clac,
		Stac,
		Encls,
		Xgetbv,
		Xsetbv,
		Vmfunc,
		Xend,
		Xtest,
		Enclu,
		Vmrunw,
		Vmrund,
		Vmrunq,
		Vmmcall,
		Vmloadw,
		Vmloadd,
		Vmloadq,
		Vmsavew,
		Vmsaved,
		Vmsaveq,
		Stgi,
		Clgi,
		Skinit,
		Invlpgaw,
		Invlpgad,
		Invlpgaq,
		Setssbsy,
		Saveprevssp,
		Rdpkru,
		Wrpkru,
		Swapgs,
		Rdtscp,
		Monitorxw,
		Monitorxd,
		Monitorxq,
		Mcommit,
		Mwaitx,
		Clzerow,
		Clzerod,
		Clzeroq,
		Rdpru,
		Lar_r16_rm16,
		Lar_r32_r32m16,
		Lar_r64_r64m16,
		Lsl_r16_rm16,
		Lsl_r32_r32m16,
		Lsl_r64_r64m16,
		Storeall,
		Loadall286,
		Syscall,
		Clts,
		Loadall386,
		Sysretd,
		Sysretq,
		Invd,
		Wbinvd,
		Wbnoinvd,
		Cl1invmb,
		Ud2,
		Reservednop_rm16_r16_0F0D,
		Reservednop_rm32_r32_0F0D,
		Reservednop_rm64_r64_0F0D,
		Prefetch_m8,
		Prefetchw_m8,
		Prefetchwt1_m8,
		Femms,
		Umov_rm8_r8,
		Umov_rm16_r16,
		Umov_rm32_r32,
		Umov_r8_rm8,
		Umov_r16_rm16,
		Umov_r32_rm32,
		Movups_xmm_xmmm128,
		VEX_Vmovups_xmm_xmmm128,
		VEX_Vmovups_ymm_ymmm256,
		EVEX_Vmovups_xmm_k1z_xmmm128,
		EVEX_Vmovups_ymm_k1z_ymmm256,
		EVEX_Vmovups_zmm_k1z_zmmm512,
		Movupd_xmm_xmmm128,
		VEX_Vmovupd_xmm_xmmm128,
		VEX_Vmovupd_ymm_ymmm256,
		EVEX_Vmovupd_xmm_k1z_xmmm128,
		EVEX_Vmovupd_ymm_k1z_ymmm256,
		EVEX_Vmovupd_zmm_k1z_zmmm512,
		Movss_xmm_xmmm32,
		VEX_Vmovss_xmm_xmm_xmm,
		VEX_Vmovss_xmm_m32,
		EVEX_Vmovss_xmm_k1z_xmm_xmm,
		EVEX_Vmovss_xmm_k1z_m32,
		Movsd_xmm_xmmm64,
		VEX_Vmovsd_xmm_xmm_xmm,
		VEX_Vmovsd_xmm_m64,
		EVEX_Vmovsd_xmm_k1z_xmm_xmm,
		EVEX_Vmovsd_xmm_k1z_m64,
		Movups_xmmm128_xmm,
		VEX_Vmovups_xmmm128_xmm,
		VEX_Vmovups_ymmm256_ymm,
		EVEX_Vmovups_xmmm128_k1z_xmm,
		EVEX_Vmovups_ymmm256_k1z_ymm,
		EVEX_Vmovups_zmmm512_k1z_zmm,
		Movupd_xmmm128_xmm,
		VEX_Vmovupd_xmmm128_xmm,
		VEX_Vmovupd_ymmm256_ymm,
		EVEX_Vmovupd_xmmm128_k1z_xmm,
		EVEX_Vmovupd_ymmm256_k1z_ymm,
		EVEX_Vmovupd_zmmm512_k1z_zmm,
		Movss_xmmm32_xmm,
		VEX_Vmovss_xmm_xmm_xmm_0F11,
		VEX_Vmovss_m32_xmm,
		EVEX_Vmovss_xmm_k1z_xmm_xmm_0F11,
		EVEX_Vmovss_m32_k1_xmm,
		Movsd_xmmm64_xmm,
		VEX_Vmovsd_xmm_xmm_xmm_0F11,
		VEX_Vmovsd_m64_xmm,
		EVEX_Vmovsd_xmm_k1z_xmm_xmm_0F11,
		EVEX_Vmovsd_m64_k1_xmm,
		Movhlps_xmm_xmm,
		Movlps_xmm_m64,
		VEX_Vmovhlps_xmm_xmm_xmm,
		VEX_Vmovlps_xmm_xmm_m64,
		EVEX_Vmovhlps_xmm_xmm_xmm,
		EVEX_Vmovlps_xmm_xmm_m64,
		Movlpd_xmm_m64,
		VEX_Vmovlpd_xmm_xmm_m64,
		EVEX_Vmovlpd_xmm_xmm_m64,
		Movsldup_xmm_xmmm128,
		VEX_Vmovsldup_xmm_xmmm128,
		VEX_Vmovsldup_ymm_ymmm256,
		EVEX_Vmovsldup_xmm_k1z_xmmm128,
		EVEX_Vmovsldup_ymm_k1z_ymmm256,
		EVEX_Vmovsldup_zmm_k1z_zmmm512,
		Movddup_xmm_xmmm64,
		VEX_Vmovddup_xmm_xmmm64,
		VEX_Vmovddup_ymm_ymmm256,
		EVEX_Vmovddup_xmm_k1z_xmmm64,
		EVEX_Vmovddup_ymm_k1z_ymmm256,
		EVEX_Vmovddup_zmm_k1z_zmmm512,
		Movlps_m64_xmm,
		VEX_Vmovlps_m64_xmm,
		EVEX_Vmovlps_m64_xmm,
		Movlpd_m64_xmm,
		VEX_Vmovlpd_m64_xmm,
		EVEX_Vmovlpd_m64_xmm,
		Unpcklps_xmm_xmmm128,
		VEX_Vunpcklps_xmm_xmm_xmmm128,
		VEX_Vunpcklps_ymm_ymm_ymmm256,
		EVEX_Vunpcklps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vunpcklps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vunpcklps_zmm_k1z_zmm_zmmm512b32,
		Unpcklpd_xmm_xmmm128,
		VEX_Vunpcklpd_xmm_xmm_xmmm128,
		VEX_Vunpcklpd_ymm_ymm_ymmm256,
		EVEX_Vunpcklpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vunpcklpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vunpcklpd_zmm_k1z_zmm_zmmm512b64,
		Unpckhps_xmm_xmmm128,
		VEX_Vunpckhps_xmm_xmm_xmmm128,
		VEX_Vunpckhps_ymm_ymm_ymmm256,
		EVEX_Vunpckhps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vunpckhps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vunpckhps_zmm_k1z_zmm_zmmm512b32,
		Unpckhpd_xmm_xmmm128,
		VEX_Vunpckhpd_xmm_xmm_xmmm128,
		VEX_Vunpckhpd_ymm_ymm_ymmm256,
		EVEX_Vunpckhpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vunpckhpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vunpckhpd_zmm_k1z_zmm_zmmm512b64,
		Movlhps_xmm_xmm,
		VEX_Vmovlhps_xmm_xmm_xmm,
		EVEX_Vmovlhps_xmm_xmm_xmm,
		Movhps_xmm_m64,
		VEX_Vmovhps_xmm_xmm_m64,
		EVEX_Vmovhps_xmm_xmm_m64,
		Movhpd_xmm_m64,
		VEX_Vmovhpd_xmm_xmm_m64,
		EVEX_Vmovhpd_xmm_xmm_m64,
		Movshdup_xmm_xmmm128,
		VEX_Vmovshdup_xmm_xmmm128,
		VEX_Vmovshdup_ymm_ymmm256,
		EVEX_Vmovshdup_xmm_k1z_xmmm128,
		EVEX_Vmovshdup_ymm_k1z_ymmm256,
		EVEX_Vmovshdup_zmm_k1z_zmmm512,
		Movhps_m64_xmm,
		VEX_Vmovhps_m64_xmm,
		EVEX_Vmovhps_m64_xmm,
		Movhpd_m64_xmm,
		VEX_Vmovhpd_m64_xmm,
		EVEX_Vmovhpd_m64_xmm,
		Reservednop_rm16_r16_0F18,
		Reservednop_rm32_r32_0F18,
		Reservednop_rm64_r64_0F18,
		Reservednop_rm16_r16_0F19,
		Reservednop_rm32_r32_0F19,
		Reservednop_rm64_r64_0F19,
		Reservednop_rm16_r16_0F1A,
		Reservednop_rm32_r32_0F1A,
		Reservednop_rm64_r64_0F1A,
		Reservednop_rm16_r16_0F1B,
		Reservednop_rm32_r32_0F1B,
		Reservednop_rm64_r64_0F1B,
		Reservednop_rm16_r16_0F1C,
		Reservednop_rm32_r32_0F1C,
		Reservednop_rm64_r64_0F1C,
		Reservednop_rm16_r16_0F1D,
		Reservednop_rm32_r32_0F1D,
		Reservednop_rm64_r64_0F1D,
		Reservednop_rm16_r16_0F1E,
		Reservednop_rm32_r32_0F1E,
		Reservednop_rm64_r64_0F1E,
		Reservednop_rm16_r16_0F1F,
		Reservednop_rm32_r32_0F1F,
		Reservednop_rm64_r64_0F1F,
		Prefetchnta_m8,
		Prefetcht0_m8,
		Prefetcht1_m8,
		Prefetcht2_m8,
		Bndldx_bnd_mib,
		Bndmov_bnd_bndm64,
		Bndmov_bnd_bndm128,
		Bndcl_bnd_rm32,
		Bndcl_bnd_rm64,
		Bndcu_bnd_rm32,
		Bndcu_bnd_rm64,
		Bndstx_mib_bnd,
		Bndmov_bndm64_bnd,
		Bndmov_bndm128_bnd,
		Bndmk_bnd_m32,
		Bndmk_bnd_m64,
		Bndcn_bnd_rm32,
		Bndcn_bnd_rm64,
		Cldemote_m8,
		Rdsspd_r32,
		Rdsspq_r64,
		Endbr64,
		Endbr32,
		Nop_rm16,
		Nop_rm32,
		Nop_rm64,
		Mov_r32_cr,
		Mov_r64_cr,
		Mov_r32_dr,
		Mov_r64_dr,
		Mov_cr_r32,
		Mov_cr_r64,
		Mov_dr_r32,
		Mov_dr_r64,
		Mov_r32_tr,
		Mov_tr_r32,
		Movaps_xmm_xmmm128,
		VEX_Vmovaps_xmm_xmmm128,
		VEX_Vmovaps_ymm_ymmm256,
		EVEX_Vmovaps_xmm_k1z_xmmm128,
		EVEX_Vmovaps_ymm_k1z_ymmm256,
		EVEX_Vmovaps_zmm_k1z_zmmm512,
		Movapd_xmm_xmmm128,
		VEX_Vmovapd_xmm_xmmm128,
		VEX_Vmovapd_ymm_ymmm256,
		EVEX_Vmovapd_xmm_k1z_xmmm128,
		EVEX_Vmovapd_ymm_k1z_ymmm256,
		EVEX_Vmovapd_zmm_k1z_zmmm512,
		Movaps_xmmm128_xmm,
		VEX_Vmovaps_xmmm128_xmm,
		VEX_Vmovaps_ymmm256_ymm,
		EVEX_Vmovaps_xmmm128_k1z_xmm,
		EVEX_Vmovaps_ymmm256_k1z_ymm,
		EVEX_Vmovaps_zmmm512_k1z_zmm,
		Movapd_xmmm128_xmm,
		VEX_Vmovapd_xmmm128_xmm,
		VEX_Vmovapd_ymmm256_ymm,
		EVEX_Vmovapd_xmmm128_k1z_xmm,
		EVEX_Vmovapd_ymmm256_k1z_ymm,
		EVEX_Vmovapd_zmmm512_k1z_zmm,
		Cvtpi2ps_xmm_mmm64,
		Cvtpi2pd_xmm_mmm64,
		Cvtsi2ss_xmm_rm32,
		Cvtsi2ss_xmm_rm64,
		VEX_Vcvtsi2ss_xmm_xmm_rm32,
		VEX_Vcvtsi2ss_xmm_xmm_rm64,
		EVEX_Vcvtsi2ss_xmm_xmm_rm32_er,
		EVEX_Vcvtsi2ss_xmm_xmm_rm64_er,
		Cvtsi2sd_xmm_rm32,
		Cvtsi2sd_xmm_rm64,
		VEX_Vcvtsi2sd_xmm_xmm_rm32,
		VEX_Vcvtsi2sd_xmm_xmm_rm64,
		EVEX_Vcvtsi2sd_xmm_xmm_rm32_er,
		EVEX_Vcvtsi2sd_xmm_xmm_rm64_er,
		Movntps_m128_xmm,
		VEX_Vmovntps_m128_xmm,
		VEX_Vmovntps_m256_ymm,
		EVEX_Vmovntps_m128_xmm,
		EVEX_Vmovntps_m256_ymm,
		EVEX_Vmovntps_m512_zmm,
		Movntpd_m128_xmm,
		VEX_Vmovntpd_m128_xmm,
		VEX_Vmovntpd_m256_ymm,
		EVEX_Vmovntpd_m128_xmm,
		EVEX_Vmovntpd_m256_ymm,
		EVEX_Vmovntpd_m512_zmm,
		Movntss_m32_xmm,
		Movntsd_m64_xmm,
		Cvttps2pi_mm_xmmm64,
		Cvttpd2pi_mm_xmmm128,
		Cvttss2si_r32_xmmm32,
		Cvttss2si_r64_xmmm32,
		VEX_Vcvttss2si_r32_xmmm32,
		VEX_Vcvttss2si_r64_xmmm32,
		EVEX_Vcvttss2si_r32_xmmm32_sae,
		EVEX_Vcvttss2si_r64_xmmm32_sae,
		Cvttsd2si_r32_xmmm64,
		Cvttsd2si_r64_xmmm64,
		VEX_Vcvttsd2si_r32_xmmm64,
		VEX_Vcvttsd2si_r64_xmmm64,
		EVEX_Vcvttsd2si_r32_xmmm64_sae,
		EVEX_Vcvttsd2si_r64_xmmm64_sae,
		Cvtps2pi_mm_xmmm64,
		Cvtpd2pi_mm_xmmm128,
		Cvtss2si_r32_xmmm32,
		Cvtss2si_r64_xmmm32,
		VEX_Vcvtss2si_r32_xmmm32,
		VEX_Vcvtss2si_r64_xmmm32,
		EVEX_Vcvtss2si_r32_xmmm32_er,
		EVEX_Vcvtss2si_r64_xmmm32_er,
		Cvtsd2si_r32_xmmm64,
		Cvtsd2si_r64_xmmm64,
		VEX_Vcvtsd2si_r32_xmmm64,
		VEX_Vcvtsd2si_r64_xmmm64,
		EVEX_Vcvtsd2si_r32_xmmm64_er,
		EVEX_Vcvtsd2si_r64_xmmm64_er,
		Ucomiss_xmm_xmmm32,
		VEX_Vucomiss_xmm_xmmm32,
		EVEX_Vucomiss_xmm_xmmm32_sae,
		Ucomisd_xmm_xmmm64,
		VEX_Vucomisd_xmm_xmmm64,
		EVEX_Vucomisd_xmm_xmmm64_sae,
		Comiss_xmm_xmmm32,
		Comisd_xmm_xmmm64,
		VEX_Vcomiss_xmm_xmmm32,
		VEX_Vcomisd_xmm_xmmm64,
		EVEX_Vcomiss_xmm_xmmm32_sae,
		EVEX_Vcomisd_xmm_xmmm64_sae,
		Wrmsr,
		Rdtsc,
		Rdmsr,
		Rdpmc,
		Sysenter,
		Sysexitd,
		Sysexitq,
		Getsecd,
		Cmovo_r16_rm16,
		Cmovo_r32_rm32,
		Cmovo_r64_rm64,
		Cmovno_r16_rm16,
		Cmovno_r32_rm32,
		Cmovno_r64_rm64,
		Cmovb_r16_rm16,
		Cmovb_r32_rm32,
		Cmovb_r64_rm64,
		Cmovae_r16_rm16,
		Cmovae_r32_rm32,
		Cmovae_r64_rm64,
		Cmove_r16_rm16,
		Cmove_r32_rm32,
		Cmove_r64_rm64,
		Cmovne_r16_rm16,
		Cmovne_r32_rm32,
		Cmovne_r64_rm64,
		Cmovbe_r16_rm16,
		Cmovbe_r32_rm32,
		Cmovbe_r64_rm64,
		Cmova_r16_rm16,
		Cmova_r32_rm32,
		Cmova_r64_rm64,
		Cmovs_r16_rm16,
		Cmovs_r32_rm32,
		Cmovs_r64_rm64,
		Cmovns_r16_rm16,
		Cmovns_r32_rm32,
		Cmovns_r64_rm64,
		Cmovp_r16_rm16,
		Cmovp_r32_rm32,
		Cmovp_r64_rm64,
		Cmovnp_r16_rm16,
		Cmovnp_r32_rm32,
		Cmovnp_r64_rm64,
		Cmovl_r16_rm16,
		Cmovl_r32_rm32,
		Cmovl_r64_rm64,
		Cmovge_r16_rm16,
		Cmovge_r32_rm32,
		Cmovge_r64_rm64,
		Cmovle_r16_rm16,
		Cmovle_r32_rm32,
		Cmovle_r64_rm64,
		Cmovg_r16_rm16,
		Cmovg_r32_rm32,
		Cmovg_r64_rm64,
		VEX_Kandw_kr_kr_kr,
		VEX_Kandq_kr_kr_kr,
		VEX_Kandb_kr_kr_kr,
		VEX_Kandd_kr_kr_kr,
		VEX_Kandnw_kr_kr_kr,
		VEX_Kandnq_kr_kr_kr,
		VEX_Kandnb_kr_kr_kr,
		VEX_Kandnd_kr_kr_kr,
		VEX_Knotw_kr_kr,
		VEX_Knotq_kr_kr,
		VEX_Knotb_kr_kr,
		VEX_Knotd_kr_kr,
		VEX_Korw_kr_kr_kr,
		VEX_Korq_kr_kr_kr,
		VEX_Korb_kr_kr_kr,
		VEX_Kord_kr_kr_kr,
		VEX_Kxnorw_kr_kr_kr,
		VEX_Kxnorq_kr_kr_kr,
		VEX_Kxnorb_kr_kr_kr,
		VEX_Kxnord_kr_kr_kr,
		VEX_Kxorw_kr_kr_kr,
		VEX_Kxorq_kr_kr_kr,
		VEX_Kxorb_kr_kr_kr,
		VEX_Kxord_kr_kr_kr,
		VEX_Kaddw_kr_kr_kr,
		VEX_Kaddq_kr_kr_kr,
		VEX_Kaddb_kr_kr_kr,
		VEX_Kaddd_kr_kr_kr,
		VEX_Kunpckwd_kr_kr_kr,
		VEX_Kunpckdq_kr_kr_kr,
		VEX_Kunpckbw_kr_kr_kr,
		Movmskps_r32_xmm,
		Movmskps_r64_xmm,
		VEX_Vmovmskps_r32_xmm,
		VEX_Vmovmskps_r64_xmm,
		VEX_Vmovmskps_r32_ymm,
		VEX_Vmovmskps_r64_ymm,
		Movmskpd_r32_xmm,
		Movmskpd_r64_xmm,
		VEX_Vmovmskpd_r32_xmm,
		VEX_Vmovmskpd_r64_xmm,
		VEX_Vmovmskpd_r32_ymm,
		VEX_Vmovmskpd_r64_ymm,
		Sqrtps_xmm_xmmm128,
		VEX_Vsqrtps_xmm_xmmm128,
		VEX_Vsqrtps_ymm_ymmm256,
		EVEX_Vsqrtps_xmm_k1z_xmmm128b32,
		EVEX_Vsqrtps_ymm_k1z_ymmm256b32,
		EVEX_Vsqrtps_zmm_k1z_zmmm512b32_er,
		Sqrtpd_xmm_xmmm128,
		VEX_Vsqrtpd_xmm_xmmm128,
		VEX_Vsqrtpd_ymm_ymmm256,
		EVEX_Vsqrtpd_xmm_k1z_xmmm128b64,
		EVEX_Vsqrtpd_ymm_k1z_ymmm256b64,
		EVEX_Vsqrtpd_zmm_k1z_zmmm512b64_er,
		Sqrtss_xmm_xmmm32,
		VEX_Vsqrtss_xmm_xmm_xmmm32,
		EVEX_Vsqrtss_xmm_k1z_xmm_xmmm32_er,
		Sqrtsd_xmm_xmmm64,
		VEX_Vsqrtsd_xmm_xmm_xmmm64,
		EVEX_Vsqrtsd_xmm_k1z_xmm_xmmm64_er,
		Rsqrtps_xmm_xmmm128,
		VEX_Vrsqrtps_xmm_xmmm128,
		VEX_Vrsqrtps_ymm_ymmm256,
		Rsqrtss_xmm_xmmm32,
		VEX_Vrsqrtss_xmm_xmm_xmmm32,
		Rcpps_xmm_xmmm128,
		VEX_Vrcpps_xmm_xmmm128,
		VEX_Vrcpps_ymm_ymmm256,
		Rcpss_xmm_xmmm32,
		VEX_Vrcpss_xmm_xmm_xmmm32,
		Andps_xmm_xmmm128,
		VEX_Vandps_xmm_xmm_xmmm128,
		VEX_Vandps_ymm_ymm_ymmm256,
		EVEX_Vandps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vandps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vandps_zmm_k1z_zmm_zmmm512b32,
		Andpd_xmm_xmmm128,
		VEX_Vandpd_xmm_xmm_xmmm128,
		VEX_Vandpd_ymm_ymm_ymmm256,
		EVEX_Vandpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vandpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vandpd_zmm_k1z_zmm_zmmm512b64,
		Andnps_xmm_xmmm128,
		VEX_Vandnps_xmm_xmm_xmmm128,
		VEX_Vandnps_ymm_ymm_ymmm256,
		EVEX_Vandnps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vandnps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vandnps_zmm_k1z_zmm_zmmm512b32,
		Andnpd_xmm_xmmm128,
		VEX_Vandnpd_xmm_xmm_xmmm128,
		VEX_Vandnpd_ymm_ymm_ymmm256,
		EVEX_Vandnpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vandnpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vandnpd_zmm_k1z_zmm_zmmm512b64,
		Orps_xmm_xmmm128,
		VEX_Vorps_xmm_xmm_xmmm128,
		VEX_Vorps_ymm_ymm_ymmm256,
		EVEX_Vorps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vorps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vorps_zmm_k1z_zmm_zmmm512b32,
		Orpd_xmm_xmmm128,
		VEX_Vorpd_xmm_xmm_xmmm128,
		VEX_Vorpd_ymm_ymm_ymmm256,
		EVEX_Vorpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vorpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vorpd_zmm_k1z_zmm_zmmm512b64,
		Xorps_xmm_xmmm128,
		VEX_Vxorps_xmm_xmm_xmmm128,
		VEX_Vxorps_ymm_ymm_ymmm256,
		EVEX_Vxorps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vxorps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vxorps_zmm_k1z_zmm_zmmm512b32,
		Xorpd_xmm_xmmm128,
		VEX_Vxorpd_xmm_xmm_xmmm128,
		VEX_Vxorpd_ymm_ymm_ymmm256,
		EVEX_Vxorpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vxorpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vxorpd_zmm_k1z_zmm_zmmm512b64,
		Addps_xmm_xmmm128,
		VEX_Vaddps_xmm_xmm_xmmm128,
		VEX_Vaddps_ymm_ymm_ymmm256,
		EVEX_Vaddps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vaddps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vaddps_zmm_k1z_zmm_zmmm512b32_er,
		Addpd_xmm_xmmm128,
		VEX_Vaddpd_xmm_xmm_xmmm128,
		VEX_Vaddpd_ymm_ymm_ymmm256,
		EVEX_Vaddpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vaddpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vaddpd_zmm_k1z_zmm_zmmm512b64_er,
		Addss_xmm_xmmm32,
		VEX_Vaddss_xmm_xmm_xmmm32,
		EVEX_Vaddss_xmm_k1z_xmm_xmmm32_er,
		Addsd_xmm_xmmm64,
		VEX_Vaddsd_xmm_xmm_xmmm64,
		EVEX_Vaddsd_xmm_k1z_xmm_xmmm64_er,
		Mulps_xmm_xmmm128,
		VEX_Vmulps_xmm_xmm_xmmm128,
		VEX_Vmulps_ymm_ymm_ymmm256,
		EVEX_Vmulps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vmulps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vmulps_zmm_k1z_zmm_zmmm512b32_er,
		Mulpd_xmm_xmmm128,
		VEX_Vmulpd_xmm_xmm_xmmm128,
		VEX_Vmulpd_ymm_ymm_ymmm256,
		EVEX_Vmulpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vmulpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vmulpd_zmm_k1z_zmm_zmmm512b64_er,
		Mulss_xmm_xmmm32,
		VEX_Vmulss_xmm_xmm_xmmm32,
		EVEX_Vmulss_xmm_k1z_xmm_xmmm32_er,
		Mulsd_xmm_xmmm64,
		VEX_Vmulsd_xmm_xmm_xmmm64,
		EVEX_Vmulsd_xmm_k1z_xmm_xmmm64_er,
		Cvtps2pd_xmm_xmmm64,
		VEX_Vcvtps2pd_xmm_xmmm64,
		VEX_Vcvtps2pd_ymm_xmmm128,
		EVEX_Vcvtps2pd_xmm_k1z_xmmm64b32,
		EVEX_Vcvtps2pd_ymm_k1z_xmmm128b32,
		EVEX_Vcvtps2pd_zmm_k1z_ymmm256b32_sae,
		Cvtpd2ps_xmm_xmmm128,
		VEX_Vcvtpd2ps_xmm_xmmm128,
		VEX_Vcvtpd2ps_xmm_ymmm256,
		EVEX_Vcvtpd2ps_xmm_k1z_xmmm128b64,
		EVEX_Vcvtpd2ps_xmm_k1z_ymmm256b64,
		EVEX_Vcvtpd2ps_ymm_k1z_zmmm512b64_er,
		Cvtss2sd_xmm_xmmm32,
		VEX_Vcvtss2sd_xmm_xmm_xmmm32,
		EVEX_Vcvtss2sd_xmm_k1z_xmm_xmmm32_sae,
		Cvtsd2ss_xmm_xmmm64,
		VEX_Vcvtsd2ss_xmm_xmm_xmmm64,
		EVEX_Vcvtsd2ss_xmm_k1z_xmm_xmmm64_er,
		Cvtdq2ps_xmm_xmmm128,
		VEX_Vcvtdq2ps_xmm_xmmm128,
		VEX_Vcvtdq2ps_ymm_ymmm256,
		EVEX_Vcvtdq2ps_xmm_k1z_xmmm128b32,
		EVEX_Vcvtdq2ps_ymm_k1z_ymmm256b32,
		EVEX_Vcvtdq2ps_zmm_k1z_zmmm512b32_er,
		EVEX_Vcvtqq2ps_xmm_k1z_xmmm128b64,
		EVEX_Vcvtqq2ps_xmm_k1z_ymmm256b64,
		EVEX_Vcvtqq2ps_ymm_k1z_zmmm512b64_er,
		Cvtps2dq_xmm_xmmm128,
		VEX_Vcvtps2dq_xmm_xmmm128,
		VEX_Vcvtps2dq_ymm_ymmm256,
		EVEX_Vcvtps2dq_xmm_k1z_xmmm128b32,
		EVEX_Vcvtps2dq_ymm_k1z_ymmm256b32,
		EVEX_Vcvtps2dq_zmm_k1z_zmmm512b32_er,
		Cvttps2dq_xmm_xmmm128,
		VEX_Vcvttps2dq_xmm_xmmm128,
		VEX_Vcvttps2dq_ymm_ymmm256,
		EVEX_Vcvttps2dq_xmm_k1z_xmmm128b32,
		EVEX_Vcvttps2dq_ymm_k1z_ymmm256b32,
		EVEX_Vcvttps2dq_zmm_k1z_zmmm512b32_sae,
		Subps_xmm_xmmm128,
		VEX_Vsubps_xmm_xmm_xmmm128,
		VEX_Vsubps_ymm_ymm_ymmm256,
		EVEX_Vsubps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vsubps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vsubps_zmm_k1z_zmm_zmmm512b32_er,
		Subpd_xmm_xmmm128,
		VEX_Vsubpd_xmm_xmm_xmmm128,
		VEX_Vsubpd_ymm_ymm_ymmm256,
		EVEX_Vsubpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vsubpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vsubpd_zmm_k1z_zmm_zmmm512b64_er,
		Subss_xmm_xmmm32,
		VEX_Vsubss_xmm_xmm_xmmm32,
		EVEX_Vsubss_xmm_k1z_xmm_xmmm32_er,
		Subsd_xmm_xmmm64,
		VEX_Vsubsd_xmm_xmm_xmmm64,
		EVEX_Vsubsd_xmm_k1z_xmm_xmmm64_er,
		Minps_xmm_xmmm128,
		VEX_Vminps_xmm_xmm_xmmm128,
		VEX_Vminps_ymm_ymm_ymmm256,
		EVEX_Vminps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vminps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vminps_zmm_k1z_zmm_zmmm512b32_sae,
		Minpd_xmm_xmmm128,
		VEX_Vminpd_xmm_xmm_xmmm128,
		VEX_Vminpd_ymm_ymm_ymmm256,
		EVEX_Vminpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vminpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vminpd_zmm_k1z_zmm_zmmm512b64_sae,
		Minss_xmm_xmmm32,
		VEX_Vminss_xmm_xmm_xmmm32,
		EVEX_Vminss_xmm_k1z_xmm_xmmm32_sae,
		Minsd_xmm_xmmm64,
		VEX_Vminsd_xmm_xmm_xmmm64,
		EVEX_Vminsd_xmm_k1z_xmm_xmmm64_sae,
		Divps_xmm_xmmm128,
		VEX_Vdivps_xmm_xmm_xmmm128,
		VEX_Vdivps_ymm_ymm_ymmm256,
		EVEX_Vdivps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vdivps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vdivps_zmm_k1z_zmm_zmmm512b32_er,
		Divpd_xmm_xmmm128,
		VEX_Vdivpd_xmm_xmm_xmmm128,
		VEX_Vdivpd_ymm_ymm_ymmm256,
		EVEX_Vdivpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vdivpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vdivpd_zmm_k1z_zmm_zmmm512b64_er,
		Divss_xmm_xmmm32,
		VEX_Vdivss_xmm_xmm_xmmm32,
		EVEX_Vdivss_xmm_k1z_xmm_xmmm32_er,
		Divsd_xmm_xmmm64,
		VEX_Vdivsd_xmm_xmm_xmmm64,
		EVEX_Vdivsd_xmm_k1z_xmm_xmmm64_er,
		Maxps_xmm_xmmm128,
		VEX_Vmaxps_xmm_xmm_xmmm128,
		VEX_Vmaxps_ymm_ymm_ymmm256,
		EVEX_Vmaxps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vmaxps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vmaxps_zmm_k1z_zmm_zmmm512b32_sae,
		Maxpd_xmm_xmmm128,
		VEX_Vmaxpd_xmm_xmm_xmmm128,
		VEX_Vmaxpd_ymm_ymm_ymmm256,
		EVEX_Vmaxpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vmaxpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vmaxpd_zmm_k1z_zmm_zmmm512b64_sae,
		Maxss_xmm_xmmm32,
		VEX_Vmaxss_xmm_xmm_xmmm32,
		EVEX_Vmaxss_xmm_k1z_xmm_xmmm32_sae,
		Maxsd_xmm_xmmm64,
		VEX_Vmaxsd_xmm_xmm_xmmm64,
		EVEX_Vmaxsd_xmm_k1z_xmm_xmmm64_sae,
		Punpcklbw_mm_mmm32,
		Punpcklbw_xmm_xmmm128,
		VEX_Vpunpcklbw_xmm_xmm_xmmm128,
		VEX_Vpunpcklbw_ymm_ymm_ymmm256,
		EVEX_Vpunpcklbw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpunpcklbw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpunpcklbw_zmm_k1z_zmm_zmmm512,
		Punpcklwd_mm_mmm32,
		Punpcklwd_xmm_xmmm128,
		VEX_Vpunpcklwd_xmm_xmm_xmmm128,
		VEX_Vpunpcklwd_ymm_ymm_ymmm256,
		EVEX_Vpunpcklwd_xmm_k1z_xmm_xmmm128,
		EVEX_Vpunpcklwd_ymm_k1z_ymm_ymmm256,
		EVEX_Vpunpcklwd_zmm_k1z_zmm_zmmm512,
		Punpckldq_mm_mmm32,
		Punpckldq_xmm_xmmm128,
		VEX_Vpunpckldq_xmm_xmm_xmmm128,
		VEX_Vpunpckldq_ymm_ymm_ymmm256,
		EVEX_Vpunpckldq_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpunpckldq_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpunpckldq_zmm_k1z_zmm_zmmm512b32,
		Packsswb_mm_mmm64,
		Packsswb_xmm_xmmm128,
		VEX_Vpacksswb_xmm_xmm_xmmm128,
		VEX_Vpacksswb_ymm_ymm_ymmm256,
		EVEX_Vpacksswb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpacksswb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpacksswb_zmm_k1z_zmm_zmmm512,
		Pcmpgtb_mm_mmm64,
		Pcmpgtb_xmm_xmmm128,
		VEX_Vpcmpgtb_xmm_xmm_xmmm128,
		VEX_Vpcmpgtb_ymm_ymm_ymmm256,
		EVEX_Vpcmpgtb_kr_k1_xmm_xmmm128,
		EVEX_Vpcmpgtb_kr_k1_ymm_ymmm256,
		EVEX_Vpcmpgtb_kr_k1_zmm_zmmm512,
		Pcmpgtw_mm_mmm64,
		Pcmpgtw_xmm_xmmm128,
		VEX_Vpcmpgtw_xmm_xmm_xmmm128,
		VEX_Vpcmpgtw_ymm_ymm_ymmm256,
		EVEX_Vpcmpgtw_kr_k1_xmm_xmmm128,
		EVEX_Vpcmpgtw_kr_k1_ymm_ymmm256,
		EVEX_Vpcmpgtw_kr_k1_zmm_zmmm512,
		Pcmpgtd_mm_mmm64,
		Pcmpgtd_xmm_xmmm128,
		VEX_Vpcmpgtd_xmm_xmm_xmmm128,
		VEX_Vpcmpgtd_ymm_ymm_ymmm256,
		EVEX_Vpcmpgtd_kr_k1_xmm_xmmm128b32,
		EVEX_Vpcmpgtd_kr_k1_ymm_ymmm256b32,
		EVEX_Vpcmpgtd_kr_k1_zmm_zmmm512b32,
		Packuswb_mm_mmm64,
		Packuswb_xmm_xmmm128,
		VEX_Vpackuswb_xmm_xmm_xmmm128,
		VEX_Vpackuswb_ymm_ymm_ymmm256,
		EVEX_Vpackuswb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpackuswb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpackuswb_zmm_k1z_zmm_zmmm512,
		Punpckhbw_mm_mmm64,
		Punpckhbw_xmm_xmmm128,
		VEX_Vpunpckhbw_xmm_xmm_xmmm128,
		VEX_Vpunpckhbw_ymm_ymm_ymmm256,
		EVEX_Vpunpckhbw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpunpckhbw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpunpckhbw_zmm_k1z_zmm_zmmm512,
		Punpckhwd_mm_mmm64,
		Punpckhwd_xmm_xmmm128,
		VEX_Vpunpckhwd_xmm_xmm_xmmm128,
		VEX_Vpunpckhwd_ymm_ymm_ymmm256,
		EVEX_Vpunpckhwd_xmm_k1z_xmm_xmmm128,
		EVEX_Vpunpckhwd_ymm_k1z_ymm_ymmm256,
		EVEX_Vpunpckhwd_zmm_k1z_zmm_zmmm512,
		Punpckhdq_mm_mmm64,
		Punpckhdq_xmm_xmmm128,
		VEX_Vpunpckhdq_xmm_xmm_xmmm128,
		VEX_Vpunpckhdq_ymm_ymm_ymmm256,
		EVEX_Vpunpckhdq_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpunpckhdq_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpunpckhdq_zmm_k1z_zmm_zmmm512b32,
		Packssdw_mm_mmm64,
		Packssdw_xmm_xmmm128,
		VEX_Vpackssdw_xmm_xmm_xmmm128,
		VEX_Vpackssdw_ymm_ymm_ymmm256,
		EVEX_Vpackssdw_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpackssdw_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpackssdw_zmm_k1z_zmm_zmmm512b32,
		Punpcklqdq_xmm_xmmm128,
		VEX_Vpunpcklqdq_xmm_xmm_xmmm128,
		VEX_Vpunpcklqdq_ymm_ymm_ymmm256,
		EVEX_Vpunpcklqdq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpunpcklqdq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpunpcklqdq_zmm_k1z_zmm_zmmm512b64,
		Punpckhqdq_xmm_xmmm128,
		VEX_Vpunpckhqdq_xmm_xmm_xmmm128,
		VEX_Vpunpckhqdq_ymm_ymm_ymmm256,
		EVEX_Vpunpckhqdq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpunpckhqdq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpunpckhqdq_zmm_k1z_zmm_zmmm512b64,
		Movd_mm_rm32,
		Movq_mm_rm64,
		Movd_xmm_rm32,
		Movq_xmm_rm64,
		VEX_Vmovd_xmm_rm32,
		VEX_Vmovq_xmm_rm64,
		EVEX_Vmovd_xmm_rm32,
		EVEX_Vmovq_xmm_rm64,
		Movq_mm_mmm64,
		Movdqa_xmm_xmmm128,
		VEX_Vmovdqa_xmm_xmmm128,
		VEX_Vmovdqa_ymm_ymmm256,
		EVEX_Vmovdqa32_xmm_k1z_xmmm128,
		EVEX_Vmovdqa32_ymm_k1z_ymmm256,
		EVEX_Vmovdqa32_zmm_k1z_zmmm512,
		EVEX_Vmovdqa64_xmm_k1z_xmmm128,
		EVEX_Vmovdqa64_ymm_k1z_ymmm256,
		EVEX_Vmovdqa64_zmm_k1z_zmmm512,
		Movdqu_xmm_xmmm128,
		VEX_Vmovdqu_xmm_xmmm128,
		VEX_Vmovdqu_ymm_ymmm256,
		EVEX_Vmovdqu32_xmm_k1z_xmmm128,
		EVEX_Vmovdqu32_ymm_k1z_ymmm256,
		EVEX_Vmovdqu32_zmm_k1z_zmmm512,
		EVEX_Vmovdqu64_xmm_k1z_xmmm128,
		EVEX_Vmovdqu64_ymm_k1z_ymmm256,
		EVEX_Vmovdqu64_zmm_k1z_zmmm512,
		EVEX_Vmovdqu8_xmm_k1z_xmmm128,
		EVEX_Vmovdqu8_ymm_k1z_ymmm256,
		EVEX_Vmovdqu8_zmm_k1z_zmmm512,
		EVEX_Vmovdqu16_xmm_k1z_xmmm128,
		EVEX_Vmovdqu16_ymm_k1z_ymmm256,
		EVEX_Vmovdqu16_zmm_k1z_zmmm512,
		Pshufw_mm_mmm64_imm8,
		Pshufd_xmm_xmmm128_imm8,
		VEX_Vpshufd_xmm_xmmm128_imm8,
		VEX_Vpshufd_ymm_ymmm256_imm8,
		EVEX_Vpshufd_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vpshufd_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vpshufd_zmm_k1z_zmmm512b32_imm8,
		Pshufhw_xmm_xmmm128_imm8,
		VEX_Vpshufhw_xmm_xmmm128_imm8,
		VEX_Vpshufhw_ymm_ymmm256_imm8,
		EVEX_Vpshufhw_xmm_k1z_xmmm128_imm8,
		EVEX_Vpshufhw_ymm_k1z_ymmm256_imm8,
		EVEX_Vpshufhw_zmm_k1z_zmmm512_imm8,
		Pshuflw_xmm_xmmm128_imm8,
		VEX_Vpshuflw_xmm_xmmm128_imm8,
		VEX_Vpshuflw_ymm_ymmm256_imm8,
		EVEX_Vpshuflw_xmm_k1z_xmmm128_imm8,
		EVEX_Vpshuflw_ymm_k1z_ymmm256_imm8,
		EVEX_Vpshuflw_zmm_k1z_zmmm512_imm8,
		Psrlw_mm_imm8,
		Psrlw_xmm_imm8,
		VEX_Vpsrlw_xmm_xmm_imm8,
		VEX_Vpsrlw_ymm_ymm_imm8,
		EVEX_Vpsrlw_xmm_k1z_xmmm128_imm8,
		EVEX_Vpsrlw_ymm_k1z_ymmm256_imm8,
		EVEX_Vpsrlw_zmm_k1z_zmmm512_imm8,
		Psraw_mm_imm8,
		Psraw_xmm_imm8,
		VEX_Vpsraw_xmm_xmm_imm8,
		VEX_Vpsraw_ymm_ymm_imm8,
		EVEX_Vpsraw_xmm_k1z_xmmm128_imm8,
		EVEX_Vpsraw_ymm_k1z_ymmm256_imm8,
		EVEX_Vpsraw_zmm_k1z_zmmm512_imm8,
		Psllw_mm_imm8,
		Psllw_xmm_imm8,
		VEX_Vpsllw_xmm_xmm_imm8,
		VEX_Vpsllw_ymm_ymm_imm8,
		EVEX_Vpsllw_xmm_k1z_xmmm128_imm8,
		EVEX_Vpsllw_ymm_k1z_ymmm256_imm8,
		EVEX_Vpsllw_zmm_k1z_zmmm512_imm8,
		EVEX_Vprord_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vprord_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vprord_zmm_k1z_zmmm512b32_imm8,
		EVEX_Vprorq_xmm_k1z_xmmm128b64_imm8,
		EVEX_Vprorq_ymm_k1z_ymmm256b64_imm8,
		EVEX_Vprorq_zmm_k1z_zmmm512b64_imm8,
		EVEX_Vprold_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vprold_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vprold_zmm_k1z_zmmm512b32_imm8,
		EVEX_Vprolq_xmm_k1z_xmmm128b64_imm8,
		EVEX_Vprolq_ymm_k1z_ymmm256b64_imm8,
		EVEX_Vprolq_zmm_k1z_zmmm512b64_imm8,
		Psrld_mm_imm8,
		Psrld_xmm_imm8,
		VEX_Vpsrld_xmm_xmm_imm8,
		VEX_Vpsrld_ymm_ymm_imm8,
		EVEX_Vpsrld_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vpsrld_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vpsrld_zmm_k1z_zmmm512b32_imm8,
		Psrad_mm_imm8,
		Psrad_xmm_imm8,
		VEX_Vpsrad_xmm_xmm_imm8,
		VEX_Vpsrad_ymm_ymm_imm8,
		EVEX_Vpsrad_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vpsrad_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vpsrad_zmm_k1z_zmmm512b32_imm8,
		EVEX_Vpsraq_xmm_k1z_xmmm128b64_imm8,
		EVEX_Vpsraq_ymm_k1z_ymmm256b64_imm8,
		EVEX_Vpsraq_zmm_k1z_zmmm512b64_imm8,
		Pslld_mm_imm8,
		Pslld_xmm_imm8,
		VEX_Vpslld_xmm_xmm_imm8,
		VEX_Vpslld_ymm_ymm_imm8,
		EVEX_Vpslld_xmm_k1z_xmmm128b32_imm8,
		EVEX_Vpslld_ymm_k1z_ymmm256b32_imm8,
		EVEX_Vpslld_zmm_k1z_zmmm512b32_imm8,
		Psrlq_mm_imm8,
		Psrlq_xmm_imm8,
		VEX_Vpsrlq_xmm_xmm_imm8,
		VEX_Vpsrlq_ymm_ymm_imm8,
		EVEX_Vpsrlq_xmm_k1z_xmmm128b64_imm8,
		EVEX_Vpsrlq_ymm_k1z_ymmm256b64_imm8,
		EVEX_Vpsrlq_zmm_k1z_zmmm512b64_imm8,
		Psrldq_xmm_imm8,
		VEX_Vpsrldq_xmm_xmm_imm8,
		VEX_Vpsrldq_ymm_ymm_imm8,
		EVEX_Vpsrldq_xmm_xmmm128_imm8,
		EVEX_Vpsrldq_ymm_ymmm256_imm8,
		EVEX_Vpsrldq_zmm_zmmm512_imm8,
		Psllq_mm_imm8,
		Psllq_xmm_imm8,
		VEX_Vpsllq_xmm_xmm_imm8,
		VEX_Vpsllq_ymm_ymm_imm8,
		EVEX_Vpsllq_xmm_k1z_xmmm128b64_imm8,
		EVEX_Vpsllq_ymm_k1z_ymmm256b64_imm8,
		EVEX_Vpsllq_zmm_k1z_zmmm512b64_imm8,
		Pslldq_xmm_imm8,
		VEX_Vpslldq_xmm_xmm_imm8,
		VEX_Vpslldq_ymm_ymm_imm8,
		EVEX_Vpslldq_xmm_xmmm128_imm8,
		EVEX_Vpslldq_ymm_ymmm256_imm8,
		EVEX_Vpslldq_zmm_zmmm512_imm8,
		Pcmpeqb_mm_mmm64,
		Pcmpeqb_xmm_xmmm128,
		VEX_Vpcmpeqb_xmm_xmm_xmmm128,
		VEX_Vpcmpeqb_ymm_ymm_ymmm256,
		EVEX_Vpcmpeqb_kr_k1_xmm_xmmm128,
		EVEX_Vpcmpeqb_kr_k1_ymm_ymmm256,
		EVEX_Vpcmpeqb_kr_k1_zmm_zmmm512,
		Pcmpeqw_mm_mmm64,
		Pcmpeqw_xmm_xmmm128,
		VEX_Vpcmpeqw_xmm_xmm_xmmm128,
		VEX_Vpcmpeqw_ymm_ymm_ymmm256,
		EVEX_Vpcmpeqw_kr_k1_xmm_xmmm128,
		EVEX_Vpcmpeqw_kr_k1_ymm_ymmm256,
		EVEX_Vpcmpeqw_kr_k1_zmm_zmmm512,
		Pcmpeqd_mm_mmm64,
		Pcmpeqd_xmm_xmmm128,
		VEX_Vpcmpeqd_xmm_xmm_xmmm128,
		VEX_Vpcmpeqd_ymm_ymm_ymmm256,
		EVEX_Vpcmpeqd_kr_k1_xmm_xmmm128b32,
		EVEX_Vpcmpeqd_kr_k1_ymm_ymmm256b32,
		EVEX_Vpcmpeqd_kr_k1_zmm_zmmm512b32,
		Emms,
		VEX_Vzeroupper,
		VEX_Vzeroall,
		Vmread_rm32_r32,
		Vmread_rm64_r64,
		EVEX_Vcvttps2udq_xmm_k1z_xmmm128b32,
		EVEX_Vcvttps2udq_ymm_k1z_ymmm256b32,
		EVEX_Vcvttps2udq_zmm_k1z_zmmm512b32_sae,
		EVEX_Vcvttpd2udq_xmm_k1z_xmmm128b64,
		EVEX_Vcvttpd2udq_xmm_k1z_ymmm256b64,
		EVEX_Vcvttpd2udq_ymm_k1z_zmmm512b64_sae,
		Extrq_xmm_imm8_imm8,
		EVEX_Vcvttps2uqq_xmm_k1z_xmmm64b32,
		EVEX_Vcvttps2uqq_ymm_k1z_xmmm128b32,
		EVEX_Vcvttps2uqq_zmm_k1z_ymmm256b32_sae,
		EVEX_Vcvttpd2uqq_xmm_k1z_xmmm128b64,
		EVEX_Vcvttpd2uqq_ymm_k1z_ymmm256b64,
		EVEX_Vcvttpd2uqq_zmm_k1z_zmmm512b64_sae,
		EVEX_Vcvttss2usi_r32_xmmm32_sae,
		EVEX_Vcvttss2usi_r64_xmmm32_sae,
		Insertq_xmm_xmm_imm8_imm8,
		EVEX_Vcvttsd2usi_r32_xmmm64_sae,
		EVEX_Vcvttsd2usi_r64_xmmm64_sae,
		Vmwrite_r32_rm32,
		Vmwrite_r64_rm64,
		EVEX_Vcvtps2udq_xmm_k1z_xmmm128b32,
		EVEX_Vcvtps2udq_ymm_k1z_ymmm256b32,
		EVEX_Vcvtps2udq_zmm_k1z_zmmm512b32_er,
		EVEX_Vcvtpd2udq_xmm_k1z_xmmm128b64,
		EVEX_Vcvtpd2udq_xmm_k1z_ymmm256b64,
		EVEX_Vcvtpd2udq_ymm_k1z_zmmm512b64_er,
		Extrq_xmm_xmm,
		EVEX_Vcvtps2uqq_xmm_k1z_xmmm64b32,
		EVEX_Vcvtps2uqq_ymm_k1z_xmmm128b32,
		EVEX_Vcvtps2uqq_zmm_k1z_ymmm256b32_er,
		EVEX_Vcvtpd2uqq_xmm_k1z_xmmm128b64,
		EVEX_Vcvtpd2uqq_ymm_k1z_ymmm256b64,
		EVEX_Vcvtpd2uqq_zmm_k1z_zmmm512b64_er,
		EVEX_Vcvtss2usi_r32_xmmm32_er,
		EVEX_Vcvtss2usi_r64_xmmm32_er,
		Insertq_xmm_xmm,
		EVEX_Vcvtsd2usi_r32_xmmm64_er,
		EVEX_Vcvtsd2usi_r64_xmmm64_er,
		EVEX_Vcvttps2qq_xmm_k1z_xmmm64b32,
		EVEX_Vcvttps2qq_ymm_k1z_xmmm128b32,
		EVEX_Vcvttps2qq_zmm_k1z_ymmm256b32_sae,
		EVEX_Vcvttpd2qq_xmm_k1z_xmmm128b64,
		EVEX_Vcvttpd2qq_ymm_k1z_ymmm256b64,
		EVEX_Vcvttpd2qq_zmm_k1z_zmmm512b64_sae,
		EVEX_Vcvtudq2pd_xmm_k1z_xmmm64b32,
		EVEX_Vcvtudq2pd_ymm_k1z_xmmm128b32,
		EVEX_Vcvtudq2pd_zmm_k1z_ymmm256b32_er,
		EVEX_Vcvtuqq2pd_xmm_k1z_xmmm128b64,
		EVEX_Vcvtuqq2pd_ymm_k1z_ymmm256b64,
		EVEX_Vcvtuqq2pd_zmm_k1z_zmmm512b64_er,
		EVEX_Vcvtudq2ps_xmm_k1z_xmmm128b32,
		EVEX_Vcvtudq2ps_ymm_k1z_ymmm256b32,
		EVEX_Vcvtudq2ps_zmm_k1z_zmmm512b32_er,
		EVEX_Vcvtuqq2ps_xmm_k1z_xmmm128b64,
		EVEX_Vcvtuqq2ps_xmm_k1z_ymmm256b64,
		EVEX_Vcvtuqq2ps_ymm_k1z_zmmm512b64_er,
		EVEX_Vcvtps2qq_xmm_k1z_xmmm64b32,
		EVEX_Vcvtps2qq_ymm_k1z_xmmm128b32,
		EVEX_Vcvtps2qq_zmm_k1z_ymmm256b32_er,
		EVEX_Vcvtpd2qq_xmm_k1z_xmmm128b64,
		EVEX_Vcvtpd2qq_ymm_k1z_ymmm256b64,
		EVEX_Vcvtpd2qq_zmm_k1z_zmmm512b64_er,
		EVEX_Vcvtusi2ss_xmm_xmm_rm32_er,
		EVEX_Vcvtusi2ss_xmm_xmm_rm64_er,
		EVEX_Vcvtusi2sd_xmm_xmm_rm32_er,
		EVEX_Vcvtusi2sd_xmm_xmm_rm64_er,
		Haddpd_xmm_xmmm128,
		VEX_Vhaddpd_xmm_xmm_xmmm128,
		VEX_Vhaddpd_ymm_ymm_ymmm256,
		Haddps_xmm_xmmm128,
		VEX_Vhaddps_xmm_xmm_xmmm128,
		VEX_Vhaddps_ymm_ymm_ymmm256,
		Hsubpd_xmm_xmmm128,
		VEX_Vhsubpd_xmm_xmm_xmmm128,
		VEX_Vhsubpd_ymm_ymm_ymmm256,
		Hsubps_xmm_xmmm128,
		VEX_Vhsubps_xmm_xmm_xmmm128,
		VEX_Vhsubps_ymm_ymm_ymmm256,
		Movd_rm32_mm,
		Movq_rm64_mm,
		Movd_rm32_xmm,
		Movq_rm64_xmm,
		VEX_Vmovd_rm32_xmm,
		VEX_Vmovq_rm64_xmm,
		EVEX_Vmovd_rm32_xmm,
		EVEX_Vmovq_rm64_xmm,
		Movq_xmm_xmmm64,
		VEX_Vmovq_xmm_xmmm64,
		EVEX_Vmovq_xmm_xmmm64,
		Movq_mmm64_mm,
		Movdqa_xmmm128_xmm,
		VEX_Vmovdqa_xmmm128_xmm,
		VEX_Vmovdqa_ymmm256_ymm,
		EVEX_Vmovdqa32_xmmm128_k1z_xmm,
		EVEX_Vmovdqa32_ymmm256_k1z_ymm,
		EVEX_Vmovdqa32_zmmm512_k1z_zmm,
		EVEX_Vmovdqa64_xmmm128_k1z_xmm,
		EVEX_Vmovdqa64_ymmm256_k1z_ymm,
		EVEX_Vmovdqa64_zmmm512_k1z_zmm,
		Movdqu_xmmm128_xmm,
		VEX_Vmovdqu_xmmm128_xmm,
		VEX_Vmovdqu_ymmm256_ymm,
		EVEX_Vmovdqu32_xmmm128_k1z_xmm,
		EVEX_Vmovdqu32_ymmm256_k1z_ymm,
		EVEX_Vmovdqu32_zmmm512_k1z_zmm,
		EVEX_Vmovdqu64_xmmm128_k1z_xmm,
		EVEX_Vmovdqu64_ymmm256_k1z_ymm,
		EVEX_Vmovdqu64_zmmm512_k1z_zmm,
		EVEX_Vmovdqu8_xmmm128_k1z_xmm,
		EVEX_Vmovdqu8_ymmm256_k1z_ymm,
		EVEX_Vmovdqu8_zmmm512_k1z_zmm,
		EVEX_Vmovdqu16_xmmm128_k1z_xmm,
		EVEX_Vmovdqu16_ymmm256_k1z_ymm,
		EVEX_Vmovdqu16_zmmm512_k1z_zmm,
		Jo_rel16,
		Jo_rel32_32,
		Jo_rel32_64,
		Jno_rel16,
		Jno_rel32_32,
		Jno_rel32_64,
		Jb_rel16,
		Jb_rel32_32,
		Jb_rel32_64,
		Jae_rel16,
		Jae_rel32_32,
		Jae_rel32_64,
		Je_rel16,
		Je_rel32_32,
		Je_rel32_64,
		Jne_rel16,
		Jne_rel32_32,
		Jne_rel32_64,
		Jbe_rel16,
		Jbe_rel32_32,
		Jbe_rel32_64,
		Ja_rel16,
		Ja_rel32_32,
		Ja_rel32_64,
		Js_rel16,
		Js_rel32_32,
		Js_rel32_64,
		Jns_rel16,
		Jns_rel32_32,
		Jns_rel32_64,
		Jp_rel16,
		Jp_rel32_32,
		Jp_rel32_64,
		Jnp_rel16,
		Jnp_rel32_32,
		Jnp_rel32_64,
		Jl_rel16,
		Jl_rel32_32,
		Jl_rel32_64,
		Jge_rel16,
		Jge_rel32_32,
		Jge_rel32_64,
		Jle_rel16,
		Jle_rel32_32,
		Jle_rel32_64,
		Jg_rel16,
		Jg_rel32_32,
		Jg_rel32_64,
		Seto_rm8,
		Setno_rm8,
		Setb_rm8,
		Setae_rm8,
		Sete_rm8,
		Setne_rm8,
		Setbe_rm8,
		Seta_rm8,
		Sets_rm8,
		Setns_rm8,
		Setp_rm8,
		Setnp_rm8,
		Setl_rm8,
		Setge_rm8,
		Setle_rm8,
		Setg_rm8,
		VEX_Kmovw_kr_km16,
		VEX_Kmovq_kr_km64,
		VEX_Kmovb_kr_km8,
		VEX_Kmovd_kr_km32,
		VEX_Kmovw_m16_kr,
		VEX_Kmovq_m64_kr,
		VEX_Kmovb_m8_kr,
		VEX_Kmovd_m32_kr,
		VEX_Kmovw_kr_r32,
		VEX_Kmovb_kr_r32,
		VEX_Kmovd_kr_r32,
		VEX_Kmovq_kr_r64,
		VEX_Kmovw_r32_kr,
		VEX_Kmovb_r32_kr,
		VEX_Kmovd_r32_kr,
		VEX_Kmovq_r64_kr,
		VEX_Kortestw_kr_kr,
		VEX_Kortestq_kr_kr,
		VEX_Kortestb_kr_kr,
		VEX_Kortestd_kr_kr,
		VEX_Ktestw_kr_kr,
		VEX_Ktestq_kr_kr,
		VEX_Ktestb_kr_kr,
		VEX_Ktestd_kr_kr,
		Pushw_FS,
		Pushd_FS,
		Pushq_FS,
		Popw_FS,
		Popd_FS,
		Popq_FS,
		Cpuid,
		Bt_rm16_r16,
		Bt_rm32_r32,
		Bt_rm64_r64,
		Shld_rm16_r16_imm8,
		Shld_rm32_r32_imm8,
		Shld_rm64_r64_imm8,
		Shld_rm16_r16_CL,
		Shld_rm32_r32_CL,
		Shld_rm64_r64_CL,
		Montmul_16,
		Montmul_32,
		Montmul_64,
		Xsha1_16,
		Xsha1_32,
		Xsha1_64,
		Xsha256_16,
		Xsha256_32,
		Xsha256_64,
		Xbts_r16_rm16,
		Xbts_r32_rm32,
		Xstore_16,
		Xstore_32,
		Xstore_64,
		Xcryptecb_16,
		Xcryptecb_32,
		Xcryptecb_64,
		Xcryptcbc_16,
		Xcryptcbc_32,
		Xcryptcbc_64,
		Xcryptctr_16,
		Xcryptctr_32,
		Xcryptctr_64,
		Xcryptcfb_16,
		Xcryptcfb_32,
		Xcryptcfb_64,
		Xcryptofb_16,
		Xcryptofb_32,
		Xcryptofb_64,
		Ibts_rm16_r16,
		Ibts_rm32_r32,
		Cmpxchg486_rm8_r8,
		Cmpxchg486_rm16_r16,
		Cmpxchg486_rm32_r32,
		Pushw_GS,
		Pushd_GS,
		Pushq_GS,
		Popw_GS,
		Popd_GS,
		Popq_GS,
		Rsm,
		Bts_rm16_r16,
		Bts_rm32_r32,
		Bts_rm64_r64,
		Shrd_rm16_r16_imm8,
		Shrd_rm32_r32_imm8,
		Shrd_rm64_r64_imm8,
		Shrd_rm16_r16_CL,
		Shrd_rm32_r32_CL,
		Shrd_rm64_r64_CL,
		Fxsave_m512byte,
		Fxsave64_m512byte,
		Rdfsbase_r32,
		Rdfsbase_r64,
		Fxrstor_m512byte,
		Fxrstor64_m512byte,
		Rdgsbase_r32,
		Rdgsbase_r64,
		Ldmxcsr_m32,
		Wrfsbase_r32,
		Wrfsbase_r64,
		VEX_Vldmxcsr_m32,
		Stmxcsr_m32,
		Wrgsbase_r32,
		Wrgsbase_r64,
		VEX_Vstmxcsr_m32,
		Xsave_mem,
		Xsave64_mem,
		Ptwrite_rm32,
		Ptwrite_rm64,
		Xrstor_mem,
		Xrstor64_mem,
		Incsspd_r32,
		Incsspq_r64,
		Xsaveopt_mem,
		Xsaveopt64_mem,
		Clwb_m8,
		Tpause_r32,
		Tpause_r64,
		Clrssbsy_m64,
		Umonitor_r16,
		Umonitor_r32,
		Umonitor_r64,
		Umwait_r32,
		Umwait_r64,
		Clflush_m8,
		Clflushopt_m8,
		Lfence,
		Lfence_E9,
		Lfence_EA,
		Lfence_EB,
		Lfence_EC,
		Lfence_ED,
		Lfence_EE,
		Lfence_EF,
		Mfence,
		Mfence_F1,
		Mfence_F2,
		Mfence_F3,
		Mfence_F4,
		Mfence_F5,
		Mfence_F6,
		Mfence_F7,
		Sfence,
		Sfence_F9,
		Sfence_FA,
		Sfence_FB,
		Sfence_FC,
		Sfence_FD,
		Sfence_FE,
		Sfence_FF,
		Pcommit,
		Imul_r16_rm16,
		Imul_r32_rm32,
		Imul_r64_rm64,
		Cmpxchg_rm8_r8,
		Cmpxchg_rm16_r16,
		Cmpxchg_rm32_r32,
		Cmpxchg_rm64_r64,
		Lss_r16_m1616,
		Lss_r32_m1632,
		Lss_r64_m1664,
		Btr_rm16_r16,
		Btr_rm32_r32,
		Btr_rm64_r64,
		Lfs_r16_m1616,
		Lfs_r32_m1632,
		Lfs_r64_m1664,
		Lgs_r16_m1616,
		Lgs_r32_m1632,
		Lgs_r64_m1664,
		Movzx_r16_rm8,
		Movzx_r32_rm8,
		Movzx_r64_rm8,
		Movzx_r16_rm16,
		Movzx_r32_rm16,
		Movzx_r64_rm16,
		Jmpe_disp16,
		Jmpe_disp32,
		Popcnt_r16_rm16,
		Popcnt_r32_rm32,
		Popcnt_r64_rm64,
		Ud1_r16_rm16,
		Ud1_r32_rm32,
		Ud1_r64_rm64,
		Bt_rm16_imm8,
		Bt_rm32_imm8,
		Bt_rm64_imm8,
		Bts_rm16_imm8,
		Bts_rm32_imm8,
		Bts_rm64_imm8,
		Btr_rm16_imm8,
		Btr_rm32_imm8,
		Btr_rm64_imm8,
		Btc_rm16_imm8,
		Btc_rm32_imm8,
		Btc_rm64_imm8,
		Btc_rm16_r16,
		Btc_rm32_r32,
		Btc_rm64_r64,
		Bsf_r16_rm16,
		Bsf_r32_rm32,
		Bsf_r64_rm64,
		Tzcnt_r16_rm16,
		Tzcnt_r32_rm32,
		Tzcnt_r64_rm64,
		Bsr_r16_rm16,
		Bsr_r32_rm32,
		Bsr_r64_rm64,
		Lzcnt_r16_rm16,
		Lzcnt_r32_rm32,
		Lzcnt_r64_rm64,
		Movsx_r16_rm8,
		Movsx_r32_rm8,
		Movsx_r64_rm8,
		Movsx_r16_rm16,
		Movsx_r32_rm16,
		Movsx_r64_rm16,
		Xadd_rm8_r8,
		Xadd_rm16_r16,
		Xadd_rm32_r32,
		Xadd_rm64_r64,
		Cmpps_xmm_xmmm128_imm8,
		VEX_Vcmpps_xmm_xmm_xmmm128_imm8,
		VEX_Vcmpps_ymm_ymm_ymmm256_imm8,
		EVEX_Vcmpps_kr_k1_xmm_xmmm128b32_imm8,
		EVEX_Vcmpps_kr_k1_ymm_ymmm256b32_imm8,
		EVEX_Vcmpps_kr_k1_zmm_zmmm512b32_imm8_sae,
		Cmppd_xmm_xmmm128_imm8,
		VEX_Vcmppd_xmm_xmm_xmmm128_imm8,
		VEX_Vcmppd_ymm_ymm_ymmm256_imm8,
		EVEX_Vcmppd_kr_k1_xmm_xmmm128b64_imm8,
		EVEX_Vcmppd_kr_k1_ymm_ymmm256b64_imm8,
		EVEX_Vcmppd_kr_k1_zmm_zmmm512b64_imm8_sae,
		Cmpss_xmm_xmmm32_imm8,
		VEX_Vcmpss_xmm_xmm_xmmm32_imm8,
		EVEX_Vcmpss_kr_k1_xmm_xmmm32_imm8_sae,
		Cmpsd_xmm_xmmm64_imm8,
		VEX_Vcmpsd_xmm_xmm_xmmm64_imm8,
		EVEX_Vcmpsd_kr_k1_xmm_xmmm64_imm8_sae,
		Movnti_m32_r32,
		Movnti_m64_r64,
		Pinsrw_mm_r32m16_imm8,
		Pinsrw_mm_r64m16_imm8,
		Pinsrw_xmm_r32m16_imm8,
		Pinsrw_xmm_r64m16_imm8,
		VEX_Vpinsrw_xmm_xmm_r32m16_imm8,
		VEX_Vpinsrw_xmm_xmm_r64m16_imm8,
		EVEX_Vpinsrw_xmm_xmm_r32m16_imm8,
		EVEX_Vpinsrw_xmm_xmm_r64m16_imm8,
		Pextrw_r32_mm_imm8,
		Pextrw_r64_mm_imm8,
		Pextrw_r32_xmm_imm8,
		Pextrw_r64_xmm_imm8,
		VEX_Vpextrw_r32_xmm_imm8,
		VEX_Vpextrw_r64_xmm_imm8,
		EVEX_Vpextrw_r32_xmm_imm8,
		EVEX_Vpextrw_r64_xmm_imm8,
		Shufps_xmm_xmmm128_imm8,
		VEX_Vshufps_xmm_xmm_xmmm128_imm8,
		VEX_Vshufps_ymm_ymm_ymmm256_imm8,
		EVEX_Vshufps_xmm_k1z_xmm_xmmm128b32_imm8,
		EVEX_Vshufps_ymm_k1z_ymm_ymmm256b32_imm8,
		EVEX_Vshufps_zmm_k1z_zmm_zmmm512b32_imm8,
		Shufpd_xmm_xmmm128_imm8,
		VEX_Vshufpd_xmm_xmm_xmmm128_imm8,
		VEX_Vshufpd_ymm_ymm_ymmm256_imm8,
		EVEX_Vshufpd_xmm_k1z_xmm_xmmm128b64_imm8,
		EVEX_Vshufpd_ymm_k1z_ymm_ymmm256b64_imm8,
		EVEX_Vshufpd_zmm_k1z_zmm_zmmm512b64_imm8,
		Cmpxchg8b_m64,
		Cmpxchg16b_m128,
		Xrstors_mem,
		Xrstors64_mem,
		Xsavec_mem,
		Xsavec64_mem,
		Xsaves_mem,
		Xsaves64_mem,
		Vmptrld_m64,
		Vmclear_m64,
		Vmxon_m64,
		Rdrand_r16,
		Rdrand_r32,
		Rdrand_r64,
		Vmptrst_m64,
		Rdseed_r16,
		Rdseed_r32,
		Rdseed_r64,
		Rdpid_r32,
		Rdpid_r64,
		Bswap_r16,
		Bswap_r32,
		Bswap_r64,
		Addsubpd_xmm_xmmm128,
		VEX_Vaddsubpd_xmm_xmm_xmmm128,
		VEX_Vaddsubpd_ymm_ymm_ymmm256,
		Addsubps_xmm_xmmm128,
		VEX_Vaddsubps_xmm_xmm_xmmm128,
		VEX_Vaddsubps_ymm_ymm_ymmm256,
		Psrlw_mm_mmm64,
		Psrlw_xmm_xmmm128,
		VEX_Vpsrlw_xmm_xmm_xmmm128,
		VEX_Vpsrlw_ymm_ymm_xmmm128,
		EVEX_Vpsrlw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsrlw_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsrlw_zmm_k1z_zmm_xmmm128,
		Psrld_mm_mmm64,
		Psrld_xmm_xmmm128,
		VEX_Vpsrld_xmm_xmm_xmmm128,
		VEX_Vpsrld_ymm_ymm_xmmm128,
		EVEX_Vpsrld_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsrld_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsrld_zmm_k1z_zmm_xmmm128,
		Psrlq_mm_mmm64,
		Psrlq_xmm_xmmm128,
		VEX_Vpsrlq_xmm_xmm_xmmm128,
		VEX_Vpsrlq_ymm_ymm_xmmm128,
		EVEX_Vpsrlq_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsrlq_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsrlq_zmm_k1z_zmm_xmmm128,
		Paddq_mm_mmm64,
		Paddq_xmm_xmmm128,
		VEX_Vpaddq_xmm_xmm_xmmm128,
		VEX_Vpaddq_ymm_ymm_ymmm256,
		EVEX_Vpaddq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpaddq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpaddq_zmm_k1z_zmm_zmmm512b64,
		Pmullw_mm_mmm64,
		Pmullw_xmm_xmmm128,
		VEX_Vpmullw_xmm_xmm_xmmm128,
		VEX_Vpmullw_ymm_ymm_ymmm256,
		EVEX_Vpmullw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmullw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmullw_zmm_k1z_zmm_zmmm512,
		Movq_xmmm64_xmm,
		VEX_Vmovq_xmmm64_xmm,
		EVEX_Vmovq_xmmm64_xmm,
		Movq2dq_xmm_mm,
		Movdq2q_mm_xmm,
		Pmovmskb_r32_mm,
		Pmovmskb_r64_mm,
		Pmovmskb_r32_xmm,
		Pmovmskb_r64_xmm,
		VEX_Vpmovmskb_r32_xmm,
		VEX_Vpmovmskb_r64_xmm,
		VEX_Vpmovmskb_r32_ymm,
		VEX_Vpmovmskb_r64_ymm,
		Psubusb_mm_mmm64,
		Psubusb_xmm_xmmm128,
		VEX_Vpsubusb_xmm_xmm_xmmm128,
		VEX_Vpsubusb_ymm_ymm_ymmm256,
		EVEX_Vpsubusb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubusb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubusb_zmm_k1z_zmm_zmmm512,
		Psubusw_mm_mmm64,
		Psubusw_xmm_xmmm128,
		VEX_Vpsubusw_xmm_xmm_xmmm128,
		VEX_Vpsubusw_ymm_ymm_ymmm256,
		EVEX_Vpsubusw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubusw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubusw_zmm_k1z_zmm_zmmm512,
		Pminub_mm_mmm64,
		Pminub_xmm_xmmm128,
		VEX_Vpminub_xmm_xmm_xmmm128,
		VEX_Vpminub_ymm_ymm_ymmm256,
		EVEX_Vpminub_xmm_k1z_xmm_xmmm128,
		EVEX_Vpminub_ymm_k1z_ymm_ymmm256,
		EVEX_Vpminub_zmm_k1z_zmm_zmmm512,
		Pand_mm_mmm64,
		Pand_xmm_xmmm128,
		VEX_Vpand_xmm_xmm_xmmm128,
		VEX_Vpand_ymm_ymm_ymmm256,
		EVEX_Vpandd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpandd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpandd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpandq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpandq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpandq_zmm_k1z_zmm_zmmm512b64,
		Paddusb_mm_mmm64,
		Paddusb_xmm_xmmm128,
		VEX_Vpaddusb_xmm_xmm_xmmm128,
		VEX_Vpaddusb_ymm_ymm_ymmm256,
		EVEX_Vpaddusb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddusb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddusb_zmm_k1z_zmm_zmmm512,
		Paddusw_mm_mmm64,
		Paddusw_xmm_xmmm128,
		VEX_Vpaddusw_xmm_xmm_xmmm128,
		VEX_Vpaddusw_ymm_ymm_ymmm256,
		EVEX_Vpaddusw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddusw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddusw_zmm_k1z_zmm_zmmm512,
		Pmaxub_mm_mmm64,
		Pmaxub_xmm_xmmm128,
		VEX_Vpmaxub_xmm_xmm_xmmm128,
		VEX_Vpmaxub_ymm_ymm_ymmm256,
		EVEX_Vpmaxub_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaxub_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaxub_zmm_k1z_zmm_zmmm512,
		Pandn_mm_mmm64,
		Pandn_xmm_xmmm128,
		VEX_Vpandn_xmm_xmm_xmmm128,
		VEX_Vpandn_ymm_ymm_ymmm256,
		EVEX_Vpandnd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpandnd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpandnd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpandnq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpandnq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpandnq_zmm_k1z_zmm_zmmm512b64,
		Pavgb_mm_mmm64,
		Pavgb_xmm_xmmm128,
		VEX_Vpavgb_xmm_xmm_xmmm128,
		VEX_Vpavgb_ymm_ymm_ymmm256,
		EVEX_Vpavgb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpavgb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpavgb_zmm_k1z_zmm_zmmm512,
		Psraw_mm_mmm64,
		Psraw_xmm_xmmm128,
		VEX_Vpsraw_xmm_xmm_xmmm128,
		VEX_Vpsraw_ymm_ymm_xmmm128,
		EVEX_Vpsraw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsraw_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsraw_zmm_k1z_zmm_xmmm128,
		Psrad_mm_mmm64,
		Psrad_xmm_xmmm128,
		VEX_Vpsrad_xmm_xmm_xmmm128,
		VEX_Vpsrad_ymm_ymm_xmmm128,
		EVEX_Vpsrad_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsrad_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsrad_zmm_k1z_zmm_xmmm128,
		EVEX_Vpsraq_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsraq_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsraq_zmm_k1z_zmm_xmmm128,
		Pavgw_mm_mmm64,
		Pavgw_xmm_xmmm128,
		VEX_Vpavgw_xmm_xmm_xmmm128,
		VEX_Vpavgw_ymm_ymm_ymmm256,
		EVEX_Vpavgw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpavgw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpavgw_zmm_k1z_zmm_zmmm512,
		Pmulhuw_mm_mmm64,
		Pmulhuw_xmm_xmmm128,
		VEX_Vpmulhuw_xmm_xmm_xmmm128,
		VEX_Vpmulhuw_ymm_ymm_ymmm256,
		EVEX_Vpmulhuw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmulhuw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmulhuw_zmm_k1z_zmm_zmmm512,
		Pmulhw_mm_mmm64,
		Pmulhw_xmm_xmmm128,
		VEX_Vpmulhw_xmm_xmm_xmmm128,
		VEX_Vpmulhw_ymm_ymm_ymmm256,
		EVEX_Vpmulhw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmulhw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmulhw_zmm_k1z_zmm_zmmm512,
		Cvttpd2dq_xmm_xmmm128,
		VEX_Vcvttpd2dq_xmm_xmmm128,
		VEX_Vcvttpd2dq_xmm_ymmm256,
		EVEX_Vcvttpd2dq_xmm_k1z_xmmm128b64,
		EVEX_Vcvttpd2dq_xmm_k1z_ymmm256b64,
		EVEX_Vcvttpd2dq_ymm_k1z_zmmm512b64_sae,
		Cvtdq2pd_xmm_xmmm64,
		VEX_Vcvtdq2pd_xmm_xmmm64,
		VEX_Vcvtdq2pd_ymm_xmmm128,
		EVEX_Vcvtdq2pd_xmm_k1z_xmmm64b32,
		EVEX_Vcvtdq2pd_ymm_k1z_xmmm128b32,
		EVEX_Vcvtdq2pd_zmm_k1z_ymmm256b32_er,
		EVEX_Vcvtqq2pd_xmm_k1z_xmmm128b64,
		EVEX_Vcvtqq2pd_ymm_k1z_ymmm256b64,
		EVEX_Vcvtqq2pd_zmm_k1z_zmmm512b64_er,
		Cvtpd2dq_xmm_xmmm128,
		VEX_Vcvtpd2dq_xmm_xmmm128,
		VEX_Vcvtpd2dq_xmm_ymmm256,
		EVEX_Vcvtpd2dq_xmm_k1z_xmmm128b64,
		EVEX_Vcvtpd2dq_xmm_k1z_ymmm256b64,
		EVEX_Vcvtpd2dq_ymm_k1z_zmmm512b64_er,
		Movntq_m64_mm,
		Movntdq_m128_xmm,
		VEX_Vmovntdq_m128_xmm,
		VEX_Vmovntdq_m256_ymm,
		EVEX_Vmovntdq_m128_xmm,
		EVEX_Vmovntdq_m256_ymm,
		EVEX_Vmovntdq_m512_zmm,
		Psubsb_mm_mmm64,
		Psubsb_xmm_xmmm128,
		VEX_Vpsubsb_xmm_xmm_xmmm128,
		VEX_Vpsubsb_ymm_ymm_ymmm256,
		EVEX_Vpsubsb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubsb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubsb_zmm_k1z_zmm_zmmm512,
		Psubsw_mm_mmm64,
		Psubsw_xmm_xmmm128,
		VEX_Vpsubsw_xmm_xmm_xmmm128,
		VEX_Vpsubsw_ymm_ymm_ymmm256,
		EVEX_Vpsubsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubsw_zmm_k1z_zmm_zmmm512,
		Pminsw_mm_mmm64,
		Pminsw_xmm_xmmm128,
		VEX_Vpminsw_xmm_xmm_xmmm128,
		VEX_Vpminsw_ymm_ymm_ymmm256,
		EVEX_Vpminsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpminsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpminsw_zmm_k1z_zmm_zmmm512,
		Por_mm_mmm64,
		Por_xmm_xmmm128,
		VEX_Vpor_xmm_xmm_xmmm128,
		VEX_Vpor_ymm_ymm_ymmm256,
		EVEX_Vpord_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpord_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpord_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vporq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vporq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vporq_zmm_k1z_zmm_zmmm512b64,
		Paddsb_mm_mmm64,
		Paddsb_xmm_xmmm128,
		VEX_Vpaddsb_xmm_xmm_xmmm128,
		VEX_Vpaddsb_ymm_ymm_ymmm256,
		EVEX_Vpaddsb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddsb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddsb_zmm_k1z_zmm_zmmm512,
		Paddsw_mm_mmm64,
		Paddsw_xmm_xmmm128,
		VEX_Vpaddsw_xmm_xmm_xmmm128,
		VEX_Vpaddsw_ymm_ymm_ymmm256,
		EVEX_Vpaddsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddsw_zmm_k1z_zmm_zmmm512,
		Pmaxsw_mm_mmm64,
		Pmaxsw_xmm_xmmm128,
		VEX_Vpmaxsw_xmm_xmm_xmmm128,
		VEX_Vpmaxsw_ymm_ymm_ymmm256,
		EVEX_Vpmaxsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaxsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaxsw_zmm_k1z_zmm_zmmm512,
		Pxor_mm_mmm64,
		Pxor_xmm_xmmm128,
		VEX_Vpxor_xmm_xmm_xmmm128,
		VEX_Vpxor_ymm_ymm_ymmm256,
		EVEX_Vpxord_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpxord_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpxord_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpxorq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpxorq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpxorq_zmm_k1z_zmm_zmmm512b64,
		Lddqu_xmm_m128,
		VEX_Vlddqu_xmm_m128,
		VEX_Vlddqu_ymm_m256,
		Psllw_mm_mmm64,
		Psllw_xmm_xmmm128,
		VEX_Vpsllw_xmm_xmm_xmmm128,
		VEX_Vpsllw_ymm_ymm_xmmm128,
		EVEX_Vpsllw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsllw_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsllw_zmm_k1z_zmm_xmmm128,
		Pslld_mm_mmm64,
		Pslld_xmm_xmmm128,
		VEX_Vpslld_xmm_xmm_xmmm128,
		VEX_Vpslld_ymm_ymm_xmmm128,
		EVEX_Vpslld_xmm_k1z_xmm_xmmm128,
		EVEX_Vpslld_ymm_k1z_ymm_xmmm128,
		EVEX_Vpslld_zmm_k1z_zmm_xmmm128,
		Psllq_mm_mmm64,
		Psllq_xmm_xmmm128,
		VEX_Vpsllq_xmm_xmm_xmmm128,
		VEX_Vpsllq_ymm_ymm_xmmm128,
		EVEX_Vpsllq_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsllq_ymm_k1z_ymm_xmmm128,
		EVEX_Vpsllq_zmm_k1z_zmm_xmmm128,
		Pmuludq_mm_mmm64,
		Pmuludq_xmm_xmmm128,
		VEX_Vpmuludq_xmm_xmm_xmmm128,
		VEX_Vpmuludq_ymm_ymm_ymmm256,
		EVEX_Vpmuludq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmuludq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmuludq_zmm_k1z_zmm_zmmm512b64,
		Pmaddwd_mm_mmm64,
		Pmaddwd_xmm_xmmm128,
		VEX_Vpmaddwd_xmm_xmm_xmmm128,
		VEX_Vpmaddwd_ymm_ymm_ymmm256,
		EVEX_Vpmaddwd_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaddwd_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaddwd_zmm_k1z_zmm_zmmm512,
		Psadbw_mm_mmm64,
		Psadbw_xmm_xmmm128,
		VEX_Vpsadbw_xmm_xmm_xmmm128,
		VEX_Vpsadbw_ymm_ymm_ymmm256,
		EVEX_Vpsadbw_xmm_xmm_xmmm128,
		EVEX_Vpsadbw_ymm_ymm_ymmm256,
		EVEX_Vpsadbw_zmm_zmm_zmmm512,
		Maskmovq_rDI_mm_mm,
		Maskmovdqu_rDI_xmm_xmm,
		VEX_Vmaskmovdqu_rDI_xmm_xmm,
		Psubb_mm_mmm64,
		Psubb_xmm_xmmm128,
		VEX_Vpsubb_xmm_xmm_xmmm128,
		VEX_Vpsubb_ymm_ymm_ymmm256,
		EVEX_Vpsubb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubb_zmm_k1z_zmm_zmmm512,
		Psubw_mm_mmm64,
		Psubw_xmm_xmmm128,
		VEX_Vpsubw_xmm_xmm_xmmm128,
		VEX_Vpsubw_ymm_ymm_ymmm256,
		EVEX_Vpsubw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsubw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsubw_zmm_k1z_zmm_zmmm512,
		Psubd_mm_mmm64,
		Psubd_xmm_xmmm128,
		VEX_Vpsubd_xmm_xmm_xmmm128,
		VEX_Vpsubd_ymm_ymm_ymmm256,
		EVEX_Vpsubd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpsubd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpsubd_zmm_k1z_zmm_zmmm512b32,
		Psubq_mm_mmm64,
		Psubq_xmm_xmmm128,
		VEX_Vpsubq_xmm_xmm_xmmm128,
		VEX_Vpsubq_ymm_ymm_ymmm256,
		EVEX_Vpsubq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpsubq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpsubq_zmm_k1z_zmm_zmmm512b64,
		Paddb_mm_mmm64,
		Paddb_xmm_xmmm128,
		VEX_Vpaddb_xmm_xmm_xmmm128,
		VEX_Vpaddb_ymm_ymm_ymmm256,
		EVEX_Vpaddb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddb_zmm_k1z_zmm_zmmm512,
		Paddw_mm_mmm64,
		Paddw_xmm_xmmm128,
		VEX_Vpaddw_xmm_xmm_xmmm128,
		VEX_Vpaddw_ymm_ymm_ymmm256,
		EVEX_Vpaddw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpaddw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpaddw_zmm_k1z_zmm_zmmm512,
		Paddd_mm_mmm64,
		Paddd_xmm_xmmm128,
		VEX_Vpaddd_xmm_xmm_xmmm128,
		VEX_Vpaddd_ymm_ymm_ymmm256,
		EVEX_Vpaddd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpaddd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpaddd_zmm_k1z_zmm_zmmm512b32,
		Ud0_r16_rm16,
		Ud0_r32_rm32,
		Ud0_r64_rm64,
		Pshufb_mm_mmm64,
		Pshufb_xmm_xmmm128,
		VEX_Vpshufb_xmm_xmm_xmmm128,
		VEX_Vpshufb_ymm_ymm_ymmm256,
		EVEX_Vpshufb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpshufb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpshufb_zmm_k1z_zmm_zmmm512,
		Phaddw_mm_mmm64,
		Phaddw_xmm_xmmm128,
		VEX_Vphaddw_xmm_xmm_xmmm128,
		VEX_Vphaddw_ymm_ymm_ymmm256,
		Phaddd_mm_mmm64,
		Phaddd_xmm_xmmm128,
		VEX_Vphaddd_xmm_xmm_xmmm128,
		VEX_Vphaddd_ymm_ymm_ymmm256,
		Phaddsw_mm_mmm64,
		Phaddsw_xmm_xmmm128,
		VEX_Vphaddsw_xmm_xmm_xmmm128,
		VEX_Vphaddsw_ymm_ymm_ymmm256,
		Pmaddubsw_mm_mmm64,
		Pmaddubsw_xmm_xmmm128,
		VEX_Vpmaddubsw_xmm_xmm_xmmm128,
		VEX_Vpmaddubsw_ymm_ymm_ymmm256,
		EVEX_Vpmaddubsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaddubsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaddubsw_zmm_k1z_zmm_zmmm512,
		Phsubw_mm_mmm64,
		Phsubw_xmm_xmmm128,
		VEX_Vphsubw_xmm_xmm_xmmm128,
		VEX_Vphsubw_ymm_ymm_ymmm256,
		Phsubd_mm_mmm64,
		Phsubd_xmm_xmmm128,
		VEX_Vphsubd_xmm_xmm_xmmm128,
		VEX_Vphsubd_ymm_ymm_ymmm256,
		Phsubsw_mm_mmm64,
		Phsubsw_xmm_xmmm128,
		VEX_Vphsubsw_xmm_xmm_xmmm128,
		VEX_Vphsubsw_ymm_ymm_ymmm256,
		Psignb_mm_mmm64,
		Psignb_xmm_xmmm128,
		VEX_Vpsignb_xmm_xmm_xmmm128,
		VEX_Vpsignb_ymm_ymm_ymmm256,
		Psignw_mm_mmm64,
		Psignw_xmm_xmmm128,
		VEX_Vpsignw_xmm_xmm_xmmm128,
		VEX_Vpsignw_ymm_ymm_ymmm256,
		Psignd_mm_mmm64,
		Psignd_xmm_xmmm128,
		VEX_Vpsignd_xmm_xmm_xmmm128,
		VEX_Vpsignd_ymm_ymm_ymmm256,
		Pmulhrsw_mm_mmm64,
		Pmulhrsw_xmm_xmmm128,
		VEX_Vpmulhrsw_xmm_xmm_xmmm128,
		VEX_Vpmulhrsw_ymm_ymm_ymmm256,
		EVEX_Vpmulhrsw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmulhrsw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmulhrsw_zmm_k1z_zmm_zmmm512,
		VEX_Vpermilps_xmm_xmm_xmmm128,
		VEX_Vpermilps_ymm_ymm_ymmm256,
		EVEX_Vpermilps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpermilps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermilps_zmm_k1z_zmm_zmmm512b32,
		VEX_Vpermilpd_xmm_xmm_xmmm128,
		VEX_Vpermilpd_ymm_ymm_ymmm256,
		EVEX_Vpermilpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpermilpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermilpd_zmm_k1z_zmm_zmmm512b64,
		VEX_Vtestps_xmm_xmmm128,
		VEX_Vtestps_ymm_ymmm256,
		VEX_Vtestpd_xmm_xmmm128,
		VEX_Vtestpd_ymm_ymmm256,
		Pblendvb_xmm_xmmm128,
		EVEX_Vpsrlvw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsrlvw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsrlvw_zmm_k1z_zmm_zmmm512,
		EVEX_Vpmovuswb_xmmm64_k1z_xmm,
		EVEX_Vpmovuswb_xmmm128_k1z_ymm,
		EVEX_Vpmovuswb_ymmm256_k1z_zmm,
		EVEX_Vpsravw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsravw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsravw_zmm_k1z_zmm_zmmm512,
		EVEX_Vpmovusdb_xmmm32_k1z_xmm,
		EVEX_Vpmovusdb_xmmm64_k1z_ymm,
		EVEX_Vpmovusdb_xmmm128_k1z_zmm,
		EVEX_Vpsllvw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpsllvw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpsllvw_zmm_k1z_zmm_zmmm512,
		EVEX_Vpmovusqb_xmmm16_k1z_xmm,
		EVEX_Vpmovusqb_xmmm32_k1z_ymm,
		EVEX_Vpmovusqb_xmmm64_k1z_zmm,
		VEX_Vcvtph2ps_xmm_xmmm64,
		VEX_Vcvtph2ps_ymm_xmmm128,
		EVEX_Vcvtph2ps_xmm_k1z_xmmm64,
		EVEX_Vcvtph2ps_ymm_k1z_xmmm128,
		EVEX_Vcvtph2ps_zmm_k1z_ymmm256_sae,
		EVEX_Vpmovusdw_xmmm64_k1z_xmm,
		EVEX_Vpmovusdw_xmmm128_k1z_ymm,
		EVEX_Vpmovusdw_ymmm256_k1z_zmm,
		Blendvps_xmm_xmmm128,
		EVEX_Vprorvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vprorvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vprorvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vprorvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vprorvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vprorvq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpmovusqw_xmmm32_k1z_xmm,
		EVEX_Vpmovusqw_xmmm64_k1z_ymm,
		EVEX_Vpmovusqw_xmmm128_k1z_zmm,
		Blendvpd_xmm_xmmm128,
		EVEX_Vprolvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vprolvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vprolvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vprolvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vprolvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vprolvq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpmovusqd_xmmm64_k1z_xmm,
		EVEX_Vpmovusqd_xmmm128_k1z_ymm,
		EVEX_Vpmovusqd_ymmm256_k1z_zmm,
		VEX_Vpermps_ymm_ymm_ymmm256,
		EVEX_Vpermps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermps_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermpd_zmm_k1z_zmm_zmmm512b64,
		Ptest_xmm_xmmm128,
		VEX_Vptest_xmm_xmmm128,
		VEX_Vptest_ymm_ymmm256,
		VEX_Vbroadcastss_xmm_m32,
		VEX_Vbroadcastss_ymm_m32,
		EVEX_Vbroadcastss_xmm_k1z_xmmm32,
		EVEX_Vbroadcastss_ymm_k1z_xmmm32,
		EVEX_Vbroadcastss_zmm_k1z_xmmm32,
		VEX_Vbroadcastsd_ymm_m64,
		EVEX_Vbroadcastf32x2_ymm_k1z_xmmm64,
		EVEX_Vbroadcastf32x2_zmm_k1z_xmmm64,
		EVEX_Vbroadcastsd_ymm_k1z_xmmm64,
		EVEX_Vbroadcastsd_zmm_k1z_xmmm64,
		VEX_Vbroadcastf128_ymm_m128,
		EVEX_Vbroadcastf32x4_ymm_k1z_m128,
		EVEX_Vbroadcastf32x4_zmm_k1z_m128,
		EVEX_Vbroadcastf64x2_ymm_k1z_m128,
		EVEX_Vbroadcastf64x2_zmm_k1z_m128,
		EVEX_Vbroadcastf32x8_zmm_k1z_m256,
		EVEX_Vbroadcastf64x4_zmm_k1z_m256,
		Pabsb_mm_mmm64,
		Pabsb_xmm_xmmm128,
		VEX_Vpabsb_xmm_xmmm128,
		VEX_Vpabsb_ymm_ymmm256,
		EVEX_Vpabsb_xmm_k1z_xmmm128,
		EVEX_Vpabsb_ymm_k1z_ymmm256,
		EVEX_Vpabsb_zmm_k1z_zmmm512,
		Pabsw_mm_mmm64,
		Pabsw_xmm_xmmm128,
		VEX_Vpabsw_xmm_xmmm128,
		VEX_Vpabsw_ymm_ymmm256,
		EVEX_Vpabsw_xmm_k1z_xmmm128,
		EVEX_Vpabsw_ymm_k1z_ymmm256,
		EVEX_Vpabsw_zmm_k1z_zmmm512,
		Pabsd_mm_mmm64,
		Pabsd_xmm_xmmm128,
		VEX_Vpabsd_xmm_xmmm128,
		VEX_Vpabsd_ymm_ymmm256,
		EVEX_Vpabsd_xmm_k1z_xmmm128b32,
		EVEX_Vpabsd_ymm_k1z_ymmm256b32,
		EVEX_Vpabsd_zmm_k1z_zmmm512b32,
		EVEX_Vpabsq_xmm_k1z_xmmm128b64,
		EVEX_Vpabsq_ymm_k1z_ymmm256b64,
		EVEX_Vpabsq_zmm_k1z_zmmm512b64,
		Pmovsxbw_xmm_xmmm64,
		VEX_Vpmovsxbw_xmm_xmmm64,
		VEX_Vpmovsxbw_ymm_xmmm128,
		EVEX_Vpmovsxbw_xmm_k1z_xmmm64,
		EVEX_Vpmovsxbw_ymm_k1z_xmmm128,
		EVEX_Vpmovsxbw_zmm_k1z_ymmm256,
		EVEX_Vpmovswb_xmmm64_k1z_xmm,
		EVEX_Vpmovswb_xmmm128_k1z_ymm,
		EVEX_Vpmovswb_ymmm256_k1z_zmm,
		Pmovsxbd_xmm_xmmm32,
		VEX_Vpmovsxbd_xmm_xmmm32,
		VEX_Vpmovsxbd_ymm_xmmm64,
		EVEX_Vpmovsxbd_xmm_k1z_xmmm32,
		EVEX_Vpmovsxbd_ymm_k1z_xmmm64,
		EVEX_Vpmovsxbd_zmm_k1z_xmmm128,
		EVEX_Vpmovsdb_xmmm32_k1z_xmm,
		EVEX_Vpmovsdb_xmmm64_k1z_ymm,
		EVEX_Vpmovsdb_xmmm128_k1z_zmm,
		Pmovsxbq_xmm_xmmm16,
		VEX_Vpmovsxbq_xmm_xmmm16,
		VEX_Vpmovsxbq_ymm_xmmm32,
		EVEX_Vpmovsxbq_xmm_k1z_xmmm16,
		EVEX_Vpmovsxbq_ymm_k1z_xmmm32,
		EVEX_Vpmovsxbq_zmm_k1z_xmmm64,
		EVEX_Vpmovsqb_xmmm16_k1z_xmm,
		EVEX_Vpmovsqb_xmmm32_k1z_ymm,
		EVEX_Vpmovsqb_xmmm64_k1z_zmm,
		Pmovsxwd_xmm_xmmm64,
		VEX_Vpmovsxwd_xmm_xmmm64,
		VEX_Vpmovsxwd_ymm_xmmm128,
		EVEX_Vpmovsxwd_xmm_k1z_xmmm64,
		EVEX_Vpmovsxwd_ymm_k1z_xmmm128,
		EVEX_Vpmovsxwd_zmm_k1z_ymmm256,
		EVEX_Vpmovsdw_xmmm64_k1z_xmm,
		EVEX_Vpmovsdw_xmmm128_k1z_ymm,
		EVEX_Vpmovsdw_ymmm256_k1z_zmm,
		Pmovsxwq_xmm_xmmm32,
		VEX_Vpmovsxwq_xmm_xmmm32,
		VEX_Vpmovsxwq_ymm_xmmm64,
		EVEX_Vpmovsxwq_xmm_k1z_xmmm32,
		EVEX_Vpmovsxwq_ymm_k1z_xmmm64,
		EVEX_Vpmovsxwq_zmm_k1z_xmmm128,
		EVEX_Vpmovsqw_xmmm32_k1z_xmm,
		EVEX_Vpmovsqw_xmmm64_k1z_ymm,
		EVEX_Vpmovsqw_xmmm128_k1z_zmm,
		Pmovsxdq_xmm_xmmm64,
		VEX_Vpmovsxdq_xmm_xmmm64,
		VEX_Vpmovsxdq_ymm_xmmm128,
		EVEX_Vpmovsxdq_xmm_k1z_xmmm64,
		EVEX_Vpmovsxdq_ymm_k1z_xmmm128,
		EVEX_Vpmovsxdq_zmm_k1z_ymmm256,
		EVEX_Vpmovsqd_xmmm64_k1z_xmm,
		EVEX_Vpmovsqd_xmmm128_k1z_ymm,
		EVEX_Vpmovsqd_ymmm256_k1z_zmm,
		EVEX_Vptestmb_kr_k1_xmm_xmmm128,
		EVEX_Vptestmb_kr_k1_ymm_ymmm256,
		EVEX_Vptestmb_kr_k1_zmm_zmmm512,
		EVEX_Vptestmw_kr_k1_xmm_xmmm128,
		EVEX_Vptestmw_kr_k1_ymm_ymmm256,
		EVEX_Vptestmw_kr_k1_zmm_zmmm512,
		EVEX_Vptestnmb_kr_k1_xmm_xmmm128,
		EVEX_Vptestnmb_kr_k1_ymm_ymmm256,
		EVEX_Vptestnmb_kr_k1_zmm_zmmm512,
		EVEX_Vptestnmw_kr_k1_xmm_xmmm128,
		EVEX_Vptestnmw_kr_k1_ymm_ymmm256,
		EVEX_Vptestnmw_kr_k1_zmm_zmmm512,
		EVEX_Vptestmd_kr_k1_xmm_xmmm128b32,
		EVEX_Vptestmd_kr_k1_ymm_ymmm256b32,
		EVEX_Vptestmd_kr_k1_zmm_zmmm512b32,
		EVEX_Vptestmq_kr_k1_xmm_xmmm128b64,
		EVEX_Vptestmq_kr_k1_ymm_ymmm256b64,
		EVEX_Vptestmq_kr_k1_zmm_zmmm512b64,
		EVEX_Vptestnmd_kr_k1_xmm_xmmm128b32,
		EVEX_Vptestnmd_kr_k1_ymm_ymmm256b32,
		EVEX_Vptestnmd_kr_k1_zmm_zmmm512b32,
		EVEX_Vptestnmq_kr_k1_xmm_xmmm128b64,
		EVEX_Vptestnmq_kr_k1_ymm_ymmm256b64,
		EVEX_Vptestnmq_kr_k1_zmm_zmmm512b64,
		Pmuldq_xmm_xmmm128,
		VEX_Vpmuldq_xmm_xmm_xmmm128,
		VEX_Vpmuldq_ymm_ymm_ymmm256,
		EVEX_Vpmuldq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmuldq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmuldq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpmovm2b_xmm_kr,
		EVEX_Vpmovm2b_ymm_kr,
		EVEX_Vpmovm2b_zmm_kr,
		EVEX_Vpmovm2w_xmm_kr,
		EVEX_Vpmovm2w_ymm_kr,
		EVEX_Vpmovm2w_zmm_kr,
		Pcmpeqq_xmm_xmmm128,
		VEX_Vpcmpeqq_xmm_xmm_xmmm128,
		VEX_Vpcmpeqq_ymm_ymm_ymmm256,
		EVEX_Vpcmpeqq_kr_k1_xmm_xmmm128b64,
		EVEX_Vpcmpeqq_kr_k1_ymm_ymmm256b64,
		EVEX_Vpcmpeqq_kr_k1_zmm_zmmm512b64,
		EVEX_Vpmovb2m_kr_xmm,
		EVEX_Vpmovb2m_kr_ymm,
		EVEX_Vpmovb2m_kr_zmm,
		EVEX_Vpmovw2m_kr_xmm,
		EVEX_Vpmovw2m_kr_ymm,
		EVEX_Vpmovw2m_kr_zmm,
		Movntdqa_xmm_m128,
		VEX_Vmovntdqa_xmm_m128,
		VEX_Vmovntdqa_ymm_m256,
		EVEX_Vmovntdqa_xmm_m128,
		EVEX_Vmovntdqa_ymm_m256,
		EVEX_Vmovntdqa_zmm_m512,
		EVEX_Vpbroadcastmb2q_xmm_kr,
		EVEX_Vpbroadcastmb2q_ymm_kr,
		EVEX_Vpbroadcastmb2q_zmm_kr,
		Packusdw_xmm_xmmm128,
		VEX_Vpackusdw_xmm_xmm_xmmm128,
		VEX_Vpackusdw_ymm_ymm_ymmm256,
		EVEX_Vpackusdw_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpackusdw_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpackusdw_zmm_k1z_zmm_zmmm512b32,
		VEX_Vmaskmovps_xmm_xmm_m128,
		VEX_Vmaskmovps_ymm_ymm_m256,
		EVEX_Vscalefps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vscalefps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vscalefps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vscalefpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vscalefpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vscalefpd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vmaskmovpd_xmm_xmm_m128,
		VEX_Vmaskmovpd_ymm_ymm_m256,
		EVEX_Vscalefss_xmm_k1z_xmm_xmmm32_er,
		EVEX_Vscalefsd_xmm_k1z_xmm_xmmm64_er,
		VEX_Vmaskmovps_m128_xmm_xmm,
		VEX_Vmaskmovps_m256_ymm_ymm,
		VEX_Vmaskmovpd_m128_xmm_xmm,
		VEX_Vmaskmovpd_m256_ymm_ymm,
		Pmovzxbw_xmm_xmmm64,
		VEX_Vpmovzxbw_xmm_xmmm64,
		VEX_Vpmovzxbw_ymm_xmmm128,
		EVEX_Vpmovzxbw_xmm_k1z_xmmm64,
		EVEX_Vpmovzxbw_ymm_k1z_xmmm128,
		EVEX_Vpmovzxbw_zmm_k1z_ymmm256,
		EVEX_Vpmovwb_xmmm64_k1z_xmm,
		EVEX_Vpmovwb_xmmm128_k1z_ymm,
		EVEX_Vpmovwb_ymmm256_k1z_zmm,
		Pmovzxbd_xmm_xmmm32,
		VEX_Vpmovzxbd_xmm_xmmm32,
		VEX_Vpmovzxbd_ymm_xmmm64,
		EVEX_Vpmovzxbd_xmm_k1z_xmmm32,
		EVEX_Vpmovzxbd_ymm_k1z_xmmm64,
		EVEX_Vpmovzxbd_zmm_k1z_xmmm128,
		EVEX_Vpmovdb_xmmm32_k1z_xmm,
		EVEX_Vpmovdb_xmmm64_k1z_ymm,
		EVEX_Vpmovdb_xmmm128_k1z_zmm,
		Pmovzxbq_xmm_xmmm16,
		VEX_Vpmovzxbq_xmm_xmmm16,
		VEX_Vpmovzxbq_ymm_xmmm32,
		EVEX_Vpmovzxbq_xmm_k1z_xmmm16,
		EVEX_Vpmovzxbq_ymm_k1z_xmmm32,
		EVEX_Vpmovzxbq_zmm_k1z_xmmm64,
		EVEX_Vpmovqb_xmmm16_k1z_xmm,
		EVEX_Vpmovqb_xmmm32_k1z_ymm,
		EVEX_Vpmovqb_xmmm64_k1z_zmm,
		Pmovzxwd_xmm_xmmm64,
		VEX_Vpmovzxwd_xmm_xmmm64,
		VEX_Vpmovzxwd_ymm_xmmm128,
		EVEX_Vpmovzxwd_xmm_k1z_xmmm64,
		EVEX_Vpmovzxwd_ymm_k1z_xmmm128,
		EVEX_Vpmovzxwd_zmm_k1z_ymmm256,
		EVEX_Vpmovdw_xmmm64_k1z_xmm,
		EVEX_Vpmovdw_xmmm128_k1z_ymm,
		EVEX_Vpmovdw_ymmm256_k1z_zmm,
		Pmovzxwq_xmm_xmmm32,
		VEX_Vpmovzxwq_xmm_xmmm32,
		VEX_Vpmovzxwq_ymm_xmmm64,
		EVEX_Vpmovzxwq_xmm_k1z_xmmm32,
		EVEX_Vpmovzxwq_ymm_k1z_xmmm64,
		EVEX_Vpmovzxwq_zmm_k1z_xmmm128,
		EVEX_Vpmovqw_xmmm32_k1z_xmm,
		EVEX_Vpmovqw_xmmm64_k1z_ymm,
		EVEX_Vpmovqw_xmmm128_k1z_zmm,
		Pmovzxdq_xmm_xmmm64,
		VEX_Vpmovzxdq_xmm_xmmm64,
		VEX_Vpmovzxdq_ymm_xmmm128,
		EVEX_Vpmovzxdq_xmm_k1z_xmmm64,
		EVEX_Vpmovzxdq_ymm_k1z_xmmm128,
		EVEX_Vpmovzxdq_zmm_k1z_ymmm256,
		EVEX_Vpmovqd_xmmm64_k1z_xmm,
		EVEX_Vpmovqd_xmmm128_k1z_ymm,
		EVEX_Vpmovqd_ymmm256_k1z_zmm,
		VEX_Vpermd_ymm_ymm_ymmm256,
		EVEX_Vpermd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermq_zmm_k1z_zmm_zmmm512b64,
		Pcmpgtq_xmm_xmmm128,
		VEX_Vpcmpgtq_xmm_xmm_xmmm128,
		VEX_Vpcmpgtq_ymm_ymm_ymmm256,
		EVEX_Vpcmpgtq_kr_k1_xmm_xmmm128b64,
		EVEX_Vpcmpgtq_kr_k1_ymm_ymmm256b64,
		EVEX_Vpcmpgtq_kr_k1_zmm_zmmm512b64,
		Pminsb_xmm_xmmm128,
		VEX_Vpminsb_xmm_xmm_xmmm128,
		VEX_Vpminsb_ymm_ymm_ymmm256,
		EVEX_Vpminsb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpminsb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpminsb_zmm_k1z_zmm_zmmm512,
		EVEX_Vpmovm2d_xmm_kr,
		EVEX_Vpmovm2d_ymm_kr,
		EVEX_Vpmovm2d_zmm_kr,
		EVEX_Vpmovm2q_xmm_kr,
		EVEX_Vpmovm2q_ymm_kr,
		EVEX_Vpmovm2q_zmm_kr,
		Pminsd_xmm_xmmm128,
		VEX_Vpminsd_xmm_xmm_xmmm128,
		VEX_Vpminsd_ymm_ymm_ymmm256,
		EVEX_Vpminsd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpminsd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpminsd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpminsq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpminsq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpminsq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpmovd2m_kr_xmm,
		EVEX_Vpmovd2m_kr_ymm,
		EVEX_Vpmovd2m_kr_zmm,
		EVEX_Vpmovq2m_kr_xmm,
		EVEX_Vpmovq2m_kr_ymm,
		EVEX_Vpmovq2m_kr_zmm,
		Pminuw_xmm_xmmm128,
		VEX_Vpminuw_xmm_xmm_xmmm128,
		VEX_Vpminuw_ymm_ymm_ymmm256,
		EVEX_Vpminuw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpminuw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpminuw_zmm_k1z_zmm_zmmm512,
		EVEX_Vpbroadcastmw2d_xmm_kr,
		EVEX_Vpbroadcastmw2d_ymm_kr,
		EVEX_Vpbroadcastmw2d_zmm_kr,
		Pminud_xmm_xmmm128,
		VEX_Vpminud_xmm_xmm_xmmm128,
		VEX_Vpminud_ymm_ymm_ymmm256,
		EVEX_Vpminud_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpminud_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpminud_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpminuq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpminuq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpminuq_zmm_k1z_zmm_zmmm512b64,
		Pmaxsb_xmm_xmmm128,
		VEX_Vpmaxsb_xmm_xmm_xmmm128,
		VEX_Vpmaxsb_ymm_ymm_ymmm256,
		EVEX_Vpmaxsb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaxsb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaxsb_zmm_k1z_zmm_zmmm512,
		Pmaxsd_xmm_xmmm128,
		VEX_Vpmaxsd_xmm_xmm_xmmm128,
		VEX_Vpmaxsd_ymm_ymm_ymmm256,
		EVEX_Vpmaxsd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpmaxsd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpmaxsd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpmaxsq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmaxsq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmaxsq_zmm_k1z_zmm_zmmm512b64,
		Pmaxuw_xmm_xmmm128,
		VEX_Vpmaxuw_xmm_xmm_xmmm128,
		VEX_Vpmaxuw_ymm_ymm_ymmm256,
		EVEX_Vpmaxuw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpmaxuw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpmaxuw_zmm_k1z_zmm_zmmm512,
		Pmaxud_xmm_xmmm128,
		VEX_Vpmaxud_xmm_xmm_xmmm128,
		VEX_Vpmaxud_ymm_ymm_ymmm256,
		EVEX_Vpmaxud_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpmaxud_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpmaxud_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpmaxuq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmaxuq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmaxuq_zmm_k1z_zmm_zmmm512b64,
		Pmulld_xmm_xmmm128,
		VEX_Vpmulld_xmm_xmm_xmmm128,
		VEX_Vpmulld_ymm_ymm_ymmm256,
		EVEX_Vpmulld_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpmulld_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpmulld_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpmullq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmullq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmullq_zmm_k1z_zmm_zmmm512b64,
		Phminposuw_xmm_xmmm128,
		VEX_Vphminposuw_xmm_xmmm128,
		EVEX_Vgetexpps_xmm_k1z_xmmm128b32,
		EVEX_Vgetexpps_ymm_k1z_ymmm256b32,
		EVEX_Vgetexpps_zmm_k1z_zmmm512b32_sae,
		EVEX_Vgetexppd_xmm_k1z_xmmm128b64,
		EVEX_Vgetexppd_ymm_k1z_ymmm256b64,
		EVEX_Vgetexppd_zmm_k1z_zmmm512b64_sae,
		EVEX_Vgetexpss_xmm_k1z_xmm_xmmm32_sae,
		EVEX_Vgetexpsd_xmm_k1z_xmm_xmmm64_sae,
		EVEX_Vplzcntd_xmm_k1z_xmmm128b32,
		EVEX_Vplzcntd_ymm_k1z_ymmm256b32,
		EVEX_Vplzcntd_zmm_k1z_zmmm512b32,
		EVEX_Vplzcntq_xmm_k1z_xmmm128b64,
		EVEX_Vplzcntq_ymm_k1z_ymmm256b64,
		EVEX_Vplzcntq_zmm_k1z_zmmm512b64,
		VEX_Vpsrlvd_xmm_xmm_xmmm128,
		VEX_Vpsrlvd_ymm_ymm_ymmm256,
		VEX_Vpsrlvq_xmm_xmm_xmmm128,
		VEX_Vpsrlvq_ymm_ymm_ymmm256,
		EVEX_Vpsrlvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpsrlvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpsrlvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpsrlvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpsrlvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpsrlvq_zmm_k1z_zmm_zmmm512b64,
		VEX_Vpsravd_xmm_xmm_xmmm128,
		VEX_Vpsravd_ymm_ymm_ymmm256,
		EVEX_Vpsravd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpsravd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpsravd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpsravq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpsravq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpsravq_zmm_k1z_zmm_zmmm512b64,
		VEX_Vpsllvd_xmm_xmm_xmmm128,
		VEX_Vpsllvd_ymm_ymm_ymmm256,
		VEX_Vpsllvq_xmm_xmm_xmmm128,
		VEX_Vpsllvq_ymm_ymm_ymmm256,
		EVEX_Vpsllvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpsllvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpsllvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpsllvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpsllvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpsllvq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vrcp14ps_xmm_k1z_xmmm128b32,
		EVEX_Vrcp14ps_ymm_k1z_ymmm256b32,
		EVEX_Vrcp14ps_zmm_k1z_zmmm512b32,
		EVEX_Vrcp14pd_xmm_k1z_xmmm128b64,
		EVEX_Vrcp14pd_ymm_k1z_ymmm256b64,
		EVEX_Vrcp14pd_zmm_k1z_zmmm512b64,
		EVEX_Vrcp14ss_xmm_k1z_xmm_xmmm32,
		EVEX_Vrcp14sd_xmm_k1z_xmm_xmmm64,
		EVEX_Vrsqrt14ps_xmm_k1z_xmmm128b32,
		EVEX_Vrsqrt14ps_ymm_k1z_ymmm256b32,
		EVEX_Vrsqrt14ps_zmm_k1z_zmmm512b32,
		EVEX_Vrsqrt14pd_xmm_k1z_xmmm128b64,
		EVEX_Vrsqrt14pd_ymm_k1z_ymmm256b64,
		EVEX_Vrsqrt14pd_zmm_k1z_zmmm512b64,
		EVEX_Vrsqrt14ss_xmm_k1z_xmm_xmmm32,
		EVEX_Vrsqrt14sd_xmm_k1z_xmm_xmmm64,
		EVEX_Vpdpbusd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpdpbusd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpdpbusd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpdpbusds_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpdpbusds_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpdpbusds_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpdpwssd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpdpwssd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpdpwssd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vdpbf16ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vdpbf16ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vdpbf16ps_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vp4dpwssd_zmm_k1z_zmmp3_m128,
		EVEX_Vpdpwssds_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpdpwssds_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpdpwssds_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vp4dpwssds_zmm_k1z_zmmp3_m128,
		EVEX_Vpopcntb_xmm_k1z_xmmm128,
		EVEX_Vpopcntb_ymm_k1z_ymmm256,
		EVEX_Vpopcntb_zmm_k1z_zmmm512,
		EVEX_Vpopcntw_xmm_k1z_xmmm128,
		EVEX_Vpopcntw_ymm_k1z_ymmm256,
		EVEX_Vpopcntw_zmm_k1z_zmmm512,
		EVEX_Vpopcntd_xmm_k1z_xmmm128b32,
		EVEX_Vpopcntd_ymm_k1z_ymmm256b32,
		EVEX_Vpopcntd_zmm_k1z_zmmm512b32,
		EVEX_Vpopcntq_xmm_k1z_xmmm128b64,
		EVEX_Vpopcntq_ymm_k1z_ymmm256b64,
		EVEX_Vpopcntq_zmm_k1z_zmmm512b64,
		VEX_Vpbroadcastd_xmm_xmmm32,
		VEX_Vpbroadcastd_ymm_xmmm32,
		EVEX_Vpbroadcastd_xmm_k1z_xmmm32,
		EVEX_Vpbroadcastd_ymm_k1z_xmmm32,
		EVEX_Vpbroadcastd_zmm_k1z_xmmm32,
		VEX_Vpbroadcastq_xmm_xmmm64,
		VEX_Vpbroadcastq_ymm_xmmm64,
		EVEX_Vbroadcasti32x2_xmm_k1z_xmmm64,
		EVEX_Vbroadcasti32x2_ymm_k1z_xmmm64,
		EVEX_Vbroadcasti32x2_zmm_k1z_xmmm64,
		EVEX_Vpbroadcastq_xmm_k1z_xmmm64,
		EVEX_Vpbroadcastq_ymm_k1z_xmmm64,
		EVEX_Vpbroadcastq_zmm_k1z_xmmm64,
		VEX_Vbroadcasti128_ymm_m128,
		EVEX_Vbroadcasti32x4_ymm_k1z_m128,
		EVEX_Vbroadcasti32x4_zmm_k1z_m128,
		EVEX_Vbroadcasti64x2_ymm_k1z_m128,
		EVEX_Vbroadcasti64x2_zmm_k1z_m128,
		EVEX_Vbroadcasti32x8_zmm_k1z_m256,
		EVEX_Vbroadcasti64x4_zmm_k1z_m256,
		EVEX_Vpexpandb_xmm_k1z_xmmm128,
		EVEX_Vpexpandb_ymm_k1z_ymmm256,
		EVEX_Vpexpandb_zmm_k1z_zmmm512,
		EVEX_Vpexpandw_xmm_k1z_xmmm128,
		EVEX_Vpexpandw_ymm_k1z_ymmm256,
		EVEX_Vpexpandw_zmm_k1z_zmmm512,
		EVEX_Vpcompressb_xmmm128_k1z_xmm,
		EVEX_Vpcompressb_ymmm256_k1z_ymm,
		EVEX_Vpcompressb_zmmm512_k1z_zmm,
		EVEX_Vpcompressw_xmmm128_k1z_xmm,
		EVEX_Vpcompressw_ymmm256_k1z_ymm,
		EVEX_Vpcompressw_zmmm512_k1z_zmm,
		EVEX_Vpblendmd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpblendmd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpblendmd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpblendmq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpblendmq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpblendmq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vblendmps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vblendmps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vblendmps_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vblendmpd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vblendmpd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vblendmpd_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpblendmb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpblendmb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpblendmb_zmm_k1z_zmm_zmmm512,
		EVEX_Vpblendmw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpblendmw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpblendmw_zmm_k1z_zmm_zmmm512,
		EVEX_Vp2intersectd_kp1_xmm_xmmm128b32,
		EVEX_Vp2intersectd_kp1_ymm_ymmm256b32,
		EVEX_Vp2intersectd_kp1_zmm_zmmm512b32,
		EVEX_Vp2intersectq_kp1_xmm_xmmm128b64,
		EVEX_Vp2intersectq_kp1_ymm_ymmm256b64,
		EVEX_Vp2intersectq_kp1_zmm_zmmm512b64,
		EVEX_Vpshldvw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpshldvw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpshldvw_zmm_k1z_zmm_zmmm512,
		EVEX_Vpshldvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpshldvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpshldvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpshldvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpshldvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpshldvq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpshrdvw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpshrdvw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpshrdvw_zmm_k1z_zmm_zmmm512,
		EVEX_Vcvtneps2bf16_xmm_k1z_xmmm128b32,
		EVEX_Vcvtneps2bf16_xmm_k1z_ymmm256b32,
		EVEX_Vcvtneps2bf16_ymm_k1z_zmmm512b32,
		EVEX_Vcvtne2ps2bf16_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vcvtne2ps2bf16_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vcvtne2ps2bf16_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpshrdvd_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpshrdvd_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpshrdvd_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpshrdvq_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpshrdvq_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpshrdvq_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpermi2b_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermi2b_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermi2b_zmm_k1z_zmm_zmmm512,
		EVEX_Vpermi2w_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermi2w_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermi2w_zmm_k1z_zmm_zmmm512,
		EVEX_Vpermi2d_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpermi2d_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermi2d_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermi2q_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpermi2q_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermi2q_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpermi2ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpermi2ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermi2ps_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermi2pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpermi2pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermi2pd_zmm_k1z_zmm_zmmm512b64,
		VEX_Vpbroadcastb_xmm_xmmm8,
		VEX_Vpbroadcastb_ymm_xmmm8,
		EVEX_Vpbroadcastb_xmm_k1z_xmmm8,
		EVEX_Vpbroadcastb_ymm_k1z_xmmm8,
		EVEX_Vpbroadcastb_zmm_k1z_xmmm8,
		VEX_Vpbroadcastw_xmm_xmmm16,
		VEX_Vpbroadcastw_ymm_xmmm16,
		EVEX_Vpbroadcastw_xmm_k1z_xmmm16,
		EVEX_Vpbroadcastw_ymm_k1z_xmmm16,
		EVEX_Vpbroadcastw_zmm_k1z_xmmm16,
		EVEX_Vpbroadcastb_xmm_k1z_r32,
		EVEX_Vpbroadcastb_ymm_k1z_r32,
		EVEX_Vpbroadcastb_zmm_k1z_r32,
		EVEX_Vpbroadcastw_xmm_k1z_r32,
		EVEX_Vpbroadcastw_ymm_k1z_r32,
		EVEX_Vpbroadcastw_zmm_k1z_r32,
		EVEX_Vpbroadcastd_xmm_k1z_r32,
		EVEX_Vpbroadcastd_ymm_k1z_r32,
		EVEX_Vpbroadcastd_zmm_k1z_r32,
		EVEX_Vpbroadcastq_xmm_k1z_r64,
		EVEX_Vpbroadcastq_ymm_k1z_r64,
		EVEX_Vpbroadcastq_zmm_k1z_r64,
		EVEX_Vpermt2b_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermt2b_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermt2b_zmm_k1z_zmm_zmmm512,
		EVEX_Vpermt2w_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermt2w_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermt2w_zmm_k1z_zmm_zmmm512,
		EVEX_Vpermt2d_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpermt2d_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermt2d_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermt2q_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpermt2q_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermt2q_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vpermt2ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vpermt2ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vpermt2ps_zmm_k1z_zmm_zmmm512b32,
		EVEX_Vpermt2pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpermt2pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpermt2pd_zmm_k1z_zmm_zmmm512b64,
		Invept_r32_m128,
		Invept_r64_m128,
		Invvpid_r32_m128,
		Invvpid_r64_m128,
		Invpcid_r32_m128,
		Invpcid_r64_m128,
		EVEX_Vpmultishiftqb_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vpmultishiftqb_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vpmultishiftqb_zmm_k1z_zmm_zmmm512b64,
		EVEX_Vexpandps_xmm_k1z_xmmm128,
		EVEX_Vexpandps_ymm_k1z_ymmm256,
		EVEX_Vexpandps_zmm_k1z_zmmm512,
		EVEX_Vexpandpd_xmm_k1z_xmmm128,
		EVEX_Vexpandpd_ymm_k1z_ymmm256,
		EVEX_Vexpandpd_zmm_k1z_zmmm512,
		EVEX_Vpexpandd_xmm_k1z_xmmm128,
		EVEX_Vpexpandd_ymm_k1z_ymmm256,
		EVEX_Vpexpandd_zmm_k1z_zmmm512,
		EVEX_Vpexpandq_xmm_k1z_xmmm128,
		EVEX_Vpexpandq_ymm_k1z_ymmm256,
		EVEX_Vpexpandq_zmm_k1z_zmmm512,
		EVEX_Vcompressps_xmmm128_k1z_xmm,
		EVEX_Vcompressps_ymmm256_k1z_ymm,
		EVEX_Vcompressps_zmmm512_k1z_zmm,
		EVEX_Vcompresspd_xmmm128_k1z_xmm,
		EVEX_Vcompresspd_ymmm256_k1z_ymm,
		EVEX_Vcompresspd_zmmm512_k1z_zmm,
		EVEX_Vpcompressd_xmmm128_k1z_xmm,
		EVEX_Vpcompressd_ymmm256_k1z_ymm,
		EVEX_Vpcompressd_zmmm512_k1z_zmm,
		EVEX_Vpcompressq_xmmm128_k1z_xmm,
		EVEX_Vpcompressq_ymmm256_k1z_ymm,
		EVEX_Vpcompressq_zmmm512_k1z_zmm,
		VEX_Vpmaskmovd_xmm_xmm_m128,
		VEX_Vpmaskmovd_ymm_ymm_m256,
		VEX_Vpmaskmovq_xmm_xmm_m128,
		VEX_Vpmaskmovq_ymm_ymm_m256,
		EVEX_Vpermb_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermb_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermb_zmm_k1z_zmm_zmmm512,
		EVEX_Vpermw_xmm_k1z_xmm_xmmm128,
		EVEX_Vpermw_ymm_k1z_ymm_ymmm256,
		EVEX_Vpermw_zmm_k1z_zmm_zmmm512,
		VEX_Vpmaskmovd_m128_xmm_xmm,
		VEX_Vpmaskmovd_m256_ymm_ymm,
		VEX_Vpmaskmovq_m128_xmm_xmm,
		VEX_Vpmaskmovq_m256_ymm_ymm,
		EVEX_Vpshufbitqmb_kr_k1_xmm_xmmm128,
		EVEX_Vpshufbitqmb_kr_k1_ymm_ymmm256,
		EVEX_Vpshufbitqmb_kr_k1_zmm_zmmm512,
		VEX_Vpgatherdd_xmm_vm32x_xmm,
		VEX_Vpgatherdd_ymm_vm32y_ymm,
		VEX_Vpgatherdq_xmm_vm32x_xmm,
		VEX_Vpgatherdq_ymm_vm32x_ymm,
		EVEX_Vpgatherdd_xmm_k1_vm32x,
		EVEX_Vpgatherdd_ymm_k1_vm32y,
		EVEX_Vpgatherdd_zmm_k1_vm32z,
		EVEX_Vpgatherdq_xmm_k1_vm32x,
		EVEX_Vpgatherdq_ymm_k1_vm32x,
		EVEX_Vpgatherdq_zmm_k1_vm32y,
		VEX_Vpgatherqd_xmm_vm64x_xmm,
		VEX_Vpgatherqd_xmm_vm64y_xmm,
		VEX_Vpgatherqq_xmm_vm64x_xmm,
		VEX_Vpgatherqq_ymm_vm64y_ymm,
		EVEX_Vpgatherqd_xmm_k1_vm64x,
		EVEX_Vpgatherqd_xmm_k1_vm64y,
		EVEX_Vpgatherqd_ymm_k1_vm64z,
		EVEX_Vpgatherqq_xmm_k1_vm64x,
		EVEX_Vpgatherqq_ymm_k1_vm64y,
		EVEX_Vpgatherqq_zmm_k1_vm64z,
		VEX_Vgatherdps_xmm_vm32x_xmm,
		VEX_Vgatherdps_ymm_vm32y_ymm,
		VEX_Vgatherdpd_xmm_vm32x_xmm,
		VEX_Vgatherdpd_ymm_vm32x_ymm,
		EVEX_Vgatherdps_xmm_k1_vm32x,
		EVEX_Vgatherdps_ymm_k1_vm32y,
		EVEX_Vgatherdps_zmm_k1_vm32z,
		EVEX_Vgatherdpd_xmm_k1_vm32x,
		EVEX_Vgatherdpd_ymm_k1_vm32x,
		EVEX_Vgatherdpd_zmm_k1_vm32y,
		VEX_Vgatherqps_xmm_vm64x_xmm,
		VEX_Vgatherqps_xmm_vm64y_xmm,
		VEX_Vgatherqpd_xmm_vm64x_xmm,
		VEX_Vgatherqpd_ymm_vm64y_ymm,
		EVEX_Vgatherqps_xmm_k1_vm64x,
		EVEX_Vgatherqps_xmm_k1_vm64y,
		EVEX_Vgatherqps_ymm_k1_vm64z,
		EVEX_Vgatherqpd_xmm_k1_vm64x,
		EVEX_Vgatherqpd_ymm_k1_vm64y,
		EVEX_Vgatherqpd_zmm_k1_vm64z,
		VEX_Vfmaddsub132ps_xmm_xmm_xmmm128,
		VEX_Vfmaddsub132ps_ymm_ymm_ymmm256,
		VEX_Vfmaddsub132pd_xmm_xmm_xmmm128,
		VEX_Vfmaddsub132pd_ymm_ymm_ymmm256,
		EVEX_Vfmaddsub132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfmaddsub132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfmaddsub132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfmaddsub132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfmaddsub132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfmaddsub132pd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vfmsubadd132ps_xmm_xmm_xmmm128,
		VEX_Vfmsubadd132ps_ymm_ymm_ymmm256,
		VEX_Vfmsubadd132pd_xmm_xmm_xmmm128,
		VEX_Vfmsubadd132pd_ymm_ymm_ymmm256,
		EVEX_Vfmsubadd132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfmsubadd132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfmsubadd132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfmsubadd132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfmsubadd132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfmsubadd132pd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vfmadd132ps_xmm_xmm_xmmm128,
		VEX_Vfmadd132ps_ymm_ymm_ymmm256,
		VEX_Vfmadd132pd_xmm_xmm_xmmm128,
		VEX_Vfmadd132pd_ymm_ymm_ymmm256,
		EVEX_Vfmadd132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfmadd132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfmadd132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfmadd132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfmadd132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfmadd132pd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vfmadd132ss_xmm_xmm_xmmm32,
		VEX_Vfmadd132sd_xmm_xmm_xmmm64,
		EVEX_Vfmadd132ss_xmm_k1z_xmm_xmmm32_er,
		EVEX_Vfmadd132sd_xmm_k1z_xmm_xmmm64_er,
		VEX_Vfmsub132ps_xmm_xmm_xmmm128,
		VEX_Vfmsub132ps_ymm_ymm_ymmm256,
		VEX_Vfmsub132pd_xmm_xmm_xmmm128,
		VEX_Vfmsub132pd_ymm_ymm_ymmm256,
		EVEX_Vfmsub132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfmsub132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfmsub132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfmsub132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfmsub132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfmsub132pd_zmm_k1z_zmm_zmmm512b64_er,
		EVEX_V4fmaddps_zmm_k1z_zmmp3_m128,
		VEX_Vfmsub132ss_xmm_xmm_xmmm32,
		VEX_Vfmsub132sd_xmm_xmm_xmmm64,
		EVEX_Vfmsub132ss_xmm_k1z_xmm_xmmm32_er,
		EVEX_Vfmsub132sd_xmm_k1z_xmm_xmmm64_er,
		EVEX_V4fmaddss_xmm_k1z_xmmp3_m128,
		VEX_Vfnmadd132ps_xmm_xmm_xmmm128,
		VEX_Vfnmadd132ps_ymm_ymm_ymmm256,
		VEX_Vfnmadd132pd_xmm_xmm_xmmm128,
		VEX_Vfnmadd132pd_ymm_ymm_ymmm256,
		EVEX_Vfnmadd132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfnmadd132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfnmadd132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfnmadd132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfnmadd132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfnmadd132pd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vfnmadd132ss_xmm_xmm_xmmm32,
		VEX_Vfnmadd132sd_xmm_xmm_xmmm64,
		EVEX_Vfnmadd132ss_xmm_k1z_xmm_xmmm32_er,
		EVEX_Vfnmadd132sd_xmm_k1z_xmm_xmmm64_er,
		VEX_Vfnmsub132ps_xmm_xmm_xmmm128,
		VEX_Vfnmsub132ps_ymm_ymm_ymmm256,
		VEX_Vfnmsub132pd_xmm_xmm_xmmm128,
		VEX_Vfnmsub132pd_ymm_ymm_ymmm256,
		EVEX_Vfnmsub132ps_xmm_k1z_xmm_xmmm128b32,
		EVEX_Vfnmsub132ps_ymm_k1z_ymm_ymmm256b32,
		EVEX_Vfnmsub132ps_zmm_k1z_zmm_zmmm512b32_er,
		EVEX_Vfnmsub132pd_xmm_k1z_xmm_xmmm128b64,
		EVEX_Vfnmsub132pd_ymm_k1z_ymm_ymmm256b64,
		EVEX_Vfnmsub132pd_zmm_k1z_zmm_zmmm512b64_er,
		VEX_Vfnmsub132ss_xmm_xmm_xmmm32,
		VEX_Vfnmsub132sd_xmm_xmm_xmmm64,
		EVEX_Vfnmsub132ss_xmm_k1z_xmm_xmmm32_er,
		EVEX_Vfnmsub132sd_xmm_k1z_xmm_xmmm64_er,
		EVEX_Vpscatterdd_vm32x_k1_xmm,
		EVEX_Vpscatterdd_vm32y_k1_ymm,
		EVEX_Vpscatterdd_vm32z_k1_zmm,
		EVEX_Vpscatterdq_vm32x_k1_xmm,
		EVEX_Vpscatterdq_vm32x_k1_ymm,
		EVEX_Vpscatterdq_vm32y_k1_zmm,
		EVEX_Vpscatterqd_vm64x_k1_xmm,
		EVEX_Vpscatterqd_vm64y_k1_xmm,
		EVEX_Vpscatterqd_vm64z_k1_ymm,
		EVEX_Vpscatterqq_vm64x_k1_xmm,
		EVEX_Vpscatterqq_vm64y_k1_ymm,
		EVEX_Vpscatterqq_vm64z_k1_zmm,
		EVEX_Vscatterdps_vm32x_k1_xmm,
		EVEX_

plugins/MonoMod.ILHelpers.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;

[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: AssemblyCopyright("Copyright 2024 0x0ade, DaNike")]
[assembly: CLSCompliant(false)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyTitle("MonoMod.ILHelpers")]
[assembly: AssemblyCompany("0x0ade, DaNike")]
[assembly: AssemblyDescription("Package Description")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: TypeForwardedTo(typeof(Unsafe))]
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class NonVersionableAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] A_0)
		{
			TransformFlags = A_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte A_0)
		{
			Flag = A_0;
		}
	}
}
namespace MonoMod
{
	public static class ILHelpers
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe static T TailCallDelegatePtr<T>(IntPtr source)
		{
			return ((delegate*<T>)source)();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static T TailCallFunc<T>(Func<T> func)
		{
			return func();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe static ref T ObjectAsRef<T>(object obj)
		{
			fixed (object obj2 = obj)
			{
				T** ptr = (T**)(&obj2);
				return ref *(*ptr);
			}
		}
	}
}
namespace MonoMod.Backports.ILHelpers
{
	public static class UnsafeRaw
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static T Read<T>(void* source)
		{
			return System.Runtime.CompilerServices.Unsafe.Read<T>(source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static T ReadUnaligned<T>(void* source)
		{
			return System.Runtime.CompilerServices.Unsafe.ReadUnaligned<T>(source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static T ReadUnaligned<T>(ref byte source)
		{
			return System.Runtime.CompilerServices.Unsafe.ReadUnaligned<T>(ref source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void Write<T>(void* destination, T value)
		{
			System.Runtime.CompilerServices.Unsafe.Write(destination, value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void WriteUnaligned<T>(void* destination, T value)
		{
			System.Runtime.CompilerServices.Unsafe.WriteUnaligned(destination, value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void WriteUnaligned<T>(ref byte destination, T value)
		{
			System.Runtime.CompilerServices.Unsafe.WriteUnaligned(ref destination, value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void Copy<T>(void* destination, ref T source)
		{
			System.Runtime.CompilerServices.Unsafe.Write(destination, source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void Copy<T>(ref T destination, void* source)
		{
			destination = System.Runtime.CompilerServices.Unsafe.Read<T>(source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void* AsPointer<T>(ref T value)
		{
			return System.Runtime.CompilerServices.Unsafe.AsPointer(ref value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void SkipInit<T>(out T value)
		{
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static int SizeOf<T>()
		{
			return System.Runtime.CompilerServices.Unsafe.SizeOf<T>();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void CopyBlock(void* destination, void* source, uint byteCount)
		{
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlock(destination, source, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void CopyBlock(ref byte destination, ref byte source, uint byteCount)
		{
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlock(ref destination, ref source, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount)
		{
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(destination, source, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount)
		{
			// IL cpblk instruction
			System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount)
		{
			// IL initblk instruction
			System.Runtime.CompilerServices.Unsafe.InitBlock(startAddress, value, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void InitBlock(ref byte startAddress, byte value, uint byteCount)
		{
			// IL initblk instruction
			System.Runtime.CompilerServices.Unsafe.InitBlock(ref startAddress, value, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount)
		{
			// IL initblk instruction
			System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(startAddress, value, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)
		{
			// IL initblk instruction
			System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static T As<T>(object o) where T : class
		{
			return (T)o;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static ref T AsRef<T>(void* source)
		{
			return ref *(T*)source;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T AsRef<T>(in T source)
		{
			return ref source;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref TTo As<TFrom, TTo>(ref TFrom source)
		{
			return ref System.Runtime.CompilerServices.Unsafe.As<TFrom, TTo>(ref source);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Unbox<T>(object box) where T : struct
		{
			return ref (T)box;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Add<T>(ref T source, int elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Add(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void* Add<T>(void* source, int elementOffset)
		{
			return (byte*)source + (nint)elementOffset * (nint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Add<T>(ref T source, nint elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Add(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Add<T>(ref T source, nuint elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Add(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T AddByteOffset<T>(ref T source, nint byteOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref source, byteOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T AddByteOffset<T>(ref T source, nuint byteOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref source, byteOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Subtract<T>(ref T source, int elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Subtract(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static void* Subtract<T>(void* source, int elementOffset)
		{
			return (byte*)source - (nint)elementOffset * (nint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Subtract<T>(ref T source, nint elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Subtract(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T Subtract<T>(ref T source, nuint elementOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.Subtract(ref source, elementOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T SubtractByteOffset<T>(ref T source, nint byteOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.SubtractByteOffset(ref source, byteOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static ref T SubtractByteOffset<T>(ref T source, nuint byteOffset)
		{
			return ref System.Runtime.CompilerServices.Unsafe.SubtractByteOffset(ref source, byteOffset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static nint ByteOffset<T>(ref T origin, ref T target)
		{
			return System.Runtime.CompilerServices.Unsafe.ByteOffset(target: ref target, origin: ref origin);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static bool AreSame<T>(ref T left, ref T right)
		{
			return System.Runtime.CompilerServices.Unsafe.AreSame(ref left, ref right);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
		{
			return System.Runtime.CompilerServices.Unsafe.IsAddressGreaterThan(ref left, ref right);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public static bool IsAddressLessThan<T>(ref T left, ref T right)
		{
			return System.Runtime.CompilerServices.Unsafe.IsAddressLessThan(ref left, ref right);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static bool IsNullRef<T>(ref T source)
		{
			return System.Runtime.CompilerServices.Unsafe.AsPointer(ref source) == null;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static ref T NullRef<T>()
		{
			return ref *(T*)null;
		}
	}
}

plugins/MonoMod.RuntimeDetour.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod;
using MonoMod.Cil;
using MonoMod.Core;
using MonoMod.Core.Platforms;
using MonoMod.Logs;
using MonoMod.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = ".NET Framework 4.5.2")]
[assembly: AssemblyCompany("0x0ade, DaNike")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2024 0x0ade, DaNike")]
[assembly: AssemblyDescription("Flexible and easily extensible runtime detouring library. Wrap, replace and manipulate (Mono.Cecil) methods at runtime.")]
[assembly: AssemblyFileVersion("25.2.1.0")]
[assembly: AssemblyInformationalVersion("25.2.1+e79d24413")]
[assembly: AssemblyProduct("MonoMod.RuntimeDetour")]
[assembly: AssemblyTitle("MonoMod.RuntimeDetour")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoMod/MonoMod.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("25.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		MMDbgLog.LogVersion();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[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 MonoMod
{
	internal static class MMDbgLog
	{
		[InterpolatedStringHandler]
		internal ref struct DebugLogSpamStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogSpamStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)0, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogTraceStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogTraceStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)1, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogInfoStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogInfoStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)2, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogWarningStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogWarningStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)3, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogErrorStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogErrorStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, (LogLevel)4, ref isEnabled);
			}

			public override string ToString()
			{
				return ((object)(DebugLogInterpolatedStringHandler)(ref handler)).ToString();
			}

			public string ToStringAndClear()
			{
				return ((DebugLogInterpolatedStringHandler)(ref handler)).ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				((DebugLogInterpolatedStringHandler)(ref handler)).AppendFormatted<T>(value, alignment, format);
			}
		}

		public static bool IsWritingLog => DebugLog.IsWritingLog;

		[ModuleInitializer]
		internal static void LogVersion()
		{
			Info("Version 25.2.1");
		}

		public static void Log(LogLevel level, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DebugLog.Log("MonoMod.RuntimeDetour", level, message);
		}

		public static void Log(LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DebugLog.Log("MonoMod.RuntimeDetour", level, ref message);
		}

		public static void Spam(string message)
		{
			Log((LogLevel)0, message);
		}

		public static void Spam(ref DebugLogSpamStringHandler message)
		{
			Log((LogLevel)0, ref message.handler);
		}

		public static void Trace(string message)
		{
			Log((LogLevel)1, message);
		}

		public static void Trace(ref DebugLogTraceStringHandler message)
		{
			Log((LogLevel)1, ref message.handler);
		}

		public static void Info(string message)
		{
			Log((LogLevel)2, message);
		}

		public static void Info(ref DebugLogInfoStringHandler message)
		{
			Log((LogLevel)2, ref message.handler);
		}

		public static void Warning(string message)
		{
			Log((LogLevel)3, message);
		}

		public static void Warning(ref DebugLogWarningStringHandler message)
		{
			Log((LogLevel)3, ref message.handler);
		}

		public static void Error(string message)
		{
			Log((LogLevel)4, message);
		}

		public static void Error(ref DebugLogErrorStringHandler message)
		{
			Log((LogLevel)4, ref message.handler);
		}
	}
	internal static class MultiTargetShims
	{
		public static TypeReference GetConstraintType(this GenericParameterConstraint constraint)
		{
			return constraint.ConstraintType;
		}
	}
}
namespace MonoMod.SourceGen.Attributes
{
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class EmitILOverloadsAttribute : Attribute
	{
		public EmitILOverloadsAttribute(string filename, string kind)
		{
		}
	}
	internal static class ILOverloadKind
	{
		public const string Cursor = "ILCursor";

		public const string Matcher = "ILMatcher";
	}
}
namespace MonoMod.RuntimeDetour
{
	public class DetourConfig
	{
		public string Id { get; }

		public int? Priority { get; }

		public IEnumerable<string> Before { get; }

		public IEnumerable<string> After { get; }

		[Browsable(false)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public int SubPriority { get; }

		public DetourConfig(string id, int? priority = null, IEnumerable<string>? before = null, IEnumerable<string>? after = null)
			: this(id, priority, before, after, 0)
		{
		}

		[Browsable(false)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public DetourConfig(string id, int? priority, IEnumerable<string>? before, IEnumerable<string>? after, int subPriority)
		{
			Id = id;
			Priority = priority;
			Before = AsFixedSize(before ?? Enumerable.Empty<string>());
			After = AsFixedSize(after ?? Enumerable.Empty<string>());
			SubPriority = subPriority;
		}

		private static IEnumerable<string> AsFixedSize(IEnumerable<string> enumerable)
		{
			if (enumerable == Enumerable.Empty<string>())
			{
				return enumerable;
			}
			if (enumerable is ICollection<string>)
			{
				return enumerable;
			}
			return enumerable.ToArray();
		}

		public DetourConfig WithPriority(int? priority)
		{
			return new DetourConfig(Id, priority, Before, After, SubPriority);
		}

		public DetourConfig WithBefore(IEnumerable<string> before)
		{
			return new DetourConfig(Id, Priority, before, After, SubPriority);
		}

		public DetourConfig WithBefore(params string[] before)
		{
			return WithBefore(before.AsEnumerable());
		}

		public DetourConfig WithAfter(IEnumerable<string> after)
		{
			return new DetourConfig(Id, Priority, Before, after, SubPriority);
		}

		public DetourConfig WithAfter(params string[] after)
		{
			return WithAfter(after.AsEnumerable());
		}

		public DetourConfig AddBefore(IEnumerable<string> before)
		{
			return WithBefore(Before.Concat(before));
		}

		public DetourConfig AddBefore(params string[] before)
		{
			return AddBefore(before.AsEnumerable());
		}

		public DetourConfig AddAfter(IEnumerable<string> after)
		{
			return WithAfter(After.Concat(after));
		}

		public DetourConfig AddAfter(params string[] after)
		{
			return AddAfter(after.AsEnumerable());
		}
	}
	public abstract class DetourContext
	{
		private sealed class Scope
		{
			public readonly DetourContext Context;

			public readonly Scope? Prev;

			public bool Active = true;

			public Scope(DetourContext context, Scope? prev)
			{
				Context = context;
				Prev = prev;
			}
		}

		private sealed class ContextScopeHandler : ScopeHandlerBase
		{
			public static readonly ContextScopeHandler Instance = new ContextScopeHandler();

			public override void EndScope(object? data)
			{
				((Scope)data).Active = false;
				while (true)
				{
					Scope current = DetourContext.current;
					if (current != null && !current.Active)
					{
						DetourContext.current = DetourContext.current.Prev;
						continue;
					}
					break;
				}
			}
		}

		private static DetourContext? globalCurrent;

		[ThreadStatic]
		private static Scope? current;

		public static DetourContext? Current
		{
			get
			{
				Scope prev = current;
				while (prev != null && !prev.Active)
				{
					prev = prev.Prev;
				}
				return prev?.Context ?? globalCurrent;
			}
		}

		public DetourConfig? Config
		{
			get
			{
				if (!TryGetConfig(out DetourConfig config))
				{
					return null;
				}
				return config;
			}
		}

		public static DetourConfig? CurrentConfig
		{
			get
			{
				if (!TryGetCurrentConfig(out DetourConfig config))
				{
					return null;
				}
				return config;
			}
		}

		public IDetourFactory? Factory
		{
			get
			{
				if (!TryGetFactory(out IDetourFactory detourFactory))
				{
					return null;
				}
				return detourFactory;
			}
		}

		public static IDetourFactory? CurrentFactory
		{
			get
			{
				if (!TryGetCurrentFactory(out IDetourFactory detourFactory))
				{
					return null;
				}
				return detourFactory;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static DetourContext? SetGlobalContext(DetourContext? context)
		{
			return Interlocked.Exchange(ref globalCurrent, context);
		}

		private static DataScope PushContext(DetourContext ctx)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			current = new Scope(ctx, current);
			return new DataScope((ScopeHandlerBase)(object)ContextScopeHandler.Instance, (object)current);
		}

		[CLSCompliant(false)]
		public DataScope Use()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return PushContext(this);
		}

		public static DetourConfig? GetDefaultConfig()
		{
			if (!TryGetCurrentConfig(out DetourConfig config))
			{
				return null;
			}
			return config;
		}

		public static IDetourFactory GetDefaultFactory()
		{
			if (!TryGetCurrentFactory(out IDetourFactory detourFactory))
			{
				return DetourFactory.Current;
			}
			return detourFactory;
		}

		protected abstract bool TryGetConfig(out DetourConfig? config);

		public static bool TryGetCurrentConfig(out DetourConfig? config)
		{
			for (Scope prev = current; prev != null; prev = prev.Prev)
			{
				if (prev.Active && prev.Context.TryGetConfig(out config))
				{
					return true;
				}
			}
			DetourContext detourContext = globalCurrent;
			if (detourContext != null && detourContext.TryGetConfig(out config))
			{
				return true;
			}
			config = null;
			return false;
		}

		protected abstract bool TryGetFactory([MaybeNullWhen(false)] out IDetourFactory detourFactory);

		public static bool TryGetCurrentFactory([MaybeNullWhen(false)] out IDetourFactory detourFactory)
		{
			for (Scope prev = current; prev != null; prev = prev.Prev)
			{
				if (prev.Context.TryGetFactory(out detourFactory))
				{
					return true;
				}
			}
			DetourContext detourContext = globalCurrent;
			if (detourContext != null && detourContext.TryGetFactory(out detourFactory))
			{
				return true;
			}
			detourFactory = null;
			return false;
		}
	}
	public abstract class EmptyDetourContext : DetourContext
	{
		protected override bool TryGetConfig(out DetourConfig? config)
		{
			config = null;
			return false;
		}

		protected override bool TryGetFactory([MaybeNullWhen(false)] out IDetourFactory detourFactory)
		{
			detourFactory = null;
			return false;
		}
	}
	public class DetourConfigContext : EmptyDetourContext
	{
		private readonly DetourConfig? cfg;

		public DetourConfigContext(DetourConfig? cfg)
		{
			this.cfg = cfg;
		}

		protected override bool TryGetConfig(out DetourConfig? config)
		{
			config = cfg;
			return true;
		}
	}
	public class DetourFactoryContext : EmptyDetourContext
	{
		private readonly IDetourFactory fac;

		public DetourFactoryContext(IDetourFactory fac)
		{
			this.fac = fac;
		}

		protected override bool TryGetFactory([MaybeNullWhen(false)] out IDetourFactory detourFactory)
		{
			detourFactory = fac;
			return true;
		}
	}
	public static class DetourManager
	{
		internal abstract class ManagedChainNode
		{
			public ManagedChainNode? Next;

			private MethodBase? lastTarget;

			private ICoreDetour? trampolineDetour;

			private bool hasStolenTrampoline;

			public abstract MethodBase Entry { get; }

			public abstract MethodBase NextTrampoline { get; }

			public abstract DetourConfig? Config { get; }

			public virtual bool DetourToFallback => true;

			public bool IsApplied { get; private set; }

			private void UndoTrampolineDetour()
			{
				ICoreDetour val = Interlocked.Exchange(ref trampolineDetour, null);
				if (val != null)
				{
					((ICoreDetourBase)val).Undo();
					((IDisposable)val).Dispose();
				}
			}

			public virtual void UpdateDetour(IDetourFactory factory, MethodBase fallback)
			{
				MethodBase methodBase = Next?.Entry;
				if ((object)methodBase == null && DetourToFallback)
				{
					methodBase = fallback;
				}
				if (!(methodBase == lastTarget))
				{
					UndoTrampolineDetour();
					if ((object)methodBase != null)
					{
						trampolineDetour = DetourFactory.CreateDetour(factory, NextTrampoline, methodBase, true);
					}
					lastTarget = methodBase;
					IsApplied = true;
				}
			}

			public void Remove()
			{
				if (!hasStolenTrampoline)
				{
					UndoTrampolineDetour();
				}
				lastTarget = null;
				Next = null;
				IsApplied = false;
			}

			public void StealTrampoline(IDetourFactory factory)
			{
				Helpers.Assert(!hasStolenTrampoline, (string)null, "!hasStolenTrampoline");
				StealTrampolineInner();
				hasStolenTrampoline = true;
				UndoTrampolineDetour();
				trampolineDetour = DetourFactory.CreateDetour(factory, NextTrampoline, (MethodBase)GetRemovedStub(MethodSignature.ForMethod(NextTrampoline)), true);
			}

			protected virtual void StealTrampolineInner()
			{
				throw new NotSupportedException("Can't steal ManagedChainNode trampoline");
			}

			public virtual void ReturnStolenTrampoline()
			{
				Helpers.Assert(hasStolenTrampoline, (string)null, "hasStolenTrampoline");
				UndoTrampolineDetour();
				ReturnStolenTrampolineInner();
				hasStolenTrampoline = false;
			}

			protected virtual void ReturnStolenTrampolineInner()
			{
				throw new NotSupportedException("Can't steal ManagedChainNode trampoline");
			}
		}

		internal sealed class ManagedDetourChainNode : ManagedChainNode
		{
			public readonly SingleManagedDetourState Detour;

			public override MethodBase Entry => Detour.InvokeTarget;

			public override MethodBase NextTrampoline => Detour.NextTrampoline.TrampolineMethod;

			public override DetourConfig? Config => Detour.Config;

			public IDetourFactory Factory => Detour.Factory;

			public ManagedDetourChainNode(SingleManagedDetourState detour)
			{
				Detour = detour;
			}

			protected override void StealTrampolineInner()
			{
				Detour.NextTrampoline.StealTrampolineOwnership();
			}

			protected override void ReturnStolenTrampolineInner()
			{
				Detour.NextTrampoline.ReturnTrampolineOwnership();
			}
		}

		internal sealed class ManagedDetourSyncInfo : DetourSyncInfo
		{
			public int HasStolenTrampolines;

			public readonly ConcurrentQueue<ManagedChainNode> TrampolineStealers = new ConcurrentQueue<ManagedChainNode>();

			public void StealTrampoline(IDetourFactory factory, ManagedChainNode node)
			{
				node.StealTrampoline(factory);
				TrampolineStealers.Enqueue(node);
				Volatile.Write(ref HasStolenTrampolines, 1);
			}

			public void ReturnStolenTrampolines()
			{
				if (Interlocked.CompareExchange(ref HasStolenTrampolines, 0, 1) == 1)
				{
					ManagedChainNode result;
					while (TrampolineStealers.TryDequeue(out result))
					{
						result.ReturnStolenTrampoline();
					}
				}
			}
		}

		internal sealed class RootManagedChainNode : ManagedChainNode
		{
			public readonly MethodSignature Sig;

			public readonly ManagedDetourSyncInfo SyncInfo = new ManagedDetourSyncInfo();

			public readonly ConcurrentQueue<Action> StolenTrampolineReturners = new ConcurrentQueue<Action>();

			private readonly DataScope<DynamicReferenceCell> syncProxyRefScope;

			public bool HasILHook;

			private ICoreDetour? syncDetour;

			private MethodInfo? sourceClone;

			private DynamicMethodDefinition? sourceCloneIl;

			public override MethodBase Entry { get; }

			public override MethodBase NextTrampoline { get; }

			public override DetourConfig? Config => null;

			public override bool DetourToFallback => true;

			public RootManagedChainNode(MethodBase method)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				Sig = MethodSignature.ForMethod(method);
				Entry = method;
				NextTrampoline = TrampolinePool.Rent(Sig);
				DataScope<DynamicReferenceCell> refScope = default(DataScope<DynamicReferenceCell>);
				ManagedDetourSyncInfo syncInfo = SyncInfo;
				FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
				((FormatInterpolatedStringHandler)(ref val))..ctor(0, 1);
				((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<MethodBase>(Entry);
				syncInfo.SyncProxy = GenerateSyncProxy(DebugFormatter.Format(ref val), Sig, delegate(MethodDefinition method, ILProcessor il)
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					DynamicReferenceCell val2 = default(DynamicReferenceCell);
					refScope = DynamicReferenceManager.EmitNewTypedReference<ManagedDetourSyncInfo>(il, SyncInfo, ref val2);
				}, delegate(MethodDefinition method, ILProcessor il, Action loadSyncInfo)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: 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_003c: Unknown result type (might be due to invalid IL or missing references)
					Enumerator<ParameterDefinition> enumerator = ((MethodReference)method).Parameters.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							ParameterDefinition current = enumerator.Current;
							il.Emit(OpCodes.Ldarg, current);
						}
					}
					finally
					{
						((IDisposable)enumerator).Dispose();
					}
					il.Emit(OpCodes.Call, ((MemberReference)method).Module.ImportReference(NextTrampoline));
				}, delegate(MethodDefinition method, ILProcessor il, Action loadSyncInfo)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					loadSyncInfo();
					Extensions.Emit(il, OpCodes.Call, (MethodBase)ManagedDetourSyncInfo_ReturnStolenTrampolines);
				});
				syncProxyRefScope = refScope;
			}

			public override void UpdateDetour(IDetourFactory factory, MethodBase fallback)
			{
				base.UpdateDetour(factory, fallback);
				Helpers.Assert(syncDetour != null, (string)null, "syncDetour is not null");
				if (!HasILHook && Next == null && ((ICoreDetourBase)syncDetour).IsApplied)
				{
					((ICoreDetourBase)syncDetour).Undo();
					((IDisposable)syncDetour).Dispose();
					syncDetour = null;
				}
				else if ((HasILHook || Next != null) && !((ICoreDetourBase)syncDetour).IsApplied)
				{
					((ICoreDetourBase)syncDetour).Apply();
				}
			}

			public void PrepareDetour(IDetourFactory factory, out MethodInfo sourceClone, out DynamicMethodDefinition? sourceCloneIl)
			{
				//IL_0035: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Expected O, but got Unknown
				//IL_00a8: Expected O, but got Unknown
				if (syncDetour == null)
				{
					CreateDetourRequest val = default(CreateDetourRequest);
					((CreateDetourRequest)(ref val))..ctor(Entry, SyncInfo.SyncProxy);
					((CreateDetourRequest)(ref val)).set_ApplyByDefault(false);
					((CreateDetourRequest)(ref val)).set_CreateSourceCloneIfNotILClone(true);
					ICoreDetour? obj = (syncDetour = factory.CreateDetour(val));
					ICoreDetourWithClone val2 = (ICoreDetourWithClone)(object)((obj is ICoreDetourWithClone) ? obj : null);
					if (val2 != null)
					{
						MethodInfo sourceMethodClone = val2.SourceMethodClone;
						if ((object)sourceMethodClone != null)
						{
							sourceClone = (this.sourceClone = sourceMethodClone);
							DynamicMethodDefinition? obj2 = this.sourceCloneIl;
							if (obj2 != null)
							{
								obj2.Dispose();
							}
							sourceCloneIl = (this.sourceCloneIl = val2.SourceMethodCloneIL);
							return;
						}
					}
					DynamicMethodDefinition obj3 = this.sourceCloneIl;
					if (obj3 == null)
					{
						DynamicMethodDefinition val3 = new DynamicMethodDefinition(Entry);
						DynamicMethodDefinition val4 = val3;
						this.sourceCloneIl = val3;
						obj3 = val4;
					}
					sourceCloneIl = obj3;
					sourceClone = this.sourceClone ?? (this.sourceClone = sourceCloneIl.Generate());
				}
				else
				{
					Helpers.Assert((object)this.sourceClone != null, (string)null, "this.sourceClone is not null");
					sourceClone = this.sourceClone;
					sourceCloneIl = this.sourceCloneIl;
				}
			}
		}

		internal sealed class ILHookEntry
		{
			public readonly SingleILHookState Hook;

			public ILContext? CurrentContext;

			public ILContext? LastContext;

			public bool IsApplied;

			public IDetourFactory Factory => Hook.Factory;

			public DetourConfig? Config => Hook.Config;

			public Manipulator Manip => Hook.Manip;

			public ILHookEntry(SingleILHookState hook)
			{
				Hook = hook;
			}

			public void Remove()
			{
				IsApplied = false;
				ILContext? lastContext = LastContext;
				if (lastContext != null)
				{
					lastContext.Dispose();
				}
			}
		}

		internal sealed class ManagedDetourState
		{
			public readonly MethodBase Source;

			public MethodInfo? SourceClone;

			public DynamicMethodDefinition? SourceCloneIl;

			public MethodInfo? EndOfChain;

			private MethodDetourInfo? info;

			private readonly DepGraph<ManagedChainNode> detourGraph = new DepGraph<ManagedChainNode>();

			internal readonly RootManagedChainNode detourList;

			private ManagedChainNode? noConfigChain;

			internal SpinLock detourLock = new SpinLock(enableThreadOwnerTracking: true);

			internal int detourChainVersion;

			internal readonly DepGraph<ILHookEntry> ilhookGraph = new DepGraph<ILHookEntry>();

			internal readonly List<ILHookEntry> noConfigIlhooks = new List<ILHookEntry>();

			internal int ilhookVersion;

			public MethodDetourInfo Info => info ?? (info = new MethodDetourInfo(this));

			public event Action<DetourInfo>? DetourApplied;

			public event Action<DetourInfo>? DetourUndone;

			public event Action<ILHookInfo>? ILHookApplied;

			public event Action<ILHookInfo>? ILHookUndone;

			public ManagedDetourState(MethodBase src)
			{
				Source = src;
				detourList = new RootManagedChainNode(src);
			}

			public void AddDetour(SingleManagedDetourState detour, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					if (detour.ManagerData != null)
					{
						throw new InvalidOperationException("Trying to add a detour which was already added");
					}
					ManagedDetourChainNode managedDetourChainNode = new ManagedDetourChainNode(detour);
					detourChainVersion++;
					DetourConfig config = managedDetourChainNode.Config;
					if (config != null)
					{
						DepGraphNode<ManagedChainNode> depGraphNode = new DepGraphNode<ManagedChainNode>(new DepListNode<ManagedChainNode>(config, managedDetourChainNode));
						detourGraph.Insert(depGraphNode);
						detour.ManagerData = depGraphNode;
					}
					else
					{
						managedDetourChainNode.Next = noConfigChain;
						noConfigChain = managedDetourChainNode;
						detour.ManagerData = managedDetourChainNode;
					}
					PrepareEndOfChain(detour.Factory);
					UpdateChain(detour.Factory, out var _);
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeDetourEvent(DetourManager.DetourApplied, this.DetourApplied, detour);
			}

			public void RemoveDetour(SingleManagedDetourState detour, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					detourChainVersion++;
					object obj = Interlocked.Exchange(ref detour.ManagerData, null);
					if (obj == null)
					{
						throw new InvalidOperationException("Trying to remove detour which wasn't added");
					}
					if (!(obj is DepGraphNode<ManagedChainNode> depGraphNode))
					{
						if (!(obj is ManagedDetourChainNode node))
						{
							throw new InvalidOperationException("Trying to remove detour with unknown manager data");
						}
						RemoveNoConfigDetour(detour, node);
					}
					else
					{
						RemoveGraphDetour(detour, depGraphNode);
						_ = (ManagedDetourChainNode)depGraphNode.ListNode.ChainNode;
					}
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeDetourEvent(DetourManager.DetourUndone, this.DetourUndone, detour);
			}

			private void RemoveGraphDetour(SingleManagedDetourState detour, DepGraphNode<ManagedChainNode> node)
			{
				detourGraph.Remove(node);
				PrepareEndOfChain(detour.Factory);
				UpdateChain(detour.Factory, out var stealTrampolines);
				if (stealTrampolines)
				{
					detourList.SyncInfo.StealTrampoline(detour.Factory, node.ListNode.ChainNode);
				}
				node.ListNode.ChainNode.Remove();
			}

			private void RemoveNoConfigDetour(SingleManagedDetourState detour, ManagedDetourChainNode node)
			{
				for (ref ManagedChainNode next = ref noConfigChain; next != null; next = ref next.Next)
				{
					if (next == node)
					{
						next = node.Next;
						node.Next = null;
						break;
					}
				}
				PrepareEndOfChain(detour.Factory);
				UpdateChain(detour.Factory, out var stealTrampolines);
				if (stealTrampolines)
				{
					detourList.SyncInfo.StealTrampoline(detour.Factory, node);
				}
				node.Remove();
			}

			public void AddILHook(SingleILHookState ilhook, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					if (ilhook.ManagerData != null)
					{
						throw new InvalidOperationException("Trying to add an IL hook which was already added");
					}
					ILHookEntry iLHookEntry = new ILHookEntry(ilhook);
					ilhookVersion++;
					DetourConfig config = iLHookEntry.Config;
					if (config != null)
					{
						DepGraphNode<ILHookEntry> depGraphNode = new DepGraphNode<ILHookEntry>(new DepListNode<ILHookEntry>(config, iLHookEntry));
						ilhookGraph.Insert(depGraphNode);
						ilhook.ManagerData = depGraphNode;
					}
					else
					{
						noConfigIlhooks.Add(iLHookEntry);
						ilhook.ManagerData = iLHookEntry;
					}
					try
					{
						PrepareEndOfChain(ilhook.Factory);
						UpdateEndOfChain();
					}
					catch
					{
						object obj = Interlocked.Exchange(ref ilhook.ManagerData, null);
						if (!(obj is DepGraphNode<ILHookEntry> node))
						{
							if (!(obj is ILHookEntry item))
							{
								throw new NotSupportedException("bad managerdata?");
							}
							noConfigIlhooks.Remove(item);
						}
						else
						{
							ilhookGraph.Remove(node);
						}
						UpdateEndOfChain();
						throw;
					}
					UpdateChain(ilhook.Factory, out var _);
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeILHookEvent(DetourManager.ILHookApplied, this.ILHookApplied, ilhook);
			}

			public void RemoveILHook(SingleILHookState ilhook, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					ilhookVersion++;
					object obj = Interlocked.Exchange(ref ilhook.ManagerData, null);
					if (obj == null)
					{
						throw new InvalidOperationException("Trying to remove IL hook which wasn't added");
					}
					if (!(obj is DepGraphNode<ILHookEntry> depGraphNode))
					{
						if (!(obj is ILHookEntry node))
						{
							throw new InvalidOperationException("Trying to remove IL hook with unknown manager data");
						}
						RemoveNoConfigILHook(ilhook, node);
					}
					else
					{
						RemoveGraphILHook(ilhook, depGraphNode);
						_ = depGraphNode.ListNode.ChainNode;
					}
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeILHookEvent(DetourManager.ILHookUndone, this.ILHookUndone, ilhook);
			}

			private void RemoveGraphILHook(SingleILHookState ilhook, DepGraphNode<ILHookEntry> node)
			{
				ilhookGraph.Remove(node);
				PrepareEndOfChain(ilhook.Factory);
				UpdateEndOfChain();
				UpdateChain(ilhook.Factory, out var _);
				CleanILContexts();
				node.ListNode.ChainNode.Remove();
			}

			private void RemoveNoConfigILHook(SingleILHookState ilhook, ILHookEntry node)
			{
				noConfigIlhooks.Remove(node);
				PrepareEndOfChain(ilhook.Factory);
				UpdateEndOfChain();
				UpdateChain(ilhook.Factory, out var _);
				CleanILContexts();
				node.Remove();
			}

			private void PrepareEndOfChain(IDetourFactory factory)
			{
				detourList.PrepareDetour(factory, out SourceClone, out SourceCloneIl);
				if ((object)EndOfChain == null)
				{
					EndOfChain = SourceClone;
				}
			}

			private void UpdateEndOfChain()
			{
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Expected O, but got Unknown
				Helpers.Assert((object)SourceClone != null, (string)null, "SourceClone is not null");
				if (noConfigIlhooks.Count == 0 && ilhookGraph.ListHead == null)
				{
					detourList.HasILHook = false;
					EndOfChain = SourceClone;
					return;
				}
				if (SourceCloneIl == null)
				{
					throw new InvalidOperationException("Target method cannot be ILHooked");
				}
				detourList.HasILHook = true;
				DynamicMethodDefinition val = new DynamicMethodDefinition(SourceCloneIl);
				try
				{
					MethodDefinition definition = val.Definition;
					for (DepListNode<ILHookEntry> depListNode = ilhookGraph.ListHead; depListNode != null; depListNode = depListNode.Next)
					{
						InvokeManipulator(depListNode.ChainNode, definition);
					}
					foreach (ILHookEntry noConfigIlhook in noConfigIlhooks)
					{
						InvokeManipulator(noConfigIlhook, definition);
					}
					MethodInfo methodInfo = val.Generate();
					PlatformTriple.Current.Compile((MethodBase)methodInfo);
					Thread.MemoryBarrier();
					EndOfChain = methodInfo;
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}

			private static void InvokeManipulator(ILHookEntry entry, MethodDefinition def)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Expected O, but got Unknown
				entry.IsApplied = true;
				ILContext val = (entry.CurrentContext = new ILContext(def));
				val.Invoke(entry.Manip);
				if (val.IsReadOnly)
				{
					val.Dispose();
				}
				else
				{
					val.MakeReadOnly();
				}
			}

			private void CleanILContexts()
			{
				for (DepListNode<ILHookEntry> depListNode = ilhookGraph.ListHead; depListNode != null; depListNode = depListNode.Next)
				{
					CleanContext(depListNode.ChainNode);
				}
				foreach (ILHookEntry noConfigIlhook in noConfigIlhooks)
				{
					CleanContext(noConfigIlhook);
				}
				static void CleanContext(ILHookEntry entry)
				{
					if (entry.CurrentContext != entry.LastContext)
					{
						ILContext? lastContext = entry.LastContext;
						entry.LastContext = entry.CurrentContext;
						if (lastContext != null)
						{
							lastContext.Dispose();
						}
					}
				}
			}

			private void UpdateChain(IDetourFactory updatingFactory, out bool stealTrampolines)
			{
				Helpers.Assert((object)SourceClone != null, (string)null, "SourceClone is not null");
				Helpers.Assert((object)EndOfChain != null, (string)null, "EndOfChain is not null");
				DepListNode<ManagedChainNode> depListNode = detourGraph.ListHead;
				ManagedChainNode managedChainNode = null;
				ref ManagedChainNode reference = ref managedChainNode;
				while (depListNode != null)
				{
					reference = depListNode.ChainNode;
					reference = ref reference.Next;
					reference = null;
					depListNode = depListNode.Next;
				}
				reference = noConfigChain;
				detourList.Next = managedChainNode;
				Volatile.Write(ref detourList.SyncInfo.UpdatingThread, EnvironmentEx.CurrentManagedThreadId);
				detourList.SyncInfo.WaitForNoActiveCalls(out stealTrampolines);
				try
				{
					for (managedChainNode = detourList; managedChainNode != null; managedChainNode = managedChainNode.Next)
					{
						IDetourFactory val = (managedChainNode.Next as ManagedDetourChainNode)?.Factory;
						if (val == null)
						{
							val = (managedChainNode as ManagedDetourChainNode)?.Factory;
						}
						if (val == null)
						{
							val = updatingFactory;
						}
						managedChainNode.UpdateDetour(val, EndOfChain);
					}
				}
				finally
				{
					Volatile.Write(ref detourList.SyncInfo.UpdatingThread, -1);
				}
			}

			private void InvokeDetourEvent(Action<DetourInfo>? evt1, Action<DetourInfo>? evt2, SingleManagedDetourState node)
			{
				if (evt1 != null || evt2 != null)
				{
					DetourInfo detourInfo = Info.GetDetourInfo(node);
					evt1?.Invoke(detourInfo);
					evt2?.Invoke(detourInfo);
				}
			}

			private void InvokeILHookEvent(Action<ILHookInfo>? evt1, Action<ILHookInfo>? evt2, SingleILHookState entry)
			{
				if (evt1 != null || evt2 != null)
				{
					ILHookInfo iLHookInfo = Info.GetILHookInfo(entry);
					evt1?.Invoke(iLHookInfo);
					evt2?.Invoke(iLHookInfo);
				}
			}
		}

		internal sealed class SingleManagedDetourState : SingleDetourStateBase
		{
			public readonly MethodInfo PublicTarget;

			public readonly MethodInfo InvokeTarget;

			public readonly IDetourTrampoline NextTrampoline;

			public DetourInfo? DetourInfo;

			public SingleManagedDetourState(IDetour dt)
				: base(dt)
			{
				PublicTarget = dt.PublicTarget;
				InvokeTarget = dt.InvokeTarget;
				NextTrampoline = dt.NextTrampoline;
			}
		}

		internal sealed class SingleILHookState : SingleDetourStateBase
		{
			public readonly Manipulator Manip;

			public ILHookInfo? HookInfo;

			public SingleILHookState(IILHook hk)
				: base(hk)
			{
				Manip = hk.Manip;
			}
		}

		internal abstract class NativeChainNode
		{
			public NativeChainNode? Next;

			public abstract Delegate EntryDelegate { get; }

			public abstract void UpdateChain(IDetourFactory factory, Delegate? fallback);

			public virtual void Remove()
			{
			}
		}

		internal sealed class NativeDetourChainNode : NativeChainNode
		{
			public readonly SingleNativeDetourState Detour;

			public readonly ChainDelegateState? ChainState;

			public DetourConfig? Config => Detour.Config;

			public override Delegate EntryDelegate => ChainState?.GetDelegate() ?? Detour.Invoker;

			public NativeDetourChainNode(SingleNativeDetourState detour)
			{
				Detour = detour;
				if (detour.HasOrigParam)
				{
					ChainState = new ChainDelegateState(detour.Invoker, detour.NativeDelegateType);
				}
			}

			public override void UpdateChain(IDetourFactory factory, Delegate? fallback)
			{
				Delegate @delegate = Next?.EntryDelegate ?? fallback;
				@delegate = (((object)@delegate != null) ? Extensions.CastDelegate(@delegate, Detour.NativeDelegateType) : null);
				if (ChainState != null)
				{
					ChainState.Next = @delegate;
				}
			}

			public override void Remove()
			{
				if (ChainState != null)
				{
					ChainState.Remove();
				}
			}
		}

		internal sealed class NativeDetourSyncInfo : DetourSyncInfo
		{
			public Delegate? FirstDelegate;
		}

		internal sealed class RootNativeDetourChainNode : NativeChainNode
		{
			public readonly NativeDetourSyncInfo SyncInfo;

			public Type EntryType;

			public Delegate SyncProxyDelegate;

			public IntPtr SyncProxyNativeEntry;

			public readonly IntPtr Function;

			private Delegate? origDelegate;

			private ICoreNativeDetour? nativeDetour;

			private IntPtr lastNativeEntry;

			public override Delegate EntryDelegate
			{
				get
				{
					throw new InvalidOperationException();
				}
			}

			public Delegate? OrigDelegate
			{
				get
				{
					Delegate @delegate = origDelegate;
					if ((object)@delegate != null)
					{
						return @delegate;
					}
					ICoreNativeDetour val = nativeDetour;
					if (val == null)
					{
						return null;
					}
					if (!val.HasOrigEntrypoint)
					{
						return null;
					}
					return origDelegate = Marshal.GetDelegateForFunctionPointer(val.OrigEntrypoint, EntryType);
				}
			}

			public RootNativeDetourChainNode(IntPtr function)
			{
				SyncInfo = new NativeDetourSyncInfo();
				Function = function;
			}

			public void MaybeSetEntryType(Type type)
			{
				if ((object)EntryType != null)
				{
					return;
				}
				MethodInfo delInvoke = type.GetMethod("Invoke");
				FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
				((FormatInterpolatedStringHandler)(ref val))..ctor(16, 1);
				((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("native->managed ");
				((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<Type>(type);
				MethodInfo methodInfo = GenerateSyncProxy(DebugFormatter.Format(ref val), MethodSignature.ForMethod((MethodBase)delInvoke, true), delegate(MethodDefinition method, ILProcessor il)
				{
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Expected O, but got Unknown
					//IL_0027: Unknown result type (might be due to invalid IL or missing references)
					((MethodReference)method).Parameters.Insert(0, new ParameterDefinition(((MemberReference)method).Module.ImportReference(typeof(NativeDetourSyncInfo))));
					il.Emit(OpCodes.Ldarg_0);
				}, delegate(MethodDefinition method, ILProcessor il, Action loadSyncInfo)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0049: Unknown result type (might be due to invalid IL or missing references)
					il.Emit(OpCodes.Ldarg_0);
					il.Emit(OpCodes.Ldfld, ((MemberReference)method).Module.ImportReference(NativeDetourSyncInfo_FirstDelegate));
					for (int i = 1; i < ((MethodReference)method).Parameters.Count; i++)
					{
						il.Emit(OpCodes.Ldarg, i);
					}
					il.Emit(OpCodes.Callvirt, ((MemberReference)method).Module.ImportReference((MethodBase)delInvoke));
				});
				Delegate @delegate = methodInfo.CreateDelegate(type, SyncInfo);
				SyncProxyNativeEntry = Marshal.GetFunctionPointerForDelegate(@delegate);
				EntryType = type;
				SyncInfo.SyncProxy = methodInfo;
				SyncProxyDelegate = @delegate;
			}

			public override void UpdateChain(IDetourFactory factory, Delegate? fallback)
			{
				if (nativeDetour == null || lastNativeEntry != SyncProxyNativeEntry)
				{
					((IDisposable)nativeDetour)?.Dispose();
					origDelegate = null;
					nativeDetour = DetourFactory.CreateNativeDetour(factory, Function, SyncProxyNativeEntry, false);
					lastNativeEntry = SyncProxyNativeEntry;
				}
				Delegate @delegate = Next?.EntryDelegate;
				@delegate = (((object)@delegate != null) ? Extensions.CastDelegate(@delegate, EntryType) : null);
				if ((object)@delegate != null && !((ICoreDetourBase)nativeDetour).IsApplied)
				{
					((ICoreDetourBase)nativeDetour).Apply();
					origDelegate = null;
				}
				else if ((object)@delegate == null && ((ICoreDetourBase)nativeDetour).IsApplied)
				{
					((ICoreDetourBase)nativeDetour).Undo();
					origDelegate = null;
				}
				SyncInfo.FirstDelegate = @delegate;
			}
		}

		internal sealed class ChainDelegateState
		{
			public readonly Delegate Orig;

			public readonly Type NextType;

			public Delegate? Next;

			private static readonly FieldInfo ChainDelegateState_Orig = typeof(ChainDelegateState).GetField("Orig");

			private static readonly FieldInfo ChainDelegateState_Next = typeof(ChainDelegateState).GetField("Next");

			private static readonly ConditionalWeakTable<Type, MethodInfo> chainMethodCache = new ConditionalWeakTable<Type, MethodInfo>();

			private Delegate? selfDelegate;

			public ChainDelegateState(Delegate orig, Type nextType)
			{
				Orig = orig;
				NextType = nextType;
			}

			private static MethodInfo GenerateChainMethod(Type origDelType, Type nextDelType)
			{
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Expected O, but got Unknown
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				MethodInfo method = origDelType.GetMethod("Invoke");
				MethodInfo method2 = nextDelType.GetMethod("Invoke");
				Helpers.Assert((object)method != null && (object)method2 != null, (string)null, "origInvoke is not null && nextInvoke is not null");
				MethodSignature obj = MethodSignature.ForMethod((MethodBase)method2, true);
				FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
				((FormatInterpolatedStringHandler)(ref val))..ctor(7, 1);
				((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("Chain<");
				((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<Type>(nextDelType);
				((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(">");
				DynamicMethodDefinition val2 = obj.CreateDmd(DebugFormatter.Format(ref val));
				try
				{
					Helpers.Assert(val2.Module != null && val2.Definition != null, (string)null, "dmd.Module is not null && dmd.Definition is not null");
					ModuleDefinition module = val2.Module;
					((MethodReference)val2.Definition).Parameters.Insert(0, new ParameterDefinition(module.ImportReference(typeof(ChainDelegateState))));
					ILProcessor iLProcessor = val2.GetILProcessor();
					iLProcessor.Emit(OpCodes.Ldarg_0);
					iLProcessor.Emit(OpCodes.Ldfld, module.ImportReference(ChainDelegateState_Orig));
					iLProcessor.Emit(OpCodes.Ldarg_0);
					iLProcessor.Emit(OpCodes.Ldfld, module.ImportReference(ChainDelegateState_Next));
					for (int i = 1; i < ((MethodReference)val2.Definition).Parameters.Count; i++)
					{
						iLProcessor.Emit(OpCodes.Ldarg, i);
					}
					iLProcessor.Emit(OpCodes.Tail);
					iLProcessor.Emit(OpCodes.Callvirt, module.ImportReference((MethodBase)method));
					iLProcessor.Emit(OpCodes.Ret);
					return val2.Generate();
				}
				finally
				{
					((IDisposable)val2)?.Dispose();
				}
			}

			private static MethodInfo GetChainMethod(Type origDelType, Type nextDelType)
			{
				Type nextDelType2 = nextDelType;
				return chainMethodCache.GetValue(origDelType, (Type orig) => GenerateChainMethod(orig, nextDelType2));
			}

			public Delegate GetDelegate()
			{
				return selfDelegate ?? (selfDelegate = GetChainMethod(Orig.GetType(), NextType).CreateDelegate(NextType, this));
			}

			public void Remove()
			{
				MethodInfo method = NextType.GetMethod("Invoke");
				Helpers.Assert((object)method != null, (string)null, "nextInvoke is not null");
				Next = GetRemovedStub(MethodSignature.ForMethod((MethodBase)method)).CreateDelegate(NextType, null);
			}
		}

		internal sealed class NativeDetourState
		{
			public readonly IntPtr Function;

			internal RootNativeDetourChainNode detourList;

			private readonly DepGraph<NativeChainNode> detourGraph = new DepGraph<NativeChainNode>();

			private NativeChainNode? noConfigChain;

			internal SpinLock detourLock = new SpinLock(enableThreadOwnerTracking: true);

			internal int detourChainVersion;

			private FunctionDetourInfo? info;

			public FunctionDetourInfo Info => info ?? (info = new FunctionDetourInfo(this));

			public event Action<NativeDetourInfo>? NativeDetourApplied;

			public event Action<NativeDetourInfo>? NativeDetourUndone;

			public NativeDetourState(IntPtr function)
			{
				Function = function;
				detourList = new RootNativeDetourChainNode(function);
			}

			public void AddDetour(SingleNativeDetourState detour, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					if (detour.ManagerData != null)
					{
						throw new InvalidOperationException("Trying to add a detour which was already added");
					}
					NativeDetourChainNode nativeDetourChainNode = new NativeDetourChainNode(detour);
					detourChainVersion++;
					DetourConfig config = nativeDetourChainNode.Config;
					if (config != null)
					{
						DepGraphNode<NativeChainNode> depGraphNode = new DepGraphNode<NativeChainNode>(new DepListNode<NativeChainNode>(config, nativeDetourChainNode));
						detourGraph.Insert(depGraphNode);
						detour.ManagerData = depGraphNode;
					}
					else
					{
						nativeDetourChainNode.Next = noConfigChain;
						noConfigChain = nativeDetourChainNode;
						detour.ManagerData = nativeDetourChainNode;
					}
					detourList.MaybeSetEntryType(detour.NativeDelegateType);
					UpdateChain(detour.Factory);
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeDetourEvent(DetourManager.NativeDetourApplied, this.NativeDetourApplied, detour);
			}

			public void RemoveDetour(SingleNativeDetourState detour, bool takeLock = true)
			{
				bool lockTaken = false;
				try
				{
					if (takeLock)
					{
						detourLock.Enter(ref lockTaken);
					}
					detourChainVersion++;
					object obj = Interlocked.Exchange(ref detour.ManagerData, null);
					if (obj == null)
					{
						throw new InvalidOperationException("Trying to remove detour which wasn't added");
					}
					if (!(obj is DepGraphNode<NativeChainNode> depGraphNode))
					{
						if (!(obj is NativeDetourChainNode node))
						{
							throw new InvalidOperationException("Trying to remove detour with unknown manager data");
						}
						RemoveNoConfigDetour(detour, node);
					}
					else
					{
						RemoveGraphDetour(detour, depGraphNode);
						_ = (NativeDetourChainNode)depGraphNode.ListNode.ChainNode;
					}
				}
				finally
				{
					if (lockTaken)
					{
						detourLock.Exit(useMemoryBarrier: true);
					}
				}
				InvokeDetourEvent(DetourManager.NativeDetourUndone, this.NativeDetourUndone, detour);
			}

			private void RemoveGraphDetour(SingleNativeDetourState detour, DepGraphNode<NativeChainNode> node)
			{
				detourGraph.Remove(node);
				UpdateChain(detour.Factory);
				node.ListNode.ChainNode.Remove();
			}

			private void RemoveNoConfigDetour(SingleNativeDetourState detour, NativeDetourChainNode node)
			{
				for (ref NativeChainNode next = ref noConfigChain; next != null; next = ref next.Next)
				{
					if (next == node)
					{
						next = node.Next;
						node.Next = null;
						break;
					}
				}
				UpdateChain(detour.Factory);
				node.Remove();
			}

			private void UpdateChain(IDetourFactory updatingFactory)
			{
				DepListNode<NativeChainNode> depListNode = detourGraph.ListHead;
				NativeChainNode nativeChainNode = null;
				ref NativeChainNode reference = ref nativeChainNode;
				while (depListNode != null)
				{
					reference = depListNode.ChainNode;
					reference = ref reference.Next;
					reference = null;
					depListNode = depListNode.Next;
				}
				reference = noConfigChain;
				detourList.Next = nativeChainNode;
				Volatile.Write(ref detourList.SyncInfo.UpdatingThread, EnvironmentEx.CurrentManagedThreadId);
				detourList.SyncInfo.WaitForNoActiveCalls(out var _);
				try
				{
					for (nativeChainNode = detourList; nativeChainNode != null; nativeChainNode = nativeChainNode.Next)
					{
						IDetourFactory val = (nativeChainNode.Next as NativeDetourChainNode)?.Detour.Factory;
						if (val == null)
						{
							val = (nativeChainNode as NativeDetourChainNode)?.Detour.Factory;
						}
						if (val == null)
						{
							val = updatingFactory;
						}
						nativeChainNode.UpdateChain(val, detourList.OrigDelegate);
					}
				}
				finally
				{
					Volatile.Write(ref detourList.SyncInfo.UpdatingThread, -1);
				}
			}

			private void InvokeDetourEvent(Action<NativeDetourInfo>? evt1, Action<NativeDetourInfo>? evt2, SingleNativeDetourState node)
			{
				if (evt1 != null || evt2 != null)
				{
					NativeDetourInfo detourInfo = Info.GetDetourInfo(node);
					evt1?.Invoke(detourInfo);
					evt2?.Invoke(detourInfo);
				}
			}
		}

		internal sealed class SingleNativeDetourState : SingleDetourStateBase
		{
			public readonly IntPtr Function;

			public readonly Type NativeDelegateType;

			public readonly Delegate Invoker;

			public readonly bool HasOrigParam;

			public NativeDetourInfo? DetourInfo;

			public SingleNativeDetourState(INativeDetour detour)
				: base(detour)
			{
				Function = detour.Function;
				NativeDelegateType = detour.NativeDelegateType;
				Invoker = detour.Invoker;
				HasOrigParam = detour.HasOrigParam;
			}
		}

		internal sealed class DepListNode<TNode>
		{
			public readonly DetourConfig Config;

			public readonly TNode ChainNode;

			public DepListNode<TNode>? Next;

			public DepListNode(DetourConfig config, TNode chainNode)
			{
				Config = config;
				ChainNode = chainNode;
			}
		}

		internal sealed class DepGraphNode<TNode>
		{
			public readonly DepListNode<TNode> ListNode;

			public readonly List<DepGraphNode<TNode>> BeforeThis = new List<DepGraphNode<TNode>>();

			public bool Visiting;

			public bool Visited;

			public DetourConfig Config => ListNode.Config;

			public DepGraphNode(DepListNode<TNode> listNode)
			{
				ListNode = listNode;
			}
		}

		internal sealed class DepGraph<TNode>
		{
			private readonly List<DepGraphNode<TNode>> nodes = new List<DepGraphNode<TNode>>();

			public DepListNode<TNode>? ListHead;

			private readonly DepListNode<TNode> dummyListNode = new DepListNode<TNode>(null, default(TNode));

			private static void PrioInsert(List<DepGraphNode<TNode>> list, DepGraphNode<TNode> node)
			{
				int? priority = node.Config.Priority;
				if (priority.HasValue)
				{
					int valueOrDefault = priority.GetValueOrDefault();
					int i = -1;
					for (int j = 0; j < list.Count; j++)
					{
						priority = list[j].Config.Priority;
						if (priority.HasValue)
						{
							int valueOrDefault2 = priority.GetValueOrDefault();
							if (valueOrDefault >= valueOrDefault2)
							{
								i = j;
								break;
							}
							continue;
						}
						i = j;
						break;
					}
					if (i < 0)
					{
						i = list.Count;
					}
					else
					{
						for (; i < list.Count; i++)
						{
							DepGraphNode<TNode> depGraphNode = list[i];
							if (depGraphNode.Config.Priority != node.Config.Priority || depGraphNode.Config.SubPriority <= node.Config.SubPriority)
							{
								break;
							}
						}
					}
					list.Insert(i, node);
				}
				else
				{
					list.Add(node);
				}
			}

			public void Insert(DepGraphNode<TNode> node)
			{
				node.ListNode.Next = null;
				node.BeforeThis.Clear();
				node.Visited = false;
				node.Visiting = false;
				int i = -1;
				for (int j = 0; j < nodes.Count; j++)
				{
					DepGraphNode<TNode> depGraphNode = nodes[j];
					depGraphNode.Visited = false;
					if (i < 0)
					{
						int? priority = node.Config.Priority;
						if (priority.HasValue)
						{
							int valueOrDefault = priority.GetValueOrDefault();
							priority = depGraphNode.Config.Priority;
							if (priority.HasValue)
							{
								int valueOrDefault2 = priority.GetValueOrDefault();
								if (valueOrDefault >= valueOrDefault2)
								{
									i = j;
								}
							}
							else
							{
								i = j;
							}
						}
					}
					bool flag = false;
					bool flag2 = false;
					if (node.Config.Before.Contains(depGraphNode.Config.Id))
					{
						PrioInsert(depGraphNode.BeforeThis, node);
						flag = true;
					}
					MMDbgLog.DebugLogWarningStringHandler message;
					bool isEnabled;
					if (node.Config.After.Contains(depGraphNode.Config.Id))
					{
						if (flag)
						{
							message = new MMDbgLog.DebugLogWarningStringHandler(53, 2, out isEnabled);
							if (isEnabled)
							{
								message.AppendLiteral("Detour '");
								message.AppendFormatted(node.Config.Id);
								message.AppendLiteral("' is marked as being both before and after '");
								message.AppendFormatted(depGraphNode.Config.Id);
								message.AppendLiteral("'");
							}
							MMDbgLog.Warning(ref message);
						}
						else
						{
							PrioInsert(node.BeforeThis, depGraphNode);
							flag2 = true;
						}
					}
					if (depGraphNode.Config.Before.Contains(node.Config.Id))
					{
						if (flag)
						{
							message = new MMDbgLog.DebugLogWarningStringHandler(53, 2, out isEnabled);
							if (isEnabled)
							{
								message.AppendLiteral("Detour '");
								message.AppendFormatted(node.Config.Id);
								message.AppendLiteral("' is marked as being both before and after '");
								message.AppendFormatted(depGraphNode.Config.Id);
								message.AppendLiteral("'");
							}
							MMDbgLog.Warning(ref message);
						}
						else
						{
							PrioInsert(node.BeforeThis, depGraphNode);
							flag2 = true;
						}
					}
					if (!depGraphNode.Config.After.Contains(node.Config.Id))
					{
						continue;
					}
					if (flag2)
					{
						message = new MMDbgLog.DebugLogWarningStringHandler(53, 2, out isEnabled);
						if (isEnabled)
						{
							message.AppendLiteral("Detour '");
							message.AppendFormatted(node.Config.Id);
							message.AppendLiteral("' is marked as being both before and after '");
							message.AppendFormatted(depGraphNode.Config.Id);
							message.AppendLiteral("'");
						}
						MMDbgLog.Warning(ref message);
					}
					else
					{
						PrioInsert(depGraphNode.BeforeThis, node);
					}
				}
				if (i < 0)
				{
					i = nodes.Count;
				}
				else
				{
					for (; i < nodes.Count; i++)
					{
						DepGraphNode<TNode> depGraphNode2 = nodes[i];
						if (depGraphNode2.Config.Priority != node.Config.Priority || depGraphNode2.Config.SubPriority <= node.Config.SubPriority)
						{
							break;
						}
					}
				}
				nodes.Insert(i, node);
				UpdateList();
			}

			public void Remove(DepGraphNode<TNode> node)
			{
				nodes.Remove(node);
				foreach (DepGraphNode<TNode> node2 in nodes)
				{
					node2.BeforeThis.Remove(node);
					node2.Visited = false;
				}
				node.BeforeThis.Clear();
				node.Visited = false;
				node.Visiting = false;
				node.ListNode.Next = null;
				UpdateList();
			}

			private void UpdateList()
			{
				DepListNode<TNode> depListNode = dummyListNode;
				depListNode.Next = null;
				DepListNode<TNode> nextHolder = depListNode;
				foreach (DepGraphNode<TNode> node in nodes)
				{
					InsertListNode(ref nextHolder, node);
				}
				ListHead = depListNode.Next;
			}

			private static void InsertListNode(ref DepListNode<TNode> nextHolder, DepGraphNode<TNode> node)
			{
				if (node.Visiting)
				{
					throw new InvalidOperationException("Cycle detected");
				}
				if (node.Visited)
				{
					return;
				}
				node.Visiting = true;
				try
				{
					DepListNode<TNode> listNode = node.ListNode;
					listNode.Next = null;
					foreach (DepGraphNode<TNode> beforeThi in node.BeforeThis)
					{
						InsertListNode(ref nextHolder, beforeThi);
					}
					nextHolder.Next = listNode;
					nextHolder = listNode;
					node.Visited = true;
				}
				finally
				{
					node.Visiting = false;
				}
			}
		}

		internal class DetourSyncInfo
		{
			public MethodBase? SyncProxy;

			public int ActiveCalls;

			public int UpdatingThread;

			public bool WaitForChainUpdate()
			{
				if (Volatile.Read(ref ActiveCalls) > 1 && DetermineThreadCallDepth() > 1)
				{
					return true;
				}
				Interlocked.Decrement(ref ActiveCalls);
				if (UpdatingThread == EnvironmentEx.CurrentManagedThreadId)
				{
					throw new InvalidOperationException("Method's detour chain is being updated by the current thread!");
				}
				SpinWait spinWait = default(SpinWait);
				while (Volatile.Read(ref UpdatingThread) != -1)
				{
					spinWait.SpinOnce();
				}
				return false;
			}

			public void WaitForNoActiveCalls(out bool hasActiveCallsFromThread)
			{
				int num = DetermineThreadCallDepth();
				hasActiveCallsFromThread = num > 0;
				SpinWait spinWait = default(SpinWait);
				while (Volatile.Read(ref ActiveCalls) > num)
				{
					spinWait.SpinOnce();
				}
			}

			private int DetermineThreadCallDepth()
			{
				if (Volatile.Read(ref ActiveCalls) <= 0 || SyncProxy == null)
				{
					return 0;
				}
				StackFrame[] frames = new StackTrace().GetFrames();
				MethodBase syncProxyIdentif = PlatformTriple.Current.GetIdentifiable(SyncProxy);
				return frames.Count(delegate(StackFrame f)
				{
					MethodBase method = f.GetMethod();
					return (object)method != null && PlatformTriple.Current.GetIdentifiable(method) == syncProxyIdentif;
				});
			}
		}

		internal abstract class SingleDetourStateBase
		{
			public readonly IDetourFactory Factory;

			public readonly DetourConfig? Config;

			public object? ManagerData;

			public bool IsValid;

			public bool IsApplied => Volatile.Read(ref ManagerData) != null;

			protected SingleDetourStateBase(IDetourBase detour)
			{
				Factory = detour.Factory;
				Config = detour.Config;
				ManagerData = null;
				IsValid = true;
			}
		}

		private static readonly MethodInfo ManagedDetourSyncInfo_ReturnStolenTrampolines = typeof(ManagedDetourSyncInfo).GetMethod("ReturnStolenTrampolines");

		private static readonly ConcurrentDictionary<MethodBase, ManagedDetourState> detourStates = new ConcurrentDictionary<MethodBase, ManagedDetourState>();

		private static readonly FieldInfo NativeDetourSyncInfo_FirstDelegate = typeof(NativeDetourSyncInfo).GetField("FirstDelegate");

		private static readonly ConcurrentDictionary<IntPtr, NativeDetourState> nativeDetourStates = new ConcurrentDictionary<IntPtr, NativeDetourState>();

		private static readonly FieldInfo DetourSyncInfo_ActiveCalls = typeof(DetourSyncInfo).GetField("ActiveCalls");

		private static readonly FieldInfo DetourSyncInfo_UpdatingThread = typeof(DetourSyncInfo).GetField("UpdatingThread");

		private static readonly MethodInfo DetourSyncInfo_WaitForChainUpdate = typeof(DetourSyncInfo).GetMethod("WaitForChainUpdate");

		private static readonly MethodInfo Interlocked_Increment = typeof(Interlocked).GetMethod("Increment", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(int).MakeByRefType() }, null);

		private static readonly MethodInfo Interlocked_Decrement = typeof(Interlocked).GetMethod("Decrement", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(int).MakeByRefType() }, null);

		private static readonly ConditionalWeakTable<MethodSignature, MethodInfo> removedStubCache = new ConditionalWeakTable<MethodSignature, MethodInfo>();

		public static event Action<DetourInfo>? DetourApplied;

		public static event Action<DetourInfo>? DetourUndone;

		public static event Action<ILHookInfo>? ILHookApplied;

		public static event Action<ILHookInfo>? ILHookUndone;

		public static event Action<NativeDetourInfo>? NativeDetourApplied;

		public static event Action<NativeDetourInfo>? NativeDetourUndone;

		internal static ManagedDetourState GetDetourState(MethodBase method)
		{
			method = PlatformTriple.Current.GetIdentifiable(method);
			return detourStates.GetOrAdd(method, (MethodBase m) => new ManagedDetourState(m));
		}

		public static MethodDetourInfo GetDetourInfo(MethodBase method)
		{
			return GetDetourState(method).Info;
		}

		internal static NativeDetourState GetNativeDetourState(IntPtr function)
		{
			return nativeDetourStates.GetOrAdd(function, (IntPtr f) => new NativeDetourState(f));
		}

		public static FunctionDetourInfo GetNativeDetourInfo(IntPtr function)
		{
			return GetNativeDetourState(function).Info;
		}

		private static MethodInfo GenerateSyncProxy(string innerName, MethodSignature Sig, Action<MethodDefinition, ILProcessor> emitLoadSyncInfo, Action<MethodDefinition, ILProcessor, Action> emitInvoke, Action<MethodDefinition, ILProcessor, Action>? emitLastCallReturn = null)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
			((FormatInterpolatedStringHandler)(ref val))..ctor(11, 1);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("SyncProxy<");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted(innerName);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(">");
			DynamicMethodDefinition val2 = Sig.CreateDmd(DebugFormatter.Format(ref val));
			try
			{
				ILProcessor il = val2.GetILProcessor();
				MethodDefinition definition = val2.Definition;
				ModuleDefinition module = val2.Module;
				TypeReference val3 = module.ImportReference(typeof(DetourSyncInfo));
				VariableDefinition syncInfoVar = new VariableDefinition(val3);
				il.Body.Variables.Add(syncInfoVar);
				emitLoadSyncInfo(definition, il);
				il.Emit(OpCodes.Stloc, syncInfoVar);
				Instruction val4 = il.Create(OpCodes.Nop);
				il.Append(val4);
				il.Emit(OpCodes.Ldloc, syncInfoVar);
				il.Emit(OpCodes.Ldflda, module.ImportReference(DetourSyncInfo_ActiveCalls));
				il.Emit(OpCodes.Call, module.ImportReference((MethodBase)Interlocked_Increment));
				il.Emit(OpCodes.Pop);
				il.Emit(OpCodes.Ldloc, syncInfoVar);
				il.Emit(OpCodes.Volatile);
				il.Emit(OpCodes.Ldfld, module.ImportReference(DetourSyncInfo_UpdatingThread));
				il.Emit(OpCodes.Ldc_I4_M1);
				Instruction val5 = il.Create(OpCodes.Nop);
				il.Emit(OpCodes.Beq_S, val5);
				il.Emit(OpCodes.Ldloc, syncInfoVar);
				il.Emit(OpCodes.Call, module.ImportReference((MethodBase)DetourSyncInfo_WaitForChainUpdate));
				il.Emit(OpCodes.Brtrue_S, val5);
				il.Emit(OpCodes.Br_S, val4);
				il.Append(val5);
				VariableDefinition val6 = null;
				if (Sig.ReturnType != typeof(void))
				{
					val6 = new VariableDefinition(((MethodReference)definition).ReturnType);
					il.Body.Variables.Add(val6);
				}
				ExceptionHandler val7 = new ExceptionHandler((ExceptionHandlerType)2);
				il.Body.ExceptionHandlers.Add(val7);
				Instruction val8 = il.Create(OpCodes.Nop);
				il.Append(val8);
				val7.TryStart = val8;
				emitInvoke(definition, il, delegate
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					il.Emit(OpCodes.Ldloc, syncInfoVar);
				});
				if (val6 != null)
				{
					il.Emit(OpCodes.Stloc, val6);
				}
				Instruction val9 = il.Create(OpCodes.Nop);
				il.Emit(OpCodes.Leave_S, val9);
				Instruction val10 = il.Create(OpCodes.Ldloc, syncInfoVar);
				Instruction tryEnd = (val7.HandlerStart = val10);
				val7.TryEnd = tryEnd;
				il.Append(val10);
				il.Emit(OpCodes.Ldflda, module.ImportReference(DetourSyncInfo_ActiveCalls));
				il.Emit(OpCodes.Call, module.ImportReference((MethodBase)Interlocked_Decrement));
				if (emitLastCallReturn == null)
				{
					il.Emit(OpCodes.Pop);
				}
				else
				{
					Instruction val12 = il.Create(OpCodes.Nop);
					il.Emit(OpCodes.Brtrue_S, val12);
					emitLastCallReturn(definition, il, delegate
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						il.Emit(OpCodes.Ldloc, syncInfoVar);
					});
					il.Append(val12);
				}
				il.Emit(OpCodes.Endfinally);
				val7.HandlerEnd = val9;
				il.Append(val9);
				if (val6 != null)
				{
					il.Emit(OpCodes.Ldloc, val6);
				}
				il.Emit(OpCodes.Ret);
				return val2.Generate();
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}

		private static MethodInfo GenerateRemovedStub(MethodSignature trampolineSig)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			FormatInterpolatedStringHandler val = default(FormatInterpolatedStringHandler);
			((FormatInterpolatedStringHandler)(ref val))..ctor(13, 1);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral("RemovedStub<");
			((FormatInterpolatedStringHandler)(ref val)).AppendFormatted<MethodSignature>(trampolineSig);
			((FormatInterpolatedStringHandler)(ref val)).AppendLiteral(">");
			DynamicMethodDefinition val2 = trampolineSig.CreateDmd(DebugFormatter.Format(ref val));
			try
			{
				Helpers.Assert(val2.Module != null && val2.Definition != null, (string)null, "dmd.Module is not null && dmd.Definition is not null");
				ModuleDefinition module = val2.Module;
				ILProcessor iLProcessor = val2.GetILProcessor();
				iLProcessor.Emit(OpCodes.Ldstr, "Detour has been removed");
				iLProcessor.Emit(OpCodes.Newobj, module.ImportReference((MethodBase)typeof(InvalidOperationException).GetConstructor(new Type[1] { typeof(string) })));
				iLProcessor.Emit(OpCodes.Throw);
				return val2.Generate();
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}

		private static MethodInfo GetRemovedStub(MethodSignature trampolineSig)
		{
			MethodSignature trampolineSig2 = trampolineSig;
			return removedStubCache.GetValue(trampolineSig2, (MethodSignature orig) => GenerateRemovedStub(trampolineSig2));
		}
	}
	internal static class Extensions
	{
		public static MethodInfo CreateILCopy(this MethodBase method)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			DynamicMethodDefinition val = new DynamicMethodDefinition(method);
			try
			{
				return val.Generate();
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	public sealed class Hook : IDetour, IDetourBase, IDisposable
	{
		private sealed class TrampolineData : IDetourTrampoline, IDisposable
		{
			private readonly MethodInfo trampoline;

			private bool alive;

			private bool hasOwnership;

			public MethodBase TrampolineMethod => trampoline;

			public TrampolineData(MethodSignature sig)
			{
				trampoline = TrampolinePool.Rent(sig);
				alive = (hasOwnership = true);
			}

			public void Dispose()
			{
				lock (this)
				{
					if (alive)
					{
						alive = false;
						if (hasOwnership)
						{
							TrampolinePool.Return(trampoline);
						}
					}
				}
			}

			public void StealTrampolineOwnership()
			{
				lock (this)
				{
					Helpers.Assert(alive && hasOwnership, (string)null, "alive && hasOwnership");
					hasOwnership = false;
				}
			}

			public void ReturnTrampolineOwnership()
			{
				lock (this)
				{
					Helpers.Assert(!hasOwnership, (string)null, "!hasOwnership");
					if (!alive)
					{
						TrampolinePool.Return(trampoline);
					}
					else
					{
						hasOwnership = true;
					}
				}
			}
		}

		private sealed class HookData
		{
			public readonly object? Target;

			public readonly Delegate? InvokeNext;

			public HookData(object? target, Delegate? invokeNext)
			{
				Target = target;
				InvokeNext = invokeNext;
			}
		}

		private const bool ApplyByDefault = true;

		private readonly IDetourFactory factory;

		private readonly MethodInfo realTarget;

		private readonly TrampolineData trampoline;

		private readonly DetourManager.ManagedDetourState state;

		private readonly DetourManager.SingleManagedDetourState detour;

		private readonly DataScope<DynamicReferenceCell> delegateObjectScope;

		private static readonly FieldInfo HookData_Target = typeof(HookData).GetField("Target");

		private static readonly FieldInfo HookData_InvokeNext = typeof(HookData).GetField("InvokeNext");

		private bool disposedValue;

		IDetourFactory IDetourBase.Factory => factory;

		public DetourConfig? Config { get; }

		public MethodBase Source { get; }

		public MethodInfo Target { get; }

		MethodInfo IDetour.PublicTarget => Target;

		MethodInfo IDetour.InvokeTarget => realTarget;

		IDetourTrampoline IDetour.NextTrampoline => trampoline;

		public bool IsValid => !disposedValue;

		public bool IsApplied => detour.IsApplied;

		public DetourInfo DetourInfo => state.Info.GetDetourInfo(detour);

		public Hook(Expression<Action> source, Expression<Action> target)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body)
		{
		}

		public Hook(Expression source, Expression target)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method)
		{
		}

		public Hook(MethodBase source, MethodInfo target)
			: this(source, target, DetourContext.GetDefaultConfig())
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, applyByDefault)
		{
		}

		public Hook(Expression source, Expression target, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, applyByDefault)
		{
		}

		public Hook(MethodBase source, MethodInfo target, bool applyByDefault)
			: this(source, target, DetourContext.GetDefaultConfig(), applyByDefault)
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, DetourConfig? config)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, config)
		{
		}

		public Hook(Expression source, Expression target, DetourConfig? config)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, config)
		{
		}

		public Hook(MethodBase source, MethodInfo target, DetourConfig? config)
			: this(source, target, config, applyByDefault: true)
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, DetourConfig? config, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, config, applyByDefault)
		{
		}

		public Hook(Expression source, Expression target, DetourConfig? config, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, config, applyByDefault)
		{
		}

		public Hook(MethodBase source, MethodInfo target, DetourConfig? config, bool applyByDefault)
			: this(source, target, DetourContext.GetDefaultFactory(), config, applyByDefault)
		{
		}

		public Hook(MethodBase source, MethodInfo target, IDetourFactory factory, DetourConfig? config, bool applyByDefault)
			: this(source, target, null, factory, config, applyByDefault)
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, object? targetObj)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, targetObj)
		{
		}

		public Hook(Expression source, Expression target, object? targetObj)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, targetObj)
		{
		}

		public Hook(MethodBase source, MethodInfo target, object? targetObj)
			: this(source, target, targetObj, DetourContext.GetDefaultConfig())
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, object? targetObj, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, targetObj, applyByDefault)
		{
		}

		public Hook(Expression source, Expression target, object? targetObj, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, targetObj, applyByDefault)
		{
		}

		public Hook(MethodBase source, MethodInfo target, object? targetObj, bool applyByDefault)
			: this(source, target, targetObj, DetourContext.GetDefaultConfig(), applyByDefault)
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, object? targetObj, DetourConfig? config)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, targetObj, config)
		{
		}

		public Hook(Expression source, Expression target, object? targetObj, DetourConfig? config)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, targetObj, config)
		{
		}

		public Hook(MethodBase source, MethodInfo target, object? targetObj, DetourConfig? config)
			: this(source, target, targetObj, config, applyByDefault: true)
		{
		}

		public Hook(Expression<Action> source, Expression<Action> target, object? targetObj, DetourConfig? config, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, Helpers.ThrowIfNull<Expression<Action>>(target, "target").Body, targetObj, config, applyByDefault)
		{
		}

		public Hook(Expression source, Expression target, object? targetObj, DetourConfig? config, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, ((MethodCallExpression)Helpers.ThrowIfNull<Expression>(target, "target")).Method, targetObj, config, applyByDefault)
		{
		}

		public Hook(MethodBase source, MethodInfo target, object? targetObj, DetourConfig? config, bool applyByDefault)
			: this(source, target, targetObj, DetourContext.GetDefaultFactory(), config, applyByDefault)
		{
		}

		public Hook(Expression<Action> source, Delegate target)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, target)
		{
		}

		public Hook(Expression source, Delegate target)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, target)
		{
		}

		public Hook(MethodBase source, Delegate target)
			: this(source, target, DetourContext.GetDefaultConfig())
		{
		}

		public Hook(Expression<Action> source, Delegate target, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, target, applyByDefault)
		{
		}

		public Hook(Expression source, Delegate target, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, target, applyByDefault)
		{
		}

		public Hook(MethodBase source, Delegate target, bool applyByDefault)
			: this(source, target, DetourContext.GetDefaultConfig(), applyByDefault)
		{
		}

		public Hook(Expression<Action> source, Delegate target, DetourConfig? config)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, target, config)
		{
		}

		public Hook(Expression source, Delegate target, DetourConfig? config)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, target, config)
		{
		}

		public Hook(MethodBase source, Delegate target, DetourConfig? config)
			: this(source, target, config, applyByDefault: true)
		{
		}

		public Hook(Expression<Action> source, Delegate target, DetourConfig? config, bool applyByDefault)
			: this(Helpers.ThrowIfNull<Expression<Action>>(source, "source").Body, target, config, applyByDefault)
		{
		}

		public Hook(Expression source, Delegate target, DetourConfig? config, bool applyByDefault)
			: this(((MethodCallExpression)Helpers.ThrowIfNull<Expression>(source, "source")).Method, target, config, applyByDefault)
		{
		}

		public Hook(MethodBase source, Delegate target, DetourConfig? config, bool applyByDefault)
			: this(source, target, DetourContext.GetDefaultFactory(), config, applyByDefault)
		{
		}

		public Hook(MethodBase source, Delegate target, IDetourFactory factory, DetourConfig? config, bool applyByDefault)
			: this(source, GetDelegateHookInfo(Helpers.ThrowIfNull<Delegate>(target, "target"), out object target2), target2, factory, config, applyByDefault)
		{
		}

		private static MethodInfo GetDelegateHookInfo(Delegate del, out object? target)
		{
			if (del.GetInvocationList().Length == 1)
			{
				target = del.Target;
				return del.Method;
			}
			target = del;
			return del.GetType().GetMethod("Invoke") ?? throw new InvalidOperationException("Could not get Invoke method of delegate");
		}

		public Hook(MethodBase source, MethodInfo target, object? targetObject, IDetourFactory factory, DetourConfig? config, bool applyByDefault)
		{
			Helpers.ThrowIfArgumentNull<MethodBase>(source, "source");
			Helpers.ThrowIfArgumentNull<MethodInfo>(target, "target");
			Helpers.ThrowIfArgumentNull<IDetourFactory>(factory, "factory");
			this.factory = factory;
			Config = config;
			Source = PlatformTriple.Current.GetIdentifiable(source);
			Target = target;
			realTarget = PrepareRealTarget(targetObject, out trampoline, out delegateObjectScope);
			bool isEnabled;
			MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(23, 2, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Creating Hook from ");
				message.AppendFormatted(Source);
				message.AppendLiteral(" to ");
				message.AppendFormatted(Target);
			}
			MMDbgLog.Trace(ref message);
			state = DetourManager.GetDetourState(source);
			detour = new DetourManager.SingleManagedDetourState(this);
			if (applyByDefault)
			{
				Apply();
			}
		}

		private MethodInfo PrepareRealTarget(object? target, out TrampolineData trampoline, out DataScope<DynamicReferenceCell> scope)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			MethodSignature val = MethodSignature.ForMethod(Source);
			MethodSignature val2 = MethodSignature.ForMethod((MethodBase)Target, true);
			if (target == null && !Target.IsStatic)
			{
				throw new ArgumentException("Target method is nonstatic, but no target object was provided");
			}
			if (target != null && Target.IsStatic)
			{
				throw new ArgumentException("Target method is static, but a target object was provided");
			}
			Type type = null;
			if (val2.ParameterCount == val.ParameterCount + 1)
			{
				type = val2.FirstParameter;
				val2 = new MethodSignature(val2.ReturnType, val2.Parameters.Skip(1));
			}
			if (!val.IsCompatibleWith(val2))
			{
				throw new ArgumentException("Target method is not compatible with source method");
			}
			MethodSignature val3 = val;
			MethodInfo methodInfo = type?.GetMethod("Invoke");
			if ((object)methodInfo != null)
			{
				val3 = MethodSignature.ForMethod((MethodBase)methodInfo, true);
			}
			if (!val3.IsCompatibleWith(val))
			{
				throw new ArgumentException("Target method's delegate parameter is not compatible with the source method");
			}
			trampoline = new TrampolineData(val3);
			if (target == null && (object)type == null)
			{
				scope = default(DataScope<DynamicReferenceCell>);
				return Target;
			}
			HookData hookData = new HookData(target, ((object)type != null) ? Extensions.CreateDelegate(trampoline.TrampolineMethod, type) : null);
			FormatInterpolatedStringHandler val4 = default(FormatInterpolatedStringHandler);
			((FormatInterpolatedStringHandler)(ref val4))..ctor(6, 1);
			((FormatInterpolatedStringHandler)(ref val4)).AppendLiteral("Hook<");
			((FormatInterpolatedStringHandler)(ref val4)).AppendFormatted(Extensions.GetID((MethodBase)Target, (string)null, (string)null, true, false, false));
			((FormatInterpolatedStringHandler)(ref val4)).AppendLiteral(">");
			DynamicMethodDefinition val5 = val.CreateDmd(DebugFormatter.Format(ref val4));
			try
			{
				ILProcessor iLProcessor = val5.GetILProcessor();
				ModuleDefinition module = val5.Module;
				MethodDefinition definition = val5.Definition;
				VariableDefinition val6 = new VariableDefinition(module.ImportReference(typeof(HookData)));
				iLProcessor.Body.Variables.Add(val6);
				DynamicReferenceCell val7 = default(DynamicReferenceCell);
				scope = DynamicReferenceManager.EmitNewTypedReference<HookData>(iLProcessor, hookData, ref val7);
				iLProcessor.Emit(OpCodes.Stloc, val6);
				if (!Target.IsStatic)
				{
					iLProcessor.Emit(OpCodes.Ldloc, val6);
					iLProcessor.Emit(OpCodes.Ldfld, module.ImportReference(HookData_Target));
					Type declaringType = Target.DeclaringType;
					if ((object)declaringType != null && declaringType.IsValueType)
					{
						iLProcessor.Emit(OpCodes.Unbox, module.ImportReference(declaringType));
					}
				}
				if ((object)type != null)
				{
					iLProcessor.Emit(OpCodes.Ldloc, val6);
					iLProcessor.Emit(OpCodes.Ldfld, module.ImportReference(HookData_InvokeNext));
				}
				Enumerator<ParameterDefinition> enumerator = ((MethodReference)definition).Parameters.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ParameterDefinition current = enumerator.Current;
						iLProcessor.Emit(OpCodes.Ldarg, ((ParameterReference)current).Index);
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				Extensions.Emit(iLProcessor, OpCodes.Call, (MethodBase)Target);
				iLProcessor.Emit(OpCodes.Ret);
				return val5.Generate();
			}
			finally
			{
				((IDisposable)val5)?.Dispose();
			}
		}

		private void CheckDisposed()
		{
			if (disposedValue)
			{
				throw new ObjectDisposedException(ToString());
			}
		}

		public void Apply()
		{
			CheckDisposed();
			bool lockTaken = false;
			try
			{
				state.detourLock.Enter(ref lockTaken);
				if (!IsApplied)
				{
					bool isEnabled;
					MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(23, 2, out isEnabled);
					if (isEnabled)
					{
						message.AppendLiteral("Applying Hook from ");
						message.AppendFormatted(Source);
						message.AppendLiteral(" to ");
						message.AppendFormatted(Target);
					}
					MMDbgLog.Trace(ref message);
					state.AddDetour(detour, !lockTaken);
				}
			}
			finally
			{
				if (lockTaken)
				{
					state.detourLock.Exit(useMemoryBarrier: true);
				}
			}
		}

		public void Undo()
		{
			CheckDisposed();
			bool lockTaken = false;
			try
			{
				state.detourLock.Enter(ref lockTaken);
				if (IsApplied)
				{
					bool isEnabled;
					MMDbgLog.DebugLogTraceStringHandler message = new MMDbgLog.DebugLogTraceStringHandler(22, 2, out isEnabled);
					if (isEnabled)
					{
						message.AppendLiteral("Undoing Hook from ");
						message.AppendFormatted(Source);
						m

plugins/MonoMod.Utils.dll

Decompiled a month ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.SymbolStore;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod;
using MonoMod.Cil;
using MonoMod.Logs;
using MonoMod.SourceGen.Attributes;
using MonoMod.Utils;
using MonoMod.Utils.Cil;
using MonoMod.Utils.Interop;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.5.2", FrameworkDisplayName = ".NET Framework 4.5.2")]
[assembly: InternalsVisibleTo("MonoMod.Utils.Cil.ILGeneratorProxy")]
[assembly: AssemblyCompany("0x0ade, DaNike")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright 2024 0x0ade, DaNike")]
[assembly: AssemblyDescription("Utilities and smaller MonoMod \"components\" (f.e. ModInterop, DynDll, DynData). Can be used for your own mods. Required by all other MonoMod components.")]
[assembly: AssemblyFileVersion("25.0.7.0")]
[assembly: AssemblyInformationalVersion("25.0.7+38f132e84")]
[assembly: AssemblyProduct("MonoMod.Utils")]
[assembly: AssemblyTitle("MonoMod.Utils")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/MonoMod/MonoMod.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("25.0.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		MMDbgLog.LogVersion();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = 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 MonoMod
{
	public static class Switches
	{
		private delegate bool TryGetSwitchFunc(string @switch, out bool isEnabled);

		private static readonly ConcurrentDictionary<string, object?> switchValues;

		private const string Prefix = "MONOMOD_";

		public const string RunningOnWine = "RunningOnWine";

		public const string DebugClr = "DebugClr";

		public const string JitPath = "JitPath";

		public const string LogRecordHoles = "LogRecordHoles";

		public const string LogInMemory = "LogInMemory";

		public const string LogSpam = "LogSpam";

		public const string LogReplayQueueLength = "LogReplayQueueLength";

		public const string LogToFile = "LogToFile";

		public const string LogToFileFilter = "LogToFileFilter";

		public const string DMDType = "DMDType";

		public const string DMDDebug = "DMDDebug";

		public const string DMDDumpTo = "DMDDumpTo";

		private static readonly Type? tAppContext;

		private static readonly Func<string, object?> dGetData;

		private static readonly MethodInfo? miTryGetSwitch;

		private static readonly TryGetSwitchFunc? dTryGetSwitch;

		static Switches()
		{
			switchValues = new ConcurrentDictionary<string, object>();
			tAppContext = typeof(AppDomain).Assembly.GetType("System.AppContext");
			dGetData = MakeGetDataDelegate();
			miTryGetSwitch = tAppContext?.GetMethod("TryGetSwitch", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
			{
				typeof(string),
				typeof(bool).MakeByRefType()
			}, null);
			dTryGetSwitch = miTryGetSwitch?.TryCreateDelegate<TryGetSwitchFunc>();
			foreach (DictionaryEntry environmentVariable in Environment.GetEnvironmentVariables())
			{
				string text = (string)environmentVariable.Key;
				if (text.StartsWith("MONOMOD_", StringComparison.Ordinal) && environmentVariable.Value != null)
				{
					string key = text.Substring("MONOMOD_".Length);
					switchValues.TryAdd(key, BestEffortParseEnvVar((string)environmentVariable.Value));
				}
			}
		}

		private static object? BestEffortParseEnvVar(string value)
		{
			if (value.Length == 0)
			{
				return null;
			}
			if (int.TryParse(value, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			if (long.TryParse(value, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out var result2))
			{
				return result2;
			}
			if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
			{
				return result;
			}
			if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result2))
			{
				return result2;
			}
			bool flag;
			switch (value[0])
			{
			case 'F':
			case 'N':
			case 'T':
			case 'Y':
			case 'f':
			case 'n':
			case 't':
			case 'y':
				flag = true;
				break;
			default:
				flag = false;
				break;
			}
			if (flag)
			{
				if (bool.TryParse(value, out var result3))
				{
					return result3;
				}
				if (value.Equals("yes", StringComparison.OrdinalIgnoreCase) || value.Equals("y", StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
				if (value.Equals("no", StringComparison.OrdinalIgnoreCase) || value.Equals("n", StringComparison.OrdinalIgnoreCase))
				{
					return false;
				}
			}
			return value;
		}

		public static void SetSwitchValue(string @switch, object? value)
		{
			switchValues[@switch] = value;
		}

		public static void ClearSwitchValue(string @switch)
		{
			switchValues.TryRemove(@switch, out object _);
		}

		private static Func<string, object?> MakeGetDataDelegate()
		{
			Func<string, object> func = (tAppContext?.GetMethod("GetData", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null))?.TryCreateDelegate<Func<string, object>>();
			if (func != null)
			{
				try
				{
					func("MonoMod.LogToFile");
				}
				catch
				{
					func = null;
				}
			}
			if (func == null)
			{
				func = AppDomain.CurrentDomain.GetData;
			}
			return func;
		}

		public static bool TryGetSwitchValue(string @switch, out object? value)
		{
			if (switchValues.TryGetValue(@switch, out value))
			{
				return true;
			}
			if (dGetData != null || dTryGetSwitch != null)
			{
				string text = "MonoMod." + @switch;
				object obj = dGetData?.Invoke(text);
				if (obj != null)
				{
					value = obj;
					return true;
				}
				TryGetSwitchFunc tryGetSwitchFunc = dTryGetSwitch;
				if (tryGetSwitchFunc != null && tryGetSwitchFunc(text, out var isEnabled))
				{
					value = isEnabled;
					return true;
				}
			}
			value = null;
			return false;
		}

		public static bool TryGetSwitchEnabled(string @switch, out bool isEnabled)
		{
			if (switchValues.TryGetValue(@switch, out object value) && value != null && TryProcessBoolData(value, out isEnabled))
			{
				return true;
			}
			if (dGetData != null || dTryGetSwitch != null)
			{
				string text = "MonoMod." + @switch;
				TryGetSwitchFunc tryGetSwitchFunc = dTryGetSwitch;
				if (tryGetSwitchFunc != null && tryGetSwitchFunc(text, out isEnabled))
				{
					return true;
				}
				object obj = dGetData?.Invoke(text);
				if (obj != null && TryProcessBoolData(obj, out isEnabled))
				{
					return true;
				}
			}
			isEnabled = false;
			return false;
		}

		private static bool TryProcessBoolData(object data, out bool boolVal)
		{
			if (!(data is bool flag))
			{
				if (!(data is int num))
				{
					if (!(data is long num2))
					{
						IConvertible convertible;
						if (!(data is string value))
						{
							convertible = data as IConvertible;
							if (convertible == null)
							{
								boolVal = false;
								return false;
							}
						}
						else
						{
							if (bool.TryParse(value, out boolVal))
							{
								return true;
							}
							convertible = (IConvertible)data;
						}
						IConvertible convertible2 = convertible;
						boolVal = convertible2.ToBoolean(CultureInfo.CurrentCulture);
						return true;
					}
					long num3 = num2;
					boolVal = num3 != 0;
					return true;
				}
				int num4 = num;
				boolVal = num4 != 0;
				return true;
			}
			bool flag2 = flag;
			boolVal = flag2;
			return true;
		}
	}
	internal static class MMDbgLog
	{
		[InterpolatedStringHandler]
		internal ref struct DebugLogSpamStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogSpamStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, LogLevel.Spam, out isEnabled);
			}

			public override string ToString()
			{
				return handler.ToString();
			}

			public string ToStringAndClear()
			{
				return handler.ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				handler.AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				handler.AppendFormatted(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				handler.AppendFormatted(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				handler.AppendFormatted(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				handler.AppendFormatted(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogTraceStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogTraceStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, LogLevel.Trace, out isEnabled);
			}

			public override string ToString()
			{
				return handler.ToString();
			}

			public string ToStringAndClear()
			{
				return handler.ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				handler.AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				handler.AppendFormatted(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				handler.AppendFormatted(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				handler.AppendFormatted(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				handler.AppendFormatted(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogInfoStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogInfoStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, LogLevel.Info, out isEnabled);
			}

			public override string ToString()
			{
				return handler.ToString();
			}

			public string ToStringAndClear()
			{
				return handler.ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				handler.AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				handler.AppendFormatted(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				handler.AppendFormatted(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				handler.AppendFormatted(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				handler.AppendFormatted(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogWarningStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogWarningStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, LogLevel.Warning, out isEnabled);
			}

			public override string ToString()
			{
				return handler.ToString();
			}

			public string ToStringAndClear()
			{
				return handler.ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				handler.AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				handler.AppendFormatted(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				handler.AppendFormatted(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				handler.AppendFormatted(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				handler.AppendFormatted(value, alignment, format);
			}
		}

		[InterpolatedStringHandler]
		internal ref struct DebugLogErrorStringHandler
		{
			internal DebugLogInterpolatedStringHandler handler;

			public DebugLogErrorStringHandler(int literalLen, int formattedCount, out bool isEnabled)
			{
				handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, LogLevel.Error, out isEnabled);
			}

			public override string ToString()
			{
				return handler.ToString();
			}

			public string ToStringAndClear()
			{
				return handler.ToStringAndClear();
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendLiteral(string s)
			{
				handler.AppendLiteral(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(string? s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s)
			{
				handler.AppendFormatted(s);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
			{
				handler.AppendFormatted(s, alignment, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value)
			{
				handler.AppendFormatted(value);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment)
			{
				handler.AppendFormatted(value, alignment);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, string? format)
			{
				handler.AppendFormatted(value, format);
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			public void AppendFormatted<T>(T value, int alignment, string? format)
			{
				handler.AppendFormatted(value, alignment, format);
			}
		}

		public static bool IsWritingLog => DebugLog.IsWritingLog;

		[ModuleInitializer]
		internal static void LogVersion()
		{
			Info("Version 25.0.7");
		}

		public static void Log(LogLevel level, string message)
		{
			DebugLog.Log("MonoMod.Utils", level, message);
		}

		public static void Log(LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			DebugLog.Log("MonoMod.Utils", level, ref message);
		}

		public static void Spam(string message)
		{
			Log(LogLevel.Spam, message);
		}

		public static void Spam(ref DebugLogSpamStringHandler message)
		{
			Log(LogLevel.Spam, ref message.handler);
		}

		public static void Trace(string message)
		{
			Log(LogLevel.Trace, message);
		}

		public static void Trace(ref DebugLogTraceStringHandler message)
		{
			Log(LogLevel.Trace, ref message.handler);
		}

		public static void Info(string message)
		{
			Log(LogLevel.Info, message);
		}

		public static void Info(ref DebugLogInfoStringHandler message)
		{
			Log(LogLevel.Info, ref message.handler);
		}

		public static void Warning(string message)
		{
			Log(LogLevel.Warning, message);
		}

		public static void Warning(ref DebugLogWarningStringHandler message)
		{
			Log(LogLevel.Warning, ref message.handler);
		}

		public static void Error(string message)
		{
			Log(LogLevel.Error, message);
		}

		public static void Error(ref DebugLogErrorStringHandler message)
		{
			Log(LogLevel.Error, ref message.handler);
		}
	}
	internal static class MultiTargetShims
	{
		public static TypeReference GetConstraintType(this GenericParameterConstraint constraint)
		{
			return constraint.ConstraintType;
		}
	}
}
namespace MonoMod.SourceGen.Attributes
{
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class EmitILOverloadsAttribute : Attribute
	{
		public EmitILOverloadsAttribute(string filename, string kind)
		{
		}
	}
	internal static class ILOverloadKind
	{
		public const string Cursor = "ILCursor";

		public const string Matcher = "ILMatcher";
	}
}
namespace MonoMod.ModInterop
{
	[AttributeUsage(AttributeTargets.Class)]
	public sealed class ModExportNameAttribute : Attribute
	{
		public string Name { get; }

		public ModExportNameAttribute(string name)
		{
			Name = name;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field)]
	public sealed class ModImportNameAttribute : Attribute
	{
		public string Name { get; }

		public ModImportNameAttribute(string name)
		{
			Name = name;
		}
	}
	public static class ModInteropManager
	{
		private static HashSet<Type> Registered = new HashSet<Type>();

		private static Dictionary<string, List<MethodInfo>> Methods = new Dictionary<string, List<MethodInfo>>();

		private static List<FieldInfo> Fields = new List<FieldInfo>();

		public static void ModInterop(this Type type)
		{
			Helpers.ThrowIfArgumentNull(type, "type");
			if (Registered.Contains(type))
			{
				return;
			}
			Registered.Add(type);
			string name = type.Assembly.GetName().Name;
			object[] customAttributes = type.GetCustomAttributes(typeof(ModExportNameAttribute), inherit: false);
			for (int i = 0; i < customAttributes.Length; i++)
			{
				name = ((ModExportNameAttribute)customAttributes[i]).Name;
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (typeof(Delegate).IsAssignableFrom(fieldInfo.FieldType))
				{
					Fields.Add(fieldInfo);
				}
			}
			MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
			foreach (MethodInfo method in methods)
			{
				method.RegisterModExport();
				method.RegisterModExport(name);
			}
			foreach (FieldInfo field in Fields)
			{
				if (!Methods.TryGetValue(field.GetModImportName(), out List<MethodInfo> value))
				{
					field.SetValue(null, null);
					continue;
				}
				bool flag = false;
				foreach (MethodInfo item in value)
				{
					try
					{
						field.SetValue(null, Delegate.CreateDelegate(field.FieldType, null, item));
						flag = true;
					}
					catch
					{
						continue;
					}
					break;
				}
				if (!flag)
				{
					field.SetValue(null, null);
				}
			}
		}

		public static void RegisterModExport(this MethodInfo method, string? prefix = null)
		{
			Helpers.ThrowIfArgumentNull(method, "method");
			if (!method.IsPublic || !method.IsStatic)
			{
				throw new MemberAccessException("Utility must be public static");
			}
			string text = method.Name;
			if (!string.IsNullOrEmpty(prefix))
			{
				text = prefix + "." + text;
			}
			if (!Methods.TryGetValue(text, out List<MethodInfo> value))
			{
				value = (Methods[text] = new List<MethodInfo>());
			}
			if (!value.Contains(method))
			{
				value.Add(method);
			}
		}

		private static string GetModImportName(this FieldInfo field)
		{
			object[] customAttributes = field.GetCustomAttributes(typeof(ModImportNameAttribute), inherit: false);
			int num = 0;
			if (num < customAttributes.Length)
			{
				return ((ModImportNameAttribute)customAttributes[num]).Name;
			}
			if ((object)field.DeclaringType != null)
			{
				customAttributes = field.DeclaringType.GetCustomAttributes(typeof(ModImportNameAttribute), inherit: false);
				num = 0;
				if (num < customAttributes.Length)
				{
					return ((ModImportNameAttribute)customAttributes[num]).Name + "." + field.Name;
				}
			}
			return field.Name;
		}
	}
}
namespace MonoMod.Logs
{
	public static class DebugFormatter
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool CanDebugFormat<T>(in T value, out object? extraData)
		{
			extraData = null;
			if (typeof(T) == typeof(Type))
			{
				return true;
			}
			if (typeof(T) == typeof(MethodBase))
			{
				return true;
			}
			if (typeof(T) == typeof(MethodInfo))
			{
				return true;
			}
			if (typeof(T) == typeof(ConstructorInfo))
			{
				return true;
			}
			if (typeof(T) == typeof(FieldInfo))
			{
				return true;
			}
			if (typeof(T) == typeof(PropertyInfo))
			{
				return true;
			}
			if (typeof(T) == typeof(Exception))
			{
				return true;
			}
			if (typeof(T) == typeof(IDebugFormattable))
			{
				return true;
			}
			T val = value;
			if ((val is Type || val is MethodBase || val is FieldInfo || val is PropertyInfo) ? true : false)
			{
				return true;
			}
			if ((object)value is Exception ex)
			{
				extraData = ex.ToString();
				return true;
			}
			if (value is IDebugFormattable)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool TryFormatInto<T>(in T value, object? extraData, Span<char> into, out int wrote)
		{
			if (default(T) == null && value == null)
			{
				wrote = 0;
				return true;
			}
			if (typeof(T) == typeof(Type))
			{
				return TryFormatType(Transmute<Type>(in value), into, out wrote);
			}
			if (typeof(T) == typeof(MethodInfo))
			{
				return TryFormatMethodInfo(Transmute<MethodInfo>(in value), into, out wrote);
			}
			if (typeof(T) == typeof(ConstructorInfo))
			{
				return TryFormatMethodBase(Transmute<ConstructorInfo>(in value), into, out wrote);
			}
			if (typeof(T) == typeof(FieldInfo))
			{
				return TryFormatFieldInfo(Transmute<FieldInfo>(in value), into, out wrote);
			}
			if (typeof(T) == typeof(PropertyInfo))
			{
				return TryFormatPropertyInfo(Transmute<PropertyInfo>(in value), into, out wrote);
			}
			if (typeof(T) == typeof(Exception))
			{
				return TryFormatException(Transmute<Exception>(in value), System.Runtime.CompilerServices.Unsafe.As<string>(extraData), into, out wrote);
			}
			if (typeof(T) == typeof(IDebugFormattable))
			{
				return Transmute<IDebugFormattable>(in value).TryFormatInto(into, out wrote);
			}
			if ((object)value is Type type)
			{
				return TryFormatType(type, into, out wrote);
			}
			if ((object)value is MethodInfo method)
			{
				return TryFormatMethodInfo(method, into, out wrote);
			}
			if ((object)value is ConstructorInfo method2)
			{
				return TryFormatMethodBase(method2, into, out wrote);
			}
			if ((object)value is MethodBase method3)
			{
				return TryFormatMethodBase(method3, into, out wrote);
			}
			if ((object)value is FieldInfo field)
			{
				return TryFormatFieldInfo(field, into, out wrote);
			}
			if ((object)value is PropertyInfo prop)
			{
				return TryFormatPropertyInfo(prop, into, out wrote);
			}
			if ((object)value is Exception e)
			{
				return TryFormatException(e, System.Runtime.CompilerServices.Unsafe.As<string>(extraData), into, out wrote);
			}
			if (value is IDebugFormattable)
			{
				return ((IDebugFormattable)(object)value).TryFormatInto(into, out wrote);
			}
			bool flag = false;
			bool isEnabled;
			AssertionInterpolatedStringHandler message = new AssertionInterpolatedStringHandler(48, 1, flag, out isEnabled);
			if (isEnabled)
			{
				message.AppendLiteral("Called TryFormatInto with value of unknown type ");
				message.AppendFormatted(value.GetType());
			}
			Helpers.Assert(flag, ref message, "false");
			wrote = 0;
			return false;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			static ref TOut Transmute<TOut>(in T val)
			{
				return ref System.Runtime.CompilerServices.Unsafe.As<T, TOut>(ref System.Runtime.CompilerServices.Unsafe.AsRef<T>(ref val));
			}
		}

		private static bool TryFormatException(Exception e, string? eStr, Span<char> into, out int wrote)
		{
			wrote = 0;
			if (eStr == null)
			{
				eStr = e.ToString();
			}
			string newLine = Environment.NewLine;
			if (into.Slice(wrote).Length < eStr.Length)
			{
				return false;
			}
			eStr.AsSpan().CopyTo(into.Slice(wrote));
			wrote += eStr.Length;
			FormatIntoInterpolatedStringHandler handler;
			bool enabled;
			int wrote2;
			if (e is ReflectionTypeLoadException ex)
			{
				for (int i = 0; i < 4 && i < ex.Types.Length; i++)
				{
					Span<char> span = into.Slice(wrote);
					Span<char> into2 = span;
					handler = new FormatIntoInterpolatedStringHandler(56, 3, span, out enabled);
					if (enabled && handler.AppendFormatted(newLine) && handler.AppendLiteral("System.Reflection.ReflectionTypeLoadException.Types[") && handler.AppendFormatted(i) && handler.AppendLiteral("] = "))
					{
						handler.AppendFormatted(ex.Types[i]);
					}
					else
						_ = 0;
					if (!Into(into2, out wrote2, ref handler))
					{
						return false;
					}
					wrote += wrote2;
				}
				if (ex.Types.Length >= 4)
				{
					Span<char> span = into.Slice(wrote);
					Span<char> into3 = span;
					handler = new FormatIntoInterpolatedStringHandler(62, 1, span, out enabled);
					if (enabled && handler.AppendFormatted(newLine))
					{
						handler.AppendLiteral("System.Reflection.ReflectionTypeLoadException.Types[...] = ...");
					}
					else
						_ = 0;
					if (!Into(into3, out wrote2, ref handler))
					{
						return false;
					}
					wrote += wrote2;
				}
				if (ex.LoaderExceptions.Length != 0)
				{
					if (into.Slice(wrote).Length < newLine.Length + "System.Reflection.ReflectionTypeLoadException.LoaderExceptions = [".Length)
					{
						return false;
					}
					newLine.AsSpan().CopyTo(into.Slice(wrote));
					wrote += newLine.Length;
					"System.Reflection.ReflectionTypeLoadException.LoaderExceptions = [".AsSpan().CopyTo(into.Slice(wrote));
					wrote += "System.Reflection.ReflectionTypeLoadException.LoaderExceptions = [".Length;
					for (int j = 0; j < ex.LoaderExceptions.Length; j++)
					{
						Exception ex2 = ex.LoaderExceptions[j];
						if (ex2 != null)
						{
							if (into.Slice(wrote).Length < newLine.Length)
							{
								return false;
							}
							newLine.AsSpan().CopyTo(into.Slice(wrote));
							wrote += newLine.Length;
							if (!TryFormatException(ex2, null, into.Slice(wrote), out wrote2))
							{
								return false;
							}
							wrote += wrote2;
						}
					}
					if (into.Slice(wrote).Length < newLine.Length + 1)
					{
						return false;
					}
					newLine.AsSpan().CopyTo(into.Slice(wrote));
					wrote += newLine.Length;
					into[wrote++] = ']';
				}
			}
			if (e is TypeLoadException ex3)
			{
				Span<char> span = into.Slice(wrote);
				Span<char> into4 = span;
				handler = new FormatIntoInterpolatedStringHandler(36, 2, span, out enabled);
				if (enabled && handler.AppendFormatted(newLine) && handler.AppendLiteral("System.TypeLoadException.TypeName = "))
				{
					handler.AppendFormatted(ex3.TypeName);
				}
				else
					_ = 0;
				if (!Into(into4, out wrote2, ref handler))
				{
					return false;
				}
				wrote += wrote2;
			}
			if (e is BadImageFormatException ex4)
			{
				Span<char> span = into.Slice(wrote);
				Span<char> into5 = span;
				handler = new FormatIntoInterpolatedStringHandler(42, 2, span, out enabled);
				if (enabled && handler.AppendFormatted(newLine) && handler.AppendLiteral("System.BadImageFormatException.FileName = "))
				{
					handler.AppendFormatted(ex4.FileName);
				}
				else
					_ = 0;
				if (!Into(into5, out wrote2, ref handler))
				{
					return false;
				}
				wrote += wrote2;
			}
			return true;
		}

		private static bool TryFormatType(Type type, Span<char> into, out int wrote)
		{
			wrote = 0;
			string text;
			if (type.HasElementType && type.GetElementType() == null)
			{
				text = type.Name;
			}
			else
			{
				string fullName = type.FullName;
				if (fullName == null)
				{
					return true;
				}
				text = fullName;
			}
			if (into.Length < text.Length)
			{
				return false;
			}
			text.AsSpan().CopyTo(into);
			wrote = text.Length;
			return true;
		}

		private static bool TryFormatMethodInfo(MethodInfo method, Span<char> into, out int wrote)
		{
			Type returnType = method.ReturnType;
			wrote = 0;
			if (!TryFormatType(returnType, into.Slice(wrote), out var wrote2))
			{
				return false;
			}
			wrote += wrote2;
			if (into.Slice(wrote).Length < 1)
			{
				return false;
			}
			into[wrote++] = ' ';
			if (!TryFormatMethodBase(method, into.Slice(wrote), out wrote2))
			{
				return false;
			}
			wrote += wrote2;
			return true;
		}

		private static bool TryFormatMemberInfoName(MemberInfo member, Span<char> into, out int wrote)
		{
			wrote = 0;
			Type declaringType = member.DeclaringType;
			if ((object)declaringType != null)
			{
				if (!TryFormatType(declaringType, into.Slice(wrote), out var wrote2))
				{
					return false;
				}
				wrote += wrote2;
				if (into.Slice(wrote).Length < 1)
				{
					return false;
				}
				into[wrote++] = ':';
			}
			string name = member.Name;
			if (into.Slice(wrote).Length < name.Length)
			{
				return false;
			}
			name.AsSpan().CopyTo(into.Slice(wrote));
			wrote += name.Length;
			return true;
		}

		private static bool TryFormatMethodBase(MethodBase method, Span<char> into, out int wrote)
		{
			wrote = 0;
			if (!TryFormatMemberInfoName(method, into.Slice(wrote), out var wrote2))
			{
				return false;
			}
			wrote += wrote2;
			if (method.IsGenericMethod)
			{
				if (into.Slice(wrote).Length < 1)
				{
					return false;
				}
				into[wrote++] = '<';
				Type[] genericArguments = method.GetGenericArguments();
				for (int i = 0; i < genericArguments.Length; i++)
				{
					if (i != 0)
					{
						if (into.Slice(wrote).Length < 2)
						{
							return false;
						}
						into[wrote++] = ',';
						into[wrote++] = ' ';
					}
					if (!TryFormatType(genericArguments[i], into.Slice(wrote), out wrote2))
					{
						return false;
					}
					wrote += wrote2;
				}
				if (into.Slice(wrote).Length < 1)
				{
					return false;
				}
				into[wrote++] = '>';
			}
			ParameterInfo[] parameters = method.GetParameters();
			if (into.Slice(wrote).Length < 1)
			{
				return false;
			}
			into[wrote++] = '(';
			for (int j = 0; j < parameters.Length; j++)
			{
				if (j != 0)
				{
					if (into.Slice(wrote).Length < 2)
					{
						return false;
					}
					into[wrote++] = ',';
					into[wrote++] = ' ';
				}
				if (!TryFormatType(parameters[j].ParameterType, into.Slice(wrote), out wrote2))
				{
					return false;
				}
				wrote += wrote2;
			}
			if (into.Slice(wrote).Length < 1)
			{
				return false;
			}
			into[wrote++] = ')';
			return true;
		}

		private static bool TryFormatFieldInfo(FieldInfo field, Span<char> into, out int wrote)
		{
			wrote = 0;
			if (!TryFormatType(field.FieldType, into.Slice(wrote), out var wrote2))
			{
				return false;
			}
			wrote += wrote2;
			if (into.Slice(wrote).Length < 1)
			{
				return false;
			}
			into[wrote++] = ' ';
			if (!TryFormatMemberInfoName(field, into.Slice(wrote), out wrote2))
			{
				return false;
			}
			wrote += wrote2;
			return true;
		}

		private static bool TryFormatPropertyInfo(PropertyInfo prop, Span<char> into, out int wrote)
		{
			wrote = 0;
			if (!TryFormatType(prop.PropertyType, into.Slice(wrote), out var wrote2))
			{
				return false;
			}
			wrote += wrote2;
			if (into.Slice(wrote).Length < 1)
			{
				return false;
			}
			into[wrote++] = ' ';
			if (!TryFormatMemberInfoName(prop, into.Slice(wrote), out wrote2))
			{
				return false;
			}
			wrote += wrote2;
			bool canRead = prop.CanRead;
			bool canWrite = prop.CanWrite;
			int num = 5 + (canRead ? 4 : 0) + (canWrite ? 4 : 0) + ((canRead && canWrite) ? 1 : 0);
			if (into.Slice(wrote).Length < num)
			{
				return false;
			}
			" { ".AsSpan().CopyTo(into.Slice(wrote));
			wrote += 3;
			if (canRead)
			{
				"get;".AsSpan().CopyTo(into.Slice(wrote));
				wrote += 4;
			}
			if (canRead && canWrite)
			{
				into[wrote++] = ' ';
			}
			if (canWrite)
			{
				"set;".AsSpan().CopyTo(into.Slice(wrote));
				wrote += 4;
			}
			" }".AsSpan().CopyTo(into.Slice(wrote));
			wrote += 2;
			return true;
		}

		public static string Format(ref FormatInterpolatedStringHandler handler)
		{
			return handler.ToStringAndClear();
		}

		public static bool Into(Span<char> into, out int wrote, [InterpolatedStringHandlerArgument("into")] ref FormatIntoInterpolatedStringHandler handler)
		{
			wrote = handler.pos;
			return !handler.incomplete;
		}
	}
	[InterpolatedStringHandler]
	public ref struct FormatInterpolatedStringHandler
	{
		private DebugLogInterpolatedStringHandler handler;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public FormatInterpolatedStringHandler(int literalLen, int formattedCount)
		{
			handler = new DebugLogInterpolatedStringHandler(literalLen, formattedCount, enabled: true, recordHoles: false, out var _);
		}

		public override string ToString()
		{
			return handler.ToString();
		}

		public string ToStringAndClear()
		{
			return handler.ToStringAndClear();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendLiteral(string s)
		{
			handler.AppendLiteral(s);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(string? s)
		{
			handler.AppendFormatted(s);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(string? s, int alignment = 0, string? format = null)
		{
			handler.AppendFormatted(s, alignment, format);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(ReadOnlySpan<char> s)
		{
			handler.AppendFormatted(s);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(ReadOnlySpan<char> s, int alignment = 0, string? format = null)
		{
			handler.AppendFormatted(s, alignment, format);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value)
		{
			handler.AppendFormatted(value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, int alignment)
		{
			handler.AppendFormatted(value, alignment);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, string? format)
		{
			handler.AppendFormatted(value, format);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, int alignment, string? format)
		{
			handler.AppendFormatted(value, alignment, format);
		}
	}
	public readonly record struct MessageHole
	{
		public int Start { get; }

		public int End { get; }

		public object? Value { get; }

		public bool IsValueUnrepresentable { get; }

		public MessageHole(int start, int end)
		{
			Value = null;
			IsValueUnrepresentable = true;
			Start = start;
			End = end;
		}

		public MessageHole(int start, int end, object? value)
		{
			Value = value;
			IsValueUnrepresentable = false;
			Start = start;
			End = end;
		}
	}
	public sealed class DebugLog
	{
		public delegate void OnLogMessage(string source, DateTime time, LogLevel level, string message);

		public delegate void OnLogMessageDetailed(string source, DateTime time, LogLevel level, string formattedMessage, ReadOnlyMemory<MessageHole> holes);

		private sealed class LogMessage
		{
			public string Source { get; private set; }

			public DateTime Time { get; private set; }

			public LogLevel Level { get; private set; }

			public string FormattedMessage { get; private set; }

			public ReadOnlyMemory<MessageHole> FormatHoles { get; private set; }

			public LogMessage(string source, DateTime time, LogLevel level, string formatted, ReadOnlyMemory<MessageHole> holes)
			{
				Source = source;
				Time = time;
				Level = level;
				FormattedMessage = formatted;
				FormatHoles = holes;
			}

			public void Clear()
			{
				Source = "";
				Time = default(DateTime);
				Level = LogLevel.Spam;
				FormattedMessage = "";
				FormatHoles = default(ReadOnlyMemory<MessageHole>);
			}

			public void Init(string source, DateTime time, LogLevel level, string formatted, ReadOnlyMemory<MessageHole> holes)
			{
				Source = source;
				Time = time;
				Level = level;
				FormattedMessage = formatted;
				FormatHoles = holes;
			}

			public void ReportTo(OnLogMessage del)
			{
				try
				{
					del(Source, Time, Level, FormattedMessage);
				}
				catch (Exception ex)
				{
					Debugger.Log(int.MaxValue, "MonoMod.DebugLog", "Exception caught while reporting to message handler");
					Debugger.Log(int.MaxValue, "MonoMod.DebugLog", ex.ToString());
				}
			}

			public void ReportTo(OnLogMessageDetailed del)
			{
				try
				{
					del(Source, Time, Level, FormattedMessage, FormatHoles);
				}
				catch (Exception ex)
				{
					Debugger.Log(int.MaxValue, "MonoMod.DebugLog", "Exception caught while reporting to message handler");
					Debugger.Log(int.MaxValue, "MonoMod.DebugLog", ex.ToString());
				}
			}
		}

		private sealed class LevelSubscriptions
		{
			public LogLevelFilter ActiveLevels;

			public LogLevelFilter DetailLevels;

			public readonly OnLogMessage?[] SimpleRegs;

			public readonly OnLogMessageDetailed?[] DetailedRegs;

			private const LogLevelFilter ValidFilter = LogLevelFilter.Spam | LogLevelFilter.Trace | LogLevelFilter.Info | LogLevelFilter.Warning | LogLevelFilter.Error | LogLevelFilter.Assert;

			public static readonly LevelSubscriptions None = new LevelSubscriptions();

			private LevelSubscriptions(LogLevelFilter active, LogLevelFilter detail, OnLogMessage?[] simple, OnLogMessageDetailed?[] detailed)
			{
				ActiveLevels = active | detail;
				DetailLevels = detail;
				SimpleRegs = simple;
				DetailedRegs = detailed;
			}

			private LevelSubscriptions()
			{
				ActiveLevels = LogLevelFilter.None;
				DetailLevels = LogLevelFilter.None;
				SimpleRegs = new OnLogMessage[6];
				DetailedRegs = new OnLogMessageDetailed[SimpleRegs.Length];
			}

			private LevelSubscriptions Clone(bool changingDetail)
			{
				OnLogMessage[] array = SimpleRegs;
				OnLogMessageDetailed[] array2 = DetailedRegs;
				if (!changingDetail)
				{
					array = new OnLogMessage[SimpleRegs.Length];
					Array.Copy(SimpleRegs, array, array.Length);
				}
				else
				{
					array2 = new OnLogMessageDetailed[DetailedRegs.Length];
					Array.Copy(DetailedRegs, array2, array2.Length);
				}
				return new LevelSubscriptions(ActiveLevels, DetailLevels, array, array2);
			}

			private void FixFilters()
			{
				ActiveLevels &= LogLevelFilter.Spam | LogLevelFilter.Trace | LogLevelFilter.Info | LogLevelFilter.Warning | LogLevelFilter.Error | LogLevelFilter.Assert;
				DetailLevels &= LogLevelFilter.Spam | LogLevelFilter.Trace | LogLevelFilter.Info | LogLevelFilter.Warning | LogLevelFilter.Error | LogLevelFilter.Assert;
			}

			public LevelSubscriptions AddSimple(LogLevelFilter filter, OnLogMessage del)
			{
				LevelSubscriptions levelSubscriptions = Clone(changingDetail: false);
				levelSubscriptions.ActiveLevels |= filter;
				for (int i = 0; i < levelSubscriptions.SimpleRegs.Length; i++)
				{
					if (((uint)filter & (uint)(1 << i)) != 0)
					{
						Helpers.EventAdd(ref levelSubscriptions.SimpleRegs[i], del);
					}
				}
				levelSubscriptions.FixFilters();
				return levelSubscriptions;
			}

			public LevelSubscriptions RemoveSimple(LogLevelFilter filter, OnLogMessage del)
			{
				LevelSubscriptions levelSubscriptions = Clone(changingDetail: false);
				for (int i = 0; i < levelSubscriptions.SimpleRegs.Length; i++)
				{
					if (((uint)filter & (uint)(1 << i)) != 0 && Helpers.EventRemove(ref levelSubscriptions.SimpleRegs[i], del) == null)
					{
						levelSubscriptions.ActiveLevels &= (LogLevelFilter)(~(1 << i));
					}
				}
				levelSubscriptions.ActiveLevels |= levelSubscriptions.DetailLevels;
				levelSubscriptions.FixFilters();
				return levelSubscriptions;
			}

			public LevelSubscriptions AddDetailed(LogLevelFilter filter, OnLogMessageDetailed del)
			{
				LevelSubscriptions levelSubscriptions = Clone(changingDetail: true);
				levelSubscriptions.DetailLevels |= filter;
				for (int i = 0; i < levelSubscriptions.DetailedRegs.Length; i++)
				{
					if (((uint)filter & (uint)(1 << i)) != 0)
					{
						Helpers.EventAdd(ref levelSubscriptions.DetailedRegs[i], del);
					}
				}
				levelSubscriptions.ActiveLevels |= levelSubscriptions.DetailLevels;
				levelSubscriptions.FixFilters();
				return levelSubscriptions;
			}

			public LevelSubscriptions RemoveDetailed(LogLevelFilter filter, OnLogMessageDetailed del)
			{
				LevelSubscriptions levelSubscriptions = Clone(changingDetail: true);
				for (int i = 0; i < levelSubscriptions.DetailedRegs.Length; i++)
				{
					if (((uint)filter & (uint)(1 << i)) != 0 && Helpers.EventRemove(ref levelSubscriptions.DetailedRegs[i], del) == null)
					{
						levelSubscriptions.DetailLevels &= (LogLevelFilter)(~(1 << i));
					}
				}
				levelSubscriptions.ActiveLevels |= levelSubscriptions.DetailLevels;
				levelSubscriptions.FixFilters();
				return levelSubscriptions;
			}
		}

		private sealed class LogSubscriptionSimple : IDisposable
		{
			private readonly DebugLog log;

			private readonly OnLogMessage del;

			private readonly LogLevelFilter filter;

			public LogSubscriptionSimple(DebugLog log, OnLogMessage del, LogLevelFilter filter)
			{
				this.log = log;
				this.del = del;
				this.filter = filter;
			}

			public void Dispose()
			{
				LevelSubscriptions subscriptions;
				LevelSubscriptions value;
				do
				{
					subscriptions = log.subscriptions;
					value = subscriptions.RemoveSimple(filter, del);
				}
				while (Interlocked.CompareExchange(ref log.subscriptions, value, subscriptions) != subscriptions);
			}
		}

		private sealed class LogSubscriptionDetailed : IDisposable
		{
			private readonly DebugLog log;

			private readonly OnLogMessageDetailed del;

			private readonly LogLevelFilter filter;

			public LogSubscriptionDetailed(DebugLog log, OnLogMessageDetailed del, LogLevelFilter filter)
			{
				this.log = log;
				this.del = del;
				this.filter = filter;
			}

			public void Dispose()
			{
				LevelSubscriptions subscriptions;
				LevelSubscriptions value;
				do
				{
					subscriptions = log.subscriptions;
					value = subscriptions.RemoveDetailed(filter, del);
				}
				while (Interlocked.CompareExchange(ref log.subscriptions, value, subscriptions) != subscriptions);
			}
		}

		internal static readonly DebugLog Instance = new DebugLog();

		private static readonly ConcurrentBag<WeakReference<LogMessage>> weakRefCache = new ConcurrentBag<WeakReference<LogMessage>>();

		private static readonly ConcurrentBag<WeakReference<LogMessage>> messageObjectCache = new ConcurrentBag<WeakReference<LogMessage>>();

		private static readonly char[] listEnvSeparator = new char[3] { ' ', ';', ',' };

		private readonly bool recordHoles;

		private readonly int replayQueueLength;

		private readonly ConcurrentQueue<LogMessage>? replayQueue;

		private LogLevelFilter globalFilter = LogLevelFilter.DefaultFilter;

		private static byte[]? memlog;

		private static int memlogPos;

		private LevelSubscriptions subscriptions = LevelSubscriptions.None;

		private static readonly ConcurrentDictionary<OnLogMessage, IDisposable> simpleRegDict = new ConcurrentDictionary<OnLogMessage, IDisposable>();

		public static bool IsFinalizing
		{
			get
			{
				if (!Environment.HasShutdownStarted)
				{
					return AppDomain.CurrentDomain.IsFinalizingForUnload();
				}
				return true;
			}
		}

		public static bool IsWritingLog => Instance.ShouldLog;

		internal bool AlwaysLog
		{
			get
			{
				if (replayQueue == null)
				{
					return Debugger.IsAttached;
				}
				return true;
			}
		}

		internal bool ShouldLog
		{
			get
			{
				if (subscriptions.ActiveLevels == LogLevelFilter.None)
				{
					return AlwaysLog;
				}
				return true;
			}
		}

		internal bool RecordHoles
		{
			get
			{
				if (!recordHoles)
				{
					return subscriptions.DetailLevels != LogLevelFilter.None;
				}
				return true;
			}
		}

		public static event OnLogMessage OnLog
		{
			add
			{
				IDisposable res = Subscribe(Instance.globalFilter, value);
				simpleRegDict.AddOrUpdate(value, res, delegate(OnLogMessage _, IDisposable d)
				{
					d.Dispose();
					return res;
				});
			}
			remove
			{
				if (simpleRegDict.TryRemove(value, out IDisposable value2))
				{
					value2.Dispose();
				}
			}
		}

		private LogMessage MakeMessage(string source, DateTime time, LogLevel level, string formatted, ReadOnlyMemory<MessageHole> holes)
		{
			try
			{
				if (replayQueue == null && !IsFinalizing)
				{
					WeakReference<LogMessage> result;
					while (messageObjectCache.TryTake(out result))
					{
						if (result.TryGetTarget(out var target))
						{
							target.Init(source, time, level, formatted, holes);
							weakRefCache.Add(result);
							return target;
						}
						weakRefCache.Add(result);
					}
				}
			}
			catch
			{
			}
			return new LogMessage(source, time, level, formatted, holes);
		}

		private void ReturnMessage(LogMessage message)
		{
			message.Clear();
			try
			{
				if (replayQueue == null && !IsFinalizing)
				{
					if (weakRefCache.TryTake(out WeakReference<LogMessage> result))
					{
						result.SetTarget(message);
						messageObjectCache.Add(result);
					}
					else
					{
						messageObjectCache.Add(new WeakReference<LogMessage>(message));
					}
				}
			}
			catch
			{
			}
		}

		private void PostMessage(LogMessage message)
		{
			if (Debugger.IsAttached)
			{
				try
				{
					LogLevel level = message.Level;
					string source = message.Source;
					FormatInterpolatedStringHandler handler = new FormatInterpolatedStringHandler(6, 3);
					handler.AppendLiteral("[");
					handler.AppendFormatted(message.Source);
					handler.AppendLiteral("] ");
					handler.AppendFormatted(message.Level.FastToString());
					handler.AppendLiteral(": ");
					handler.AppendFormatted(message.FormattedMessage);
					handler.AppendLiteral("\n");
					Debugger.Log((int)level, source, DebugFormatter.Format(ref handler));
				}
				catch
				{
				}
			}
			try
			{
				LevelSubscriptions levelSubscriptions = subscriptions;
				int level2 = (int)message.Level;
				OnLogMessage onLogMessage = levelSubscriptions.SimpleRegs[level2];
				if (onLogMessage != null)
				{
					message.ReportTo(onLogMessage);
				}
				OnLogMessageDetailed onLogMessageDetailed = levelSubscriptions.DetailedRegs[level2];
				if (onLogMessageDetailed != null)
				{
					message.ReportTo(onLogMessageDetailed);
				}
				if (IsFinalizing)
				{
					return;
				}
				ConcurrentQueue<LogMessage> concurrentQueue = replayQueue;
				if (concurrentQueue != null)
				{
					concurrentQueue.Enqueue(message);
					LogMessage result;
					while (concurrentQueue.Count > replayQueueLength && concurrentQueue.TryDequeue(out result))
					{
					}
				}
				else
				{
					ReturnMessage(message);
				}
			}
			catch
			{
			}
		}

		internal bool ShouldLogLevel(LogLevel level)
		{
			if (((uint)(1 << (int)level) & (uint)subscriptions.ActiveLevels) == 0)
			{
				if (((uint)(1 << (int)level) & (uint)globalFilter) != 0)
				{
					return AlwaysLog;
				}
				return false;
			}
			return true;
		}

		internal bool ShouldLevelRecordHoles(LogLevel level)
		{
			if (!recordHoles)
			{
				return ((uint)(1 << (int)level) & (uint)subscriptions.DetailLevels) != 0;
			}
			return true;
		}

		public void Write(string source, DateTime time, LogLevel level, string message)
		{
			if (ShouldLogLevel(level))
			{
				PostMessage(MakeMessage(source, time, level, message, default(ReadOnlyMemory<MessageHole>)));
			}
		}

		public void Write(string source, DateTime time, LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			if (message.enabled && ShouldLogLevel(level))
			{
				ReadOnlyMemory<MessageHole> holes;
				string formatted = message.ToStringAndClear(out holes);
				PostMessage(MakeMessage(source, time, level, formatted, holes));
			}
		}

		internal void LogCore(string source, LogLevel level, string message)
		{
			if (ShouldLogLevel(level))
			{
				Write(source, DateTime.UtcNow, level, message);
			}
		}

		internal void LogCore(string source, LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			if (message.enabled && ShouldLogLevel(level))
			{
				Write(source, DateTime.UtcNow, level, ref message);
			}
		}

		public static void Log(string source, LogLevel level, string message)
		{
			DebugLog instance = Instance;
			if (instance.ShouldLogLevel(level))
			{
				instance.Write(source, DateTime.UtcNow, level, message);
			}
		}

		public static void Log(string source, LogLevel level, [InterpolatedStringHandlerArgument("level")] ref DebugLogInterpolatedStringHandler message)
		{
			DebugLog instance = Instance;
			if (message.enabled && instance.ShouldLogLevel(level))
			{
				instance.Write(source, DateTime.UtcNow, level, ref message);
			}
		}

		private static string[]? GetListEnvVar(string text)
		{
			string text2 = text.Trim();
			if (string.IsNullOrEmpty(text2))
			{
				return null;
			}
			string[] array = text2.Split(listEnvSeparator, StringSplitOptions.RemoveEmptyEntries);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = array[i].Trim();
			}
			return array;
		}

		private DebugLog()
		{
			recordHoles = Switches.TryGetSwitchEnabled("LogRecordHoles", out var isEnabled) && isEnabled;
			replayQueueLength = 0;
			if (Switches.TryGetSwitchValue("LogReplayQueueLength", out object value))
			{
				replayQueueLength = (value as int?).GetValueOrDefault();
			}
			if (Switches.TryGetSwitchEnabled("LogSpam", out isEnabled) && isEnabled)
			{
				globalFilter |= LogLevelFilter.Spam;
			}
			if (replayQueueLength > 0)
			{
				replayQueue = new ConcurrentQueue<LogMessage>();
			}
			string text = (Switches.TryGetSwitchValue("LogToFile", out value) ? (value as string) : null);
			string[] sourceFilter = null;
			if (Switches.TryGetSwitchValue("LogToFileFilter", out value))
			{
				sourceFilter = ((value is string[] array) ? array : ((!(value is string text2)) ? null : GetListEnvVar(text2)));
			}
			if (text != null)
			{
				TryInitializeLogToFile(text, sourceFilter, globalFilter);
			}
			if (Switches.TryGetSwitchEnabled("LogInMemory", out isEnabled) && isEnabled)
			{
				TryInitializeMemoryLog(globalFilter);
			}
		}

		private void TryInitializeLogToFile(string file, string[]? sourceFilter, LogLevelFilter filter)
		{
			string[] sourceFilter2 = sourceFilter;
			try
			{
				StringComparer comparer = StringComparerEx.FromComparison(StringComparison.OrdinalIgnoreCase);
				if (sourceFilter2 != null)
				{
					Array.Sort(sourceFilter2, (IComparer<string>?)comparer);
				}
				object sync = new object();
				TextWriter writer;
				if (file == "-")
				{
					writer = Console.Out;
				}
				else
				{
					FileStream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Write);
					writer = new StreamWriter(stream, Encoding.UTF8)
					{
						AutoFlush = true
					};
				}
				SubscribeCore(filter, delegate(string source, DateTime time, LogLevel level, string msg)
				{
					if (sourceFilter2 != null && sourceFilter2.AsSpan().BinarySearch(source, comparer) < 0)
					{
						return;
					}
					DateTime value2 = time.ToLocalTime();
					string value3 = $"[{source}]({value2}) {level.FastToString()}: {msg}";
					lock (sync)
					{
						writer.WriteLine(value3);
					}
				});
			}
			catch (Exception value)
			{
				LogLevel logLevel = LogLevel.Error;
				LogLevel level2 = logLevel;
				bool isEnabled;
				DebugLogInterpolatedStringHandler message = new DebugLogInterpolatedStringHandler(61, 1, logLevel, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Exception while trying to initialize writing logs to a file: ");
					message.AppendFormatted(value);
				}
				Instance.LogCore("DebugLog", level2, ref message);
			}
		}

		private void TryInitializeMemoryLog(LogLevelFilter filter)
		{
			try
			{
				memlogPos = 0;
				memlog = new byte[4096];
				object sync = new object();
				_ = Encoding.UTF8;
				SubscribeCore(filter, delegate(string source, DateTime time, LogLevel level, string msg)
				{
					byte b = (byte)level;
					long ticks = time.Ticks;
					if (source.Length > 255)
					{
						source = source.Substring(0, 255);
					}
					byte b2 = (byte)source.Length;
					int length = msg.Length;
					int num = 14 + b2 * 2 + length * 2;
					lock (sync)
					{
						if (memlog.Length - memlogPos < num)
						{
							int num2 = memlog.Length * 4;
							while (num2 - memlogPos < num)
							{
								num2 *= 4;
							}
							Array.Resize(ref memlog, num2);
						}
						ref byte reference = ref MemoryMarshal.GetReference(memlog.AsSpan().Slice(memlogPos));
						int num3 = 0;
						System.Runtime.CompilerServices.Unsafe.WriteUnaligned<byte>(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), b);
						num3++;
						System.Runtime.CompilerServices.Unsafe.WriteUnaligned<long>(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), ticks);
						num3 += 8;
						System.Runtime.CompilerServices.Unsafe.WriteUnaligned<byte>(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), b2);
						num3++;
						System.Runtime.CompilerServices.Unsafe.CopyBlock(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), ref System.Runtime.CompilerServices.Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(source.AsSpan())), (uint)(b2 * 2));
						num3 += b2 * 2;
						System.Runtime.CompilerServices.Unsafe.WriteUnaligned<int>(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), length);
						num3 += 4;
						System.Runtime.CompilerServices.Unsafe.CopyBlock(ref System.Runtime.CompilerServices.Unsafe.Add<byte>(ref reference, num3), ref System.Runtime.CompilerServices.Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(msg.AsSpan())), (uint)(length * 2));
						num3 += length * 2;
						memlogPos += num3;
					}
				});
			}
			catch (Exception value)
			{
				LogLevel logLevel = LogLevel.Error;
				LogLevel level2 = logLevel;
				bool isEnabled;
				DebugLogInterpolatedStringHandler message = new DebugLogInterpolatedStringHandler(45, 1, logLevel, out isEnabled);
				if (isEnabled)
				{
					message.AppendLiteral("Exception while initializing the memory log: ");
					message.AppendFormatted(value);
				}
				Instance.LogCore("DebugLog", level2, ref message);
			}
		}

		private void MaybeReplayTo(LogLevelFilter filter, OnLogMessage del)
		{
			if (replayQueue == null || filter == LogLevelFilter.None)
			{
				return;
			}
			LogMessage[] array = replayQueue.ToArray();
			foreach (LogMessage logMessage in array)
			{
				if (((uint)(1 << (int)logMessage.Level) & (uint)filter) != 0)
				{
					logMessage.ReportTo(del);
				}
			}
		}

		private void MaybeReplayTo(LogLevelFilter filter, OnLogMessageDetailed del)
		{
			if (replayQueue == null || filter == LogLevelFilter.None)
			{
				return;
			}
			LogMessage[] array = replayQueue.ToArray();
			foreach (LogMessage logMessage in array)
			{
				if (((uint)(1 << (int)logMessage.Level) & (uint)filter) != 0)
				{
					logMessage.ReportTo(del);
				}
			}
		}

		public static IDisposable Subscribe(LogLevelFilter filter, OnLogMessage value)
		{
			return Instance.SubscribeCore(filter, value);
		}

		private IDisposable SubscribeCore(LogLevelFilter filter, OnLogMessage value)
		{
			LevelSubscriptions levelSubscriptions;
			LevelSubscriptions value2;
			do
			{
				levelSubscriptions = subscriptions;
				value2 = levelSubscriptions.AddSimple(filter, value);
			}
			while (Interlocked.CompareExchange(ref subscriptions, value2, levelSubscriptions) != levelSubscriptions);
			MaybeReplayTo(filter, value);
			return new LogSubscriptionSimple(this, value, filter);
		}

		public static IDisposable Subscribe(LogLevelFilter filter, OnLogMessageDetailed value)
		{
			return Instance.SubscribeCore(filter, value);
		}

		private IDisposable SubscribeCore(LogLevelFilter filter, OnLogMessageDetailed value)
		{
			LevelSubscriptions levelSubscriptions;
			LevelSubscriptions value2;
			do
			{
				levelSubscriptions = subscriptions;
				value2 = levelSubscriptions.AddDetailed(filter, value);
			}
			while (Interlocked.CompareExchange(ref subscriptions, value2, levelSubscriptions) != levelSubscriptions);
			MaybeReplayTo(filter, value);
			return new LogSubscriptionDetailed(this, value, filter);
		}
	}
	[InterpolatedStringHandler]
	public ref struct DebugLogInterpolatedStringHandler
	{
		private const int GuessedLengthPerHole = 11;

		private const int MinimumArrayPoolLength = 256;

		private char[]? _arrayToReturnToPool;

		private Span<char> _chars;

		private int _pos;

		private int holeBegin;

		private int holePos;

		private Memory<MessageHole> holes;

		internal readonly bool enabled;

		internal ReadOnlySpan<char> Text => _chars.Slice(0, _pos);

		public DebugLogInterpolatedStringHandler(int literalLength, int formattedCount, bool enabled, bool recordHoles, out bool isEnabled)
		{
			_pos = (holeBegin = (holePos = 0));
			this.enabled = (isEnabled = enabled);
			if (enabled)
			{
				_chars = (_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount)));
				if (recordHoles)
				{
					holes = new MessageHole[formattedCount];
				}
				else
				{
					holes = default(Memory<MessageHole>);
				}
			}
			else
			{
				_chars = (_arrayToReturnToPool = null);
				holes = default(Memory<MessageHole>);
			}
		}

		public DebugLogInterpolatedStringHandler(int literalLength, int formattedCount, out bool isEnabled)
		{
			DebugLog instance = DebugLog.Instance;
			_pos = (holeBegin = (holePos = 0));
			if (instance.ShouldLog)
			{
				enabled = (isEnabled = true);
				_chars = (_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount)));
				if (instance.RecordHoles)
				{
					holes = new MessageHole[formattedCount];
				}
				else
				{
					holes = default(Memory<MessageHole>);
				}
			}
			else
			{
				enabled = (isEnabled = false);
				_chars = (_arrayToReturnToPool = null);
				holes = default(Memory<MessageHole>);
			}
		}

		public DebugLogInterpolatedStringHandler(int literalLength, int formattedCount, LogLevel level, out bool isEnabled)
		{
			DebugLog instance = DebugLog.Instance;
			_pos = (holeBegin = (holePos = 0));
			if (instance.ShouldLogLevel(level))
			{
				enabled = (isEnabled = true);
				_chars = (_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount)));
				if (instance.ShouldLevelRecordHoles(level))
				{
					holes = new MessageHole[formattedCount];
				}
				else
				{
					holes = default(Memory<MessageHole>);
				}
			}
			else
			{
				enabled = (isEnabled = false);
				_chars = (_arrayToReturnToPool = null);
				holes = default(Memory<MessageHole>);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static int GetDefaultLength(int literalLength, int formattedCount)
		{
			return Math.Max(256, literalLength + formattedCount * 11);
		}

		public override string ToString()
		{
			return Text.ToString();
		}

		public string ToStringAndClear()
		{
			string result = Text.ToString();
			Clear();
			return result;
		}

		internal string ToStringAndClear(out ReadOnlyMemory<MessageHole> holes)
		{
			holes = this.holes;
			return ToStringAndClear();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal void Clear()
		{
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			this = default(DebugLogInterpolatedStringHandler);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendLiteral(string value)
		{
			if (value.Length == 1)
			{
				Span<char> chars = _chars;
				int pos = _pos;
				if ((uint)pos < (uint)chars.Length)
				{
					chars[pos] = value[0];
					_pos = pos + 1;
				}
				else
				{
					GrowThenCopyString(value);
				}
			}
			else if (value.Length == 2)
			{
				Span<char> chars2 = _chars;
				int pos2 = _pos;
				if ((uint)pos2 < chars2.Length - 1)
				{
					value.AsSpan().CopyTo(chars2.Slice(pos2));
					_pos = pos2 + 2;
				}
				else
				{
					GrowThenCopyString(value);
				}
			}
			else
			{
				AppendStringDirect(value);
			}
		}

		private void AppendStringDirect(string value)
		{
			if (value.AsSpan().TryCopyTo(_chars.Slice(_pos)))
			{
				_pos += value.Length;
			}
			else
			{
				GrowThenCopyString(value);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void BeginHole()
		{
			holeBegin = _pos;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void EndHole(object? obj, bool reprd)
		{
			EndHole(in obj, reprd);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void EndHole<T>(in T obj, bool reprd)
		{
			if (!holes.IsEmpty)
			{
				holes.Span[holePos++] = (reprd ? new MessageHole(holeBegin, _pos, obj) : new MessageHole(holeBegin, _pos));
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(string? value)
		{
			BeginHole();
			if (value != null && value.AsSpan().TryCopyTo(_chars.Slice(_pos)))
			{
				_pos += value.Length;
			}
			else
			{
				AppendFormattedSlow(value);
			}
			EndHole(in value, reprd: true);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void AppendFormattedSlow(string? value)
		{
			if (value != null)
			{
				EnsureCapacityForAdditionalChars(value.Length);
				value.AsSpan().CopyTo(_chars.Slice(_pos));
				_pos += value.Length;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted(string? value, int alignment = 0, string? format = null)
		{
			this.AppendFormatted<string>(value, alignment, format);
		}

		public void AppendFormatted(ReadOnlySpan<char> value)
		{
			BeginHole();
			if (value.TryCopyTo(_chars.Slice(_pos)))
			{
				_pos += value.Length;
			}
			else
			{
				GrowThenCopySpan(value);
			}
			EndHole(null, reprd: false);
		}

		public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
		{
			bool flag = false;
			if (alignment < 0)
			{
				flag = true;
				alignment = -alignment;
			}
			int num = alignment - value.Length;
			if (num <= 0)
			{
				AppendFormatted(value);
				return;
			}
			BeginHole();
			EnsureCapacityForAdditionalChars(value.Length + num);
			if (flag)
			{
				value.CopyTo(_chars.Slice(_pos));
				_pos += value.Length;
				_chars.Slice(_pos, num).Fill(' ');
				_pos += num;
			}
			else
			{
				_chars.Slice(_pos, num).Fill(' ');
				_pos += num;
				value.CopyTo(_chars.Slice(_pos));
				_pos += value.Length;
			}
			EndHole(null, reprd: false);
		}

		public void AppendFormatted<T>(T value)
		{
			if (typeof(T) == typeof(IntPtr))
			{
				AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, IntPtr>(ref value));
				return;
			}
			if (typeof(T) == typeof(UIntPtr))
			{
				AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, UIntPtr>(ref value));
				return;
			}
			BeginHole();
			if (DebugFormatter.CanDebugFormat(in value, out object extraData))
			{
				int wrote;
				while (!DebugFormatter.TryFormatInto(in value, extraData, _chars.Slice(_pos), out wrote))
				{
					Grow();
				}
				_pos += wrote;
				return;
			}
			string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(null, null));
			if (text != null)
			{
				AppendStringDirect(text);
			}
			EndHole(in value, reprd: true);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void AppendFormatted(IntPtr value)
		{
			if (IntPtr.Size == 4)
			{
				AppendFormatted((int)value);
			}
			else
			{
				AppendFormatted((long)value);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void AppendFormatted(IntPtr value, string? format)
		{
			if (IntPtr.Size == 4)
			{
				AppendFormatted((int)value, format);
			}
			else
			{
				AppendFormatted((long)value, format);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void AppendFormatted(UIntPtr value)
		{
			if (UIntPtr.Size == 4)
			{
				AppendFormatted((uint)value);
			}
			else
			{
				AppendFormatted((ulong)value);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void AppendFormatted(UIntPtr value, string? format)
		{
			if (UIntPtr.Size == 4)
			{
				AppendFormatted((uint)value, format);
			}
			else
			{
				AppendFormatted((ulong)value, format);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, int alignment)
		{
			int pos = _pos;
			AppendFormatted(value);
			if (alignment != 0)
			{
				AppendOrInsertAlignmentIfNeeded(pos, alignment);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, string? format)
		{
			if (typeof(T) == typeof(IntPtr))
			{
				AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, IntPtr>(ref value), format);
				return;
			}
			if (typeof(T) == typeof(UIntPtr))
			{
				AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, UIntPtr>(ref value), format);
				return;
			}
			BeginHole();
			if (DebugFormatter.CanDebugFormat(in value, out object extraData))
			{
				int wrote;
				while (!DebugFormatter.TryFormatInto(in value, extraData, _chars.Slice(_pos), out wrote))
				{
					Grow();
				}
				_pos += wrote;
				return;
			}
			string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(format, null));
			if (text != null)
			{
				AppendStringDirect(text);
			}
			EndHole(in value, reprd: true);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void AppendFormatted<T>(T value, int alignment, string? format)
		{
			int pos = _pos;
			AppendFormatted(value, format);
			if (alignment != 0)
			{
				AppendOrInsertAlignmentIfNeeded(pos, alignment);
			}
		}

		private void AppendOrInsertAlignmentIfNeeded(int startingPos, int alignment)
		{
			int num = _pos - startingPos;
			bool flag = false;
			if (alignment < 0)
			{
				flag = true;
				alignment = -alignment;
			}
			int num2 = alignment - num;
			if (num2 > 0)
			{
				EnsureCapacityForAdditionalChars(num2);
				if (flag)
				{
					_chars.Slice(_pos, num2).Fill(' ');
				}
				else
				{
					_chars.Slice(startingPos, num).CopyTo(_chars.Slice(startingPos + num2));
					_chars.Slice(startingPos, num2).Fill(' ');
				}
				_pos += num2;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void EnsureCapacityForAdditionalChars(int additionalChars)
		{
			if (_chars.Length - _pos < additionalChars)
			{
				Grow(additionalChars);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void GrowThenCopyString(string value)
		{
			Grow(value.Length);
			value.AsSpan().CopyTo(_chars.Slice(_pos));
			_pos += value.Length;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void GrowThenCopySpan(ReadOnlySpan<char> value)
		{
			Grow(value.Length);
			value.CopyTo(_chars.Slice(_pos));
			_pos += value.Length;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void Grow(int additionalChars)
		{
			GrowCore((uint)(_pos + additionalChars));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void Grow()
		{
			GrowCore((uint)(_chars.Length + 1));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void GrowCore(uint requiredMinCapacity)
		{
			int minimumLength = (int)MathEx.Clamp(Math.Max(requiredMinCapacity, Math.Min((uint)(_chars.Length * 2), uint.MaxValue)), 256u, 2147483647u);
			char[] array = ArrayPool<char>.Shared.Rent(minimumLength);
			_chars.Slice(0, _pos).CopyTo(array);
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			_chars = (_arrayToReturnToPool = array);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}
	}
	[InterpolatedStringHandler]
	public ref struct FormatIntoInterpolatedStringHandler
	{
		private readonly Span<char> _chars;

		internal int pos;

		internal bool incomplete;

		public FormatIntoInterpolatedStringHandler(int literalLen, int numHoles, Span<char> into, out bool enabled)
		{
			_chars = into;
			pos = 0;
			if (into.Length < literalLen)
			{
				incomplete = true;
				enabled = false;
			}
			else
			{
				incomplete = false;
				enabled = true;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendLiteral(string value)
		{
			if (value.Length == 1)
			{
				Span<char> chars = _chars;
				int num = pos;
				if ((uint)num < (uint)chars.Length)
				{
					chars[num] = value[0];
					pos = num + 1;
					return true;
				}
				incomplete = true;
				return false;
			}
			if (value.Length == 2)
			{
				Span<char> chars2 = _chars;
				int num2 = pos;
				if ((uint)num2 < chars2.Length - 1)
				{
					value.AsSpan().CopyTo(chars2.Slice(num2));
					pos = num2 + 2;
					return true;
				}
				incomplete = true;
				return false;
			}
			return AppendStringDirect(value);
		}

		private bool AppendStringDirect(string value)
		{
			if (value.AsSpan().TryCopyTo(_chars.Slice(pos)))
			{
				pos += value.Length;
				return true;
			}
			incomplete = true;
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendFormatted(string? value)
		{
			if (value == null)
			{
				return true;
			}
			if (value.AsSpan().TryCopyTo(_chars.Slice(pos)))
			{
				pos += value.Length;
				return true;
			}
			incomplete = true;
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendFormatted(string? value, int alignment = 0, string? format = null)
		{
			return this.AppendFormatted<string>(value, alignment, format);
		}

		public bool AppendFormatted(ReadOnlySpan<char> value)
		{
			if (value.TryCopyTo(_chars.Slice(pos)))
			{
				pos += value.Length;
				return true;
			}
			incomplete = true;
			return false;
		}

		public bool AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
		{
			bool flag = false;
			if (alignment < 0)
			{
				flag = true;
				alignment = -alignment;
			}
			int num = alignment - value.Length;
			if (num <= 0)
			{
				return AppendFormatted(value);
			}
			if (_chars.Slice(pos).Length < value.Length + num)
			{
				incomplete = true;
				return false;
			}
			if (flag)
			{
				value.CopyTo(_chars.Slice(pos));
				pos += value.Length;
				_chars.Slice(pos, num).Fill(' ');
				pos += num;
			}
			else
			{
				_chars.Slice(pos, num).Fill(' ');
				pos += num;
				value.CopyTo(_chars.Slice(pos));
				pos += value.Length;
			}
			return true;
		}

		public bool AppendFormatted<T>(T value)
		{
			if (typeof(T) == typeof(IntPtr))
			{
				return AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, IntPtr>(ref value));
			}
			if (typeof(T) == typeof(UIntPtr))
			{
				return AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, UIntPtr>(ref value));
			}
			if (DebugFormatter.CanDebugFormat(in value, out object extraData))
			{
				if (!DebugFormatter.TryFormatInto(in value, extraData, _chars.Slice(pos), out var wrote))
				{
					incomplete = true;
					return false;
				}
				pos += wrote;
				return true;
			}
			string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(null, null));
			if (text != null)
			{
				return AppendStringDirect(text);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private bool AppendFormatted(IntPtr value)
		{
			if (IntPtr.Size == 4)
			{
				return AppendFormatted((int)value);
			}
			return AppendFormatted((long)value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private bool AppendFormatted(IntPtr value, string? format)
		{
			if (IntPtr.Size == 4)
			{
				return AppendFormatted((int)value, format);
			}
			return AppendFormatted((long)value, format);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private bool AppendFormatted(UIntPtr value)
		{
			if (UIntPtr.Size == 4)
			{
				return AppendFormatted((uint)value);
			}
			return AppendFormatted((ulong)value);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private bool AppendFormatted(UIntPtr value, string? format)
		{
			if (UIntPtr.Size == 4)
			{
				return AppendFormatted((uint)value, format);
			}
			return AppendFormatted((ulong)value, format);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendFormatted<T>(T value, int alignment)
		{
			int startingPos = pos;
			if (!AppendFormatted(value))
			{
				return false;
			}
			if (alignment != 0)
			{
				return AppendOrInsertAlignmentIfNeeded(startingPos, alignment);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendFormatted<T>(T value, string? format)
		{
			if (typeof(T) == typeof(IntPtr))
			{
				return AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, IntPtr>(ref value), format);
			}
			if (typeof(T) == typeof(UIntPtr))
			{
				return AppendFormatted(System.Runtime.CompilerServices.Unsafe.As<T, UIntPtr>(ref value), format);
			}
			if (DebugFormatter.CanDebugFormat(in value, out object extraData))
			{
				if (!DebugFormatter.TryFormatInto(in value, extraData, _chars.Slice(pos), out var wrote))
				{
					incomplete = true;
					return false;
				}
				pos += wrote;
				return true;
			}
			string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(format, null));
			if (text != null)
			{
				return AppendStringDirect(text);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool AppendFormatted<T>(T value, int alignment, string? format)
		{
			int startingPos = pos;
			if (!AppendFormatted(value, format))
			{
				return false;
			}
			if (alignment != 0)
			{
				return AppendOrInsertAlignmentIfNeeded(startingPos, alignment);
			}
			return true;
		}

		private bool AppendOrInsertAlignmentIfNeeded(int startingPos, int alignment)
		{
			int num = pos - startingPos;
			bool flag = false;
			if (alignment < 0)
			{
				flag = true;
				alignment = -alignment;
			}
			int num2 = alignment - num;
			if (num2 > 0)
			{
				if (_chars.Slice(pos).Length < num2)
				{
					incomplete = true;
					return false;
				}
				if (flag)
				{
					_chars.Slice(pos, num2).Fill(' ');
				}
				else
				{
					_chars.Slice(startingPos, num).CopyTo(_chars.Slice(startingPos + num2));
					_chars.Slice(startingPos, num2).Fill(' ');
				}
				pos += num2;
			}
			return true;
		}
	}
	public interface IDebugFormattable
	{
		bool TryFormatInto(Span<char> span, out int wrote);
	}
	public enum LogLevel
	{
		Spam,
		Trace,
		Info,
		Warning,
		Error,
		Assert
	}
	[Flags]
	public enum LogLevelFilter
	{
		None = 0,
		Spam = 1,
		Trace = 2,
		Info = 4,
		Warning = 8,
		Error = 0x10,
		Assert = 0x20,
		DefaultFilter = -2
	}
	public static class LogLevelExtensions
	{
		public const LogLevel MaxLevel = LogLevel.Assert;

		public static string FastToString(this LogLevel level, IFormatProvider? provider = null)
		{
			switch (level)
			{
			case LogLevel.Spam:
				return "Spam";
			case LogLevel.Trace:
				return "Trace";
			case LogLevel.Info:
				return "Info";
			case LogLevel.Warning:
				return "Warning";
			case LogLevel.Error:
				return "Error";
			case LogLevel.Assert:
				return "Assert";
			default:
			{
				int num = (int)level;
				return num.ToString(provider);
			}
			}
		}
	}
}
namespace MonoMod.Cil
{
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class GetFastDelegateInvokersArrayAttribute : Attribute
	{
		public int MaxParams { get; }

		public GetFastDelegateInvokersArrayAttribute(int maxParams)
		{
			MaxParams = maxParams;
		}
	}
	public static class FastDelegateInvokers
	{
		private delegate void VoidVal1<T0>(T0 _0);

		private delegate TResult TypeVal1<TResult, T0>(T0 _0);

		private delegate void VoidRef1<T0>(ref T0 _0);

		private delegate TResult TypeRef1<TResult, T0>(ref T0 _0);

		private delegate void VoidVal2<T0, T1>(T0 _0, T1 _1);

		private delegate TResult TypeVal2<TResult, T0, T1>(T0 _0, T1 _1);

		private delegate void VoidRef2<T0, T1>(ref T0 _0, T1 _1);

		private delegate TResult TypeRef2<TResult, T0, T1>(ref T0 _0, T1 _1);

		private delegate void VoidVal3<T0, T1, T2>(T0 _0, T1 _1, T2 _2);

		private delegate TResult TypeVal3<TResult, T0, T1, T2>(T0 _0, T1 _1, T2 _2);

		private delegate void VoidRef3<T0, T1, T2>(ref T0 _0, T1 _1, T2 _2);

		private delegate TResult TypeRef3<TResult, T0, T1, T2>(ref T0 _0, T1 _1, T2 _2);

		private delegate void VoidVal4<T0, T1, T2, T3>(T0 _0, T1 _1, T2 _2, T3 _3);

		private delegate TResult TypeVal4<TResult, T0, T1, T2, T3>(T0 _0, T1 _1, T2 _2, T3 _3);

		private delegate void VoidRef4<T0, T1, T2, T3>(ref T0 _0, T1 _1, T2 _2, T3 _3);

		private delegate TResult TypeRef4<TResult, T0, T1, T2, T3>(ref T0 _0, T1 _1, T2 _2, T3 _3);

		private delegate void VoidVal5<T0, T1, T2, T3, T4>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4);

		private delegate TResult TypeVal5<TResult, T0, T1, T2, T3, T4>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4);

		private delegate void VoidRef5<T0, T1, T2, T3, T4>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4);

		private delegate TResult TypeRef5<TResult, T0, T1, T2, T3, T4>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4);

		private delegate void VoidVal6<T0, T1, T2, T3, T4, T5>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5);

		private delegate TResult TypeVal6<TResult, T0, T1, T2, T3, T4, T5>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5);

		private delegate void VoidRef6<T0, T1, T2, T3, T4, T5>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5);

		private delegate TResult TypeRef6<TResult, T0, T1, T2, T3, T4, T5>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5);

		private delegate void VoidVal7<T0, T1, T2, T3, T4, T5, T6>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6);

		private delegate TResult TypeVal7<TResult, T0, T1, T2, T3, T4, T5, T6>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6);

		private delegate void VoidRef7<T0, T1, T2, T3, T4, T5, T6>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6);

		private delegate TResult TypeRef7<TResult, T0, T1, T2, T3, T4, T5, T6>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6);

		private delegate void VoidVal8<T0, T1, T2, T3, T4, T5, T6, T7>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7);

		private delegate TResult TypeVal8<TResult, T0, T1, T2, T3, T4, T5, T6, T7>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7);

		private delegate void VoidRef8<T0, T1, T2, T3, T4, T5, T6, T7>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7);

		private delegate TResult TypeRef8<TResult, T0, T1, T2, T3, T4, T5, T6, T7>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7);

		private delegate void VoidVal9<T0, T1, T2, T3, T4, T5, T6, T7, T8>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8);

		private delegate TResult TypeVal9<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8);

		private delegate void VoidRef9<T0, T1, T2, T3, T4, T5, T6, T7, T8>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8);

		private delegate TResult TypeRef9<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8);

		private delegate void VoidVal10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9);

		private delegate TResult TypeVal10<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9);

		private delegate void VoidRef10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9);

		private delegate TResult TypeRef10<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9);

		private delegate void VoidVal11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10);

		private delegate TResult TypeVal11<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10);

		private delegate void VoidRef11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10);

		private delegate TResult TypeRef11<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10);

		private delegate void VoidVal12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11);

		private delegate TResult TypeVal12<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11);

		private delegate void VoidRef12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11);

		private delegate TResult TypeRef12<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11);

		private delegate void VoidVal13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12);

		private delegate TResult TypeVal13<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12);

		private delegate void VoidRef13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12);

		private delegate TResult TypeRef13<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12);

		private delegate void VoidVal14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13);

		private delegate TResult TypeVal14<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13);

		private delegate void VoidRef14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13);

		private delegate TResult TypeRef14<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13);

		private delegate void VoidVal15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14);

		private delegate TResult TypeVal15<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14);

		private delegate void VoidRef15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14);

		private delegate TResult TypeRef15<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14);

		private delegate void VoidVal16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14, T15 _15);

		private delegate TResult TypeVal16<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14, T15 _15);

		private delegate void VoidRef16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14, T15 _15);

		private delegate TResult TypeRef16<TResult, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(ref T0 _0, T1 _1, T2 _2, T3 _3, T4 _4, T5 _5, T6 _6, T7 _7, T8 _8, T9 _9, T10 _10, T11 _11, T12 _12, T13 _13, T14 _14, T15 _15);

		private static readonly (MethodInfo, Type)[] invokers = GetInvokers();

		private const int MaxFastInvokerParams = 16;

		private static readonly ConditionalWeakTable<Type, Tuple<MethodInfo?, Type>> invokerCache = new ConditionalWeakTable<Type, Tuple<MethodInfo, Type>>();

		[GetFastDelegateInvokersArray(16)]
		private static (MethodInfo, Type)[] GetInvokers()
		{
			return new(MethodInfo, Type)[64]
			{
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal1", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal1<>)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal1", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal1<, >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef1", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef1<>)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef1", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef1<, >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal2", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal2<, >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal2", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal2<, , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef2", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef2<, >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef2", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef2<, , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal3", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal3<, , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal3", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal3<, , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef3", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef3<, , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef3", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef3<, , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal4", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal4<, , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal4", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal4<, , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef4", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef4<, , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef4", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef4<, , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal5", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal5<, , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal5", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal5<, , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef5", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef5<, , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef5", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef5<, , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal6", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal6<, , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal6", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal6<, , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef6", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef6<, , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef6", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef6<, , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal7", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal7<, , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal7", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal7<, , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef7", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef7<, , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef7", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef7<, , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal8", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal8<, , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal8", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal8<, , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef8", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef8<, , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef8", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef8<, , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal9", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal9<, , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal9", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal9<, , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef9", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef9<, , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef9", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef9<, , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal10", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal10<, , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal10", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal10<, , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef10", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef10<, , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef10", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef10<, , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal11", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal11<, , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal11", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal11<, , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef11", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef11<, , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef11", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef11<, , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal12", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal12<, , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal12", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal12<, , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef12", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef12<, , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef12", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef12<, , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal13", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal13<, , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal13", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal13<, , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef13", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef13<, , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef13", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef13<, , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal14", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal14<, , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal14", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal14<, , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef14", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef14<, , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef14", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef14<, , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal15", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal15<, , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal15", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal15<, , , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef15", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef15<, , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef15", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef15<, , , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidVal16", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidVal16<, , , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeVal16", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeVal16<, , , , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeVoidRef16", BindingFlags.Static | BindingFlags.NonPublic), typeof(VoidRef16<, , , , , , , , , , , , , , , >)),
				(typeof(FastDelegateInvokers).GetMethod("InvokeTypeRef16", BindingFlags.Static | BindingFlags.NonPublic), typeof(TypeRef16<, , , , , , , , , , , , , , , , >))
			};
		}

		private static (MethodInfo Invoker, Type Delegate)? TryGetInvokerForSig(MethodSignature sig)
		{
			if (sig.ParameterCount == 0)
			{
				return null;
			}
			if (sig.ParameterCount > 16)
			{
				return null;
			}
			if (sig.ReturnType.IsByRef || TypeExtensions.IsByRefLike(sig.ReturnType))
			{
				return null;
			}
			if (TypeExtensions.IsByRefLike(sig.FirstParameter))
			{
				return null;
			}
			if (sig.Parameters.Skip(1).Any((Type t) => t.IsByRef || TypeExtensions.IsByRefLike(t)))
			{
				return null;
			}
			int num = 0;
			num |= ((sig.ReturnType != typeof(void)) ? 1 : 0);
			num |= (sig.FirstParameter.IsByRef ? 2 : 0);
			num |= sig.ParameterCount - 1 << 2;
			(MethodInfo, Type) tuple = invokers[num];
			MethodInfo item = tuple.Item1;
			Type item2 = tuple.Item2;
			Type[] array = new Type[sig.ParameterCount + (num & 1)];
			int num2 = 0;
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				array[num2++] = sig.ReturnType;
			}
			foreach (Type parameter in sig.Parameters)
			{
				Type type = parameter;
				if (type.IsByRef)
				{
					type = type.GetElementType();
				}
				array[nu

plugins/RuntimeUnityEditor.Bepin5.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using RuntimeUnityEditor.Bepin5.LogViewer;
using RuntimeUnityEditor.Core;
using RuntimeUnityEditor.Core.Inspector;
using RuntimeUnityEditor.Core.Inspector.Entries;
using RuntimeUnityEditor.Core.Utils;
using RuntimeUnityEditor.Core.Utils.Abstractions;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RuntimeUnityEditor.Bepin5")]
[assembly: AssemblyDescription("Debugging tool for applications made with Unity3D game engine (Mono runtime)")]
[assembly: AssemblyCompany("https://github.com/ManlyMarco/RuntimeUnityEditor")]
[assembly: AssemblyProduct("RuntimeUnityEditor.Bepin5")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: ComVisible(false)]
[assembly: Guid("e64cb875-bafa-4b0f-bdc9-e33a15d5a87e")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("5.5.1.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
namespace RuntimeUnityEditor.Bepin5
{
	[Obsolete("It's recommended to reference RuntimeUnityEditorCore directly")]
	[BepInPlugin("RuntimeUnityEditor", "Runtime Unity Editor", "5.5.1")]
	public class RuntimeUnityEditor5 : BaseUnityPlugin
	{
		private sealed class Bep5InitSettings : InitSettings
		{
			private readonly RuntimeUnityEditor5 _instance;

			public override MonoBehaviour PluginMonoBehaviour => (MonoBehaviour)(object)_instance;

			public override ILoggerWrapper LoggerWrapper { get; }

			public override string ConfigPath => Paths.ConfigPath;

			public Bep5InitSettings(RuntimeUnityEditor5 instance)
			{
				_instance = instance;
				LoggerWrapper = (ILoggerWrapper)(object)new Logger5(((BaseUnityPlugin)_instance).Logger);
			}

			public override Action<T> RegisterSetting<T>(string category, string name, T defaultValue, string description, Action<T> onValueUpdated)
			{
				ConfigEntry<T> s = ((BaseUnityPlugin)_instance).Config.Bind<T>(category, name, defaultValue, description);
				s.SettingChanged += delegate
				{
					onValueUpdated(s.Value);
				};
				onValueUpdated(s.Value);
				return delegate(T x)
				{
					s.Value = x;
				};
			}
		}

		private sealed class Logger5 : ILoggerWrapper
		{
			private readonly ManualLogSource _logger;

			public Logger5(ManualLogSource logger)
			{
				_logger = logger;
			}

			public void Log(LogLevel logLevel, object content)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				_logger.Log((LogLevel)logLevel, content);
			}
		}

		private static RuntimeUnityEditorCore Instance { get; set; }

		private void Start()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			if (!TomlTypeConverter.CanConvert(typeof(Rect)))
			{
				TypeConverter converter = TomlTypeConverter.GetConverter(typeof(Rect));
				TomlTypeConverter.AddConverter(typeof(Rect), new TypeConverter
				{
					ConvertToObject = converter.ConvertToObject,
					ConvertToString = converter.ConvertToString
				});
			}
			Instance = new RuntimeUnityEditorCore((InitSettings)(object)new Bep5InitSettings(this));
			Instance.AddFeature((IFeature)(object)new LogViewerWindow());
		}

		private void Update()
		{
			Instance.Update();
		}

		private void LateUpdate()
		{
			Instance.LateUpdate();
		}

		private void OnGUI()
		{
			Instance.OnGUI();
		}
	}
}
namespace RuntimeUnityEditor.Bepin5.LogViewer
{
	internal readonly struct LogViewerEntry
	{
		private readonly GUIContent _timeString;

		private readonly GUIContent _logLevelString;

		private readonly GUIContent _sourceNameString;

		private readonly GUIContent _dataString;

		private const int SkippedStackFrames = 4;

		private static bool _stacktraceTostringFallback;

		public MethodBase Method { get; }

		public LogEventArgs LogEventArgs { get; }

		public StackFrame[] FilteredStackTrace { get; }

		public string FilteredStackTraceString { get; }

		public object Sender { get; }

		private LogViewerEntry(object sender, LogEventArgs logEventArgs, StackFrame[] filteredStackTrace, string filteredStackTraceString)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_005e: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			Sender = sender;
			LogEventArgs = logEventArgs;
			FilteredStackTrace = filteredStackTrace;
			FilteredStackTraceString = filteredStackTraceString;
			Method = ((filteredStackTrace != null && filteredStackTrace.Length != 0) ? filteredStackTrace[0].GetMethod() : null);
			string text = "Filtered stack trace of this log write:\n\n" + filteredStackTraceString;
			_timeString = new GUIContent(DateTime.UtcNow.ToShortTimeString(), text);
			LogLevel level = logEventArgs.Level;
			_logLevelString = new GUIContent(((object)(LogLevel)(ref level)).ToString(), text);
			_sourceNameString = new GUIContent(logEventArgs.Source.SourceName, text);
			_dataString = new GUIContent(logEventArgs.Data?.ToString() ?? "NULL", text);
		}

		public string GetClipboardString()
		{
			object[] obj = new object[7] { _timeString, _logLevelString, _sourceNameString, _dataString, FilteredStackTraceString, Sender, null };
			object sender = Sender;
			obj[6] = ((sender != null) ? TypeNameExtensions.GetSourceCodeRepresentation(sender.GetType()) : null) ?? "NULL";
			return string.Format("{0} {1} {2} {3}\n{4}\nSender: {5} ({6})", obj);
		}

		public bool DrawEntry()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = GetColor();
			bool flag = GUILayout.Button(_timeString, GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(35f) });
			GUILayout.Label("[", IMGUIUtils.LayoutOptionsExpandWidthFalse);
			flag |= GUILayout.Button(_logLevelString, GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(45f) });
			GUILayout.Label(":", IMGUIUtils.LayoutOptionsExpandWidthFalse);
			flag |= GUILayout.Button(_sourceNameString, GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(100f) });
			GUILayout.Label("]", IMGUIUtils.LayoutOptionsExpandWidthFalse);
			GUI.color = Color.white;
			return flag | GUILayout.Button(_dataString, GUI.skin.label, IMGUIUtils.LayoutOptionsExpandWidthTrue);
		}

		public Color GetColor()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0045: 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_0035: 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_0055: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			LogLevel level = LogEventArgs.Level;
			LogLevel val = level;
			if ((int)val <= 4)
			{
				if (val - 1 <= 1)
				{
					return Color.red;
				}
				if ((int)val == 4)
				{
					return Color.yellow;
				}
			}
			else if ((int)val != 8 && (int)val != 16 && (int)val == 32)
			{
				return Color.gray;
			}
			return Color.white;
		}

		public bool IsMatch(string searchString, LogLevel logLevelFilter)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return (logLevelFilter & LogEventArgs.Level) != 0 && (string.IsNullOrEmpty(searchString) || Extensions.REContains(_dataString.text, searchString, StringComparison.OrdinalIgnoreCase) || Extensions.REContains(FilteredStackTraceString, searchString, StringComparison.OrdinalIgnoreCase) || Extensions.REContains(LogEventArgs.Source.SourceName, searchString, StringComparison.OrdinalIgnoreCase));
		}

		public static LogViewerEntry CreateFromLogEventArgs(object sender, LogEventArgs eventArgs)
		{
			StackTrace stackTrace = new StackTrace(4);
			StackFrame[] filteredFrames = null;
			string filteredStackTraceString;
			while (true)
			{
				if (!_stacktraceTostringFallback)
				{
					try
					{
						filteredStackTraceString = ParseStackTrace(stackTrace, out filteredFrames);
					}
					catch (Exception ex)
					{
						RuntimeUnityEditorCore.Logger.Log((LogLevel)2, (object)("[LogViewerWindow] Crash when trying to parse stack trace, falling back to using ToString\n" + ex));
						_stacktraceTostringFallback = true;
						continue;
					}
				}
				else
				{
					filteredStackTraceString = ParseStackTraceString(stackTrace);
					try
					{
						filteredFrames = stackTrace.GetFrames();
					}
					catch (Exception value)
					{
						Console.WriteLine(value);
					}
				}
				break;
			}
			return new LogViewerEntry(sender, eventArgs, filteredFrames, filteredStackTraceString);
		}

		private static string ParseStackTrace(StackTrace st, out StackFrame[] filteredFrames)
		{
			filteredFrames = null;
			StackFrame[] frames = st.GetFrames();
			if (frames == null || frames.Length == 0)
			{
				return ParseStackTraceString(st);
			}
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = false;
			int count = 0;
			for (int i = 0; i < frames.Length; i++)
			{
				StackFrame stackFrame = frames[i];
				MethodBase method = stackFrame.GetMethod();
				string name = method.Name;
				Type? obj = method.DeclaringType ?? method.ReflectedType;
				string text = (((object)obj != null) ? TypeNameExtensions.GetSourceCodeRepresentation(obj) : null) ?? "???";
				bool flag2 = false;
				if (!flag)
				{
					if (text.StartsWith("BepInEx.", StringComparison.Ordinal) || text.StartsWith("System.", StringComparison.Ordinal) || (text.StartsWith("UnityEngine.", StringComparison.Ordinal) && Extensions.REContains(name, "Log", StringComparison.Ordinal)) || (text.StartsWith("RuntimeUnityEditor", StringComparison.Ordinal) && name.Equals("Log", StringComparison.Ordinal)))
					{
						continue;
					}
					flag = true;
					flag2 = true;
				}
				if (flag2)
				{
					count = i;
				}
				stringBuilder.AppendFormat("[{0}] ", i + 4);
				stringBuilder.Append(text);
				stringBuilder.Append('.');
				stringBuilder.Append(name);
				stringBuilder.AppendLine();
			}
			filteredFrames = frames.Skip(count).ToArray();
			if (stringBuilder.Length == 0)
			{
				stringBuilder.Append("\u00af\\_(ツ)_/\u00af");
			}
			return stringBuilder.ToString();
		}

		private static string ParseStackTraceString(StackTrace st)
		{
			string[] array = st.ToString().Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
			int num = Array.FindIndex(array, (string part) => !part.Contains("at BepInEx.") && !part.Contains("at System."));
			if (num >= 0)
			{
				string[] array2 = new string[array.Length - num];
				Array.Copy(array, num, array2, 0, array.Length - num);
				return "Origin: " + string.Join("\n", array2);
			}
			return string.Empty;
		}
	}
	internal sealed class LogViewerListener : ILogListener, IDisposable
	{
		private readonly LogViewerWindow _owner;

		public LogViewerListener(LogViewerWindow owner)
		{
			_owner = owner;
		}

		public void Dispose()
		{
		}

		public void LogEvent(object sender, LogEventArgs eventArgs)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if ((_owner.LogLevelFilter & eventArgs.Level) == 0)
			{
				return;
			}
			try
			{
				_owner.OnLogEvent(sender, eventArgs);
			}
			catch (Exception ex)
			{
				RuntimeUnityEditorCore.Logger.Log((LogLevel)2, (object)("[LogViewerWindow] Unexpected crash when trying to parse stack trace, disabling log capture!" + ex));
				_owner.Capture = false;
			}
		}
	}
	public sealed class LogViewerWindow : Window<LogViewerWindow>
	{
		private bool _captureOnStartup;

		private Action<bool> _captureOnStartupCallback;

		private bool _capture;

		private LogViewerListener _listener;

		private Action<LogLevel> _logLevelFilterCallback;

		private LogLevel _logLevelFilter;

		private string _searchString;

		private readonly List<LogViewerEntry> _logEntries = new List<LogViewerEntry>();

		private readonly List<LogViewerEntry> _filteredLogEntries = new List<LogViewerEntry>();

		private Vector2 _scrollPosition;

		private int _itemHeight;

		public bool CaptureOnStartup
		{
			get
			{
				return _captureOnStartup;
			}
			set
			{
				if (_captureOnStartup != value)
				{
					_captureOnStartup = value;
					_captureOnStartupCallback(value);
				}
			}
		}

		public bool Capture
		{
			get
			{
				return _capture;
			}
			set
			{
				if (_capture != value)
				{
					_capture = value;
					if (_capture)
					{
						Logger.Listeners.Add((ILogListener)(object)_listener);
					}
					else
					{
						Logger.Listeners.Remove((ILogListener)(object)_listener);
					}
				}
			}
		}

		public LogLevel LogLevelFilter
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _logLevelFilter;
			}
			set
			{
				//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_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				if (_logLevelFilter != value)
				{
					_logLevelFilter = value;
					_logLevelFilterCallback(value);
					UpdateFilteredLogEntries();
				}
			}
		}

		public string SearchString
		{
			get
			{
				return _searchString;
			}
			set
			{
				if (_searchString != value)
				{
					_searchString = value;
					UpdateFilteredLogEntries();
				}
			}
		}

		private void UpdateFilteredLogEntries()
		{
			_filteredLogEntries.Clear();
			_filteredLogEntries.AddRange(_logEntries.Where((LogViewerEntry entry) => entry.IsMatch(SearchString, LogLevelFilter)));
		}

		protected override void Initialize(InitSettings initSettings)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			((FeatureBase<LogViewerWindow>)(object)this).Enabled = false;
			base.DefaultScreenPosition = (ScreenPartition)12;
			((FeatureBase<LogViewerWindow>)(object)this).DisplayName = "Logger";
			((Window<LogViewerWindow>)this).Title = "BepInEx Log Viewer";
			base.MinimumSize = new Vector2(640f, 200f);
			_listener = new LogViewerListener(this);
			_captureOnStartupCallback = initSettings.RegisterSetting<bool>("Log Viewer", "Enable capture on startup", false, "Start capturing log messages as soon as possible after game starts.", (Action<bool>)delegate(bool b)
			{
				_captureOnStartup = b;
			});
			if (_captureOnStartup)
			{
				Capture = true;
			}
			_logLevelFilterCallback = initSettings.RegisterSetting<LogLevel>("Log Viewer", "Log level filter", (LogLevel)63, "Filter captured log messages by their log level.", (Action<LogLevel>)delegate(LogLevel level)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				_logLevelFilter = level;
			});
			ToStringConverter.AddConverter<ILogSource>((Func<ILogSource, string>)((ILogSource obj) => obj.SourceName + " (" + GetTrimmedTypeName(obj) + ")"));
			static string GetTrimmedTypeName(ILogSource obj)
			{
				string text = ((obj != null) ? TypeNameExtensions.GetSourceCodeRepresentation(((object)obj).GetType()) : null) ?? "NULL";
				if (text.StartsWith("BepInEx.Logging.", StringComparison.Ordinal))
				{
					text = text.Substring("BepInEx.Logging.".Length);
				}
				return text;
			}
		}

		protected override void DrawContents()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Expected O, but got Unknown
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Invalid comparison between Unknown and I4
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Invalid comparison between Unknown and I4
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(GUI.skin.box, IMGUIUtils.LayoutOptionsExpandWidthTrue);
			GUI.changed = false;
			string searchString = SearchString;
			bool flag = string.IsNullOrEmpty(searchString) && GUI.GetNameOfFocusedControl() != "sbox";
			if (flag)
			{
				GUI.color = Color.gray;
			}
			GUI.SetNextControlName("sbox");
			string searchString2 = GUILayout.TextField(flag ? "Search log text and stack traces..." : searchString, IMGUIUtils.LayoutOptionsExpandWidthTrue);
			if (GUI.changed)
			{
				SearchString = searchString2;
			}
			GUI.color = Color.white;
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(GUI.skin.box, IMGUIUtils.LayoutOptionsExpandWidthFalse);
			if (!Capture)
			{
				GUI.color = Color.red;
			}
			Capture = GUILayout.Toggle(Capture, new GUIContent("Enable log capture", "Note: This can hurt performance, especially if there is log spam."), Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			CaptureOnStartup = GUILayout.Toggle(CaptureOnStartup, new GUIContent("Enable on game startup", "Warning: This can hurt performance, especially after running for a while!"), Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Clear the list", Array.Empty<GUILayoutOption>()))
			{
				_logEntries.Clear();
				_filteredLogEntries.Clear();
			}
			GUILayout.EndHorizontal();
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.Label(new GUIContent("Captured log levels:", "Only new log messages with these levels will be captured, therefore enabling levels will not show past log messages!"), Array.Empty<GUILayoutOption>());
			LogLevel logLevelFilter = LogLevelFilter;
			LogLevel[] array = new LogLevel[7];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			LogLevel[] array2 = (LogLevel[])(object)array;
			for (int i = 0; i < array2.Length; i++)
			{
				LogLevel val = array2[i];
				GUI.changed = false;
				bool flag2 = GUILayout.Toggle((logLevelFilter & val) > 0, ((object)(LogLevel)(ref val)).ToString(), Array.Empty<GUILayoutOption>());
				if (GUI.changed)
				{
					LogLevelFilter = (LogLevel)(flag2 ? (logLevelFilter | val) : (logLevelFilter & ~val));
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Sources", Array.Empty<GUILayoutOption>()))
			{
				FeatureBase<Inspector>.Instance.Push((InspectorStackEntryBase)new InstanceStackEntry((object)Logger.Sources, "Log Sources"), true);
			}
			if (GUILayout.Button("Listeners", Array.Empty<GUILayoutOption>()))
			{
				FeatureBase<Inspector>.Instance.Push((InspectorStackEntryBase)new InstanceStackEntry((object)Logger.Listeners, "Log Listeners"), true);
			}
			GUILayout.EndHorizontal();
			GUILayout.EndHorizontal();
			bool flag3 = _itemHeight != 0;
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, Array.Empty<GUILayoutOption>());
			List<LogViewerEntry> filteredLogEntries = _filteredLogEntries;
			int num = (flag3 ? ((int)(_scrollPosition.y / (float)_itemHeight)) : 0);
			int num2;
			Rect val2;
			if (!flag3)
			{
				num2 = filteredLogEntries.Count;
			}
			else
			{
				val2 = ((Window<LogViewerWindow>)this).WindowRect;
				num2 = Mathf.Min((int)((Rect)(ref val2)).height / _itemHeight, filteredLogEntries.Count - num);
			}
			int num3 = num2;
			int num4 = filteredLogEntries.Count - num - num3 + 3;
			GUILayout.Space((float)(num * _itemHeight));
			for (int j = num; j < num + num3; j++)
			{
				LogViewerEntry logViewerEntry = filteredLogEntries[filteredLogEntries.Count - 1 - j];
				GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
				if (logViewerEntry.DrawEntry())
				{
					if (IMGUIUtils.IsMouseRightClick() && FeatureBase<ContextMenu>.Initialized)
					{
						if (logViewerEntry.Sender != null)
						{
							FeatureBase<ContextMenu>.Instance.Show(logViewerEntry.Sender, (MemberInfo)null);
						}
						else
						{
							RuntimeUnityEditorCore.Logger.Log((LogLevel)4, (object)"[LogViewerWindow] Sender is null, cannot inspect");
						}
					}
					else
					{
						try
						{
							UnityFeatureHelper.systemCopyBuffer = logViewerEntry.GetClipboardString();
							RuntimeUnityEditorCore.Logger.Log((LogLevel)8, (object)"[LogViewerWindow] Copied to clipboard");
						}
						catch (Exception ex)
						{
							RuntimeUnityEditorCore.Logger.Log((LogLevel)10, (object)("[LogViewerWindow] Failed to copy to clipboard: " + ex.Message));
						}
					}
				}
				if (logViewerEntry.Sender != null && GUILayout.Button("Inspect", IMGUIUtils.LayoutOptionsExpandWidthFalse))
				{
					FeatureBase<Inspector>.Instance.Push((InspectorStackEntryBase)new InstanceStackEntry((object)logViewerEntry, logViewerEntry.LogEventArgs.Source.SourceName + " -> Log entry"), true);
				}
				DnSpyHelper.DrawDnSpyButtonIfAvailable((MemberInfo)logViewerEntry.Method, new GUIContent("^", "In dnSpy, attempt to navigate to the method that produced this log message:\n\n" + TypeNameExtensions.GetFancyDescription((MemberInfo)logViewerEntry.Method)));
				GUILayout.EndHorizontal();
				if (!flag3 && (int)Event.current.type == 7)
				{
					val2 = GUILayoutUtility.GetLastRect();
					int num5 = (int)((Rect)(ref val2)).height;
					if (_itemHeight == 0 || _itemHeight > num5)
					{
						_itemHeight = num5;
					}
				}
			}
			GUILayout.Space((float)(num4 * _itemHeight));
			GUILayout.EndScrollView();
			val2 = ((Window<LogViewerWindow>)this).WindowRect;
			base.TooltipWidth = Mathf.Min(777, Mathf.Max(300, (int)((Rect)(ref val2)).width - 100));
		}

		internal void OnLogEvent(object sender, LogEventArgs eventArgs)
		{
			try
			{
				LogViewerEntry entry = LogViewerEntry.CreateFromLogEventArgs(sender, eventArgs);
				AddEntry(entry);
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
			}
		}

		private void AddEntry(LogViewerEntry entry)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			_logEntries.Add(entry);
			if (entry.IsMatch(SearchString, LogLevelFilter))
			{
				_filteredLogEntries.Add(entry);
			}
		}
	}
}

plugins/RuntimeUnityEditor.Core.dll

Decompiled a month ago
#define DEBUG
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.CSharp;
using Mono.CSharp.Linq;
using Mono.CSharp.Nullable;
using Mono.CSharp.yyParser;
using Mono.CSharp.yydebug;
using Mono.CompilerServices.SymbolWriter;
using MonoMod.RuntimeDetour;
using RuntimeUnityEditor.Core.Breakpoints;
using RuntimeUnityEditor.Core.ChangeHistory;
using RuntimeUnityEditor.Core.Clipboard;
using RuntimeUnityEditor.Core.Gizmos.lib;
using RuntimeUnityEditor.Core.Gizmos.lib.Drawers;
using RuntimeUnityEditor.Core.Inspector;
using RuntimeUnityEditor.Core.Inspector.Entries;
using RuntimeUnityEditor.Core.ObjectTree;
using RuntimeUnityEditor.Core.ObjectView;
using RuntimeUnityEditor.Core.Profiler;
using RuntimeUnityEditor.Core.REPL;
using RuntimeUnityEditor.Core.REPL.MCS;
using RuntimeUnityEditor.Core.UI;
using RuntimeUnityEditor.Core.Utils;
using RuntimeUnityEditor.Core.Utils.Abstractions;
using RuntimeUnityEditor.Core.Utils.ObjectDumper;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: InternalsVisibleTo("RuntimeUnityEditor.Bepin6.IL2CPP")]
[assembly: InternalsVisibleTo("RuntimeUnityEditor.Bepin5")]
[assembly: Guid("a66a97b4-f32f-4748-8332-48f0876f0aac")]
[assembly: ComVisible(false)]
[assembly: AssemblyCopyright("Copyright ©  2018")]
[assembly: AssemblyProduct("RuntimeUnityEditor.Core")]
[assembly: AssemblyCompany("https://github.com/ManlyMarco/RuntimeUnityEditor")]
[assembly: AssemblyDescription("In-game inspector, editor and interactive console for applications made with Unity3D game engine")]
[assembly: AssemblyTitle("RuntimeUnityEditor.Core")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: InternalsVisibleTo("RuntimeUnityEditor.UMM")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("5.5.1.0")]
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
internal static class FailedToGetGenericArguments
{
}
namespace RuntimeUnityEditor.Core
{
	public interface IFeature
	{
		bool Enabled { get; set; }

		FeatureDisplayType DisplayType { get; }

		string DisplayName { get; }

		void OnInitialize(InitSettings initSettings);

		void OnUpdate();

		void OnLateUpdate();

		void OnOnGUI();

		void OnEditorShownChanged(bool visible);
	}
	public enum FeatureDisplayType
	{
		Hidden,
		Feature,
		Window
	}
	public abstract class FeatureBase<T> : IFeature where T : FeatureBase<T>
	{
		private static bool _initialized;

		protected string SettingCategory = "Features";

		private protected string _displayName;

		private bool _enabled;

		private Action<bool> _confEnabled;

		public static bool Initialized => _initialized;

		public static T Instance { get; private set; }

		public virtual string DisplayName
		{
			get
			{
				return _displayName ?? (_displayName = GetType().Name);
			}
			set
			{
				_displayName = value;
			}
		}

		public virtual bool Enabled
		{
			get
			{
				return _enabled;
			}
			set
			{
				if (_enabled != value)
				{
					bool visible = Visible;
					_enabled = value;
					bool visible2 = Visible;
					if (visible != visible2)
					{
						OnVisibleChanged(visible2);
					}
					_confEnabled?.Invoke(value);
				}
			}
		}

		public bool Visible => Enabled && RuntimeUnityEditorCore.Instance.Show;

		public FeatureDisplayType DisplayType { get; protected set; }

		protected FeatureBase()
		{
			DisplayType = FeatureDisplayType.Feature;
			Instance = (T)this;
		}

		void IFeature.OnInitialize(InitSettings initSettings)
		{
			if (Initialized)
			{
				throw new InvalidOperationException("The Feature is already initialized");
			}
			Initialize(initSettings);
			AfterInitialized(initSettings);
			_initialized = true;
		}

		protected virtual void AfterInitialized(InitSettings initSettings)
		{
			_confEnabled = initSettings.RegisterSetting(SettingCategory, DisplayName + " enabled", Enabled, string.Empty, delegate(bool b)
			{
				Enabled = b;
			});
		}

		void IFeature.OnUpdate()
		{
			if (_initialized && Enabled)
			{
				try
				{
					Update();
				}
				catch (Exception content)
				{
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, content);
				}
			}
		}

		void IFeature.OnLateUpdate()
		{
			if (_initialized && Enabled)
			{
				try
				{
					LateUpdate();
				}
				catch (Exception content)
				{
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, content);
				}
			}
		}

		void IFeature.OnOnGUI()
		{
			if (_initialized && Enabled)
			{
				try
				{
					OnGUI();
				}
				catch (Exception content)
				{
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, content);
				}
			}
		}

		void IFeature.OnEditorShownChanged(bool visible)
		{
			if (_initialized && Enabled)
			{
				OnVisibleChanged(visible);
			}
		}

		protected virtual void OnVisibleChanged(bool visible)
		{
			try
			{
				VisibleChanged(visible);
			}
			catch (Exception content)
			{
				RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, content);
			}
		}

		protected abstract void Initialize(InitSettings initSettings);

		protected virtual void Update()
		{
		}

		protected virtual void LateUpdate()
		{
		}

		protected virtual void OnGUI()
		{
		}

		protected virtual void VisibleChanged(bool visible)
		{
		}
	}
	public class ContextMenu : FeatureBase<ContextMenu>
	{
		public readonly struct MenuEntry
		{
			private readonly GUIContent _name;

			private readonly Func<object, bool> _onCheckVisible;

			private readonly Action<object> _onClick;

			public MenuEntry(string name, Func<object, bool> onCheckVisible, Action<object> onClick)
				: this(new GUIContent(name), onCheckVisible, onClick)
			{
			}//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown


			public MenuEntry(GUIContent name, Func<object, bool> onCheckVisible, Action<object> onClick)
			{
				_name = name;
				_onCheckVisible = onCheckVisible;
				_onClick = onClick;
			}

			public bool IsVisible(object obj)
			{
				return _onCheckVisible == null || _onCheckVisible(obj);
			}

			public bool Draw(object obj)
			{
				if (_onClick != null)
				{
					if (GUILayout.Button(_name, Array.Empty<GUILayoutOption>()))
					{
						if (IMGUIUtils.IsMouseRightClick())
						{
							return false;
						}
						_onClick(obj);
						return true;
					}
				}
				else if (_name != null)
				{
					GUILayout.Label(_name, Array.Empty<GUILayoutOption>());
				}
				else
				{
					GUILayout.Space(4f);
				}
				return false;
			}
		}

		private object _obj;

		private MemberInfo _objMemberInfo;

		private string _objName;

		private Rect _windowRect;

		private int _windowId;

		private List<MenuEntry> _currentContents;

		public override bool Enabled
		{
			get
			{
				return base.Enabled && (_obj != null || _objMemberInfo != null);
			}
			set
			{
				if (value && _obj == null && _objMemberInfo == null)
				{
					value = false;
				}
				base.Enabled = value;
			}
		}

		public List<MenuEntry> MenuContents { get; } = new List<MenuEntry>();


		protected override void Initialize(InitSettings initSettings)
		{
			MenuContents.AddRange(new MenuEntry[8]
			{
				new MenuEntry("! Destroyed unity Object !", delegate(object obj)
				{
					Object val25 = (Object)((obj is Object) ? obj : null);
					return val25 != null && !Object.op_Implicit(val25);
				}, null),
				new MenuEntry("Preview", (object o) => o != null && FeatureBase<ObjectViewWindow>.Initialized && FeatureBase<ObjectViewWindow>.Instance.CanPreview(o), delegate(object o)
				{
					FeatureBase<ObjectViewWindow>.Instance.SetShownObject(o, _objName);
				}),
				new MenuEntry("Show event details", (object o) => o is UnityEventBase && FeatureBase<ObjectViewWindow>.Initialized, delegate(object o)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Expected O, but got Unknown
					FeatureBase<ObjectViewWindow>.Instance.SetShownObject(ReflectionUtils.GetEventDetails((UnityEventBase)o), o?.ToString() + " - Event details");
				}),
				new MenuEntry("Find in object tree", (object o) => o is GameObject || o is Component, delegate(object o)
				{
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					ObjectTreeViewer instance = FeatureBase<ObjectTreeViewer>.Instance;
					object obj2 = ((o is GameObject) ? o : null);
					instance.SelectAndShowObject(((obj2 != null) ? ((GameObject)obj2).transform : null) ?? ((Component)o).transform);
				}),
				default(MenuEntry),
				new MenuEntry("Send to inspector", (object o) => o != null && FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Initialized, delegate(object o)
				{
					if (o is Type staticType)
					{
						FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Push(new StaticStackEntry(staticType, _objName), newTab: true);
					}
					else
					{
						FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Push(new InstanceStackEntry(o, _objName), newTab: true);
					}
				}),
				new MenuEntry("Send to REPL", (object o) => o != null && FeatureBase<ReplWindow>.Initialized, delegate(object o)
				{
					FeatureBase<ReplWindow>.Instance.IngestObject(o);
				}),
				default(MenuEntry)
			});
			AddBreakpointControls(MenuContents);
			MenuContents.AddRange(new MenuEntry[12]
			{
				new MenuEntry("Copy to clipboard", (object o) => o != null && FeatureBase<ClipboardWindow>.Initialized, delegate(object o)
				{
					if (ClipboardWindow.Contents.LastOrDefault() != o)
					{
						ClipboardWindow.Contents.Add(o);
					}
				}),
				new MenuEntry("Export texture...", delegate(object o)
				{
					int result2;
					if (!(o is Texture) && !(o is Sprite))
					{
						Material val21 = (Material)((o is Material) ? o : null);
						if (val21 == null || !((Object)(object)val21.mainTexture != (Object)null))
						{
							Image val22 = (Image)((o is Image) ? o : null);
							if (val22 == null || !((Object)(object)((Graphic)val22).mainTexture != (Object)null))
							{
								RawImage val23 = (RawImage)((o is RawImage) ? o : null);
								if (val23 == null || !((Object)(object)((Graphic)val23).mainTexture != (Object)null))
								{
									Renderer val24 = (Renderer)((o is Renderer) ? o : null);
									result2 = ((val24 != null && (Object)(object)(val24.sharedMaterial ?? val24.material) != (Object)null && (Object)(object)(val24.sharedMaterial ?? val24.material).mainTexture != (Object)null) ? 1 : 0);
									goto IL_00a1;
								}
							}
						}
					}
					result2 = 1;
					goto IL_00a1;
					IL_00a1:
					return (byte)result2 != 0;
				}, delegate(object o)
				{
					Texture val15 = (Texture)((o is Texture) ? o : null);
					if (val15 != null)
					{
						val15.SaveTextureToFileWithDialog();
					}
					else
					{
						Sprite val16 = (Sprite)((o is Sprite) ? o : null);
						if (val16 != null)
						{
							((Texture)(object)val16.texture).SaveTextureToFileWithDialog();
						}
						else
						{
							Material val17 = (Material)((o is Material) ? o : null);
							if (val17 != null)
							{
								val17.mainTexture.SaveTextureToFileWithDialog();
							}
							else
							{
								Image val18 = (Image)((o is Image) ? o : null);
								if (val18 != null)
								{
									((Graphic)val18).mainTexture.SaveTextureToFileWithDialog();
								}
								else
								{
									RawImage val19 = (RawImage)((o is RawImage) ? o : null);
									if (val19 != null)
									{
										((Graphic)val19).mainTexture.SaveTextureToFileWithDialog();
									}
									else
									{
										Renderer val20 = (Renderer)((o is Renderer) ? o : null);
										if (val20 != null)
										{
											(val20.sharedMaterial ?? val20.material).mainTexture.SaveTextureToFileWithDialog();
										}
									}
								}
							}
						}
					}
				}),
				new MenuEntry("Replace texture...", delegate(object o)
				{
					int result;
					if (!(o is Texture2D))
					{
						Material val12 = (Material)((o is Material) ? o : null);
						if (val12 == null || !((Object)(object)val12.mainTexture != (Object)null))
						{
							RawImage val13 = (RawImage)((o is RawImage) ? o : null);
							if (val13 == null || !((Object)(object)((Graphic)val13).mainTexture != (Object)null))
							{
								Renderer val14 = (Renderer)((o is Renderer) ? o : null);
								result = ((val14 != null && (Object)(object)(val14.sharedMaterial ?? val14.material) != (Object)null && (Object)(object)(val14.sharedMaterial ?? val14.material).mainTexture != (Object)null) ? 1 : 0);
								goto IL_007b;
							}
						}
					}
					result = 1;
					goto IL_007b;
					IL_007b:
					return (byte)result != 0;
				}, delegate(object o)
				{
					string filename = "null";
					Texture2D val6 = TextureUtils.LoadTextureFromFileWithDialog(ref filename);
					Texture2D val7 = (Texture2D)((o is Texture2D) ? o : null);
					if (val7 != null)
					{
						val7.LoadRawTextureData(val6.GetRawTextureData());
						val7.Apply(true);
						Object.Destroy((Object)(object)val6);
						Change.Report($"(ContextMenu)::{_objName}.LoadImage(File.ReadAllBytes(\"{filename}\"))");
					}
					else
					{
						Material val8 = (Material)((o is Material) ? o : null);
						if (val8 != null)
						{
							val8.mainTexture = (Texture)(object)val6;
							Change.Report($"(ContextMenu)::{_objName}.mainTexture = Texture2D.LoadImage(File.ReadAllBytes(\"{filename}\"))");
						}
						else
						{
							Image val9 = (Image)((o is Image) ? o : null);
							if (val9 != null && (Object)(object)((Graphic)val9).material != (Object)null)
							{
								((Graphic)val9).material.mainTexture = (Texture)(object)val6;
								Change.Report($"(ContextMenu)::{_objName}.mainTexture = Texture2D.LoadImage(File.ReadAllBytes(\"{filename}\"))");
							}
							else
							{
								RawImage val10 = (RawImage)((o is RawImage) ? o : null);
								if (val10 != null)
								{
									val10.texture = (Texture)(object)val6;
									Change.Report($"(ContextMenu)::{_objName}.texture = Texture2D.LoadImage(File.ReadAllBytes(\"{filename}\"))");
								}
								else
								{
									Renderer val11 = (Renderer)((o is Renderer) ? o : null);
									if (val11 != null)
									{
										(val11.sharedMaterial ?? val11.material).mainTexture = (Texture)(object)val6;
										Change.Report($"(ContextMenu)::{_objName}.mainTexture = Texture2D.LoadImage(File.ReadAllBytes(\"{filename}\"))");
									}
								}
							}
						}
					}
				}),
				new MenuEntry("Export mesh to .obj", delegate(object o)
				{
					Renderer val5 = (Renderer)((o is Renderer) ? o : null);
					return val5 != null && MeshExport.CanExport(val5);
				}, delegate(object o)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Expected O, but got Unknown
					MeshExport.ExportObj((Renderer)o, bakedMesh: false, bakedWorldPosition: false);
				}),
				new MenuEntry("Export mesh to .obj (Baked)", delegate(object o)
				{
					Renderer val4 = (Renderer)((o is Renderer) ? o : null);
					return val4 != null && MeshExport.CanExport(val4);
				}, delegate(object o)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Expected O, but got Unknown
					MeshExport.ExportObj((Renderer)o, bakedMesh: true, bakedWorldPosition: false);
				}),
				new MenuEntry("Export mesh to .obj (World)", delegate(object o)
				{
					Renderer val3 = (Renderer)((o is Renderer) ? o : null);
					return val3 != null && MeshExport.CanExport(val3);
				}, delegate(object o)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Expected O, but got Unknown
					MeshExport.ExportObj((Renderer)o, bakedMesh: true, bakedWorldPosition: true);
				}),
				new MenuEntry("Dump object to file...", (object o) => o != null, delegate(object o)
				{
					Dumper.DumpToTempFile(o, _objName);
				}),
				new MenuEntry("Destroy", delegate(object o)
				{
					Object val2 = (Object)((o is Object) ? o : null);
					return val2 != null && Object.op_Implicit(val2);
				}, delegate(object o)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					Transform val = (Transform)((o is Transform) ? o : null);
					Change.Action("(ContextMenu)::UnityEngine.Object.Destroy({0})", (Object)((val != null) ? ((object)((Component)val).gameObject) : ((object)(Object)o)), (Action<Object>)Object.Destroy, (Action<Object>)null);
				}),
				default(MenuEntry),
				new MenuEntry("Find references in scene", (object o) => o != null && FeatureBase<ObjectViewWindow>.Initialized && o.GetType().IsClass, delegate(object o)
				{
					FeatureBase<ObjectTreeViewer>.Instance.FindReferencesInScene(o);
				}),
				new MenuEntry("Find member in dnSpy", (object o) => DnSpyHelper.IsAvailable && _objMemberInfo != null, delegate
				{
					DnSpyHelper.OpenInDnSpy(_objMemberInfo);
				}),
				new MenuEntry("Find member type in dnSpy", (object o) => o != null && DnSpyHelper.IsAvailable, delegate(object o)
				{
					DnSpyHelper.OpenInDnSpy(o.GetType());
				})
			});
			_windowId = base.GetHashCode();
			Enabled = false;
			base.DisplayType = FeatureDisplayType.Hidden;
		}

		private void AddBreakpointControls(List<MenuEntry> menuContents)
		{
			menuContents.AddRange(AddGroup("call", (object o, MemberInfo info) => info as MethodBase));
			menuContents.AddRange(AddGroup("getter", (object o, MemberInfo info) => (info is PropertyInfo propertyInfo2) ? propertyInfo2.GetGetMethod(nonPublic: true) : null));
			menuContents.AddRange(AddGroup("setter", (object o, MemberInfo info) => (info is PropertyInfo propertyInfo) ? propertyInfo.GetSetMethod(nonPublic: true) : null));
			menuContents.Add(default(MenuEntry));
			IEnumerable<MenuEntry> AddGroup(string name, Func<object, MemberInfo, MethodBase> getMethod)
			{
				yield return new MenuEntry("Attach " + name + " breakpoint (this instance)", delegate(object o)
				{
					if (o == null)
					{
						return false;
					}
					MethodBase methodBase4 = getMethod(o, _objMemberInfo);
					return methodBase4 != null && !RuntimeUnityEditor.Core.Breakpoints.Breakpoints.IsAttached(methodBase4, o);
				}, delegate(object o)
				{
					RuntimeUnityEditor.Core.Breakpoints.Breakpoints.AttachBreakpoint(getMethod(o, _objMemberInfo), o);
				});
				yield return new MenuEntry("Detach " + name + " breakpoint (this instance)", delegate(object o)
				{
					if (o == null)
					{
						return false;
					}
					MethodBase methodBase3 = getMethod(o, _objMemberInfo);
					return methodBase3 != null && RuntimeUnityEditor.Core.Breakpoints.Breakpoints.IsAttached(methodBase3, o);
				}, delegate(object o)
				{
					RuntimeUnityEditor.Core.Breakpoints.Breakpoints.DetachBreakpoint(getMethod(o, _objMemberInfo), o);
				});
				yield return new MenuEntry("Attach " + name + " breakpoint (all instances)", delegate(object o)
				{
					MethodBase methodBase2 = getMethod(o, _objMemberInfo);
					return methodBase2 != null && !RuntimeUnityEditor.Core.Breakpoints.Breakpoints.IsAttached(methodBase2, null);
				}, delegate(object o)
				{
					RuntimeUnityEditor.Core.Breakpoints.Breakpoints.AttachBreakpoint(getMethod(o, _objMemberInfo), null);
				});
				yield return new MenuEntry("Detach " + name + " breakpoint (all instances)", delegate(object o)
				{
					MethodBase methodBase = getMethod(o, _objMemberInfo);
					return methodBase != null && RuntimeUnityEditor.Core.Breakpoints.Breakpoints.IsAttached(methodBase, null);
				}, delegate(object o)
				{
					RuntimeUnityEditor.Core.Breakpoints.Breakpoints.DetachBreakpoint(getMethod(o, _objMemberInfo), null);
				});
			}
		}

		public void Show(object obj, MemberInfo objMemberInfo)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			Vector3 mousePosition = UnityInput.Current.mousePosition;
			Show(obj, objMemberInfo, new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y));
		}

		public void Show(object obj, MemberInfo objMemberInfo, Vector2 clickPoint)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			_windowRect = new Rect(clickPoint.x, clickPoint.y, 100f, 100f);
			if (obj != null || objMemberInfo != null)
			{
				_obj = obj;
				_objMemberInfo = objMemberInfo;
				_objName = ((objMemberInfo != null) ? (objMemberInfo.DeclaringType?.Name + "." + objMemberInfo.Name) : GeneralExtensions.FullDescription(obj.GetType()));
				_currentContents = MenuContents.Where((MenuEntry x) => x.IsVisible(_obj)).ToList();
				_windowId++;
				Enabled = true;
			}
			else
			{
				_obj = null;
				Enabled = false;
			}
		}

		public void DrawContextButton(object obj, MemberInfo objMemberInfo)
		{
			if (obj != null && GUILayout.Button("...", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				Show(obj, objMemberInfo);
			}
		}

		protected override void OnGUI()
		{
			//IL_0022: 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_004c: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			int num = _windowId - 10;
			GUILayout.Window(num, new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new WindowFunction(DisableOnClickWindowFunc), string.Empty, GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUI.color = Color.white;
			IMGUIUtils.DrawSolidBox(_windowRect);
			_windowRect = GUILayout.Window(_windowId, _windowRect, new WindowFunction(DrawMenu), _objName, Array.Empty<GUILayoutOption>());
			IMGUIUtils.EatInputInRect(_windowRect);
			GUI.BringWindowToFront(num);
			GUI.BringWindowToFront(_windowId);
			if (((Rect)(ref _windowRect)).xMax > (float)Screen.width)
			{
				((Rect)(ref _windowRect)).x = (float)Screen.width - ((Rect)(ref _windowRect)).width;
			}
			if (((Rect)(ref _windowRect)).yMax > (float)Screen.height)
			{
				((Rect)(ref _windowRect)).y = (float)Screen.height - ((Rect)(ref _windowRect)).height;
			}
		}

		private void DisableOnClickWindowFunc(int id)
		{
			if (GUILayout.Button(GUIContent.none, GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			}))
			{
				Enabled = false;
			}
		}

		private void DrawMenu(int id)
		{
			if (_currentContents == null || _currentContents.Count == 0)
			{
				Enabled = false;
				return;
			}
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			foreach (MenuEntry currentContent in _currentContents)
			{
				if (currentContent.Draw(_obj))
				{
					Enabled = false;
				}
			}
			GUILayout.EndVertical();
		}
	}
	public sealed class CursorUnlocker : FeatureBase<CursorUnlocker>
	{
		private bool _obsoleteCursor;

		private PropertyInfo _curLockState;

		private PropertyInfo _curVisible;

		private int _previousCursorLockState;

		private bool _previousCursorVisible;

		protected override void Initialize(InitSettings initSettings)
		{
			Type typeFromHandle = typeof(Cursor);
			_curLockState = typeFromHandle.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public);
			_curVisible = typeFromHandle.GetProperty("visible", BindingFlags.Static | BindingFlags.Public);
			if (_curLockState == null || _curVisible == null)
			{
				_obsoleteCursor = true;
				_curLockState = typeof(Screen).GetProperty("lockCursor", BindingFlags.Static | BindingFlags.Public);
				_curVisible = typeof(Screen).GetProperty("showCursor", BindingFlags.Static | BindingFlags.Public);
				if (_curLockState == null || _curVisible == null)
				{
					throw new InvalidOperationException("Unsupported Cursor class");
				}
			}
			DisplayName = "Unlock cursor";
			Enabled = true;
			base.DisplayType = FeatureDisplayType.Hidden;
		}

		protected override void Update()
		{
			if (_obsoleteCursor)
			{
				_curLockState.SetValue(null, false, null);
			}
			else
			{
				_curLockState.SetValue(null, 0, null);
			}
			_curVisible.SetValue(null, true, null);
		}

		protected override void LateUpdate()
		{
			if (_obsoleteCursor)
			{
				_curLockState.SetValue(null, false, null);
			}
			else
			{
				_curLockState.SetValue(null, 0, null);
			}
			_curVisible.SetValue(null, true, null);
		}

		protected override void OnGUI()
		{
			if (_obsoleteCursor)
			{
				_curLockState.SetValue(null, false, null);
			}
			else
			{
				_curLockState.SetValue(null, 0, null);
			}
			_curVisible.SetValue(null, true, null);
		}

		protected override void VisibleChanged(bool visible)
		{
			if (visible)
			{
				_previousCursorLockState = (_obsoleteCursor ? System.Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : ((int)_curLockState.GetValue(null, null)));
				_previousCursorVisible = (bool)_curVisible.GetValue(null, null);
			}
			else if (!_previousCursorVisible || _previousCursorLockState != 0)
			{
				if (_obsoleteCursor)
				{
					_curLockState.SetValue(null, System.Convert.ToBoolean(_previousCursorLockState), null);
				}
				else
				{
					_curLockState.SetValue(null, _previousCursorLockState, null);
				}
				_curVisible.SetValue(null, _previousCursorVisible, null);
			}
		}
	}
	public class MouseInspect : FeatureBase<MouseInspect>
	{
		private static readonly StringBuilder _hoverTextSb = new StringBuilder(100);

		private static string _hoverText = string.Empty;

		private GUIStyle _labelSkin;

		protected override void Initialize(InitSettings initSettings)
		{
			DisplayName = "Mouse inspect";
		}

		protected override void Update()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			Transform val = DoRaycast(main);
			List<RectTransform> list = DoCanvas(main);
			Transform selectedTransform = FeatureBase<ObjectTreeViewer>.Instance.SelectedTransform;
			_hoverTextSb.Length = 0;
			if ((Object)(object)val != (Object)null)
			{
				_hoverTextSb.AppendFormat("Raycast hit:\n{0}0: {1} pos={2}\n", ((Object)(object)selectedTransform == (Object)(object)val) ? "> " : "", ((Object)val).name, val.position);
			}
			if (list.Count > 0)
			{
				_hoverTextSb.AppendLine("Canvas hits:");
				for (int i = 0; i < list.Count && i < 10; i++)
				{
					RectTransform val2 = list[i];
					_hoverTextSb.AppendFormat("{0}{1}: {2} pos={3} size={4}\n", ((Object)(object)selectedTransform == (Object)(object)val2) ? "> " : "", i + 1, ((Object)val2).name, ((Transform)val2).position, val2.sizeDelta);
				}
			}
			if (_hoverTextSb.Length > 0)
			{
				if (FeatureBase<ObjectTreeViewer>.Initialized)
				{
					_hoverTextSb.Append("[ Press Middle Mouse Button to browse to the next object ]");
					if (UnityInput.Current.GetMouseButtonDown(2))
					{
						List<Transform> list2 = (from x in Enumerable.Repeat<Transform>(val, 1).Concat(list.Cast<Transform>())
							where (Object)(object)x != (Object)null
							select x).ToList();
						int num = list2.IndexOf(selectedTransform);
						Transform target = list2.Concat(list2).Skip(num + 1).First();
						FeatureBase<ObjectTreeViewer>.Instance.SelectAndShowObject(target);
					}
				}
				_hoverText = _hoverTextSb.ToString();
			}
			else
			{
				_hoverText = string.Empty;
			}
		}

		protected override void OnGUI()
		{
			//IL_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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)
			if (_hoverText.Length > 0)
			{
				if (_labelSkin == null)
				{
					_labelSkin = GUI.skin.label.CreateCopy();
				}
				_labelSkin.alignment = (TextAnchor)0;
				Vector3 mousePosition = UnityInput.Current.mousePosition;
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor((float)((int)mousePosition.x + 5), (float)(Screen.height - (int)mousePosition.y + 20), (float)(Screen.width / 2), 500f);
				if ((int)((Rect)(ref rect)).x > Screen.width / 2)
				{
					((Rect)(ref rect)).x = (int)(((Rect)(ref rect)).x - ((Rect)(ref rect)).width);
					_labelSkin.alignment = (TextAnchor)2;
				}
				if ((int)((Rect)(ref rect)).y > Screen.height / 2)
				{
					((Rect)(ref rect)).y = (int)(((Rect)(ref rect)).y - (((Rect)(ref rect)).height + 23f));
					GUIStyle labelSkin = _labelSkin;
					labelSkin.alignment = (TextAnchor)(labelSkin.alignment + 6);
				}
				IMGUIUtils.DrawLabelWithOutline(rect, _hoverText, _labelSkin, Color.white, Color.black, 2);
			}
		}

		private static Transform DoRaycast(Camera camera)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)camera == (Object)null)
			{
				return null;
			}
			Ray val = camera.ScreenPointToRay(UnityInput.Current.mousePosition);
			RaycastHit val2 = default(RaycastHit);
			return Physics.Raycast(val, ref val2, 1000f) ? ((RaycastHit)(ref val2)).transform : null;
		}

		private static List<RectTransform> DoCanvas(Camera camera)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			Vector2 mousePosition = Vector2.op_Implicit(UnityInput.Current.mousePosition);
			IEnumerable<RectTransform> source = Object.FindObjectsOfType<RectTransform>().Where(delegate(RectTransform rt)
			{
				//IL_000a: 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_008e: 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)
				if (Object.op_Implicit((Object)(object)rt) && rt.sizeDelta.x > 0f && rt.sizeDelta.y > 0f && ((Component)rt).gameObject.activeInHierarchy)
				{
					Canvas componentInParent = ((Component)rt).GetComponentInParent<Canvas>();
					if ((Object)(object)componentInParent != (Object)null && ((Behaviour)componentInParent).enabled && ((Component)rt).GetComponentsInParent<CanvasGroup>().All((CanvasGroup x) => x.alpha > 0.1f))
					{
						Camera val = (((int)componentInParent.renderMode == 0) ? null : (((Object)(object)componentInParent.worldCamera != (Object)null) ? componentInParent.worldCamera : camera));
						return RectTransformUtility.RectangleContainsScreenPoint(rt, mousePosition, val);
					}
				}
				return false;
			});
			return source.OrderBy(delegate(RectTransform x)
			{
				//IL_0001: 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)
				Vector2 sizeDelta = x.sizeDelta;
				return ((Vector2)(ref sizeDelta)).sqrMagnitude;
			}).ToList();
		}
	}
	public sealed class WireframeFeature : FeatureBase<WireframeFeature>
	{
		private static readonly string[] _disableEffectNames = new string[5] { "GlobalFog", "BloomAndFlares", "CustomRender", "AmplifyColorEffect", "PostProcessLayer" };

		private MonoBehaviour _monoBehaviour;

		private readonly List<Behaviour> _disabledEffects = new List<Behaviour>();

		private static Camera _targetCamera;

		private bool _updateCoRunning;

		public override bool Enabled
		{
			get
			{
				return base.Enabled;
			}
			set
			{
				if (base.Enabled != value)
				{
					base.Enabled = value;
					if (value)
					{
						_monoBehaviour.AbstractStartCoroutine(UpdateCo());
					}
				}
			}
		}

		protected override void Initialize(InitSettings initSettings)
		{
			UnityFeatureHelper.EnsureCameraRenderEventsAreAvailable();
			DisplayName = "Wireframe";
			Enabled = false;
			_monoBehaviour = initSettings.PluginMonoBehaviour;
		}

		private IEnumerator UpdateCo()
		{
			if (_updateCoRunning)
			{
				yield break;
			}
			_updateCoRunning = true;
			CollectEffects();
			SetEffectEnabled(enabled: false);
			yield return null;
			if (Enabled)
			{
				yield return null;
			}
			if (Enabled)
			{
				Camera.onPreRender = (CameraCallback)System.Delegate.Combine((System.Delegate?)(object)Camera.onPreRender, (System.Delegate?)new CameraCallback(OnPreRender));
				Camera.onPostRender = (CameraCallback)System.Delegate.Combine((System.Delegate?)(object)Camera.onPostRender, (System.Delegate?)new CameraCallback(OnPostRender));
				yield return null;
				while (Enabled)
				{
					SetEffectEnabled(enabled: false);
					yield return null;
				}
				Camera.onPreRender = (CameraCallback)System.Delegate.Remove((System.Delegate?)(object)Camera.onPreRender, (System.Delegate?)new CameraCallback(OnPreRender));
				Camera.onPostRender = (CameraCallback)System.Delegate.Remove((System.Delegate?)(object)Camera.onPostRender, (System.Delegate?)new CameraCallback(OnPostRender));
			}
			SetEffectEnabled(enabled: true);
			_updateCoRunning = false;
		}

		private void CollectEffects()
		{
			_disabledEffects.Clear();
			_disabledEffects.AddRange(from b in Object.FindObjectsOfType<Camera>().SelectMany((Camera cam) => ((IEnumerable<string>)_disableEffectNames).Select((Func<string, Component>)((Component)cam).GetComponent)).OfType<Behaviour>()
				where Object.op_Implicit((Object)(object)b) && b.enabled
				select b);
		}

		private void SetEffectEnabled(bool enabled)
		{
			for (int i = 0; i < _disabledEffects.Count; i++)
			{
				Behaviour val = _disabledEffects[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					val.enabled = enabled;
				}
			}
		}

		private static void OnPreRender(Camera cam)
		{
			if (!GL.wireframe)
			{
				_targetCamera = cam;
				GL.wireframe = true;
			}
		}

		private static void OnPostRender(Camera cam)
		{
			if ((Object)(object)_targetCamera == (Object)(object)cam)
			{
				GL.wireframe = false;
				_targetCamera = null;
			}
		}
	}
	public class RuntimeUnityEditorCore
	{
		public const string Version = "5.5.1";

		public const string GUID = "RuntimeUnityEditor";

		private readonly Action<KeyCode> _onHotkeyChanged;

		internal static InitSettings _initSettings;

		private readonly List<IFeature> _initializedFeatures = new List<IFeature>();

		private KeyCode _showHotkey = (KeyCode)293;

		public static string InstalledVersion => "5.5.1";

		[Obsolete("Use window Instance instead", true)]
		public RuntimeUnityEditor.Core.Inspector.Inspector Inspector => FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Initialized ? FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance : null;

		[Obsolete("Use window Instance instead", true)]
		public ObjectTreeViewer TreeViewer => FeatureBase<ObjectTreeViewer>.Initialized ? FeatureBase<ObjectTreeViewer>.Instance : null;

		[Obsolete("Use window Instance instead", true)]
		public ObjectViewWindow PreviewWindow => FeatureBase<ObjectViewWindow>.Initialized ? FeatureBase<ObjectViewWindow>.Instance : null;

		[Obsolete("Use window Instance instead", true)]
		public ProfilerWindow ProfilerWindow => FeatureBase<ProfilerWindow>.Initialized ? FeatureBase<ProfilerWindow>.Instance : null;

		[Obsolete("Use window Instance instead", true)]
		public ReplWindow Repl => FeatureBase<ReplWindow>.Initialized ? FeatureBase<ReplWindow>.Instance : null;

		[Obsolete("Avoid changing the hotkey through code since it will overwrite user setting. Set the Show property instead if you need to show/hide RUE at specific times.")]
		public KeyCode ShowHotkey
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _showHotkey;
			}
			set
			{
				//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_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				if (_showHotkey != value)
				{
					_showHotkey = value;
					_onHotkeyChanged?.Invoke(value);
				}
			}
		}

		[Obsolete("Use window Instance instead", true)]
		public bool ShowRepl
		{
			get
			{
				return FeatureBase<ReplWindow>.Initialized && FeatureBase<ReplWindow>.Instance.Enabled;
			}
			set
			{
				if (FeatureBase<ReplWindow>.Initialized)
				{
					FeatureBase<ReplWindow>.Instance.Enabled = value;
				}
			}
		}

		[Obsolete("Use window Instance instead", true)]
		public bool EnableMouseInspect
		{
			get
			{
				return FeatureBase<MouseInspect>.Initialized && FeatureBase<MouseInspect>.Instance.Enabled;
			}
			set
			{
				if (FeatureBase<MouseInspect>.Initialized)
				{
					FeatureBase<MouseInspect>.Instance.Enabled = value;
				}
			}
		}

		[Obsolete("Use window Instance instead", true)]
		public bool ShowInspector
		{
			get
			{
				return FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Initialized && FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Enabled;
			}
			set
			{
				if (FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Initialized)
				{
					FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Enabled = value;
				}
			}
		}

		public static RuntimeUnityEditorCore Instance { get; private set; }

		public bool Show
		{
			get
			{
				return Taskbar.Instance.Enabled;
			}
			set
			{
				if (Taskbar.Instance.Enabled != value)
				{
					Taskbar.Instance.Enabled = value;
					for (int i = 0; i < _initializedFeatures.Count; i++)
					{
						_initializedFeatures[i].OnEditorShownChanged(value);
					}
				}
			}
		}

		public IEnumerable<IFeature> InitializedFeatures => _initializedFeatures;

		internal static MonoBehaviour PluginObject => _initSettings.PluginMonoBehaviour;

		internal static ILoggerWrapper Logger => _initSettings.LoggerWrapper;

		[Obsolete("No longer works", true)]
		public event EventHandler SettingsChanged;

		public static bool IsInitialized()
		{
			lock ("RuntimeUnityEditor")
			{
				return Instance != null;
			}
		}

		public void AddFeature(IFeature feature)
		{
			AddFeatureInt(feature);
			Taskbar.Instance.SetFeatures(_initializedFeatures);
		}

		internal bool RemoveFeature(IFeature feature)
		{
			if (_initializedFeatures.Remove(feature))
			{
				Taskbar.Instance.SetFeatures(_initializedFeatures);
				return true;
			}
			return false;
		}

		internal RuntimeUnityEditorCore(InitSettings initSettings)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			lock ("RuntimeUnityEditor")
			{
				if (Instance != null)
				{
					throw new InvalidOperationException("Can create only one instance of the Core object");
				}
				_initSettings = initSettings;
				Instance = this;
				try
				{
					_onHotkeyChanged = initSettings.RegisterSetting("General", "Open/close runtime editor", (KeyCode)293, "", delegate(KeyCode x)
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						ShowHotkey = x;
					});
					Type iFeatureType = typeof(IFeature);
					List<IFeature> list = (from t in typeof(RuntimeUnityEditorCore).Assembly.GetTypesSafe()
						where !t.IsAbstract && iFeatureType.IsAssignableFrom(t)
						select t).Select(Activator.CreateInstance).Cast<IFeature>().ToList();
					foreach (IFeature item in list)
					{
						try
						{
							AddFeatureInt(item);
						}
						catch (Exception ex)
						{
							if (item is Taskbar)
							{
								throw new InvalidOperationException("WindowManager somehow failed to initialize! I am die, thank you forever.", ex);
							}
							Logger.Log(LogLevel.Warning, "Failed to initialize " + item.GetType().Name + " - " + ((ex is NotSupportedException) ? ex.Message : ex.ToString()));
						}
					}
					Taskbar.Instance.SetFeatures(_initializedFeatures);
					Logger.Log(LogLevel.Info, $"Successfully initialized {_initializedFeatures.Count}/{list.Count} features: {string.Join(", ", _initializedFeatures.Select((IFeature x) => x.GetType().Name).ToArray())}");
				}
				catch
				{
					Instance = null;
					throw;
				}
			}
		}

		private void AddFeatureInt(IFeature feature)
		{
			feature.OnInitialize(_initSettings);
			_initializedFeatures.Add(feature);
		}

		internal void OnGUI()
		{
			if (Show)
			{
				GUISkin skin = GUI.skin;
				GUI.skin = InterfaceMaker.CustomSkin;
				for (int i = 0; i < _initializedFeatures.Count; i++)
				{
					_initializedFeatures[i].OnOnGUI();
				}
				GUI.skin = skin;
			}
		}

		internal void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (UnityInput.Current.GetKeyDown(ShowHotkey))
			{
				Show = !Show;
			}
			if (Show)
			{
				for (int i = 0; i < _initializedFeatures.Count; i++)
				{
					_initializedFeatures[i].OnUpdate();
				}
			}
		}

		internal void LateUpdate()
		{
			if (Show)
			{
				for (int i = 0; i < _initializedFeatures.Count; i++)
				{
					_initializedFeatures[i].OnLateUpdate();
				}
			}
		}
	}
	public enum ScreenPartition
	{
		Default = 0,
		Full = 5,
		Center = 10,
		CenterUpper = 11,
		CenterLower = 12,
		Left = 20,
		LeftUpper = 21,
		LeftLower = 22,
		Right = 30,
		RightUpper = 31,
		RightLower = 32
	}
	internal static class IL2CppAbstractions
	{
		public static void Set(this RectOffset obj, int left, int right, int top, int bottom)
		{
			obj.left = left;
			obj.right = right;
			obj.top = top;
			obj.bottom = bottom;
		}

		public static Transform[] AbstractGetChildren(this Transform transform, bool castedIl2Cpp = true)
		{
			Transform[] array = (Transform[])(object)new Transform[transform.childCount];
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				array[i] = child;
			}
			return array;
		}

		public static Component[] AbstractGetAllComponents(this GameObject gameObject, bool castedIl2Cpp = true)
		{
			return gameObject.GetComponents<Component>();
		}

		public static Component[] AbstractGetAllComponents(this Component component, bool castedIl2Cpp = true)
		{
			return component.GetComponents<Component>();
		}

		public static Component[] AbstractGetAllComponentsInChildren(this GameObject gameObject, bool includeInactive, bool castedIl2Cpp = true)
		{
			return gameObject.GetComponentsInChildren<Component>(includeInactive);
		}

		public static Component[] AbstractGetAllComponentsInChildren(this Component component, bool includeInactive, bool castedIl2Cpp = true)
		{
			return component.GetComponentsInChildren<Component>(includeInactive);
		}

		public static Coroutine AbstractStartCoroutine(this MonoBehaviour monoBehaviour, IEnumerator routine)
		{
			return monoBehaviour.StartCoroutine(routine);
		}

		public static T AbstractAddComponent<T>(this GameObject go) where T : Component
		{
			return go.AddComponent<T>();
		}
	}
	public interface IWindow : IFeature
	{
		string Title { get; set; }

		int WindowId { get; set; }

		Rect WindowRect { get; set; }

		Vector2 MinimumSize { get; set; }

		ScreenPartition DefaultScreenPosition { get; }
	}
	public abstract class Window<T> : FeatureBase<T>, IWindow, IFeature where T : Window<T>
	{
		protected const int DefaultTooltipWidth = 400;

		private static GUIStyle _tooltipStyle;

		private static GUIContent _tooltipContent;

		private static Texture2D _tooltipBackground;

		private bool _canShow;

		private Rect _windowRect;

		private Action<Rect> _confRect;

		public int TooltipWidth { get; set; } = 400;


		public override string DisplayName
		{
			get
			{
				string text = _displayName;
				if (text == null)
				{
					string obj = Title ?? base.DisplayName;
					string text2 = obj;
					_displayName = obj;
					text = text2;
				}
				return text;
			}
			set
			{
				_displayName = value;
			}
		}

		public virtual string Title { get; set; }

		public int WindowId { get; set; }

		public virtual Rect WindowRect
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _windowRect;
			}
			set
			{
				//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_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				if (_windowRect != value)
				{
					_windowRect = value;
					_confRect?.Invoke(value);
				}
			}
		}

		public Vector2 MinimumSize { get; set; } = new Vector2(100f, 100f);


		public ScreenPartition DefaultScreenPosition { get; protected set; } = ScreenPartition.Default;


		protected Window()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			base.DisplayType = FeatureDisplayType.Window;
			SettingCategory = "Windows";
		}

		protected override void AfterInitialized(InitSettings initSettings)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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)
			base.AfterInitialized(initSettings);
			WindowId = base.GetHashCode();
			_confRect = initSettings.RegisterSetting(SettingCategory, DisplayName + " window size", WindowRect, string.Empty, delegate(Rect b)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				WindowRect = b;
			});
			if (DefaultScreenPosition == ScreenPartition.Default && GetDefaultWindowRect(new Rect(0f, 0f, 1600f, 900f)) != default(Rect))
			{
				DefaultScreenPosition = ScreenPartition.LeftLower;
			}
		}

		protected override void OnGUI()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0073: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			if (_canShow)
			{
				string title = Title;
				title = $"{title} {WindowRect}";
				WindowRect = GUILayout.Window(WindowId, WindowRect, new WindowFunction(DrawContentsInt), title, Array.Empty<GUILayoutOption>());
				Rect windowRect = WindowRect;
				if (((Rect)(ref windowRect)).width < MinimumSize.x)
				{
					Rect windowRect2 = WindowRect;
					((Rect)(ref windowRect2)).width = MinimumSize.x;
					WindowRect = windowRect2;
				}
				windowRect = WindowRect;
				if (((Rect)(ref windowRect)).height < MinimumSize.y)
				{
					Rect windowRect3 = WindowRect;
					((Rect)(ref windowRect3)).height = MinimumSize.y;
					WindowRect = windowRect3;
				}
			}
		}

		private void DrawContentsInt(int id)
		{
			//IL_0019: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			int num = GUI.skin.window.border.top - 4;
			Rect windowRect = WindowRect;
			if (GUI.Button(new Rect(((Rect)(ref windowRect)).width - (float)num - 2f, 2f, (float)num, (float)num), "X"))
			{
				Enabled = false;
				return;
			}
			try
			{
				DrawContents();
				DrawTooltip(WindowRect);
			}
			catch (Exception ex)
			{
				if (!ex.Message.Contains("GUILayout"))
				{
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, $"[{Title}] GUI crash: {ex}");
				}
			}
			WindowRect = IMGUIUtils.DragResizeEat(id, WindowRect);
		}

		private void DrawTooltip(Rect area)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003d: 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_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)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_007b: Expected O, but got Unknown
			//IL_007c: 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)
			//IL_0091: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(GUI.tooltip))
			{
				if ((Object)(object)_tooltipBackground == (Object)null)
				{
					_tooltipBackground = new Texture2D(1, 1, (TextureFormat)5, false);
					_tooltipBackground.SetPixel(0, 0, Color.black);
					_tooltipBackground.Apply();
					_tooltipStyle = new GUIStyle
					{
						normal = new GUIStyleState
						{
							textColor = Color.white,
							background = _tooltipBackground
						},
						wordWrap = true,
						alignment = (TextAnchor)4
					};
					_tooltipContent = new GUIContent();
				}
				_tooltipContent.text = GUI.tooltip;
				float num = TooltipWidth;
				Rect windowRect = WindowRect;
				float num2 = Mathf.Min(num, ((Rect)(ref windowRect)).width);
				float num3 = _tooltipStyle.CalcHeight(_tooltipContent, num2) + 10f;
				Event current = Event.current;
				float num4 = ((current.mousePosition.x + num2 > ((Rect)(ref area)).width) ? (((Rect)(ref area)).width - num2) : current.mousePosition.x);
				float num5 = ((current.mousePosition.y + 25f + num3 > ((Rect)(ref area)).height) ? (current.mousePosition.y - num3) : (current.mousePosition.y + 25f));
				GUI.Box(new Rect(num4, num5, num2, num3), GUI.tooltip, _tooltipStyle);
			}
		}

		protected override void OnVisibleChanged(bool visible)
		{
			if (visible && Taskbar.Instance.Height == 0)
			{
				RuntimeUnityEditorCore.PluginObject.AbstractStartCoroutine(DelayedVisible());
			}
			else
			{
				base.OnVisibleChanged(visible);
			}
			IEnumerator DelayedVisible()
			{
				yield return null;
				base.OnVisibleChanged(base.Visible);
			}
		}

		protected override void VisibleChanged(bool visible)
		{
			if (visible)
			{
				if (!WindowManager.IsWindowRectValid(this))
				{
					ResetWindowRect();
				}
				_canShow = true;
			}
		}

		public void ResetWindowRect()
		{
			WindowManager.ResetWindowRect(this);
		}

		[Obsolete("No longer used, set DefaultScreenPosition instead", false)]
		protected virtual Rect GetDefaultWindowRect(Rect screenClientRect)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return default(Rect);
		}

		[Obsolete("Use set DefaultScreenPosition or use WindowManager.MakeDefaultWindowRect instead", true)]
		public static Rect MakeDefaultWindowRect(Rect screenClientRect, TextAlignment side)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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: Expected I4, but got Unknown
			//IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_004c: 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)
			return (Rect)((int)side switch
			{
				0 => WindowManager.MakeDefaultWindowRect(screenClientRect, ScreenPartition.LeftUpper), 
				1 => WindowManager.MakeDefaultWindowRect(screenClientRect, ScreenPartition.CenterUpper), 
				2 => WindowManager.MakeDefaultWindowRect(screenClientRect, ScreenPartition.Right), 
				_ => throw new ArgumentOutOfRangeException("side", side, null), 
			});
		}

		protected abstract void DrawContents();
	}
	public class WindowManager
	{
		private const int ScreenMargin = 10;

		private const int SideWidth = 350;

		public static Rect MakeDefaultWindowRect(Rect screenClientRect, ScreenPartition screenPartition)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			switch (screenPartition)
			{
			case ScreenPartition.Left:
				return new Rect(((Rect)(ref screenClientRect)).xMin, ((Rect)(ref screenClientRect)).yMin, 350f, ((Rect)(ref screenClientRect)).height);
			case ScreenPartition.LeftUpper:
				return new Rect(((Rect)(ref screenClientRect)).xMin, ((Rect)(ref screenClientRect)).yMin, 350f, ((Rect)(ref screenClientRect)).height / 2f - 10f);
			case ScreenPartition.LeftLower:
				return new Rect(((Rect)(ref screenClientRect)).xMin, ((Rect)(ref screenClientRect)).yMin + ((Rect)(ref screenClientRect)).height / 2f, 350f, ((Rect)(ref screenClientRect)).height / 2f);
			case ScreenPartition.Center:
			{
				int num7 = (int)Mathf.Min(850f, ((Rect)(ref screenClientRect)).width);
				int num8 = (int)(((Rect)(ref screenClientRect)).xMin + ((Rect)(ref screenClientRect)).width / 2f - (float)Mathf.RoundToInt((float)num7 / 2f));
				return new Rect((float)num8, ((Rect)(ref screenClientRect)).yMin, (float)num7, ((Rect)(ref screenClientRect)).height);
			}
			case ScreenPartition.CenterUpper:
			{
				int num4 = (int)Mathf.Min(850f, ((Rect)(ref screenClientRect)).width);
				int num5 = (int)(((Rect)(ref screenClientRect)).xMin + ((Rect)(ref screenClientRect)).width / 2f - (float)Mathf.RoundToInt((float)num4 / 2f));
				int num6 = (int)(((Rect)(ref screenClientRect)).height / 4f) * 3;
				return new Rect((float)num5, ((Rect)(ref screenClientRect)).yMin, (float)num4, (float)num6);
			}
			case ScreenPartition.CenterLower:
			{
				int num = (int)Mathf.Min(850f, ((Rect)(ref screenClientRect)).width);
				int num2 = (int)(((Rect)(ref screenClientRect)).xMin + ((Rect)(ref screenClientRect)).width / 2f - (float)Mathf.RoundToInt((float)num / 2f));
				int num3 = (int)(((Rect)(ref screenClientRect)).height / 4f) * 3;
				return new Rect((float)num2, ((Rect)(ref screenClientRect)).yMin + (float)num3 + 10f, (float)num, ((Rect)(ref screenClientRect)).height - (float)num3 - 10f);
			}
			case ScreenPartition.Right:
				return new Rect(((Rect)(ref screenClientRect)).xMax - 350f, ((Rect)(ref screenClientRect)).yMin, 350f, ((Rect)(ref screenClientRect)).height);
			case ScreenPartition.RightUpper:
				return new Rect(((Rect)(ref screenClientRect)).xMax - 350f, ((Rect)(ref screenClientRect)).yMin, 350f, ((Rect)(ref screenClientRect)).height / 2f);
			case ScreenPartition.RightLower:
				return new Rect(((Rect)(ref screenClientRect)).xMax - 350f, ((Rect)(ref screenClientRect)).yMin + ((Rect)(ref screenClientRect)).height / 2f, 350f, ((Rect)(ref screenClientRect)).height / 2f);
			case ScreenPartition.Full:
				return screenClientRect;
			case ScreenPartition.Default:
				if (FeatureBase<ReplWindow>.Initialized)
				{
					goto case ScreenPartition.CenterUpper;
				}
				goto case ScreenPartition.Center;
			default:
				throw new ArgumentOutOfRangeException("screenPartition", screenPartition, null);
			}
		}

		public static void ResetWindowRect(IWindow window)
		{
			//IL_0030: 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)
			Rect screenClientRect = default(Rect);
			((Rect)(ref screenClientRect))..ctor(10f, 10f, (float)(Screen.width - 20), (float)(Screen.height - 20 - Taskbar.Instance.Height));
			window.WindowRect = MakeDefaultWindowRect(screenClientRect, window.DefaultScreenPosition);
		}

		public static bool IsWindowRectValid(IWindow window)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003e: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0075: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			Rect windowRect = window.WindowRect;
			int result;
			if (((Rect)(ref windowRect)).width >= window.MinimumSize.x)
			{
				windowRect = window.WindowRect;
				if (((Rect)(ref windowRect)).height >= window.MinimumSize.y)
				{
					windowRect = window.WindowRect;
					if (((Rect)(ref windowRect)).x < (float)(Screen.width - 10))
					{
						windowRect = window.WindowRect;
						if (((Rect)(ref windowRect)).y < (float)(Screen.height - 10))
						{
							windowRect = window.WindowRect;
							float x = ((Rect)(ref windowRect)).x;
							windowRect = window.WindowRect;
							if (x >= 0f - ((Rect)(ref windowRect)).width + 10f)
							{
								windowRect = window.WindowRect;
								float y = ((Rect)(ref windowRect)).y;
								windowRect = window.WindowRect;
								result = ((y >= 0f - ((Rect)(ref windowRect)).height + 10f) ? 1 : 0);
								goto IL_00bf;
							}
						}
					}
				}
			}
			result = 0;
			goto IL_00bf;
			IL_00bf:
			return (byte)result != 0;
		}
	}
	public class Taskbar : IFeature
	{
		private int _windowId;

		private Rect _windowRect;

		private List<IFeature> _orderedFeatures;

		private string _title;

		public static Taskbar Instance { get; private set; }

		public int Height => (int)((Rect)(ref _windowRect)).height;

		public bool Enabled { get; set; }

		FeatureDisplayType IFeature.DisplayType => FeatureDisplayType.Hidden;

		string IFeature.DisplayName => "WindowManager";

		protected string GetTitle()
		{
			//IL_0005: 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)
			return ((int)RuntimeUnityEditorCore.Instance.ShowHotkey == 0) ? _title : (_title + $" / Press {RuntimeUnityEditorCore.Instance.ShowHotkey} to show/hide");
		}

		public Taskbar()
		{
			Instance = this;
		}

		void IFeature.OnInitialize(InitSettings initSettings)
		{
			_windowId = GetHashCode();
			_title = "RuntimeUnityEditor v5.5.1";
		}

		public void SetFeatures(List<IFeature> initializedFeatures)
		{
			_orderedFeatures = (from x in initializedFeatures
				orderby x.DisplayType descending, x.DisplayName
				select x).ToList();
		}

		void IFeature.OnOnGUI()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0046: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			_windowRect = GUILayout.Window(_windowId, _windowRect, new WindowFunction(DrawTaskbar), GetTitle(), (GUILayoutOption[])(object)new GUILayoutOption[3]
			{
				GUILayout.ExpandHeight(false),
				GUILayout.ExpandWidth(false),
				GUILayout.MaxWidth((float)Screen.width)
			});
			IMGUIUtils.EatInputInRect(_windowRect);
			((Rect)(ref _windowRect)).x = (int)(((float)Screen.width - ((Rect)(ref _windowRect)).width) / 2f);
			((Rect)(ref _windowRect)).y = (int)((float)Screen.height - ((Rect)(ref _windowRect)).height);
		}

		private void DrawTaskbar(int id)
		{
			//IL_004b: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			bool flag = true;
			foreach (IFeature orderedFeature in _orderedFeatures)
			{
				if (orderedFeature.DisplayType == FeatureDisplayType.Window)
				{
					GUI.color = (orderedFeature.Enabled ? Color.cyan : Color.white);
					if (GUILayout.Button(orderedFeature.DisplayName, Array.Empty<GUILayoutOption>()))
					{
						orderedFeature.Enabled = !orderedFeature.Enabled;
					}
				}
				else
				{
					if (orderedFeature.DisplayType != FeatureDisplayType.Feature)
					{
						continue;
					}
					if (flag)
					{
						GUI.color = new Color(1f, 1f, 1f, 0.75f);
						if (GUILayout.Button("Reset", Array.Empty<GUILayoutOption>()))
						{
							foreach (IWindow item in _orderedFeatures.OfType<IWindow>())
							{
								WindowManager.ResetWindowRect(item);
							}
						}
						flag = false;
						GUI.color = Color.white;
						GUILayout.Label("|", Array.Empty<GUILayoutOption>());
					}
					orderedFeature.Enabled = GUILayout.Toggle(orderedFeature.Enabled, orderedFeature.DisplayName, Array.Empty<GUILayoutOption>());
				}
			}
			GUILayout.Label("|", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Time", IMGUIUtils.LayoutOptionsExpandWidthFalse);
			if (GUILayout.Button(">", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				Time.timeScale = 1f;
			}
			if (GUILayout.Button("||", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				Time.timeScale = 0f;
			}
			if (float.TryParse(GUILayout.TextField(Time.timeScale.ToString("F2", CultureInfo.InvariantCulture), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(38f) }), NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				Time.timeScale = result;
			}
			GUI.changed = false;
			bool runInBackground = GUILayout.Toggle(Application.runInBackground, "in BG", Array.Empty<GUILayoutOption>());
			if (GUI.changed)
			{
				Application.runInBackground = runInBackground;
			}
			GUILayout.Label("|", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Log", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				UnityFeatureHelper.OpenLog();
			}
			AssetBundleManagerHelper.DrawButtonIfAvailable();
			GUILayout.EndHorizontal();
		}

		void IFeature.OnUpdate()
		{
		}

		void IFeature.OnLateUpdate()
		{
		}

		void IFeature.OnEditorShownChanged(bool visible)
		{
		}
	}
}
namespace RuntimeUnityEditor.Core.REPL
{
	public class REPL : InteractiveBase
	{
		[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
		private class DocumentationAttribute : System.Attribute
		{
			public string Docs { get; }

			public DocumentationAttribute(string doc)
			{
				Docs = doc;
			}
		}

		public static string clear
		{
			get
			{
				FeatureBase<ReplWindow>.Instance.Clear();
				return "Log cleared";
			}
		}

		public new static string help
		{
			get
			{
				string value = InteractiveBase.help;
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("  clear;                   - Clear this log\n");
				stringBuilder.AppendLine();
				stringBuilder.AppendLine("In addition, the following helper methods are provided:");
				MethodInfo[] methods = typeof(REPL).GetMethods(BindingFlags.Static | BindingFlags.Public);
				foreach (MethodInfo methodInfo in methods)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(DocumentationAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						stringBuilder.Append("  ");
						stringBuilder.AppendLine(((DocumentationAttribute)customAttributes[0]).Docs);
					}
				}
				return $"{value}{stringBuilder}";
			}
		}

		public static object InteropTempVar { get; set; }

		[Documentation("MB - A dummy MonoBehaviour for accessing Unity.")]
		public static ReplHelper MB { get; }

		static REPL()
		{
			MB = ((Component)RuntimeUnityEditorCore.PluginObject).gameObject.AbstractAddComponent<ReplHelper>();
		}

		[Documentation("find<T>() - find a UnityEngine.Object of type T.")]
		public static T find<T>() where T : Object
		{
			return MB.Find<T>();
		}

		[Documentation("findAll<T>() - find all UnityEngine.Object of type T.")]
		public static T[] findAll<T>() where T : Object
		{
			return MB.FindAll<T>();
		}

		[Documentation("runCoroutine(enumerator) - runs an IEnumerator as a Unity coroutine.")]
		public static Coroutine runCoroutine(IEnumerator i)
		{
			return MB.RunCoroutine(i);
		}

		[Documentation("endCoroutine(co) - ends a Unity coroutine.")]
		public static void endCoroutine(Coroutine c)
		{
			MB.EndCoroutine(c);
		}

		[Documentation("type<T>() - obtain type info about a type T. Provides some Reflection helpers.")]
		public static TypeHelper type<T>()
		{
			return new TypeHelper(typeof(T));
		}

		[Documentation("type(obj) - obtain type info about object obj. Provides some Reflection helpers.")]
		public static TypeHelper type(object instance)
		{
			return new TypeHelper(instance);
		}

		[Documentation("dir(obj) - lists all available methods and fiels of a given obj.")]
		public static string dir(object instance)
		{
			return type(instance).info();
		}

		[Documentation("dir<T>() - lists all available methods and fields of type T.")]
		public static string dir<T>()
		{
			return type<T>().info();
		}

		[Documentation("findrefs(obj) - find references to the object in currently loaded components.")]
		public static Component[] findrefs(object obj)
		{
			if (obj == null)
			{
				throw new ArgumentNullException("obj");
			}
			List<Component> list = new List<Component>();
			Component[] array = Object.FindObjectsOfType<Component>();
			foreach (Component val in array)
			{
				Type type = ((object)val).GetType();
				string[] nameBlacklist = new string[5] { "parent", "parentInternal", "root", "transform", "gameObject" };
				Type[] typeBlacklist = new Type[1] { typeof(bool) };
				foreach (PropertyInfo item in from x in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where x.CanRead && !nameBlacklist.Contains(x.Name) && !typeBlacklist.Contains(x.PropertyType)
					select x)
				{
					try
					{
						if (object.Equals(item.GetValue(val, null), obj))
						{
							list.Add(val);
							goto IL_01a3;
						}
					}
					catch
					{
					}
				}
				foreach (FieldInfo item2 in from x in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where !nameBlacklist.Contains(x.Name) && !typeBlacklist.Contains(x.FieldType)
					select x)
				{
					try
					{
						if (object.Equals(item2.GetValue(val), obj))
						{
							list.Add(val);
							break;
						}
					}
					catch
					{
					}
				}
				IL_01a3:;
			}
			return list.ToArray();
		}

		[Documentation("geti() - get object currently opened in inspector. Will get expanded upon accepting. Best to use like this: var x = geti()")]
		public static object geti()
		{
			return FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.GetInspectedObject() ?? throw new InvalidOperationException("No object is opened in inspector or a static type is opened");
		}

		public static T geti<T>()
		{
			return (T)geti();
		}

		[Documentation("seti(obj) - send the object to the inspector. To send a static class use the setis(type) command.")]
		public static void seti(object obj)
		{
			if (obj == null)
			{
				throw new ArgumentNullException("obj");
			}
			FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Push(new InstanceStackEntry(obj, "REPL > " + obj.GetType().Name), newTab: true);
		}

		[Documentation("setis(type) - send the static class to the inspector.")]
		public static void setis(Type type)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			FeatureBase<RuntimeUnityEditor.Core.Inspector.Inspector>.Instance.Push(new StaticStackEntry(type, "REPL > " + type.Name), newTab: true);
		}

		[Documentation("getTree() - get the transform currently selected in tree view.")]
		public static Transform getTree()
		{
			return FeatureBase<ObjectTreeViewer>.Instance.SelectedTransform;
		}

		[Documentation("findTree(Transform) - find and select the transform in the tree view.")]
		public static void findTree(Transform tr)
		{
			if ((Object)(object)tr == (Object)null)
			{
				throw new ArgumentNullException("tr");
			}
			FeatureBase<ObjectTreeViewer>.Instance.SelectAndShowObject(tr);
		}

		[Documentation("findTree(GameObject) - find and select the object in the tree view.")]
		public static void findTree(GameObject go)
		{
			if ((Object)(object)go == (Object)null)
			{
				throw new ArgumentNullException("go");
			}
			FeatureBase<ObjectTreeViewer>.Instance.SelectAndShowObject(go.transform);
		}

		[Documentation("dnspy(type) - open the type in dnSpy if dnSpy path is configured.")]
		public static void dnspy(Type type)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			DnSpyHelper.OpenInDnSpy(type);
		}

		[Documentation("dnspy(memberInfo) - open the type member in dnSpy if dnSpy is configured.")]
		public static void dnspy(MemberInfo member)
		{
			if (member == null)
			{
				throw new ArgumentNullException("member");
			}
			DnSpyHelper.OpenInDnSpy(member);
		}

		[Documentation("echo(string) - write a string to REPL output.")]
		public static void echo(string message)
		{
			FeatureBase<ReplWindow>.Instance.AppendLogLine(message);
		}

		[Documentation("message(string) - write a string to log.")]
		public static void message(string message)
		{
			RuntimeUnityEditorCore.Logger.Log(LogLevel.Message, message);
		}

		[Documentation("paste(index) - paste clipboard contents from a given int index.")]
		public static object paste(int index)
		{
			return ClipboardWindow.Contents[index];
		}

		[Documentation("copy(object) - copy given object to clipboard (classes are copied by reference, returns the index it was added under).")]
		public static int copy(object @object)
		{
			ClipboardWindow.Contents.Add(@object);
			return ClipboardWindow.Contents.Count - 1;
		}

		[Documentation("dump(object, fileName) - dump given object to a new text file at specitied path.")]
		public static void dump(object @object, string fileName)
		{
			@object.DumpToFile("REPL_OBJECT", fileName);
		}

		[Documentation("dump(object) - dump given object to a temporary text file and open it in notepad. Returns path to the temp file.")]
		public static string dump(object @object)
		{
			return Dumper.DumpToTempFile(@object, "REPL_OBJECT");
		}
	}
	public class ReplHelper : MonoBehaviour
	{
		public T Find<T>() where T : Object
		{
			return Object.FindObjectOfType<T>();
		}

		public T[] FindAll<T>() where T : Object
		{
			return Object.FindObjectsOfType<T>();
		}

		public Coroutine RunCoroutine(IEnumerator i)
		{
			return ((MonoBehaviour)(object)this).AbstractStartCoroutine(i);
		}

		public void EndCoroutine(Coroutine c)
		{
			((MonoBehaviour)this).StopCoroutine(c);
		}
	}
	public sealed class ReplWindow : Window<ReplWindow>
	{
		private class VoidType
		{
			public static readonly VoidType Value = new VoidType();

			private VoidType()
			{
			}
		}

		private string _autostartFilename;

		private static readonly char[] _inputSplitChars = new char[11]
		{
			',', ';', '<', '>', '(', ')', '[', ']', '=', '|',
			'&'
		};

		private const int HistoryLimit = 50;

		private ScriptEvaluator _evaluator;

		private readonly List<string> _history = new List<string>();

		private int _historyPosition;

		private readonly StringBuilder _sb = new StringBuilder();

		private string _inputField = "";

		private string _prevInput = "";

		private Vector2 _scrollPosition = Vector2.zero;

		private TextEditor _textEditor;

		private int _newCursorLocation = -1;

		private MemberInfo _cursorIndex;

		private MemberInfo _selectIndex;

		private HashSet<string> _namespaces;

		private readonly List<Suggestion> _suggestions = new List<Suggestion>();

		private const string SnippletSeparator = "/****************************************/";

		private string _snippletFilename;

		private readonly List<string> _savedSnipplets = new List<string>();

		private bool _snippletsShown;

		private GUIStyle _completionsListingStyle;

		private bool _refocus;

		private int _refocusCursorIndex = -1;

		private int _refocusSelectIndex;

		private Action<bool> _onEnabledChanged;

		private HashSet<string> Namespaces
		{
			get
			{
				if (_namespaces == null)
				{
					_namespaces = new HashSet<string>(from x in AppDomain.CurrentDomain.GetAssemblies().SelectMany(Extensions.GetTypesSafe)
						where x.IsPublic && !string.IsNullOrEmpty(x.Namespace)
						select x.Namespace);
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Debug, $"[REPL] Found {_namespaces.Count} public namespaces");
				}
				return _namespaces;
			}
		}

		public override bool Enabled
		{
			get
			{
				return base.Enabled;
			}
			set
			{
				if (base.Enabled != value)
				{
					base.Enabled = value;
					_onEnabledChanged?.Invoke(value);
				}
			}
		}

		protected override void Initialize(InitSettings initSettings)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!UnityFeatureHelper.SupportsRepl)
			{
				throw new InvalidOperationException("mcs is not supported on this Unity version");
			}
			bool disable = false;
			initSettings.RegisterSetting("General", "Disable REPL function", defaultValue: false, "Completely turn off REPL even if it's supported. Useful if mcs is causing compatibility issues (e.g. in rare cases it can crash the game when used together with some versions of RuntimeDetours in some Unity versions).", delegate(bool x)
			{
				disable = x;
			});
			if (disable)
			{
				throw new InvalidOperationException("REPL is disabled in config");
			}
			string configPath = initSettings.ConfigPath;
			_autostartFilename = Path.Combine(configPath, "RuntimeUnityEditor.Autostart.cs");
			_snippletFilename = Path.Combine(configPath, "RuntimeUnityEditor.Snipplets.cs");
			Title = "C# REPL Console";
			_sb.AppendLine("Welcome to C# REPL (read-evaluate-print loop)! Enter \"help\" to get a list of common methods.");
			_evaluator = new ScriptEvaluator(new StringWriter(_sb))
			{
				InteractiveBaseClass = typeof(REPL)
			};
			_onEnabledChanged = initSettings.RegisterSetting("General", "Show REPL console", defaultValue: true, "", delegate(bool x)
			{
				Enabled = x;
			});
			initSettings.PluginMonoBehaviour.AbstractStartCoroutine(DelayedReplSetup());
			DisplayName = "REPL console";
			base.MinimumSize = new Vector2(280f, 130f);
			Enabled = false;
			base.DefaultScreenPosition = ScreenPartition.CenterLower;
		}

		private IEnumerator DelayedReplSetup()
		{
			yield return null;
			try
			{
				RunEnvSetup();
			}
			catch (Exception ex)
			{
				RuntimeUnityEditorCore.Logger.Log(LogLevel.Warning, "Failed to initialize REPL environment - " + ex.Message);
				try
				{
					RuntimeUnityEditorCore.Instance.RemoveFeature(this);
					_evaluator.Dispose();
				}
				catch (Exception ex2)
				{
					Exception e = ex2;
					RuntimeUnityEditorCore.Logger.Log(LogLevel.Debug, e);
				}
			}
		}

		public void RunEnvSetup()
		{
			string str = "using System;using UnityEngine;using System.Linq;using System.Collections;using System.Collections.Generic;";
			Evaluate(str);
			RunAutostart(_autostartFilename);
		}

		private void RunAutostart(string autostartFilename)
		{
			if (!File.Exists(autostartFilename))
			{
				return;
			}
			string[] array = (from x in File.ReadAllLines(autostartFilename)
				select x.Trim('\t', ' ', '\r', '\n') into x
				where !string.IsNullOrEmpty(x) && !x.StartsWith("//")
				select x).ToArray();
			if (array.Length != 0)
			{
				string text = "Executing code from " + autostartFilename;
				RuntimeUnityEditorCore.Logger.Log(LogLevel.Info, text);
				AppendLogLine(text);
				string[] array2 = array;
				foreach (string str in array2)
				{
					Evaluate(str);
				}
			}
		}

		protected override void DrawContents()
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			if (_completionsListingStyle == null)
			{
				_completionsListingStyle = GUI.skin.button.CreateCopy();
				_completionsListingStyle.border = new RectOffset();
				_completionsListingStyle.margin = new RectOffset();
				_completionsListingStyle.padding = new RectOffset();
				_completionsListingStyle.hover.background = Texture2D.whiteTexture;
				_completionsListingStyle.hover.textColor = Color.black;
				_completionsListingStyle.normal.background = null;
				_completionsListingStyle.focused.background = Texture2D.whiteTexture;
				_completionsListingStyle.focused.textColor = Color.black;
				_completionsListingStyle.active.background = Texture2D.whiteTexture;
				_completionsListingStyle.active.textColor = Color.black;
			}
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.textArea, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (_snippletsShown)
			{
				if (_savedSnipplets.Count == 0)
				{
					GUILayout.Label("This is a list of saved snipplets of code that you can load later into the input field.\n\nTo save a snipplet, type someting in the input field and click the Save button.\nTo load a snipplet, make sure the input field is empty, click the Load button, then choose a snipplet.\nTo remove a snipplet you can edit the snipplet file by choosing the bottom option on the snipplet list.\n\nClose this menu without loading anything by clicking the Cancel button below.", GUI.skin.box, Array.Empty<GUILayoutOption>());
				}
				else
				{
					_completionsListingStyle.normal.textColor = Color.white;
					foreach (string savedSnipplet in _savedSnipplets)
					{
						if (GUILayout.Button(savedSnipplet, GUI.skin.box, IMGUIUtils.LayoutOptionsExpandWidthTrue))
						{
							_inputField = savedSnipplet;
							_snippletsShown = false;
							break;
						}
					}
					if (GUILayout.Button(">> Edit snipplet list in external editor <<", GUI.skin.box, IMGUIUtils.LayoutOptionsExpandWidthTrue))
					{
						AppendLogLine("Opening snipplet file at " + _snippletFilename);
						if (!File.Exists(_snippletFilename))
						{
							File.WriteAllText(_snippletFilename, "");
						}
						try
						{
							Process.Start(_snippletFilename);
						}
						catch (Exception ex)
						{
							AppendLogLine(ex.Message);
						}
					}
				}
			}
			else if (_suggestions.Count > 0)
			{
				foreach (Suggestion suggestion in _suggestions)
				{
					_completionsListingStyle.normal.textColor = suggestion.GetTextColor();
					if (GUILayout.Button(suggestion.Full, _completionsListingStyle, IMGUIUtils.LayoutOptionsExpandWidthTrue))
					{
						AcceptSuggestion(suggestion.Addition);
						break;
					}
				}
			}
			else
			{
				GUILayout.TextArea(_sb.ToString(), GUI.skin.label, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.SetNextControlName("replInput");
			_inputField = GUILayout.TextArea(_inputField, Array.Empty<GUILayoutOption>());
			if (_refocus)
			{
				_refocusCursorIndex = (int)ReflectionUtils.GetValue(_cursorIndex, _textEditor);
				_refocusSelectIndex = (int)ReflectionUtils.GetValue(_selectIndex, _textEditor);
				GUI.FocusControl("replInput");
				_refocus = false;
			}
			else if (_refocusCursorIndex >= 0)
			{
				ReflectionUtils.SetValue(_cursorIndex, _textEditor, _refocusCursorIndex);
				ReflectionUtils.SetValue(_selectIndex, _textEditor, _refocusSelectIndex);
				_refocusCursorIndex = -1;
			}
			if (GUILayout.Button("Run", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				AcceptInput();
			}
			if (GUILayout.Button(_snippletsShown ? "Cancel" : ((_inputField.Length == 0) ? "Load" : "Save"), IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				if (_snippletsShown)
				{
					_snippletsShown = false;
				}
				else if (_inputField.Length == 0)
				{
					_snippletsShown = true;
					IEnumerable<string> enumerable2;
					if (!File.Exists(_snippletFilename))
					{
						IEnumerable<string> enumerable = new string[0];
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from x in File.ReadAllText(_snippletFilename).Split(new string[1] { "/****************************************/" }, StringSplitOptions.RemoveEmptyEntries)
							select x.Replace("\t", "    ").Trim(' ', '\r', '\n') into x
							where x.Length > 0
							select x;
					}
					IEnumerable<string> collection = enumerable2;
					_savedSnipplets.Clear();
					_savedSnipplets.AddRange(collection);
				}
				else
				{
					string contents = (File.Exists(_snippletFilename) ? $"{_inputField}{Environment.NewLine}{"/****************************************/"}{Environment.NewLine}{File.ReadAllText(_snippletFilename)}" : _inputField);
					File.WriteAllText(_snippletFilename, contents);
					AppendLogLine("Saved current command to snipplets. Clear the input box and click Load to load it.");
				}
			}
			if (GUILayout.Button("Autostart", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				AppendLogLine("Opening autostart file at " + _autostartFilename);
				if (!File.Exists(_autostartFilename))
				{
					File.WriteAllText(_autostartFilename, "// This C# code will be executed by the REPL near the end of plugin initialization. Only single-line statements are supported. Use echo(string) to write to REPL log and message(string) to write to global log.\n\n");
				}
				try
				{
					Process.Start(_autostartFilename);
				}
				catch (Exception ex2)
				{
					AppendLogLine(ex2.Message);
				}
				ScrollToBottom();
			}
			if (GUILayout.Button("History", IMGUIUtils.LayoutOptionsExpandWidthFalse))
			{
				AppendLogLine("");
				AppendLogLine("# History of executed commands:");
				foreach (string item in _history)
				{
					AppendLogLine(item);
				}
				ScrollToBottom();
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			CheckReplInput();
		}

		private void AcceptSuggestion(string suggestion)
		{
			int num = (int)ReflectionUtils.GetValue(_cursorIndex, _textEditor);
			_inputField = _inputField.Insert(num, suggestion);
			_newCursorLocation = (int)ReflectionUtils.GetValue(_cursorIndex, _textEditor) + suggestion.Length;
			ClearSuggestions();
			_refocus = true;
			_refocusCursorIndex = num + suggestion.Length;
		}

		public object Evaluate(string str)
		{
			object retvalue = VoidType.Value;
			_evaluator.Compile(str, out var compiled);
			try
			{
				compiled?.Invoke(ref retvalue);
			}
			catch (Exception ex)
			{
				AppendLogLine(ex.ToString());
			}
			return retvalue;
		}

		private void FetchHistory(int move)
		{
			if (_history.Count != 0)
			{
				_historyPosition += move;
				_historyPosition %= _history.Count;
				if (_historyPosition < 0)
				{
					_historyPosition = _history.Count - 1;
				}
				_inputField = _history[_historyPosition];
			}
		}

		private void FetchSuggestions(string input)
		{
			try
			{
				_suggestions.Clear();
				if (input.IndexOfAny(new char[5] { '?', '{', '}', '[', ']' }) < 0)
				{
					int length = _sb.Length;
					string prefix;
					string[] completions = _evaluator.GetCompletions(input, out prefix);
					_sb.Length = length;
					if (completions != null)
					{
						if (prefix == null)
						{
							prefix = input;
						}
						_suggestions.AddRange(from x in completions
							where !string.IsNullOrEmpty(x)
							select new Suggestion(x, prefix, SuggestionKind.Unknown));
					}
					_suggestions.AddRange(from x in GetNamespaceSuggestions(input)
						orderby x.Full
						select x);
				}
				_refocus = true;
			}
			catch (Exception ex)
			{
				RuntimeUnityEditorCore.Logger.Log(LogLevel.Debug, "[REPL] " + ex);
				ClearSuggestions();
			}
		}

		private IEnumerable<Suggestion> GetNamespaceSuggestions(string input)
		{
			string trimmedInput = input.Trim();
			if (trimmedInput.StartsWith("using"))
			{
				trimmedInput = trimmedInput.Remove(0, 5).Trim();
			}
			return from x in Namespaces
				where x.StartsWith(trimmedInput) && x.Length > trimmedInput.Length
				select new Suggestion(x.Substring(trimmedInput.Length), x.Substring(0, trimmedInput.Length), SuggestionKind.Namespace);
		}

		private void CheckReplInput()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Invalid comparison between Unknown and I4
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Invalid comparison between Unknown and I4
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Invalid comparison between Unknown and I4
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Invalid comparison between Unknown and I4
			if (GUI.GetNameOfFocusedControl() != "replInput")
			{
				return;
			}
			_textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
			Type typeFromHandle = typeof(TextEditor);
			_cursorIndex = typeFromHandle.GetProperty("cursorIndex", BindingFlags.Instance | BindingFlags.Public);
			_selectIndex = typeFromHandle.GetProperty("selectIndex", BindingFlags.Instance | BindingFlags.Public);
			if (_cursorIndex == null && _selectIndex == null)
			{
				_cursorIndex = typeFromHandle.GetField("pos", BindingFlags.Instance | BindingFlags.Public);
				_selectIndex = typeFromHandle.GetField("selectPos", BindingFlags.Instance | BindingFlags.Public);
			}
			if (_newCursorLocation >= 0)
			{
				ReflectionUtils.SetValue(_cursorIndex, _textEditor, _newCursorLocation);
				ReflectionUtils.SetValue(_selectIndex, _textEditor, _newCursorLocation);
				_newCursorLocation = -1;
			}
			string text = _inputField;
			Event current = Event.current;
			if (current.isKey)
			{
				if ((int)current.keyCode == 13 || (int)current.keyCode == 271)
				{
					if (!current.shift)
					{
						int num = (int)ReflectionUtils.GetValue(_cursorIndex, _textEditor);
						if (num - 1 >= 0)
						{
							_inputField = _inputField.Remove(num - 1, 1);
						}
						AcceptInput();
						current.Use();
					}
				}
				else if (text == null || !Enumerable.Contains(text, '\n'))
				{
					if ((int)current.keyCode == 273)
					{
						FetchHistory(-1);
						current.Use();
						ClearSuggestions();
					}
					else if ((int)current.keyCode == 274)
					{
						FetchHistory(1);
						current.Use();
						ClearSuggestions();
					}
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				try
				{
					int num2 = ((_refocusCursorIndex >= 0) ? _refocusCursorIndex : ((int)ReflectionUtils.GetValue(_cursorIndex, _textEditor)));
					int num3 = ((num2 > 0) ? (text.LastIndexOfAny(_inputSplitChars, num2 - 1) + 1) : 0);
					int num4 = ((num2 <= 0) ? text.Length : text.IndexOfAny(_inputSplitChars, num2 - 1));
					if (num4 < 0 || num4 < num3)
					{
						num4 = text.Length;
					}
					text = text.Substring(num3, num4 - num3);
				}
				catch (ArgumentException)
				{
				}
				if (text != _prevInput && !string.IsNullOrEmpty(text))
				{
					FetchSuggestions(text);
				}
			}
			else
			{
				ClearSuggestions();
			}
			_prevInput = text;
		}

		private void ClearSuggestions()
		{
			if (_suggestions.Any())
			{
				_suggestions.Clear();
				_refocus = true;
			}
		}

		private void AcceptInput()
		{
			_inputField = _inputField.Trim();
			if (_inputField == "")
			{
				return;
			}
			_history.Add(_inputField);
			if (_history.Count > 50)
			{
				_history.RemoveRange(0, _history.Count - 50);
			}
			_historyPosition = 0;
			Change.Report("(REPL)::" + _inputField);
			if (_inputField.Contains("geti()"))
			{
				try
				{
					object obj = REPL.geti();
					if (obj != null)
					{
						_inputField = _inputField.Replace("geti()", "geti<" + obj.GetType().GetSourceCodeRepresentation() + ">()");
					}
				}
				catch (SystemException)
				{
				}
			}
			AppendLogLine("> " + _inputField);
			object obj2 = Evaluate(_inputField);
			if (obj2 != null && !object.Equals(obj2, VoidType.Value))
			{
				AppendLogLine(obj2.ToString());
			}
			ScrollToBottom();
			_inputField = string.Empty;
			ClearSuggestions();
		}

		private void ScrollToBottom()
		{
			_scrollPosition.y = float.MaxValue;
		}

		internal void AppendLogLine(string message)
		{
			_sb.AppendLine(message);
		}

		public void Clear()
		{
			_sb.Length = 0;
		}

		public void IngestObject(object obj)
		{
			if (obj == null)
			{
				RuntimeUnityEditorCore.Logger.Log(LogLevel.Warning, "obj is null in: " + new StackTrace());
				return;
			}
			REPL.InteropTempVar = obj;
			_prevInput = (_inputField = $"var {GetUniqueVarName("q")} = ({obj.GetType().GetSourceCodeRepresentation()}){"InteropTempVar"}");
			ClearSuggestions();
		}

		private string GetUniqueVarName(string baseName)
		{
			string text = (from x in _evaluator.fields.Keys
				where Regex.IsMatch(x, "^q\\d*$", RegexOptions.Singleline)
				orderby x.Length, x
				select x).LastOrDefault();
			if (text != null)
			{
				if (text.Length > 1)
				{
					int num = int.Parse(text.Substring(1));
					baseName += num + 1;
				}
				else
				{
					baseName += "1";
				}
			}
			return baseName;
		}
	}
	internal struct Suggestion
	{
		public readonly string Prefix;

		public readonly string Addition;

		public readonly SuggestionKind Kind;

		public string Full => Prefix + Addition;

		public Suggestion(string addition, string prefix, SuggestionKind kind)
		{
			Prefix = prefix;
			Kind = kind;
			Addition = addition;
		}

		public Color GetTextColor()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return (Kind == SuggestionKind.Namespace) ? Color.gray : Color.white;
		}
	}
	internal enum SuggestionKind
	{
		Unknown,
		Namespace
	}
	public class TypeHelper
	{
		public object instance;

		public Type type;

		public TypeHelper(Type type)
		{
			this.type = type;
			instance = null;
		}

		public TypeHelper(object instance)
		{
			this.instance = instance;
			type = instance.GetType();
		}

		public T val<T>(string name) where T : class
		{
			FieldInfo field = type.GetField(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				if (!field.IsStatic && instance == null)
				{
					throw new ArgumentException("Field is not static, but instance is missing.");
				}
				return field.GetValue(field.IsStatic ? null : instance) as T;
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property == null || !property.CanWrite)
			{
				throw new ArgumentException("No field or settable property of name " + name + " was found!");
			}
			MethodInfo setMethod = property.GetSetMethod(nonPublic: true);
			if (!setMethod.IsStatic && instance == null)
			{
				throw new ArgumentException("Property is not static, but instance is missing.");
			}
			return setMethod.Invoke(setMethod.IsStatic ? null : instance, null) as T;
		}

		public void set(string name, object value)
		{
			FieldInfo field = type.GetField(name, BindingFlags.IgnoreCase | BindingFlags.Instance | Bind

plugins/System.ValueTuple.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Numerics.Hashing;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using FxResources.System.ValueTuple;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.ValueTuple")]
[assembly: AssemblyDescription("System.ValueTuple")]
[assembly: AssemblyDefaultAlias("System.ValueTuple")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.26515.06")]
[assembly: AssemblyInformationalVersion("4.6.26515.06 @BuiltBy: dlab-DDVSOWINAGE059 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/30ab651fcb4354552bd4891619a0bdd81e0ebdbf")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyVersion("4.0.3.0")]
namespace FxResources.System.ValueTuple
{
	internal static class SR
	{
	}
}
namespace System
{
	public static class TupleExtensions
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1>(this Tuple<T1> value, out T1 item1)
		{
			item1 = value.Item1;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2>(this Tuple<T1, T2> value, out T1 item1, out T2 item2)
		{
			item1 = value.Item1;
			item2 = value.Item2;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3>(this Tuple<T1, T2, T3> value, out T1 item1, out T2 item2, out T3 item3)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5>(this Tuple<T1, T2, T3, T4, T5> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6>(this Tuple<T1, T2, T3, T4, T5, T6> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7>(this Tuple<T1, T2, T3, T4, T5, T6, T7> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19, out T20 item20)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
			item20 = value.Rest.Rest.Item6;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Deconstruct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> value, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9, out T10 item10, out T11 item11, out T12 item12, out T13 item13, out T14 item14, out T15 item15, out T16 item16, out T17 item17, out T18 item18, out T19 item19, out T20 item20, out T21 item21)
		{
			item1 = value.Item1;
			item2 = value.Item2;
			item3 = value.Item3;
			item4 = value.Item4;
			item5 = value.Item5;
			item6 = value.Item6;
			item7 = value.Item7;
			item8 = value.Rest.Item1;
			item9 = value.Rest.Item2;
			item10 = value.Rest.Item3;
			item11 = value.Rest.Item4;
			item12 = value.Rest.Item5;
			item13 = value.Rest.Item6;
			item14 = value.Rest.Item7;
			item15 = value.Rest.Rest.Item1;
			item16 = value.Rest.Rest.Item2;
			item17 = value.Rest.Rest.Item3;
			item18 = value.Rest.Rest.Item4;
			item19 = value.Rest.Rest.Item5;
			item20 = value.Rest.Rest.Item6;
			item21 = value.Rest.Rest.Item7;
		}

		public static ValueTuple<T1> ToValueTuple<T1>(this Tuple<T1> value)
		{
			return ValueTuple.Create(value.Item1);
		}

		public static (T1, T2) ToValueTuple<T1, T2>(this Tuple<T1, T2> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2);
		}

		public static (T1, T2, T3) ToValueTuple<T1, T2, T3>(this Tuple<T1, T2, T3> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3);
		}

		public static (T1, T2, T3, T4) ToValueTuple<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4);
		}

		public static (T1, T2, T3, T4, T5) ToValueTuple<T1, T2, T3, T4, T5>(this Tuple<T1, T2, T3, T4, T5> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5);
		}

		public static (T1, T2, T3, T4, T5, T6) ToValueTuple<T1, T2, T3, T4, T5, T6>(this Tuple<T1, T2, T3, T4, T5, T6> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6);
		}

		public static (T1, T2, T3, T4, T5, T6, T7) ToValueTuple<T1, T2, T3, T4, T5, T6, T7>(this Tuple<T1, T2, T3, T4, T5, T6, T7> value)
		{
			return ValueTuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7);
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> value)
		{
			return CreateLong<T1, T2, T3, T4, T5, T6, T7, (T8, T9, T10, T11, T12, T13, T14)>(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, ValueTuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19, T20)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6)));
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) ToValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> value)
		{
			return CreateLong(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLong<T8, T9, T10, T11, T12, T13, T14, (T15, T16, T17, T18, T19, T20, T21)>(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, ValueTuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6, value.Rest.Rest.Item7)));
		}

		public static Tuple<T1> ToTuple<T1>(this ValueTuple<T1> value)
		{
			return Tuple.Create(value.Item1);
		}

		public static Tuple<T1, T2> ToTuple<T1, T2>(this (T1, T2) value)
		{
			return Tuple.Create(value.Item1, value.Item2);
		}

		public static Tuple<T1, T2, T3> ToTuple<T1, T2, T3>(this (T1, T2, T3) value)
		{
			return Tuple.Create(value.Item1, value.Item2, value.Item3);
		}

		public static Tuple<T1, T2, T3, T4> ToTuple<T1, T2, T3, T4>(this (T1, T2, T3, T4) value)
		{
			return Tuple.Create(value.Item1, value.Item2, value.Item3, value.Item4);
		}

		public static Tuple<T1, T2, T3, T4, T5> ToTuple<T1, T2, T3, T4, T5>(this (T1, T2, T3, T4, T5) value)
		{
			return Tuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6> ToTuple<T1, T2, T3, T4, T5, T6>(this (T1, T2, T3, T4, T5, T6) value)
		{
			return Tuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7> ToTuple<T1, T2, T3, T4, T5, T6, T7>(this (T1, T2, T3, T4, T5, T6, T7) value)
		{
			return Tuple.Create(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7);
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8>(this (T1, T2, T3, T4, T5, T6, T7, T8) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, Tuple.Create(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6)));
		}

		public static Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15, T16, T17, T18, T19, T20, T21>>> ToTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(this (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) value)
		{
			return CreateLongRef(value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, value.Item6, value.Item7, CreateLongRef(value.Rest.Item1, value.Rest.Item2, value.Rest.Item3, value.Rest.Item4, value.Rest.Item5, value.Rest.Item6, value.Rest.Item7, Tuple.Create(value.Rest.Rest.Item1, value.Rest.Rest.Item2, value.Rest.Rest.Item3, value.Rest.Rest.Item4, value.Rest.Rest.Item5, value.Rest.Rest.Item6, value.Rest.Rest.Item7)));
		}

		private static ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> CreateLong<T1, T2, T3, T4, T5, T6, T7, TRest>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest) where TRest : struct
		{
			return new ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>(item1, item2, item3, item4, item5, item6, item7, rest);
		}

		private static Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> CreateLongRef<T1, T2, T3, T4, T5, T6, T7, TRest>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
		{
			return new Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>(item1, item2, item3, item4, item5, item6, item7, rest);
		}
	}
	internal interface ITupleInternal
	{
		int Size { get; }

		int GetHashCode(IEqualityComparer comparer);

		string ToStringEnd();
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct ValueTuple : IEquatable<ValueTuple>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple>, System.ITupleInternal
	{
		int System.ITupleInternal.Size => 0;

		public override bool Equals(object obj)
		{
			return obj is ValueTuple;
		}

		public bool Equals(ValueTuple other)
		{
			return true;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			return other is ValueTuple;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return 0;
		}

		public int CompareTo(ValueTuple other)
		{
			return 0;
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return 0;
		}

		public override int GetHashCode()
		{
			return 0;
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return 0;
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return 0;
		}

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

		string System.ITupleInternal.ToStringEnd()
		{
			return ")";
		}

		public static ValueTuple Create()
		{
			return default(ValueTuple);
		}

		public static ValueTuple<T1> Create<T1>(T1 item1)
		{
			return new ValueTuple<T1>(item1);
		}

		public static (T1, T2) Create<T1, T2>(T1 item1, T2 item2)
		{
			return (item1, item2);
		}

		public static (T1, T2, T3) Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
		{
			return (item1, item2, item3);
		}

		public static (T1, T2, T3, T4) Create<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4)
		{
			return (item1, item2, item3, item4);
		}

		public static (T1, T2, T3, T4, T5) Create<T1, T2, T3, T4, T5>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
		{
			return (item1, item2, item3, item4, item5);
		}

		public static (T1, T2, T3, T4, T5, T6) Create<T1, T2, T3, T4, T5, T6>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
		{
			return (item1, item2, item3, item4, item5, item6);
		}

		public static (T1, T2, T3, T4, T5, T6, T7) Create<T1, T2, T3, T4, T5, T6, T7>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
		{
			return (item1, item2, item3, item4, item5, item6, item7);
		}

		public static (T1, T2, T3, T4, T5, T6, T7, T8) Create<T1, T2, T3, T4, T5, T6, T7, T8>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
		{
			return new ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>>(item1, item2, item3, item4, item5, item6, item7, Create(item8));
		}

		internal static int CombineHashCodes(int h1, int h2)
		{
			return HashHelpers.Combine(HashHelpers.Combine(HashHelpers.RandomSeed, h1), h2);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2), h3);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3), h4);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4), h5);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5), h6);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5, h6), h7);
		}

		internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8)
		{
			return HashHelpers.Combine(CombineHashCodes(h1, h2, h3, h4, h5, h6, h7), h8);
		}
	}
	public struct ValueTuple<T1> : IEquatable<ValueTuple<T1>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1>>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		public T1 Item1;

		int System.ITupleInternal.Size => 1;

		public ValueTuple(T1 item1)
		{
			Item1 = item1;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1>)
			{
				return Equals((ValueTuple<T1>)obj);
			}
			return false;
		}

		public bool Equals(ValueTuple<T1> other)
		{
			return s_t1Comparer.Equals(Item1, other.Item1);
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is ValueTuple<T1> valueTuple))
			{
				return false;
			}
			return comparer.Equals(Item1, valueTuple.Item1);
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return Comparer<T1>.Default.Compare(Item1, valueTuple.Item1);
		}

		public int CompareTo(ValueTuple<T1> other)
		{
			return Comparer<T1>.Default.Compare(Item1, other.Item1);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return comparer.Compare(Item1, valueTuple.Item1);
		}

		public override int GetHashCode()
		{
			return s_t1Comparer.GetHashCode(Item1);
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return comparer.GetHashCode(Item1);
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return comparer.GetHashCode(Item1);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2> : IEquatable<(T1, T2)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		public T1 Item1;

		public T2 Item2;

		int System.ITupleInternal.Size => 2;

		public ValueTuple(T1 item1, T2 item2)
		{
			Item1 = item1;
			Item2 = item2;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2>)
			{
				return Equals(((T1, T2))obj);
			}
			return false;
		}

		public bool Equals((T1, T2) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1))
			{
				return s_t2Comparer.Equals(Item2, other.Item2);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1))
			{
				return comparer.Equals(Item2, tuple.Item2);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2))other);
		}

		public int CompareTo((T1, T2) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T2>.Default.Compare(Item2, other.Item2);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item2, tuple.Item2);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3> : IEquatable<(T1, T2, T3)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		int System.ITupleInternal.Size => 3;

		public ValueTuple(T1 item1, T2 item2, T3 item3)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3>)
			{
				return Equals(((T1, T2, T3))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2))
			{
				return s_t3Comparer.Equals(Item3, other.Item3);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1) && comparer.Equals(Item2, tuple.Item2))
			{
				return comparer.Equals(Item3, tuple.Item3);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3))other);
		}

		public int CompareTo((T1, T2, T3) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T3>.Default.Compare(Item3, other.Item3);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item3, tuple.Item3);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3, T4> : IEquatable<(T1, T2, T3, T4)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<T4>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		int System.ITupleInternal.Size => 4;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4>)
			{
				return Equals(((T1, T2, T3, T4))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2) && s_t3Comparer.Equals(Item3, other.Item3))
			{
				return s_t4Comparer.Equals(Item4, other.Item4);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1) && comparer.Equals(Item2, tuple.Item2) && comparer.Equals(Item3, tuple.Item3))
			{
				return comparer.Equals(Item4, tuple.Item4);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4))other);
		}

		public int CompareTo((T1, T2, T3, T4) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T3>.Default.Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T4>.Default.Compare(Item4, other.Item4);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item3, tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item4, tuple.Item4);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3, T4, T5> : IEquatable<(T1, T2, T3, T4, T5)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<T4>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<T5>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		int System.ITupleInternal.Size => 5;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5>)
			{
				return Equals(((T1, T2, T3, T4, T5))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2) && s_t3Comparer.Equals(Item3, other.Item3) && s_t4Comparer.Equals(Item4, other.Item4))
			{
				return s_t5Comparer.Equals(Item5, other.Item5);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1) && comparer.Equals(Item2, tuple.Item2) && comparer.Equals(Item3, tuple.Item3) && comparer.Equals(Item4, tuple.Item4))
			{
				return comparer.Equals(Item5, tuple.Item5);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T3>.Default.Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T4>.Default.Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T5>.Default.Compare(Item5, other.Item5);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item3, tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item4, tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item5, tuple.Item5);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6> : IEquatable<(T1, T2, T3, T4, T5, T6)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5, T6)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<T4>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<T5>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<T6>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		int System.ITupleInternal.Size => 6;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6>)
			{
				return Equals(((T1, T2, T3, T4, T5, T6))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5, T6) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2) && s_t3Comparer.Equals(Item3, other.Item3) && s_t4Comparer.Equals(Item4, other.Item4) && s_t5Comparer.Equals(Item5, other.Item5))
			{
				return s_t6Comparer.Equals(Item6, other.Item6);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5, T6) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1) && comparer.Equals(Item2, tuple.Item2) && comparer.Equals(Item3, tuple.Item3) && comparer.Equals(Item4, tuple.Item4) && comparer.Equals(Item5, tuple.Item5))
			{
				return comparer.Equals(Item6, tuple.Item6);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5, T6))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5, T6) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T3>.Default.Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T4>.Default.Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T5>.Default.Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T6>.Default.Compare(Item6, other.Item6);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5, T6) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item3, tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item4, tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item5, tuple.Item5);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item6, tuple.Item6);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7> : IEquatable<(T1, T2, T3, T4, T5, T6, T7)>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<(T1, T2, T3, T4, T5, T6, T7)>, System.ITupleInternal
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<T4>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<T5>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<T6>.Default;

		private static readonly EqualityComparer<T7> s_t7Comparer = EqualityComparer<T7>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		public T7 Item7;

		int System.ITupleInternal.Size => 7;

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
		{
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
			Item7 = item7;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7>)
			{
				return Equals(((T1, T2, T3, T4, T5, T6, T7))obj);
			}
			return false;
		}

		public bool Equals((T1, T2, T3, T4, T5, T6, T7) other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2) && s_t3Comparer.Equals(Item3, other.Item3) && s_t4Comparer.Equals(Item4, other.Item4) && s_t5Comparer.Equals(Item5, other.Item5) && s_t6Comparer.Equals(Item6, other.Item6))
			{
				return s_t7Comparer.Equals(Item7, other.Item7);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is (T1, T2, T3, T4, T5, T6, T7) tuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, tuple.Item1) && comparer.Equals(Item2, tuple.Item2) && comparer.Equals(Item3, tuple.Item3) && comparer.Equals(Item4, tuple.Item4) && comparer.Equals(Item5, tuple.Item5) && comparer.Equals(Item6, tuple.Item6))
			{
				return comparer.Equals(Item7, tuple.Item7);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo(((T1, T2, T3, T4, T5, T6, T7))other);
		}

		public int CompareTo((T1, T2, T3, T4, T5, T6, T7) other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T3>.Default.Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T4>.Default.Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T5>.Default.Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T6>.Default.Compare(Item6, other.Item6);
			if (num != 0)
			{
				return num;
			}
			return Comparer<T7>.Default.Compare(Item7, other.Item7);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is (T1, T2, T3, T4, T5, T6, T7) tuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, tuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, tuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item3, tuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item4, tuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item5, tuple.Item5);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item6, tuple.Item6);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Item7, tuple.Item7);
		}

		public override int GetHashCode()
		{
			return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7));
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7));
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ")";
		}

		string System.ITupleInternal.ToStringEnd()
		{
			return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ")";
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, System.ITupleInternal where TRest : struct
	{
		private static readonly EqualityComparer<T1> s_t1Comparer = EqualityComparer<T1>.Default;

		private static readonly EqualityComparer<T2> s_t2Comparer = EqualityComparer<T2>.Default;

		private static readonly EqualityComparer<T3> s_t3Comparer = EqualityComparer<T3>.Default;

		private static readonly EqualityComparer<T4> s_t4Comparer = EqualityComparer<T4>.Default;

		private static readonly EqualityComparer<T5> s_t5Comparer = EqualityComparer<T5>.Default;

		private static readonly EqualityComparer<T6> s_t6Comparer = EqualityComparer<T6>.Default;

		private static readonly EqualityComparer<T7> s_t7Comparer = EqualityComparer<T7>.Default;

		private static readonly EqualityComparer<TRest> s_tRestComparer = EqualityComparer<TRest>.Default;

		public T1 Item1;

		public T2 Item2;

		public T3 Item3;

		public T4 Item4;

		public T5 Item5;

		public T6 Item6;

		public T7 Item7;

		public TRest Rest;

		int System.ITupleInternal.Size
		{
			get
			{
				if ((object)Rest is System.ITupleInternal tupleInternal)
				{
					return 7 + tupleInternal.Size;
				}
				return 8;
			}
		}

		public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
		{
			if (!(rest is System.ITupleInternal))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleLastArgumentNotAValueTuple);
			}
			Item1 = item1;
			Item2 = item2;
			Item3 = item3;
			Item4 = item4;
			Item5 = item5;
			Item6 = item6;
			Item7 = item7;
			Rest = rest;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)
			{
				return Equals((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)obj);
			}
			return false;
		}

		public bool Equals(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> other)
		{
			if (s_t1Comparer.Equals(Item1, other.Item1) && s_t2Comparer.Equals(Item2, other.Item2) && s_t3Comparer.Equals(Item3, other.Item3) && s_t4Comparer.Equals(Item4, other.Item4) && s_t5Comparer.Equals(Item5, other.Item5) && s_t6Comparer.Equals(Item6, other.Item6) && s_t7Comparer.Equals(Item7, other.Item7))
			{
				return s_tRestComparer.Equals(Rest, other.Rest);
			}
			return false;
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> valueTuple))
			{
				return false;
			}
			if (comparer.Equals(Item1, valueTuple.Item1) && comparer.Equals(Item2, valueTuple.Item2) && comparer.Equals(Item3, valueTuple.Item3) && comparer.Equals(Item4, valueTuple.Item4) && comparer.Equals(Item5, valueTuple.Item5) && comparer.Equals(Item6, valueTuple.Item6) && comparer.Equals(Item7, valueTuple.Item7))
			{
				return comparer.Equals(Rest, valueTuple.Rest);
			}
			return false;
		}

		int IComparable.CompareTo(object other)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			return CompareTo((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)other);
		}

		public int CompareTo(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> other)
		{
			int num = Comparer<T1>.Default.Compare(Item1, other.Item1);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T2>.Default.Compare(Item2, other.Item2);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T3>.Default.Compare(Item3, other.Item3);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T4>.Default.Compare(Item4, other.Item4);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T5>.Default.Compare(Item5, other.Item5);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T6>.Default.Compare(Item6, other.Item6);
			if (num != 0)
			{
				return num;
			}
			num = Comparer<T7>.Default.Compare(Item7, other.Item7);
			if (num != 0)
			{
				return num;
			}
			return Comparer<TRest>.Default.Compare(Rest, other.Rest);
		}

		int IStructuralComparable.CompareTo(object other, IComparer comparer)
		{
			if (other == null)
			{
				return 1;
			}
			if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> valueTuple))
			{
				throw new ArgumentException(System.SR.ArgumentException_ValueTupleIncorrectType, "other");
			}
			int num = comparer.Compare(Item1, valueTuple.Item1);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item2, valueTuple.Item2);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item3, valueTuple.Item3);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item4, valueTuple.Item4);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item5, valueTuple.Item5);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item6, valueTuple.Item6);
			if (num != 0)
			{
				return num;
			}
			num = comparer.Compare(Item7, valueTuple.Item7);
			if (num != 0)
			{
				return num;
			}
			return comparer.Compare(Rest, valueTuple.Rest);
		}

		public override int GetHashCode()
		{
			if (!((object)Rest is System.ITupleInternal tupleInternal))
			{
				return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7));
			}
			int size = tupleInternal.Size;
			if (size >= 8)
			{
				return tupleInternal.GetHashCode();
			}
			switch (8 - size)
			{
			case 1:
				return ValueTuple.CombineHashCodes(s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 2:
				return ValueTuple.CombineHashCodes(s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 3:
				return ValueTuple.CombineHashCodes(s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 4:
				return ValueTuple.CombineHashCodes(s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 5:
				return ValueTuple.CombineHashCodes(s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 6:
				return ValueTuple.CombineHashCodes(s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			case 7:
			case 8:
				return ValueTuple.CombineHashCodes(s_t1Comparer.GetHashCode(Item1), s_t2Comparer.GetHashCode(Item2), s_t3Comparer.GetHashCode(Item3), s_t4Comparer.GetHashCode(Item4), s_t5Comparer.GetHashCode(Item5), s_t6Comparer.GetHashCode(Item6), s_t7Comparer.GetHashCode(Item7), tupleInternal.GetHashCode());
			default:
				return -1;
			}
		}

		int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		private int GetHashCodeCore(IEqualityComparer comparer)
		{
			if (!((object)Rest is System.ITupleInternal tupleInternal))
			{
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7));
			}
			int size = tupleInternal.Size;
			if (size >= 8)
			{
				return tupleInternal.GetHashCode(comparer);
			}
			switch (8 - size)
			{
			case 1:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 2:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 3:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 4:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 5:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 6:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			case 7:
			case 8:
				return ValueTuple.CombineHashCodes(comparer.GetHashCode(Item1), comparer.GetHashCode(Item2), comparer.GetHashCode(Item3), comparer.GetHashCode(Item4), comparer.GetHashCode(Item5), comparer.GetHashCode(Item6), comparer.GetHashCode(Item7), tupleInternal.GetHashCode(comparer));
			default:
				return -1;
			}
		}

		int System.ITupleInternal.GetHashCode(IEqualityComparer comparer)
		{
			return GetHashCodeCore(comparer);
		}

		public override string ToString()
		{
			string[] obj;
			T1 val;
			object obj2;
			if (!((object)Rest is System.ITupleInternal tupleInternal))
			{
				obj = new string[17]
				{
					"(", null, null, null, null, null, null, null, null, null,
					null, null, null, null, null, null, null
				};
				ref T1 reference = ref Item1;
				val = default(T1);
				if (val == null)
				{
					val = reference;
					reference = ref val;
					if (val == null)
					{
						obj2 = null;
						goto IL_005d;
					}
				}
				obj2 = reference.ToString();
				goto IL_005d;
			}
			string[] obj3 = new string[16]
			{
				"(", null, null, null, null, null, null, null, null, null,
				null, null, null, null, null, null
			};
			ref T1 reference2 = ref Item1;
			val = default(T1);
			object obj4;
			if (val == null)
			{
				val = reference2;
				reference2 = ref val;
				if (val == null)
				{
					obj4 = null;
					goto IL_0262;
				}
			}
			obj4 = reference2.ToString();
			goto IL_0262;
			IL_02e2:
			object obj5;
			obj3[5] = (string)obj5;
			obj3[6] = ", ";
			ref T4 reference3 = ref Item4;
			T4 val2 = default(T4);
			object obj6;
			if (val2 == null)
			{
				val2 = reference3;
				reference3 = ref val2;
				if (val2 == null)
				{
					obj6 = null;
					goto IL_0325;
				}
			}
			obj6 = reference3.ToString();
			goto IL_0325;
			IL_03f3:
			object obj7;
			obj3[13] = (string)obj7;
			obj3[14] = ", ";
			obj3[15] = tupleInternal.ToStringEnd();
			return string.Concat(obj3);
			IL_03ae:
			object obj8;
			obj3[11] = (string)obj8;
			obj3[12] = ", ";
			ref T7 reference4 = ref Item7;
			T7 val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference4;
				reference4 = ref val3;
				if (val3 == null)
				{
					obj7 = null;
					goto IL_03f3;
				}
			}
			obj7 = reference4.ToString();
			goto IL_03f3;
			IL_0120:
			object obj9;
			obj[7] = (string)obj9;
			obj[8] = ", ";
			ref T5 reference5 = ref Item5;
			T5 val4 = default(T5);
			object obj10;
			if (val4 == null)
			{
				val4 = reference5;
				reference5 = ref val4;
				if (val4 == null)
				{
					obj10 = null;
					goto IL_0164;
				}
			}
			obj10 = reference5.ToString();
			goto IL_0164;
			IL_005d:
			obj[1] = (string)obj2;
			obj[2] = ", ";
			ref T2 reference6 = ref Item2;
			T2 val5 = default(T2);
			object obj11;
			if (val5 == null)
			{
				val5 = reference6;
				reference6 = ref val5;
				if (val5 == null)
				{
					obj11 = null;
					goto IL_009d;
				}
			}
			obj11 = reference6.ToString();
			goto IL_009d;
			IL_0164:
			obj[9] = (string)obj10;
			obj[10] = ", ";
			ref T6 reference7 = ref Item6;
			T6 val6 = default(T6);
			object obj12;
			if (val6 == null)
			{
				val6 = reference7;
				reference7 = ref val6;
				if (val6 == null)
				{
					obj12 = null;
					goto IL_01a9;
				}
			}
			obj12 = reference7.ToString();
			goto IL_01a9;
			IL_02a2:
			object obj13;
			obj3[3] = (string)obj13;
			obj3[4] = ", ";
			ref T3 reference8 = ref Item3;
			T3 val7 = default(T3);
			if (val7 == null)
			{
				val7 = reference8;
				reference8 = ref val7;
				if (val7 == null)
				{
					obj5 = null;
					goto IL_02e2;
				}
			}
			obj5 = reference8.ToString();
			goto IL_02e2;
			IL_01ee:
			object obj14;
			obj[13] = (string)obj14;
			obj[14] = ", ";
			obj[15] = Rest.ToString();
			obj[16] = ")";
			return string.Concat(obj);
			IL_009d:
			obj[3] = (string)obj11;
			obj[4] = ", ";
			ref T3 reference9 = ref Item3;
			val7 = default(T3);
			object obj15;
			if (val7 == null)
			{
				val7 = reference9;
				reference9 = ref val7;
				if (val7 == null)
				{
					obj15 = null;
					goto IL_00dd;
				}
			}
			obj15 = reference9.ToString();
			goto IL_00dd;
			IL_0325:
			obj3[7] = (string)obj6;
			obj3[8] = ", ";
			ref T5 reference10 = ref Item5;
			val4 = default(T5);
			object obj16;
			if (val4 == null)
			{
				val4 = reference10;
				reference10 = ref val4;
				if (val4 == null)
				{
					obj16 = null;
					goto IL_0369;
				}
			}
			obj16 = reference10.ToString();
			goto IL_0369;
			IL_01a9:
			obj[11] = (string)obj12;
			obj[12] = ", ";
			ref T7 reference11 = ref Item7;
			val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference11;
				reference11 = ref val3;
				if (val3 == null)
				{
					obj14 = null;
					goto IL_01ee;
				}
			}
			obj14 = reference11.ToString();
			goto IL_01ee;
			IL_0262:
			obj3[1] = (string)obj4;
			obj3[2] = ", ";
			ref T2 reference12 = ref Item2;
			val5 = default(T2);
			if (val5 == null)
			{
				val5 = reference12;
				reference12 = ref val5;
				if (val5 == null)
				{
					obj13 = null;
					goto IL_02a2;
				}
			}
			obj13 = reference12.ToString();
			goto IL_02a2;
			IL_00dd:
			obj[5] = (string)obj15;
			obj[6] = ", ";
			ref T4 reference13 = ref Item4;
			val2 = default(T4);
			if (val2 == null)
			{
				val2 = reference13;
				reference13 = ref val2;
				if (val2 == null)
				{
					obj9 = null;
					goto IL_0120;
				}
			}
			obj9 = reference13.ToString();
			goto IL_0120;
			IL_0369:
			obj3[9] = (string)obj16;
			obj3[10] = ", ";
			ref T6 reference14 = ref Item6;
			val6 = default(T6);
			if (val6 == null)
			{
				val6 = reference14;
				reference14 = ref val6;
				if (val6 == null)
				{
					obj8 = null;
					goto IL_03ae;
				}
			}
			obj8 = reference14.ToString();
			goto IL_03ae;
		}

		string System.ITupleInternal.ToStringEnd()
		{
			string[] array;
			T1 val;
			object obj;
			if (!((object)Rest is System.ITupleInternal tupleInternal))
			{
				array = new string[16];
				ref T1 reference = ref Item1;
				val = default(T1);
				if (val == null)
				{
					val = reference;
					reference = ref val;
					if (val == null)
					{
						obj = null;
						goto IL_0055;
					}
				}
				obj = reference.ToString();
				goto IL_0055;
			}
			string[] array2 = new string[15];
			ref T1 reference2 = ref Item1;
			val = default(T1);
			object obj2;
			if (val == null)
			{
				val = reference2;
				reference2 = ref val;
				if (val == null)
				{
					obj2 = null;
					goto IL_0251;
				}
			}
			obj2 = reference2.ToString();
			goto IL_0251;
			IL_02d1:
			object obj3;
			array2[4] = (string)obj3;
			array2[5] = ", ";
			ref T4 reference3 = ref Item4;
			T4 val2 = default(T4);
			object obj4;
			if (val2 == null)
			{
				val2 = reference3;
				reference3 = ref val2;
				if (val2 == null)
				{
					obj4 = null;
					goto IL_0314;
				}
			}
			obj4 = reference3.ToString();
			goto IL_0314;
			IL_03e1:
			object obj5;
			array2[12] = (string)obj5;
			array2[13] = ", ";
			array2[14] = tupleInternal.ToStringEnd();
			return string.Concat(array2);
			IL_039c:
			object obj6;
			array2[10] = (string)obj6;
			array2[11] = ", ";
			ref T7 reference4 = ref Item7;
			T7 val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference4;
				reference4 = ref val3;
				if (val3 == null)
				{
					obj5 = null;
					goto IL_03e1;
				}
			}
			obj5 = reference4.ToString();
			goto IL_03e1;
			IL_0118:
			object obj7;
			array[6] = (string)obj7;
			array[7] = ", ";
			ref T5 reference5 = ref Item5;
			T5 val4 = default(T5);
			object obj8;
			if (val4 == null)
			{
				val4 = reference5;
				reference5 = ref val4;
				if (val4 == null)
				{
					obj8 = null;
					goto IL_015b;
				}
			}
			obj8 = reference5.ToString();
			goto IL_015b;
			IL_0055:
			array[0] = (string)obj;
			array[1] = ", ";
			ref T2 reference6 = ref Item2;
			T2 val5 = default(T2);
			object obj9;
			if (val5 == null)
			{
				val5 = reference6;
				reference6 = ref val5;
				if (val5 == null)
				{
					obj9 = null;
					goto IL_0095;
				}
			}
			obj9 = reference6.ToString();
			goto IL_0095;
			IL_015b:
			array[8] = (string)obj8;
			array[9] = ", ";
			ref T6 reference7 = ref Item6;
			T6 val6 = default(T6);
			object obj10;
			if (val6 == null)
			{
				val6 = reference7;
				reference7 = ref val6;
				if (val6 == null)
				{
					obj10 = null;
					goto IL_01a0;
				}
			}
			obj10 = reference7.ToString();
			goto IL_01a0;
			IL_0291:
			object obj11;
			array2[2] = (string)obj11;
			array2[3] = ", ";
			ref T3 reference8 = ref Item3;
			T3 val7 = default(T3);
			if (val7 == null)
			{
				val7 = reference8;
				reference8 = ref val7;
				if (val7 == null)
				{
					obj3 = null;
					goto IL_02d1;
				}
			}
			obj3 = reference8.ToString();
			goto IL_02d1;
			IL_01e5:
			object obj12;
			array[12] = (string)obj12;
			array[13] = ", ";
			array[14] = Rest.ToString();
			array[15] = ")";
			return string.Concat(array);
			IL_0095:
			array[2] = (string)obj9;
			array[3] = ", ";
			ref T3 reference9 = ref Item3;
			val7 = default(T3);
			object obj13;
			if (val7 == null)
			{
				val7 = reference9;
				reference9 = ref val7;
				if (val7 == null)
				{
					obj13 = null;
					goto IL_00d5;
				}
			}
			obj13 = reference9.ToString();
			goto IL_00d5;
			IL_0314:
			array2[6] = (string)obj4;
			array2[7] = ", ";
			ref T5 reference10 = ref Item5;
			val4 = default(T5);
			object obj14;
			if (val4 == null)
			{
				val4 = reference10;
				reference10 = ref val4;
				if (val4 == null)
				{
					obj14 = null;
					goto IL_0357;
				}
			}
			obj14 = reference10.ToString();
			goto IL_0357;
			IL_01a0:
			array[10] = (string)obj10;
			array[11] = ", ";
			ref T7 reference11 = ref Item7;
			val3 = default(T7);
			if (val3 == null)
			{
				val3 = reference11;
				reference11 = ref val3;
				if (val3 == null)
				{
					obj12 = null;
					goto IL_01e5;
				}
			}
			obj12 = reference11.ToString();
			goto IL_01e5;
			IL_0251:
			array2[0] = (string)obj2;
			array2[1] = ", ";
			ref T2 reference12 = ref Item2;
			val5 = default(T2);
			if (val5 == null)
			{
				val5 = reference12;
				reference12 = ref val5;
				if (val5 == null)
				{
					obj11 = null;
					goto IL_0291;
				}
			}
			obj11 = reference12.ToString();
			goto IL_0291;
			IL_00d5:
			array[4] = (string)obj13;
			array[5] = ", ";
			ref T4 reference13 = ref Item4;
			val2 = default(T4);
			if (val2 == null)
			{
				val2 = reference13;
				reference13 = ref val2;
				if (val2 == null)
				{
					obj7 = null;
					goto IL_0118;
				}
			}
			obj7 = reference13.ToString();
			goto IL_0118;
			IL_0357:
			array2[8] = (string)obj14;
			array2[9] = ", ";
			ref T6 reference14 = ref Item6;
			val6 = default(T6);
			if (val6 == null)
			{
				val6 = reference14;
				reference14 = ref val6;
				if (val6 == null)
				{
					obj6 = null;
					goto IL_039c;
				}
			}
			obj6 = reference14.ToString();
			goto IL_039c;
		}
	}
	internal static class SR
	{
		private static ResourceManager s_resourceManager;

		private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType));

		internal static Type ResourceType { get; } = typeof(SR);


		internal static string ArgumentException_ValueTupleIncorrectType => GetResourceString("ArgumentException_ValueTupleIncorrectType", null);

		internal static string ArgumentException_ValueTupleLastArgumentNotAValueTuple => GetResourceString("ArgumentException_ValueTupleLastArgumentNotAValueTuple", null);

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static bool UsingResourceKeys()
		{
			return false;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string text = null;
			try
			{
				text = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal))
			{
				return defaultString;
			}
			return text;
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + string.Join(", ", args);
				}
				return string.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(resourceFormat, p1);
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(resourceFormat, p1, p2);
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(resourceFormat, p1, p2, p3);
		}
	}
}
namespace System.Numerics.Hashing
{
	internal static class HashHelpers
	{
		public static readonly int RandomSeed = Guid.NewGuid().GetHashCode();

		public static int Combine(int h1, int h2)
		{
			uint num = (uint)(h1 << 5) | ((uint)h1 >> 27);
			return ((int)num + h1) ^ h2;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[CLSCompliant(false)]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
	public sealed class TupleElementNamesAttribute : Attribute
	{
		private readonly string[] _transformNames;

		public IList<string> TransformNames => _transformNames;

		public TupleElementNamesAttribute(string[] transformNames)
		{
			if (transformNames == null)
			{
				throw new ArgumentNullException("transformNames");
			}
			_transformNames = transformNames;
		}
	}
}