Decompiled source of BrigadierForLethalCompany v1.0.1

Brigadier for Lethal Company.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using Brigadier for Lethal Company.NetcodePatcher;
using Brigadier.NET;
using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Builder;
using Brigadier.NET.Context;
using Brigadier.NET.Exceptions;
using Brigadier.NET.Suggestion;
using Brigadier.NET.Tree;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Rumi.BrigadierForLethalCompany.API;
using Rumi.BrigadierForLethalCompany.API.Arguments;
using Rumi.BrigadierForLethalCompany.API.Arguments.Selectors;
using Rumi.BrigadierForLethalCompany.API.Arguments.Selectors.Options;
using Rumi.BrigadierForLethalCompany.Components;
using Rumi.BrigadierForLethalCompany.Networking;
using Rumi.LCNetworks;
using Rumi.LCNetworks.API;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany
{
	public static class BFLCPatches
	{
		public static void Patch()
		{
			Debug.Log("HUDManager Patch...");
			try
			{
				BFLCPlugin.harmony.PatchAll(typeof(BFLCPatches));
				Debug.Log("HUDManager Patched!");
			}
			catch (Exception data)
			{
				Debug.LogError(data);
				Debug.Log("HUDManager Patch Fail!");
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void HUDManager_Start_Postfix(HUDManager __instance)
		{
			CommandIntelliSense.Create(__instance);
			__instance.chatTextField.characterLimit = 0;
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool HUDManager_SubmitChat_performed_Prefix(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			if (!text.StartsWith("/"))
			{
				return true;
			}
			text = text.Remove(0, 1);
			BFLCNetworkHandler.ExecuteCommand(text);
			__instance.chatTextField.text = "";
			__instance.localPlayer.isTypingChat = false;
			((Behaviour)__instance.typingIndicator).enabled = false;
			EventSystem.current.SetSelectedGameObject((GameObject)null);
			return false;
		}
	}
	[BepInPlugin("Rumi.BrigadierForLethalCompany", "Brigadier for Lethal Company", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class BFLCPlugin : BaseUnityPlugin
	{
		public const string modGuid = "Rumi.BrigadierForLethalCompany";

		public const string modName = "Brigadier for Lethal Company";

		public const string modVersion = "1.0.1";

		internal static ManualLogSource? logger { get; private set; } = null;


		internal static Harmony harmony { get; } = new Harmony("Rumi.BrigadierForLethalCompany");


		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			Debug.Log("Start loading plugin...");
			LCNHPlugin.NetcodePatcher();
			BFLCPatches.Patch();
			Debug.Log("Plugin Brigadier for Lethal Company is loaded!");
		}
	}
	public static class BFLCUtility
	{
		public static void AddChatClient(string text)
		{
			HUDManager instance = HUDManager.Instance;
			if (instance.ChatMessageHistory.Count >= 4)
			{
				instance.ChatMessageHistory.Remove(instance.ChatMessageHistory[0]);
			}
			instance.ChatMessageHistory.Add("<color=white>" + text + "</color>");
			((TMP_Text)instance.chatText).text = string.Empty;
			for (int i = 0; i < instance.ChatMessageHistory.Count; i++)
			{
				TextMeshProUGUI chatText = instance.chatText;
				((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + instance.ChatMessageHistory[i];
			}
		}

		public static string GetEntityName(this NetworkBehaviour entity)
		{
			return Enumerable.Repeat<NetworkBehaviour>(entity, 1).GetEntityName(1);
		}

		public static string GetEntityName(this IEnumerable<NetworkBehaviour> entitys, int count = -1)
		{
			if (entitys.CountIsOne())
			{
				NetworkBehaviour val = entitys.First();
				PlayerControllerB val2 = (PlayerControllerB)(object)((val is PlayerControllerB) ? val : null);
				if (val2 != null)
				{
					return val2.playerUsername;
				}
				EnemyAI val3 = (EnemyAI)(object)((val is EnemyAI) ? val : null);
				if (val3 != null)
				{
					return val3.enemyType.enemyName;
				}
				Anomaly val4 = (Anomaly)(object)((val is Anomaly) ? val : null);
				if (val4 != null)
				{
					return val4.anomalyType.anomalyName;
				}
				GrabbableObject val5 = (GrabbableObject)(object)((val is GrabbableObject) ? val : null);
				if (val5 != null)
				{
					return val5.itemProperties.itemName;
				}
				return ((Object)val).name;
			}
			if (count < 0)
			{
				return $"{entitys.Count()} entities";
			}
			return $"{count} entities";
		}
	}
	internal static class Debug
	{
		public static void Log(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogInfo(data);
			}
		}

		public static void LogWarning(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogWarning(data);
			}
		}

		public static void LogError(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogError(data);
			}
		}
	}
	internal static class ReflectionManager
	{
		public static IReadOnlyList<Assembly> assemblys { get; }

		public static IReadOnlyList<Type> types { get; }

		static ReflectionManager()
		{
			assemblys = AppDomain.CurrentDomain.GetAssemblies();
			List<Type> list = new List<Type>();
			for (int i = 0; i < assemblys.Count; i++)
			{
				Type[] array = assemblys[i].GetTypes();
				foreach (Type item in array)
				{
					list.Add(item);
				}
			}
			types = list.ToArray();
		}

		public static bool IsSubtypeOf<T>(this Type type)
		{
			if (type != typeof(T))
			{
				return typeof(T).IsAssignableFrom(type);
			}
			return false;
		}

		public static bool IsSubtypeOf(this Type type, Type surclass)
		{
			if (type != surclass)
			{
				return surclass.IsAssignableFrom(type);
			}
			return false;
		}

		public static bool AttributeContains<T>(this MemberInfo element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this MemberInfo element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this Assembly element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this Assembly element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this ParameterInfo element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this ParameterInfo element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this Module element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this Module element, Type attribute)
		{
			return element.GetCustomAttributes(attribute, inherit: false).Length != 0;
		}

		public static bool IsAsyncMethod(this MethodBase methodBase)
		{
			return methodBase.AttributeContains<AsyncStateMachineAttribute>();
		}

		public static bool IsCompilerGenerated(this Type type)
		{
			return type.AttributeContains<CompilerGeneratedAttribute>();
		}

		public static bool IsCompilerGenerated(this MemberInfo memberInfo)
		{
			return memberInfo.AttributeContains<CompilerGeneratedAttribute>();
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.Networking
{
	public sealed class BFLCNetworkHandler : LCNHNetworkBehaviour<BFLCNetworkHandler>
	{
		public override string name => "BFLC Network Handler";

		public override uint globalIdHash => 133444399u;

		public override void OnNetworkSpawn()
		{
			base.OnNetworkSpawn();
			ServerCommand.Reset();
			ServerCommand.AllRegister();
		}

		public static void ExecuteCommand(string command)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)LCNHNetworkBehaviour<BFLCNetworkHandler>.instance == (Object)null))
			{
				Debug.Log("Sending commands to the server side : " + command);
				LCNHNetworkBehaviour<BFLCNetworkHandler>.instance.InternalExecuteCommandServerRpc(command, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)GameNetworkManager.Instance.localPlayerController));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void InternalExecuteCommandServerRpc(string command, NetworkBehaviourReference entityRef)
		{
			//IL_0165: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4207560014u, val, (RpcDelivery)0);
				bool flag = command != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(command, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref entityRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4207560014u, val, (RpcDelivery)0);
			}
			NetworkBehaviour val3 = default(NetworkBehaviour);
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || !((NetworkBehaviour)this).IsServer || !((NetworkBehaviourReference)(ref entityRef)).TryGet(ref val3, (NetworkManager)null))
			{
				return;
			}
			PlayerControllerB val4 = (PlayerControllerB)(object)((val3 is PlayerControllerB) ? val3 : null);
			if (val4 == null)
			{
				return;
			}
			Debug.Log("Received command from " + val4.playerUsername + " : " + command);
			ServerCommandSource serverCommandSource = new ServerCommandSource((NetworkBehaviour)(object)val4);
			try
			{
				ServerCommand.dispatcher.Execute(command, serverCommandSource);
			}
			catch (CommandSyntaxException val5)
			{
				CommandSyntaxException e = val5;
				serverCommandSource.SendCommandResult((Exception)(object)e);
			}
			catch (Exception data)
			{
				Debug.LogError(data);
			}
		}

		public static void AddGlobalChat(string text, PlayerControllerB? targetPlayer)
		{
			//IL_003a: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)LCNHNetworkBehaviour<BFLCNetworkHandler>.instance == (Object)null) && ((NetworkBehaviour)LCNHNetworkBehaviour<BFLCNetworkHandler>.instance).IsServer)
			{
				LCNHNetworkBehaviour<BFLCNetworkHandler>.instance.InternalAddGlobalChatClientRpc(text, (NetworkObjectReference)(((Object)(object)targetPlayer != (Object)null) ? NetworkObjectReference.op_Implicit(((Component)targetPlayer).GetComponent<NetworkObject>()) : default(NetworkObjectReference)));
			}
		}

		public static void AddChat(string text, PlayerControllerB? targetPlayer)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)LCNHNetworkBehaviour<BFLCNetworkHandler>.instance == (Object)null) && ((NetworkBehaviour)LCNHNetworkBehaviour<BFLCNetworkHandler>.instance).IsServer && !((Object)(object)targetPlayer == (Object)null))
			{
				NetworkObject component = ((Component)targetPlayer).GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					LCNHNetworkBehaviour<BFLCNetworkHandler>.instance.InternalAddChatClientRpc(text, NetworkObjectReference.op_Implicit(component));
				}
			}
		}

		[ClientRpc]
		private void InternalAddGlobalChatClientRpc(string text, NetworkObjectReference networkObjectReference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4288993996u, val, (RpcDelivery)0);
				bool flag = text != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(text, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4288993996u, val, (RpcDelivery)0);
			}
			NetworkObject val3 = default(NetworkObject);
			PlayerControllerB val4 = default(PlayerControllerB);
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (!((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref val3, (NetworkManager)null) || !((Component)val3).TryGetComponent<PlayerControllerB>(ref val4) || !((Object)(object)val4 == (Object)(object)GameNetworkManager.Instance.localPlayerController)))
			{
				BFLCUtility.AddChatClient(text);
			}
		}

		[ClientRpc]
		private void InternalAddChatClientRpc(string text, NetworkObjectReference networkObjectReference)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(849914934u, val, (RpcDelivery)0);
				bool flag = text != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(text, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 849914934u, val, (RpcDelivery)0);
			}
			NetworkObject val3 = default(NetworkObject);
			PlayerControllerB val4 = default(PlayerControllerB);
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref val3, (NetworkManager)null) && ((Component)val3).TryGetComponent<PlayerControllerB>(ref val4) && (Object)(object)val4 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				BFLCUtility.AddChatClient(text);
			}
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BFLCNetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4207560014u, new RpcReceiveHandler(__rpc_handler_4207560014));
			NetworkManager.__rpc_func_table.Add(4288993996u, new RpcReceiveHandler(__rpc_handler_4288993996));
			NetworkManager.__rpc_func_table.Add(849914934u, new RpcReceiveHandler(__rpc_handler_849914934));
		}

		private static void __rpc_handler_4207560014(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string command = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref command, false);
				}
				NetworkBehaviourReference entityRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref entityRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BFLCNetworkHandler)(object)target).InternalExecuteCommandServerRpc(command, entityRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4288993996(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string text = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				}
				NetworkObjectReference networkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BFLCNetworkHandler)(object)target).InternalAddGlobalChatClientRpc(text, networkObjectReference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_849914934(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string text = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				}
				NetworkObjectReference networkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BFLCNetworkHandler)(object)target).InternalAddChatClientRpc(text, networkObjectReference);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BFLCNetworkHandler";
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.Components
{
	public sealed class CommandIntelliSense : MonoBehaviour
	{
		private RectTransform? _rectTransform;

		private Image? _bgImage;

		private VerticalLayoutGroup? _layout;

		private ContentSizeFitter? _contentSizeFitter;

		private static readonly Color orgCaretColor = new Color(0.4157f, 0.3569f, 1f, 0.7725f);

		private static readonly Color orgTextColor = new Color(0.3451f, 0.3686f, 0.8196f, 0.8314f);

		private int lastCaretPosition;

		public static TMP_FontAsset? font => ((TMP_Text)HUDManager.Instance.chatText).font;

		public RectTransform rectTransform
		{
			get
			{
				//IL_0011: 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_0018: Expected O, but got Unknown
				//IL_001d: Expected O, but got Unknown
				RectTransform obj = _rectTransform;
				if (obj == null)
				{
					RectTransform val = (RectTransform)((Component)this).transform;
					RectTransform val2 = val;
					_rectTransform = val;
					obj = val2;
				}
				return obj;
			}
		}

		public Image bgImage => _bgImage ?? (_bgImage = ((Component)this).GetComponent<Image>());

		public VerticalLayoutGroup layout => _layout ?? (_layout = ((Component)this).GetComponent<VerticalLayoutGroup>());

		public ContentSizeFitter sizeFitter => _contentSizeFitter ?? (_contentSizeFitter = ((Component)this).GetComponent<ContentSizeFitter>());

		public HUDManager? hudManager { get; private set; }

		public TMP_InputField? chatField
		{
			get
			{
				if (!((Object)(object)hudManager != (Object)null))
				{
					return null;
				}
				return hudManager.chatTextField;
			}
		}

		public Image? inputBgImage { get; private set; }

		public CommandIntelliSenseText? text { get; private set; }

		private void Update()
		{
			if (!((Object)(object)chatField == (Object)null) && lastCaretPosition != chatField.caretPosition)
			{
				UpdateIntelliSenseText(chatField.text);
				lastCaretPosition = chatField.caretPosition;
			}
		}

		public async void UpdateIntelliSenseText(string input)
		{
			if (!((Object)(object)text == (Object)null) && !((Object)(object)inputBgImage == (Object)null) && !((Object)(object)chatField == (Object)null))
			{
				bool isCommand = input.StartsWith("/");
				if (isCommand && (Object)(object)hudManager != (Object)null)
				{
					TextMeshProUGUI val = text.text;
					((TMP_Text)val).text = await ServerCommand.dispatcher.GetIntelliSenseText(input.Remove(0, 1), new ServerCommandSource((NetworkBehaviour)(object)hudManager.localPlayer), chatField.caretPosition - 1);
				}
				else
				{
					((TMP_Text)text.text).text = string.Empty;
				}
				((Graphic)bgImage).color = (string.IsNullOrEmpty(((TMP_Text)text.text).text) ? Color.clear : Color.black);
				((Graphic)inputBgImage).color = (isCommand ? Color.black : Color.clear);
				chatField.caretColor = (isCommand ? Color.white : orgCaretColor);
				((Graphic)chatField.textComponent).color = (isCommand ? Color.white : orgTextColor);
				chatField.richText = !isCommand;
				((TMP_Text)text.text).fontSize = 14f * Mathf.Clamp(30f / (float)((TMP_Text)text.text).text.Count((char x) => x == '\n'), 0f, 1f);
				UpdateSize();
			}
		}

		public void UpdateSize()
		{
			if (!((Object)(object)text == (Object)null))
			{
				text.sizeFitter.SetLayoutHorizontal();
				text.sizeFitter.SetLayoutVertical();
			}
		}

		public static CommandIntelliSense Create(HUDManager hudManager)
		{
			//IL_0053: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			TMP_InputField chatTextField = hudManager.chatTextField;
			CommandIntelliSense commandIntelliSense = new GameObject("Command Intelli Sense", new Type[5]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			}).AddComponent<CommandIntelliSense>();
			((Component)commandIntelliSense).transform.SetParent(((Component)chatTextField).transform, false);
			((UnityEvent<string>)(object)chatTextField.onValueChanged).AddListener((UnityAction<string>)commandIntelliSense.UpdateIntelliSenseText);
			commandIntelliSense.rectTransform.anchorMin = Vector2.up;
			commandIntelliSense.rectTransform.anchorMax = Vector2.up;
			commandIntelliSense.rectTransform.pivot = new Vector2(0f, 0f);
			((Graphic)commandIntelliSense.bgImage).color = Color.clear;
			((LayoutGroup)commandIntelliSense.layout).padding = new RectOffset(5, 5, 5, 5);
			((HorizontalOrVerticalLayoutGroup)commandIntelliSense.layout).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)commandIntelliSense.layout).childForceExpandHeight = false;
			commandIntelliSense.sizeFitter.horizontalFit = (FitMode)2;
			commandIntelliSense.sizeFitter.verticalFit = (FitMode)2;
			Image val = new GameObject("Command Intelli Sense Input Field BG", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			}).AddComponent<Image>();
			((Component)val).transform.SetParent(((Component)chatTextField).transform, false);
			((Component)val).transform.SetAsFirstSibling();
			((Graphic)val).rectTransform.anchorMin = Vector2.zero;
			((Graphic)val).rectTransform.anchorMax = Vector2.one;
			((Graphic)val).rectTransform.sizeDelta = Vector2.zero;
			((Graphic)val).rectTransform.offsetMin = new Vector2(((Graphic)val).rectTransform.offsetMin.x, ((Graphic)val).rectTransform.offsetMin.y + 37f);
			((Graphic)val).rectTransform.offsetMax = new Vector2(((Graphic)val).rectTransform.offsetMax.x, ((Graphic)val).rectTransform.offsetMax.y - 2f);
			((Graphic)val).color = Color.clear;
			commandIntelliSense.inputBgImage = val;
			commandIntelliSense.hudManager = hudManager;
			commandIntelliSense.text = CommandIntelliSenseText.Create(commandIntelliSense);
			commandIntelliSense.UpdateSize();
			return commandIntelliSense;
		}
	}
	public sealed class CommandIntelliSenseText : MonoBehaviour
	{
		private RectTransform? _rectTransform;

		private TextMeshProUGUI? _text;

		private ContentSizeFitter? _sizeFitter;

		public RectTransform rectTransform
		{
			get
			{
				//IL_0011: 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_0018: Expected O, but got Unknown
				//IL_001d: Expected O, but got Unknown
				RectTransform obj = _rectTransform;
				if (obj == null)
				{
					RectTransform val = (RectTransform)((Component)this).transform;
					RectTransform val2 = val;
					_rectTransform = val;
					obj = val2;
				}
				return obj;
			}
		}

		public TextMeshProUGUI text => _text ?? (_text = ((Component)this).GetComponent<TextMeshProUGUI>());

		public ContentSizeFitter sizeFitter => _sizeFitter ?? (_sizeFitter = ((Component)this).GetComponent<ContentSizeFitter>());

		public static CommandIntelliSenseText Create(CommandIntelliSense parent)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			CommandIntelliSenseText commandIntelliSenseText = new GameObject("Text", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(TextMeshProUGUI),
				typeof(ContentSizeFitter)
			}).AddComponent<CommandIntelliSenseText>();
			((Component)commandIntelliSenseText).transform.SetParent(((Component)parent).transform, false);
			((TMP_Text)commandIntelliSenseText.text).text = "";
			((TMP_Text)commandIntelliSenseText.text).font = CommandIntelliSense.font;
			((TMP_Text)commandIntelliSenseText.text).fontSize = 14f;
			((TMP_Text)commandIntelliSenseText.text).enableWordWrapping = false;
			((TMP_Text)commandIntelliSenseText.text).alignment = (TextAlignmentOptions)1025;
			commandIntelliSenseText.sizeFitter.horizontalFit = (FitMode)2;
			commandIntelliSenseText.sizeFitter.verticalFit = (FitMode)2;
			return commandIntelliSenseText;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API
{
	public static class BuiltInExceptionsExpansion
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Function <>9__0_0;

			public static Function <>9__6_0;

			public static Function <>9__7_0;

			public static Function <>9__9_0;

			public static Function <>9__11_0;

			public static Function <>9__12_0;

			public static Function <>9__13_0;

			internal IMessage <ColonTooMany>b__0_0(object found, object max)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Number of colons must not be many than {max}, found {found}");
			}

			internal IMessage <SelectorUnkown>b__6_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown selector type '{x}'");
			}

			internal IMessage <SelectorOptionsUnknown>b__7_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown option '{x}'");
			}

			internal IMessage <SelectorOptionsValueless>b__9_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Expected value for option '{x}'");
			}

			internal IMessage <InvalidSort>b__11_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Invalid or unknown sort type '{x}'");
			}

			internal IMessage <InvalidEntityType>b__12_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Invalid or unknown entity type '{x}'");
			}

			internal IMessage <InvalidItemType>b__13_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown item '{x}'");
			}
		}

		public static Dynamic2CommandExceptionType ColonTooMany(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				Function val = (object found, object max) => (IMessage)new LiteralMessage($"Number of colons must not be many than {max}, found {found}");
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			return new Dynamic2CommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType InvalidPosSwizzle(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Invalid swizzle, expected combination of 'x', 'y' and 'z'"));
		}

		public static SimpleCommandExceptionType WorldLocalPosMixed(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Cannot mix world & local coordinates (everything must either use ^ or not)"));
		}

		public static SimpleCommandExceptionType EntityToMany(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only one entity is allowed, but the provided selector allows more than one"));
		}

		public static SimpleCommandExceptionType PlayerToMany(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only one player is allowed, but the provided selector allows more than one"));
		}

		public static SimpleCommandExceptionType OnlyPlayer(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only players may be affected by this command, but the provided selector includes entities"));
		}

		public static DynamicCommandExceptionType SelectorUnkown(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown selector type '{x}'");
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType SelectorOptionsUnknown(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown option '{x}'");
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType SelectorOptionsUnterminated(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Expected end of options"));
		}

		public static DynamicCommandExceptionType SelectorOptionsValueless(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Expected value for option '{x}'");
				<>c.<>9__9_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType RangeEmpty(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Expected value or range of values"));
		}

		public static DynamicCommandExceptionType InvalidSort(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Invalid or unknown sort type '{x}'");
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType InvalidEntityType(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Invalid or unknown entity type '{x}'");
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType InvalidItemType(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown item '{x}'");
				<>c.<>9__13_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}
	}
	public static class CommandUtility
	{
		public static async Task<string> GetIntelliSenseText<TSource>(this CommandDispatcher<TSource> dispatcher, string input, TSource source, int cursor)
		{
			if (cursor < 0 || cursor > input.Length)
			{
				return string.Empty;
			}
			StringReader val = new StringReader(input);
			ParseResults<TSource> parseResults = dispatcher.Parse(val, source);
			List<Suggestion> list = (await dispatcher.GetCompletionSuggestions(parseResults, cursor)).List;
			if (list.Count > 0)
			{
				return string.Join("\n", list.Select((Suggestion x) => x.Text));
			}
			IDictionary<CommandNode<TSource>, CommandSyntaxException> exceptions = parseResults.Exceptions;
			if (exceptions.Count > 0)
			{
				return string.Join("\n", exceptions.Select((KeyValuePair<CommandNode<TSource>, CommandSyntaxException> x) => ((Exception)(object)x.Value).Message));
			}
			SuggestionContext<TSource> val2 = parseResults.Context.FindSuggestionContext(cursor);
			if (val2.Parent.Children.Any((CommandNode<TSource> x) => x is ArgumentCommandNode<TSource>))
			{
				ICollection<string> values = dispatcher.GetSmartUsage(val2.Parent, source).Values;
				if (values.Count > 0)
				{
					return string.Join("\n", values);
				}
			}
			return string.Empty;
		}
	}
	public readonly struct Range : IEquatable<Range>
	{
		public readonly float? min;

		public readonly float? max;

		public Range(float? value)
		{
			min = (max = value);
		}

		public Range(float? min, float? max)
		{
			if (min.HasValue && max.HasValue && max < min)
			{
				this.max = max;
				this.min = min;
			}
			else
			{
				this.min = min;
				this.max = max;
			}
		}

		public bool Contains(float value)
		{
			if (!min.HasValue || min.Value <= value)
			{
				if (max.HasValue)
				{
					return value <= max.Value;
				}
				return true;
			}
			return false;
		}

		public bool Equals(Range other)
		{
			if ((!min.HasValue && !other.min.HasValue) || (min.HasValue && other.min.HasValue && min.Value == other.min.Value))
			{
				if (max.HasValue || other.max.HasValue)
				{
					if (max.HasValue && other.max.HasValue)
					{
						return max.Value == other.max.Value;
					}
					return false;
				}
				return true;
			}
			return false;
		}

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

		public override int GetHashCode()
		{
			return 542216 + min.GetHashCode() * 215321 + max.GetHashCode() * 826715;
		}

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

		public static bool operator !=(Range left, Range right)
		{
			return !(left == right);
		}

		public override string ToString()
		{
			return $"{min}..{max}";
		}
	}
	public readonly struct RangeInt : IEquatable<RangeInt>
	{
		public readonly int? min;

		public readonly int? max;

		public RangeInt(int? value)
		{
			min = (max = value);
		}

		public RangeInt(int? min, int? max)
		{
			if (min.HasValue && max.HasValue && max < min)
			{
				this.max = max;
				this.min = min;
			}
			else
			{
				this.min = min;
				this.max = max;
			}
		}

		public bool Contains(float value)
		{
			if (!min.HasValue || (float)min.Value <= value)
			{
				if (max.HasValue)
				{
					return value <= (float)max.Value;
				}
				return true;
			}
			return false;
		}

		public bool Equals(RangeInt other)
		{
			if ((!min.HasValue && !other.min.HasValue) || (min.HasValue && other.min.HasValue && min.Value == other.min.Value))
			{
				if (max.HasValue || other.max.HasValue)
				{
					if (max.HasValue && other.max.HasValue)
					{
						return max.Value == other.max.Value;
					}
					return false;
				}
				return true;
			}
			return false;
		}

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

		public override int GetHashCode()
		{
			return 542216 + min.GetHashCode() * 215321 + max.GetHashCode() * 826715;
		}

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

		public static bool operator !=(RangeInt left, RangeInt right)
		{
			return !(left == right);
		}

		public override string ToString()
		{
			return $"{min}..{max}";
		}
	}
	public abstract class ServerCommand
	{
		public static RootCommandNode<ServerCommandSource> rootNode
		{
			get
			{
				return dispatcher.GetRoot();
			}
			set
			{
				dispatcher = new CommandDispatcher<ServerCommandSource>(value);
			}
		}

		public static CommandDispatcher<ServerCommandSource> dispatcher { get; private set; } = new CommandDispatcher<ServerCommandSource>();


		public abstract void Register();

		public static void Reset()
		{
			dispatcher = new CommandDispatcher<ServerCommandSource>();
		}

		public static void AllRegister()
		{
			Debug.Log("Command Registering...");
			for (int i = 0; i < ReflectionManager.types.Count; i++)
			{
				Type type = ReflectionManager.types[i];
				if (!type.IsAbstract && typeof(ServerCommand).IsAssignableFrom(type))
				{
					try
					{
						((ServerCommand)Activator.CreateInstance(type, nonPublic: true))?.Register();
					}
					catch (Exception data)
					{
						Debug.LogError(data);
					}
				}
			}
			Debug.Log("Command Registered!");
		}
	}
	public class ServerCommandSource : ICloneable
	{
		public string name { get; private set; }

		public NetworkBehaviour? sender { get; private set; }

		public PlayerControllerB? player { get; private set; }

		public PlayerControllerB? firstPlayer { get; }

		public Vector3 position { get; private set; } = Vector3.zero;


		public Vector3 rotation { get; private set; } = Vector3.zero;


		public override string ToString()
		{
			//IL_004a: 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)
			return string.Format("{0}:{1}, {2}:{3}, {4}:{5}, {6}:{7}, {8}:{9}", "name", name, "sender", sender, "player", player, "position", position, "rotation", rotation);
		}

		public ServerCommandSource SetSender(NetworkBehaviour sender)
		{
			name = ((Object)sender).name;
			this.sender = sender;
			player = (PlayerControllerB?)(object)((sender is PlayerControllerB) ? sender : null);
			return this;
		}

		public ServerCommandSource SetPosition(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.position = position;
			return this;
		}

		public ServerCommandSource SetRotation(Vector3 rotation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.rotation = rotation;
			return this;
		}

		public void SendCommandResult(string text, bool sendGlobal = true)
		{
			if (!((Object)(object)sender == (Object)null))
			{
				BFLCNetworkHandler.AddChat("<color=white><size=10>" + text + "</size></color>", player);
				if (sendGlobal)
				{
					BFLCNetworkHandler.AddGlobalChat("<color=#aaaaaa><size=10><i>[" + sender.GetEntityName() + "] " + text + "</i></size></color>", player);
				}
			}
		}

		public void SendCommandResult(Exception e)
		{
			if (!((Object)(object)firstPlayer == (Object)null))
			{
				BFLCNetworkHandler.AddChat("<color=#ff5555><size=10>" + e.Message + "</size></color>", firstPlayer);
			}
		}

		public ServerCommandSource Clone()
		{
			return new ServerCommandSource(this);
		}

		object ICloneable.Clone()
		{
			return Clone();
		}

		public ServerCommandSource(string name = "IL")
			: this(name, Vector3.zero, Vector3.zero)
		{
		}//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)


		public ServerCommandSource(Vector3 position, Vector3 rotation)
			: this("IL", position, rotation)
		{
		}//IL_0006: 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)


		public ServerCommandSource(NetworkBehaviour entity)
			: this(entity, ((Component)entity).transform.position, ((Component)entity).transform.eulerAngles)
		{
			//IL_0008: 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)
			sender = entity;
		}

		public ServerCommandSource(NetworkBehaviour entity, Vector3 position, Vector3 rotation)
			: this(((Object)entity).name, position, rotation)
		{
			//IL_0007: 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)
			sender = entity;
			NetworkBehaviour? obj = sender;
			player = (PlayerControllerB?)(object)((obj is PlayerControllerB) ? obj : null);
			firstPlayer = player;
		}

		public ServerCommandSource(string name, Vector3 position, Vector3 rotation)
		{
			//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)
			//IL_000c: 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_0024: 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)
			this.name = name;
			this.position = position;
			this.rotation = rotation;
		}

		public ServerCommandSource(ServerCommandSource source)
		{
			//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)
			//IL_000c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			name = source.name;
			sender = source.sender;
			player = source.player;
			firstPlayer = player;
			position = source.position;
			rotation = source.rotation;
		}
	}
	public static class StringReaderExpansion
	{
		public static PosSwizzleEnum ReadPosSwizzle(this IStringReader reader)
		{
			PosSwizzleEnum posSwizzleEnum = PosSwizzleEnum.none;
			while (((IImmutableStringReader)reader).CanRead() && !char.IsWhiteSpace(((IImmutableStringReader)reader).Peek()))
			{
				if (((IImmutableStringReader)reader).Peek() == 'x')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.x))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.x : (posSwizzleEnum | PosSwizzleEnum.x));
					continue;
				}
				if (((IImmutableStringReader)reader).Peek() == 'y')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.y))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.y : (posSwizzleEnum | PosSwizzleEnum.y));
					continue;
				}
				if (((IImmutableStringReader)reader).Peek() == 'z')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.z))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.z : (posSwizzleEnum | PosSwizzleEnum.z));
					continue;
				}
				throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
			}
			return posSwizzleEnum;
		}

		public static Range ReadRange(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			string text = reader.ReadNumberString();
			string[] array = text.Split("..");
			if (array.Length == 2)
			{
				float? min = null;
				string text2 = array[0];
				if (!string.IsNullOrEmpty(text2))
				{
					try
					{
						min = float.Parse(text2);
					}
					catch (FormatException)
					{
						reader.Cursor = cursor;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text2);
					}
				}
				float? max = null;
				string text3 = array[1];
				if (!string.IsNullOrEmpty(text3))
				{
					try
					{
						max = float.Parse(text3);
					}
					catch (FormatException)
					{
						reader.Cursor = cursor;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text3);
					}
				}
				if (!min.HasValue && !max.HasValue)
				{
					throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				return new Range(min, max);
			}
			if (array.Length == 1)
			{
				try
				{
					return new Range(float.Parse(text));
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
		}

		public static RangeInt ReadRangeInt(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			string text = reader.ReadNumberString();
			string[] array = text.Split("..");
			if (array.Length == 2)
			{
				int? min;
				try
				{
					min = int.Parse(array[0]);
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)array[0]);
				}
				int? max;
				try
				{
					max = int.Parse(array[1]);
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)array[1]);
				}
				if (!min.HasValue && !max.HasValue)
				{
					throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				return new RangeInt(min, max);
			}
			if (array.Length == 1)
			{
				try
				{
					return new RangeInt(int.Parse(text));
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)text);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
		}

		public static string ReadNumberString(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			while (((IImmutableStringReader)reader).CanRead() && IsAllowedNumber(((IImmutableStringReader)reader).Peek()))
			{
				reader.Skip();
			}
			return ((IImmutableStringReader)reader).String.Substring(cursor, reader.Cursor - cursor);
		}

		public static bool IsAllowedNumber(char c)
		{
			if ((c < '0' || c > '9') && c != '-')
			{
				return c == '.';
			}
			return true;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API.Commands
{
	public sealed class Log : ServerCommand
	{
		public const string resultText = "Successfully sent the log command to the server";

		private Log()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "log")).Then<ArgumentCommandNode<ServerCommandSource, string>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, string>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, string>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, string>, ArgumentCommandNode<ServerCommandSource, string>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, string>(x, "message", (ArgumentType<string>)(object)RuniArguments.GreedyString())).Executes((Command<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				string @string = RuniArguments.GetString<ServerCommandSource>(x, "message");
				Debug.Log(@string);
				x.Source.SendCommandResult("Successfully sent the log command to the server");
				return @string.Length;
			})))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "source")).Executes((Command<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				string text = x.Source.ToString();
				Debug.Log(text);
				return text.Length;
			})))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "types")).Executes((Command<ServerCommandSource>)delegate
			{
				Debug.Log("player");
				Debug.Log("enemy");
				Debug.Log("item");
				return 4;
			})))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "entitys")).Executes((Command<ServerCommandSource>)delegate
			{
				int num3 = 0;
				foreach (var enemyType in EnemyTypeArgumentType.GetEnemyTypes())
				{
					Debug.Log(enemyType.enemyName);
					num3++;
				}
				return num3;
			})))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "anomalys")).Executes((Command<ServerCommandSource>)delegate
			{
				int num2 = 0;
				foreach (var anomalyType in AnomalyTypeArgumentType.GetAnomalyTypes())
				{
					Debug.Log(anomalyType.anomalyName);
					num2++;
				}
				return num2;
			})))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "items")).Executes((Command<ServerCommandSource>)delegate
			{
				int num = 0;
				foreach (var itemType in ItemTypeArgumentType.GetItemTypes())
				{
					Debug.Log(itemType.itemName);
					num++;
				}
				return num;
			})))));
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API.Commands.Executes
{
	public static class Execute
	{
		private static LiteralCommandNode<ServerCommandSource>? _execute;

		public static LiteralCommandNode<ServerCommandSource> root => _execute ?? (_execute = ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "run")).Redirect((CommandNode<ServerCommandSource>)(object)ServerCommand.dispatcher.GetRoot()))))));
	}
	public sealed class ExecuteAlign : ServerCommand
	{
		private ExecuteAlign()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "align")).Then<ArgumentCommandNode<ServerCommandSource, PosSwizzleEnum>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, PosSwizzleEnum>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, PosSwizzleEnum>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, PosSwizzleEnum>, ArgumentCommandNode<ServerCommandSource, PosSwizzleEnum>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, PosSwizzleEnum>(x, "axes", (ArgumentType<PosSwizzleEnum>)RuniArguments.PosSwizzle())).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				//IL_0012: 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_002d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				PosSwizzleEnum posSwizzle = RuniArguments.GetPosSwizzle<ServerCommandSource>(x, "axes");
				Vector3 position = x.Source.position;
				if (posSwizzle.HasFlag(PosSwizzleEnum.x))
				{
					position.x = Mathf.Floor(position.x);
				}
				if (posSwizzle.HasFlag(PosSwizzleEnum.y))
				{
					position.y = Mathf.Floor(position.y);
				}
				if (posSwizzle.HasFlag(PosSwizzleEnum.z))
				{
					position.z = Mathf.Floor(position.z);
				}
				return x.Source.SetPosition(position);
			})))))));
		}
	}
	public sealed class ExecuteAs : ServerCommand
	{
		private ExecuteAs()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "as")).Then<ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, SelectorArgumentValue>, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, SelectorArgumentValue>(x, "targets", (ArgumentType<SelectorArgumentValue>)RuniArguments.Selector())).Fork((CommandNode<ServerCommandSource>)(object)Execute.root, (RedirectModifier<ServerCommandSource>)((CommandContext<ServerCommandSource> x) => (from y in RuniArguments.GetSelector<ServerCommandSource>(x, "targets").GetEntitys(x.Source)
				select x.Source.Clone().SetSender(y)).ToArray()))))))));
		}
	}
	public sealed class ExecuteAt : ServerCommand
	{
		private ExecuteAt()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "at")).Then<ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, SelectorArgumentValue>, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, SelectorArgumentValue>(x, "targets", (ArgumentType<SelectorArgumentValue>)RuniArguments.Selector(onlyPlayer: false, limit: true))).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				//IL_0035: 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)
				IEnumerable<NetworkBehaviour> entitys = RuniArguments.GetSelector<ServerCommandSource>(x, "targets").GetEntitys(x.Source);
				if (entitys.Any())
				{
					NetworkBehaviour val = entitys.First();
					x.Source.SetPosition(((Component)val).transform.position);
					x.Source.SetRotation(((Component)val).transform.eulerAngles);
				}
				return x.Source;
			})))))));
		}
	}
	public sealed class ExecuteFacing : ServerCommand
	{
		private ExecuteFacing()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "facing")).Then<ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, CoordinatesArgumentValue<float>[]>, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, CoordinatesArgumentValue<float>[]>(x, "pos", (ArgumentType<CoordinatesArgumentValue<float>[]>)(object)RuniArguments.Vector3())).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				//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_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Quaternion val = Quaternion.LookRotation(RuniArguments.GetVector3<ServerCommandSource>(x, "pos"));
				Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles;
				return x.Source.SetRotation(eulerAngles);
			})))))));
		}
	}
	public sealed class ExecuteLog : ServerCommand
	{
		private ExecuteLog()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "log")).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				Debug.Log(x.Source);
				x.Source.SendCommandResult("Successfully sent the log command to the server");
				return x.Source;
			})).Executes((Command<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				Debug.Log(x.Source);
				x.Source.SendCommandResult("Successfully sent the log command to the server");
				return 1;
			})))));
		}
	}
	public sealed class ExecuteLoop : ServerCommand
	{
		private ExecuteLoop()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "loop")).Then<ArgumentCommandNode<ServerCommandSource, int>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, int>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, int>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, int>, ArgumentCommandNode<ServerCommandSource, int>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, int>(x, "count", (ArgumentType<int>)(object)RuniArguments.Integer())).Fork((CommandNode<ServerCommandSource>)(object)Execute.root, (RedirectModifier<ServerCommandSource>)((CommandContext<ServerCommandSource> x) => Enumerable.Repeat(x.Source.Clone(), RuniArguments.GetInteger<ServerCommandSource>(x, "count")).ToArray()))))))));
		}
	}
	public sealed class ExecutePositioned : ServerCommand
	{
		private ExecutePositioned()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "positioned")).Then<ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, CoordinatesArgumentValue<float>[]>, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, CoordinatesArgumentValue<float>[]>, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, CoordinatesArgumentValue<float>[]>(x, "pos", (ArgumentType<CoordinatesArgumentValue<float>[]>)(object)RuniArguments.Vector3())).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)((CommandContext<ServerCommandSource> x) => x.Source.SetPosition(RuniArguments.GetVector3<ServerCommandSource>(x, "pos"))))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "as")).Then<ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, SelectorArgumentValue>, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, SelectorArgumentValue>(x, "targets", (ArgumentType<SelectorArgumentValue>)RuniArguments.Selector(onlyPlayer: false, limit: true))).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				IEnumerable<NetworkBehaviour> entitys = RuniArguments.GetSelector<ServerCommandSource>(x, "targets").GetEntitys(x.Source);
				if (entitys.CountIsOne())
				{
					NetworkBehaviour val = entitys.First();
					return x.Source.SetPosition(((Component)val).transform.position);
				}
				return x.Source;
			})))))))))));
		}
	}
	public sealed class ExecuteRotated : ServerCommand
	{
		private ExecuteRotated()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "execute")).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "rotated")).Then<ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, CoordinatesArgumentValue<float>[]>, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, CoordinatesArgumentValue<float>[]>, ArgumentCommandNode<ServerCommandSource, CoordinatesArgumentValue<float>[]>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, CoordinatesArgumentValue<float>[]>(x, "rot", (ArgumentType<CoordinatesArgumentValue<float>[]>)(object)RuniArguments.Vector3())).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)((CommandContext<ServerCommandSource> x) => x.Source.SetRotation(RuniArguments.GetVector3<ServerCommandSource>(x, "rot"))))).Then<LiteralCommandNode<ServerCommandSource>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "as")).Then<ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, SelectorArgumentValue>, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, SelectorArgumentValue>(x, "targets", (ArgumentType<SelectorArgumentValue>)RuniArguments.Selector(onlyPlayer: false, limit: true))).Redirect((CommandNode<ServerCommandSource>)(object)Execute.root, (SingleRedirectModifier<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				IEnumerable<NetworkBehaviour> entitys = RuniArguments.GetSelector<ServerCommandSource>(x, "targets").GetEntitys(x.Source);
				if (entitys.CountIsOne())
				{
					NetworkBehaviour val = entitys.First();
					return x.Source.SetRotation(((Component)val).transform.eulerAngles);
				}
				return x.Source;
			})))))))))));
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API.Arguments
{
	public class AnomalyTypeArgumentType : RuniArgumentType<AnomalyType>
	{
		private static IEnumerable<(string anomalyName, AnomalyType anomalyType)>? types;

		public override AnomalyType Parse(IStringReader reader)
		{
			string type = reader.ReadString();
			IEnumerable<(string, AnomalyType)> source = from x in GetAnomalyTypes()
				where x.anomalyName == type
				select x;
			if (source.Any())
			{
				return source.First().Item2;
			}
			throw CommandSyntaxException.BuiltInExceptions.InvalidEntityType().CreateWithContext((IImmutableStringReader)(object)reader, (object)type);
		}

		public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			foreach (var anomalyType in GetAnomalyTypes())
			{
				string item = anomalyType.anomalyName;
				if (item.StartsWith(builder.Remaining))
				{
					builder.Suggest(item);
				}
			}
			return builder.BuildFuture();
		}

		public static IEnumerable<(string anomalyName, AnomalyType anomalyType)> GetAnomalyTypes()
		{
			return types ?? (types = from x in Resources.FindObjectsOfTypeAll<AnomalyType>()
				select (x.anomalyName.Replace(" ", "_").ToLower(), x));
		}
	}
	public class CoordinatesArgument<T> : RuniArgumentType<CoordinatesArgumentValue<T>[]> where T : struct, IComparable<T>
	{
		private readonly Func<IStringReader, T> readFunc;

		public virtual T? minimum { get; }

		public virtual T? maximum { get; }

		public virtual int argumentCount { get; }

		public virtual int localArgumentCount { get; }

		protected internal CoordinatesArgument(T? minimum, T? maximum, Func<IStringReader, T> readFunc, int argumentCount, int localArgumentCount = 0)
		{
			if (!minimum.HasValue || !maximum.HasValue || minimum.Value.CompareTo(maximum.Value) < 0)
			{
				this.minimum = minimum;
				this.maximum = maximum;
			}
			else
			{
				this.minimum = maximum;
				this.maximum = minimum;
			}
			this.readFunc = readFunc;
			this.argumentCount = argumentCount;
			this.localArgumentCount = localArgumentCount;
		}

		public T Read(IStringReader reader, ref CoordinateType numberBaseType)
		{
			if (!((IImmutableStringReader)reader).CanRead())
			{
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext((IImmutableStringReader)(object)reader);
			}
			if (((IImmutableStringReader)reader).Peek() == '~')
			{
				if (numberBaseType == CoordinateType.local)
				{
					throw CommandSyntaxException.BuiltInExceptions.WorldLocalPosMixed().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				reader.Skip();
				numberBaseType = CoordinateType.offset;
				if (!((IImmutableStringReader)reader).CanRead() || char.IsWhiteSpace(((IImmutableStringReader)reader).Peek()))
				{
					return default(T);
				}
				return readFunc(reader);
			}
			if (localArgumentCount > 0 && ((IImmutableStringReader)reader).Peek() == '^')
			{
				if (numberBaseType != 0 && numberBaseType != CoordinateType.local)
				{
					throw CommandSyntaxException.BuiltInExceptions.WorldLocalPosMixed().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				reader.Skip();
				numberBaseType = CoordinateType.local;
				if (!((IImmutableStringReader)reader).CanRead() || char.IsWhiteSpace(((IImmutableStringReader)reader).Peek()))
				{
					return default(T);
				}
				return readFunc(reader);
			}
			if (numberBaseType == CoordinateType.local)
			{
				throw CommandSyntaxException.BuiltInExceptions.WorldLocalPosMixed().CreateWithContext((IImmutableStringReader)(object)reader);
			}
			numberBaseType = CoordinateType.world;
			return readFunc(reader);
		}

		public override CoordinatesArgumentValue<T>[] Parse(IStringReader reader)
		{
			CoordinatesArgumentValue<T>[] array = new CoordinatesArgumentValue<T>[argumentCount];
			int cursor = reader.Cursor;
			CoordinateType numberBaseType = CoordinateType.none;
			for (int i = 0; i < ((numberBaseType == CoordinateType.local) ? localArgumentCount : argumentCount); i++)
			{
				if (i > 0)
				{
					reader.Skip();
				}
				T value = Read(reader, ref numberBaseType);
				MinMaxThrow(reader, reader.Cursor, value);
				if (i < argumentCount - 1)
				{
					NextCanReadThrow(reader, cursor);
				}
				array[i] = new CoordinatesArgumentValue<T>(value, numberBaseType);
			}
			return array;
		}

		private void MinMaxThrow(IStringReader reader, int cursor, T value)
		{
			if (minimum.HasValue && value.CompareTo(minimum.Value) < 0)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooLow().CreateWithContext((IImmutableStringReader)(object)reader, (object)value, (object)minimum);
			}
			if (maximum.HasValue && value.CompareTo(maximum.Value) > 0)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooHigh().CreateWithContext((IImmutableStringReader)(object)reader, (object)value, (object)maximum);
			}
		}

		private void NextCanReadThrow(IStringReader reader, int firstCursor)
		{
			if (!((IImmutableStringReader)reader).CanRead(2))
			{
				reader.Cursor = firstCursor;
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext((IImmutableStringReader)(object)reader);
			}
		}

		public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			string text = builder.Remaining.Trim();
			if (text.StartsWith('~'))
			{
				builder.Suggest("~ ~ ~");
			}
			else if (text.StartsWith('^'))
			{
				builder.Suggest("^ ^ ^");
			}
			return builder.BuildFuture();
		}

		public override bool Equals(object? o)
		{
			if (o is CoordinatesArgument<T> coordinatesArgument && object.Equals(minimum, coordinatesArgument.minimum))
			{
				return object.Equals(maximum, coordinatesArgument.maximum);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return ((object)this).GetType().GetHashCode() * minimum.GetHashCode() * maximum.GetHashCode();
		}

		public override string ToString()
		{
			return $"{typeof(T)}({(minimum.HasValue ? ((object)minimum) : string.Empty)}~{(maximum.HasValue ? ((object)maximum) : string.Empty)})";
		}
	}
	public struct CoordinatesArgumentValue<T>
	{
		public T value;

		public CoordinateType coordinatesType;

		public CoordinatesArgumentValue(T value, CoordinateType coordinatesType)
		{
			this.value = value;
			this.coordinatesType = coordinatesType;
		}
	}
	public enum CoordinateType
	{
		none,
		world,
		offset,
		local
	}
	public class EnemyTypeArgumentType : RuniArgumentType<EnemyType>
	{
		private static IEnumerable<(string enemyName, EnemyType enemyType)>? types;

		public override EnemyType Parse(IStringReader reader)
		{
			string type = reader.ReadString();
			IEnumerable<(string, EnemyType)> source = from x in GetEnemyTypes()
				where x.enemyName == type
				select x;
			if (source.Any())
			{
				return source.First().Item2;
			}
			throw CommandSyntaxException.BuiltInExceptions.InvalidEntityType().CreateWithContext((IImmutableStringReader)(object)reader, (object)type);
		}

		public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			foreach (var enemyType in GetEnemyTypes())
			{
				string item = enemyType.enemyName;
				if (item.StartsWith(builder.Remaining))
				{
					builder.Suggest(item);
				}
			}
			return builder.BuildFuture();
		}

		public static IEnumerable<(string enemyName, EnemyType enemyType)> GetEnemyTypes()
		{
			return types ?? (types = from x in Resources.FindObjectsOfTypeAll<EnemyType>()
				select (x.enemyName.Replace(" ", "_").ToLower(), x));
		}
	}
	public class GameObjectArgumentType : RuniArgumentType<GameObject>
	{
		public override GameObject Parse(IStringReader reader)
		{
			int hashCode = reader.ReadInt();
			return Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0).First((GameObject x) => ((object)x).GetHashCode() == hashCode);
		}
	}
	public class GameObjectsStringArgumentType : RuniArgumentType<GameObject[]>
	{
		public override GameObject[] Parse(IStringReader reader)
		{
			string name = reader.ReadString();
			return (from x in Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0)
				where ((Object)x).name == name
				select x).ToArray();
		}
	}
	public class ItemTypeArgumentType : RuniArgumentType<Item>
	{
		private static IEnumerable<(string itemName, Item itemType)>? types;

		public override Item Parse(IStringReader reader)
		{
			string type = reader.ReadString();
			IEnumerable<(string, Item)> source = from x in GetItemTypes()
				where x.itemName == type
				select x;
			if (source.Any())
			{
				return source.First().Item2;
			}
			throw CommandSyntaxException.BuiltInExceptions.InvalidItemType().CreateWithContext((IImmutableStringReader)(object)reader, (object)type);
		}

		public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			foreach (var itemType in GetItemTypes())
			{
				string item = itemType.itemName;
				if (item.StartsWith(builder.Remaining))
				{
					builder.Suggest(item);
				}
			}
			return builder.BuildFuture();
		}

		public static IEnumerable<(string itemName, Item itemType)> GetItemTypes()
		{
			return types ?? (types = from x in Resources.FindObjectsOfTypeAll<Item>()
				select (x.itemName.Replace(" ", "_").ToLower(), x));
		}
	}
	public class NumbersArgument<T> : RuniArgumentType<T[]> where T : struct, IComparable<T>
	{
		private readonly Func<IStringReader, T> readFunc;

		public virtual T? minimum { get; }

		public virtual T? maximum { get; }

		public virtual int argumentCount { get; }

		protected internal NumbersArgument(T? minimum, T? maximum, Func<IStringReader, T> readFunc, int argumentCount)
		{
			if (!minimum.HasValue || !maximum.HasValue || minimum.Value.CompareTo(maximum.Value) < 0)
			{
				this.minimum = minimum;
				this.maximum = maximum;
			}
			else
			{
				this.minimum = maximum;
				this.maximum = minimum;
			}
			this.readFunc = readFunc;
			this.argumentCount = argumentCount;
		}

		public override T[] Parse(IStringReader reader)
		{
			if (!((IImmutableStringReader)reader).CanRead())
			{
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext((IImmutableStringReader)(object)reader);
			}
			T[] array = new T[argumentCount];
			int cursor = reader.Cursor;
			for (int i = 0; i < argumentCount; i++)
			{
				if (i > 0)
				{
					int cursor2 = reader.Cursor;
					reader.Cursor = cursor2 + 1;
				}
				T val = readFunc(reader);
				MinMaxThrow(reader, reader.Cursor, val);
				if (i < argumentCount - 1)
				{
					NextCanReadThrow(reader, cursor);
				}
				array[i] = val;
			}
			return array;
		}

		private void MinMaxThrow(IStringReader reader, int cursor, T value)
		{
			if (minimum.HasValue && value.CompareTo(minimum.Value) < 0)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooLow().CreateWithContext((IImmutableStringReader)(object)reader, (object)value, (object)minimum);
			}
			if (maximum.HasValue && value.CompareTo(maximum.Value) > 0)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooHigh().CreateWithContext((IImmutableStringReader)(object)reader, (object)value, (object)maximum);
			}
		}

		private void NextCanReadThrow(IStringReader reader, int firstCursor)
		{
			if (!((IImmutableStringReader)reader).CanRead(2))
			{
				reader.Cursor = firstCursor;
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext((IImmutableStringReader)(object)reader);
			}
		}

		public override bool Equals(object? o)
		{
			if (o is NumbersArgument<T> numbersArgument && object.Equals(minimum, numbersArgument.minimum))
			{
				return object.Equals(maximum, numbersArgument.maximum);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return ((object)this).GetType().GetHashCode() * minimu

Brigadier.NET.dll

Decompiled 3 hours ago
using System;
using System.Collections;
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 System.Threading.Tasks;
using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Builder;
using Brigadier.NET.Context;
using Brigadier.NET.Exceptions;
using Brigadier.NET.Suggestion;
using Brigadier.NET.Tree;
using Brigadier.NET.Util;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Steven Blom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Brigadier.NET is a port of Mojang's brigadier command line parser & dispatcher, originally for Minecraft: Java Edition and now freely available for use elsewhere under the MIT license.\n\nThis port is not supported by Mojang or Microsoft.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Brigadier.NET")]
[assembly: AssemblyTitle("Brigadier.NET")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AtomicBlom/Brigadier.NET")]
[assembly: AssemblyVersion("1.0.0.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 Brigadier.NET
{
	public delegate void AmbiguityConsumer<TSource>(CommandNode<TSource> parent, CommandNode<TSource> child, CommandNode<TSource> sibling, IEnumerable<string> inputs);
	public class Arguments
	{
		public static IntegerArgumentType Integer(int min = int.MinValue, int max = int.MaxValue)
		{
			return new IntegerArgumentType(min, max);
		}

		public static int GetInteger<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<int>(name);
		}

		public static BoolArgumentType Bool()
		{
			return new BoolArgumentType();
		}

		public static bool GetBool<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<bool>(name);
		}

		public static DoubleArgumentType Double(double min = double.MinValue, double max = double.MaxValue)
		{
			return new DoubleArgumentType(min, max);
		}

		public static double GetDouble<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<double>(name);
		}

		public static FloatArgumentType Float(float min = float.MinValue, float max = float.MaxValue)
		{
			return new FloatArgumentType(min, max);
		}

		public static float GetFloat<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<float>(name);
		}

		public static LongArgumentType Long(long min = long.MinValue, long max = long.MaxValue)
		{
			return new LongArgumentType(min, max);
		}

		public static long GetLong<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<long>(name);
		}

		public static StringArgumentType Word()
		{
			return new StringArgumentType(StringArgType.SingleWord);
		}

		public static StringArgumentType String()
		{
			return new StringArgumentType(StringArgType.QuotablePhrase);
		}

		public static StringArgumentType GreedyString()
		{
			return new StringArgumentType(StringArgType.GreedyPhrase);
		}

		public static string GetString<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<string>(name);
		}
	}
	public delegate int Command<TSource>(CommandContext<TSource> context);
	public class CommandDispatcher<TSource>
	{
		public string ArgumentSeparator = " ";

		public char ArgumentSeparatorChar = ' ';

		private const string UsageOptionalOpen = "[";

		private const string UsageOptionalClose = "]";

		private const string UsageRequiredOpen = "(";

		private const string UsageRequiredClose = ")";

		private const string UsageOr = "|";

		private readonly RootCommandNode<TSource> _root;

		private readonly Predicate<CommandNode<TSource>> _hasCommand;

		private ResultConsumer<TSource> Consumer { get; } = delegate
		{
		};


		public CommandDispatcher(RootCommandNode<TSource> root)
		{
			_root = root;
			_hasCommand = (CommandNode<TSource> input) => input != null && (input.Command != null || input.Children.Any((CommandNode<TSource> c) => _hasCommand(c)));
		}

		public CommandDispatcher()
			: this(new RootCommandNode<TSource>())
		{
		}

		public LiteralCommandNode<TSource> Register(LiteralArgumentBuilder<TSource> command)
		{
			LiteralCommandNode<TSource> literalCommandNode = command.Build();
			_root.AddChild(literalCommandNode);
			return literalCommandNode;
		}

		public LiteralCommandNode<TSource> Register(Func<IArgumentContext<TSource>, LiteralArgumentBuilder<TSource>> command)
		{
			LiteralCommandNode<TSource> literalCommandNode = command(default(ArgumentContext<TSource>)).Build();
			_root.AddChild(literalCommandNode);
			return literalCommandNode;
		}

		public int Execute(string input, TSource source)
		{
			return Execute(new StringReader(input), source);
		}

		public int Execute(StringReader input, TSource source)
		{
			ParseResults<TSource> parse = Parse(input, source);
			return Execute(parse);
		}

		public int Execute(ParseResults<TSource> parse)
		{
			if (parse.Reader.CanRead())
			{
				if (parse.Exceptions.Count == 1)
				{
					throw parse.Exceptions.Values.Single();
				}
				if (parse.Context.Range.IsEmpty)
				{
					throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownCommand().CreateWithContext(parse.Reader);
				}
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext(parse.Reader);
			}
			int num = 0;
			int num2 = 0;
			bool flag = false;
			bool flag2 = false;
			string @string = parse.Reader.String;
			CommandContext<TSource> commandContext = parse.Context.Build(@string);
			List<CommandContext<TSource>> list = new List<CommandContext<TSource>> { commandContext };
			List<CommandContext<TSource>> list2 = null;
			while (list != null)
			{
				int count = list.Count;
				for (int i = 0; i < count; i++)
				{
					CommandContext<TSource> commandContext2 = list[i];
					CommandContext<TSource> child = commandContext2.Child;
					if (child != null)
					{
						flag |= commandContext2.IsForked();
						if (!child.HasNodes())
						{
							continue;
						}
						flag2 = true;
						RedirectModifier<TSource> redirectModifier = commandContext2.RedirectModifier;
						if (redirectModifier == null)
						{
							if (list2 == null)
							{
								list2 = new List<CommandContext<TSource>>(1);
							}
							list2.Add(child.CopyFor(commandContext2.Source));
							continue;
						}
						try
						{
							IList<TSource> list3 = redirectModifier(commandContext2);
							if (list3.Count <= 0)
							{
								continue;
							}
							if (list2 == null)
							{
								list2 = new List<CommandContext<TSource>>(list3.Count());
							}
							foreach (TSource item in list3)
							{
								list2.Add(child.CopyFor(item));
							}
						}
						catch (CommandSyntaxException)
						{
							Consumer(commandContext2, success: false, 0);
							if (!flag)
							{
								throw;
							}
						}
					}
					else
					{
						if (commandContext2.Command == null)
						{
							continue;
						}
						flag2 = true;
						try
						{
							int num3 = commandContext2.Command(commandContext2);
							num += num3;
							Consumer(commandContext2, success: true, num3);
							num2++;
						}
						catch (CommandSyntaxException)
						{
							Consumer(commandContext2, success: false, 0);
							if (!flag)
							{
								throw;
							}
						}
					}
				}
				list = list2;
				list2 = null;
			}
			if (!flag2)
			{
				Consumer(commandContext, success: false, 0);
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownCommand().CreateWithContext(parse.Reader);
			}
			if (!flag)
			{
				return num;
			}
			return num2;
		}

		public ParseResults<TSource> Parse(string command, TSource source)
		{
			return Parse(new StringReader(command), source);
		}

		public ParseResults<TSource> Parse(StringReader command, TSource source)
		{
			CommandContextBuilder<TSource> contextSoFar = new CommandContextBuilder<TSource>(this, source, _root, command.Cursor);
			return ParseNodes(_root, command, contextSoFar);
		}

		private ParseResults<TSource> ParseNodes(CommandNode<TSource> node, StringReader originalReader, CommandContextBuilder<TSource> contextSoFar)
		{
			TSource source = contextSoFar.Source;
			IDictionary<CommandNode<TSource>, CommandSyntaxException> dictionary = null;
			List<ParseResults<TSource>> list = null;
			int cursor = originalReader.Cursor;
			foreach (CommandNode<TSource> relevantNode in node.GetRelevantNodes(originalReader))
			{
				if (!relevantNode.CanUse(source))
				{
					continue;
				}
				CommandContextBuilder<TSource> commandContextBuilder = contextSoFar.Copy();
				StringReader stringReader = new StringReader(originalReader);
				try
				{
					try
					{
						relevantNode.Parse(stringReader, commandContextBuilder);
					}
					catch (CommandSyntaxException)
					{
						throw;
					}
					catch (Exception ex2)
					{
						throw CommandSyntaxException.BuiltInExceptions.DispatcherParseException().CreateWithContext(stringReader, ex2.Message);
					}
					if (stringReader.CanRead() && stringReader.Peek() != ArgumentSeparatorChar)
					{
						throw CommandSyntaxException.BuiltInExceptions.DispatcherExpectedArgumentSeparator().CreateWithContext(stringReader);
					}
				}
				catch (CommandSyntaxException value)
				{
					if (dictionary == null)
					{
						dictionary = new Dictionary<CommandNode<TSource>, CommandSyntaxException>();
					}
					dictionary.Add(relevantNode, value);
					stringReader.Cursor = cursor;
					continue;
				}
				commandContextBuilder.WithCommand(relevantNode.Command);
				if (stringReader.CanRead((relevantNode.Redirect != null) ? 1 : 2))
				{
					stringReader.Skip();
					if (relevantNode.Redirect != null)
					{
						CommandContextBuilder<TSource> contextSoFar2 = new CommandContextBuilder<TSource>(this, source, relevantNode.Redirect, stringReader.Cursor);
						ParseResults<TSource> parseResults = ParseNodes(relevantNode.Redirect, stringReader, contextSoFar2);
						commandContextBuilder.WithChild(parseResults.Context);
						return new ParseResults<TSource>(commandContextBuilder, parseResults.Reader, parseResults.Exceptions);
					}
					ParseResults<TSource> item = ParseNodes(relevantNode, stringReader, commandContextBuilder);
					if (list == null)
					{
						list = new List<ParseResults<TSource>>(1);
					}
					list.Add(item);
				}
				else
				{
					if (list == null)
					{
						list = new List<ParseResults<TSource>>(1);
					}
					list.Add(new ParseResults<TSource>(commandContextBuilder, stringReader, new Dictionary<CommandNode<TSource>, CommandSyntaxException>()));
				}
			}
			if (list != null)
			{
				if (list.Count > 1)
				{
					list.Sort(delegate(ParseResults<TSource> a, ParseResults<TSource> b)
					{
						if (!a.Reader.CanRead() && b.Reader.CanRead())
						{
							return -1;
						}
						if (a.Reader.CanRead() && !b.Reader.CanRead())
						{
							return 1;
						}
						if (a.Exceptions.Count == 0 && b.Exceptions.Count > 0)
						{
							return -1;
						}
						return (a.Exceptions.Count > 0 && b.Exceptions.Count == 0) ? 1 : 0;
					});
				}
				return list[0];
			}
			return new ParseResults<TSource>(contextSoFar, originalReader, dictionary ?? new Dictionary<CommandNode<TSource>, CommandSyntaxException>());
		}

		public string[] GetAllUsage(CommandNode<TSource> node, TSource source, bool restricted)
		{
			List<string> list = new List<string>();
			GetAllUsage(node, source, list, "", restricted);
			return list.ToArray();
		}

		private void GetAllUsage(CommandNode<TSource> node, TSource source, List<string> result, string prefix, bool restricted)
		{
			if (restricted && !node.CanUse(source))
			{
				return;
			}
			if (node.Command != null)
			{
				result.Add(prefix);
			}
			if (node.Redirect != null)
			{
				string text = ((node.Redirect == _root) ? "..." : ("-> " + node.Redirect.UsageText));
				result.Add((prefix.Length == 0) ? (node.UsageText + ArgumentSeparator + text) : (prefix + ArgumentSeparator + text));
			}
			else
			{
				if (node.Children.Count <= 0)
				{
					return;
				}
				foreach (CommandNode<TSource> child in node.Children)
				{
					GetAllUsage(child, source, result, (prefix.Length == 0) ? child.UsageText : (prefix + ArgumentSeparator + child.UsageText), restricted);
				}
			}
		}

		public IDictionary<CommandNode<TSource>, string> GetSmartUsage(CommandNode<TSource> node, TSource source)
		{
			IDictionary<CommandNode<TSource>, string> dictionary = new Dictionary<CommandNode<TSource>, string>();
			bool optional = node.Command != null;
			foreach (CommandNode<TSource> child in node.Children)
			{
				string smartUsage = GetSmartUsage(child, source, optional, deep: false);
				if (smartUsage != null)
				{
					dictionary.Add(child, smartUsage);
				}
			}
			return dictionary;
		}

		private string GetSmartUsage(CommandNode<TSource> node, TSource source, bool optional, bool deep)
		{
			if (!node.CanUse(source))
			{
				return null;
			}
			string text = (optional ? ("[" + node.UsageText + "]") : node.UsageText);
			bool flag = node.Command != null;
			string value = (flag ? "[" : "(");
			string value2 = (flag ? "]" : ")");
			if (!deep)
			{
				if (node.Redirect != null)
				{
					string text2 = ((node.Redirect == _root) ? "..." : ("-> " + node.Redirect.UsageText));
					return text + ArgumentSeparator + text2;
				}
				List<CommandNode<TSource>> list = node.Children.Where((CommandNode<TSource> c) => c.CanUse(source)).ToList();
				if (list.Count == 1)
				{
					string smartUsage = GetSmartUsage(list.Single(), source, flag, flag);
					if (smartUsage != null)
					{
						return text + ArgumentSeparator + smartUsage;
					}
				}
				else if (list.Count > 1)
				{
					ISet<string> set = new HashSet<string>();
					foreach (CommandNode<TSource> item in list)
					{
						string smartUsage2 = GetSmartUsage(item, source, flag, deep: true);
						if (smartUsage2 != null)
						{
							set.Add(smartUsage2);
						}
					}
					if (set.Count == 1)
					{
						string text3 = set.Single();
						return text + ArgumentSeparator + (flag ? ("[" + text3 + "]") : text3);
					}
					if (set.Count > 1)
					{
						StringBuilder stringBuilder = new StringBuilder(value);
						int num = 0;
						foreach (CommandNode<TSource> item2 in list)
						{
							if (num > 0)
							{
								stringBuilder.Append("|");
							}
							stringBuilder.Append(item2.UsageText);
							num++;
						}
						if (num > 0)
						{
							stringBuilder.Append(value2);
							return text + ArgumentSeparator + stringBuilder;
						}
					}
				}
			}
			return text;
		}

		public Task<Suggestions> GetCompletionSuggestions(ParseResults<TSource> parse)
		{
			return GetCompletionSuggestions(parse, parse.Reader.TotalLength);
		}

		public async Task<Suggestions> GetCompletionSuggestions(ParseResults<TSource> parse, int cursor)
		{
			CommandContextBuilder<TSource> context = parse.Context;
			SuggestionContext<TSource> suggestionContext = context.FindSuggestionContext(cursor);
			CommandNode<TSource> parent = suggestionContext.Parent;
			int start = Math.Min(suggestionContext.StartPos, cursor);
			string fullInput = parse.Reader.String;
			string text = fullInput.Substring(0, cursor);
			string inputLowerCase = text.ToLowerInvariant();
			Task<Suggestions>[] futures = new Task<Suggestions>[parent.Children.Count()];
			int num = 0;
			foreach (CommandNode<TSource> child in parent.Children)
			{
				Task<Suggestions> task = Suggestions.Empty();
				try
				{
					task = child.ListSuggestions(context.Build(text), new SuggestionsBuilder(text, inputLowerCase, start));
				}
				catch (CommandSyntaxException)
				{
				}
				futures[num++] = task;
			}
			await Task.WhenAll(futures);
			return Suggestions.Merge(fullInput, futures.Select((Task<Suggestions> s) => s.Result).ToArray());
		}

		public RootCommandNode<TSource> GetRoot()
		{
			return _root;
		}

		public List<string> GetPath(CommandNode<TSource> target)
		{
			List<List<CommandNode<TSource>>> list = new List<List<CommandNode<TSource>>>();
			AddPaths(_root, list, new List<CommandNode<TSource>>());
			foreach (List<CommandNode<TSource>> item in list)
			{
				if (item[item.Count - 1] != target)
				{
					continue;
				}
				List<string> list2 = new List<string>(item.Count);
				foreach (CommandNode<TSource> item2 in item)
				{
					if (item2 != _root)
					{
						list2.Add(item2.Name);
					}
				}
				return list2;
			}
			return new List<string>();
		}

		public CommandNode<TSource> FindNode(IEnumerable<string> path)
		{
			CommandNode<TSource> commandNode = _root;
			foreach (string item in path)
			{
				commandNode = commandNode.GetChild(item);
				if (commandNode == null)
				{
					return null;
				}
			}
			return commandNode;
		}

		public void FindAmbiguities(AmbiguityConsumer<TSource> consumer)
		{
			_root.FindAmbiguities(consumer);
		}

		private void AddPaths(CommandNode<TSource> node, List<List<CommandNode<TSource>>> result, List<CommandNode<TSource>> parents)
		{
			List<CommandNode<TSource>> list = new List<CommandNode<TSource>>(parents) { node };
			result.Add(list);
			foreach (CommandNode<TSource> child in node.Children)
			{
				AddPaths(child, result, list);
			}
		}
	}
	public interface IImmutableStringReader
	{
		string String { get; }

		int RemainingLength { get; }

		int TotalLength { get; }

		int Cursor { get; }

		string Read { get; }

		string Remaining { get; }

		bool CanRead(int length);

		bool CanRead();

		char Peek();

		char Peek(int offset);
	}
	public interface IStringReader : IImmutableStringReader
	{
		new int Cursor { get; set; }

		char Next();

		void Skip();

		void SkipWhitespace();

		int ReadInt();

		long ReadLong();

		double ReadDouble();

		float ReadFloat();

		string ReadUnquotedString();

		string ReadQuotedString();

		string ReadString();

		bool ReadBoolean();

		void Expect(char c);
	}
	public class LiteralMessage : IMessage
	{
		public string String { get; }

		public LiteralMessage(string message)
		{
			String = message;
		}

		public override string ToString()
		{
			return String;
		}
	}
	public interface IMessage
	{
		string String { get; }
	}
	public class ParseResults<TSource>
	{
		public CommandContextBuilder<TSource> Context { get; }

		public IImmutableStringReader Reader { get; }

		public IDictionary<CommandNode<TSource>, CommandSyntaxException> Exceptions { get; }

		public ParseResults(CommandContextBuilder<TSource> context, IImmutableStringReader reader, IDictionary<CommandNode<TSource>, CommandSyntaxException> exceptions)
		{
			Context = context;
			Reader = reader;
			Exceptions = exceptions;
		}

		public ParseResults(CommandContextBuilder<TSource> context)
			: this(context, (IImmutableStringReader)new StringReader(""), (IDictionary<CommandNode<TSource>, CommandSyntaxException>)new Dictionary<CommandNode<TSource>, CommandSyntaxException>())
		{
		}
	}
	public delegate IList<TSource> RedirectModifier<TSource>(CommandContext<TSource> context);
	public delegate void ResultConsumer<TSource>(CommandContext<TSource> context, bool success, int result);
	public delegate TSource SingleRedirectModifier<TSource>(CommandContext<TSource> context);
	public class StringReader : IStringReader, IImmutableStringReader
	{
		private static readonly char SyntaxEscape = '\\';

		private static readonly char SyntaxDoubleQuote = '"';

		private static readonly char SyntaxSingleQuote = '\'';

		public string String { get; }

		public int Cursor { get; set; }

		public int RemainingLength => String.Length - Cursor;

		public int TotalLength => String.Length;

		public string Read => String.Substring(0, Cursor);

		public string Remaining => String.Substring(Cursor);

		public StringReader(StringReader other)
		{
			String = other.String;
			Cursor = other.Cursor;
		}

		public StringReader(string input)
		{
			String = input;
		}

		public bool CanRead(int length)
		{
			return Cursor + length <= String.Length;
		}

		public bool CanRead()
		{
			return CanRead(1);
		}

		public char Peek()
		{
			return String[Cursor];
		}

		public char Peek(int offset)
		{
			return String[Cursor + offset];
		}

		public char Next()
		{
			return String[Cursor++];
		}

		public void Skip()
		{
			Cursor++;
		}

		private static bool IsAllowedNumber(char c)
		{
			if ((c < '0' || c > '9') && c != '.')
			{
				return c == '-';
			}
			return true;
		}

		private static bool IsQuotedStringStart(char c)
		{
			if (c != SyntaxDoubleQuote)
			{
				return c == SyntaxSingleQuote;
			}
			return true;
		}

		public void SkipWhitespace()
		{
			while (CanRead() && char.IsWhiteSpace(Peek()))
			{
				Skip();
			}
		}

		public int ReadInt()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			string text = String.Substring(cursor, Cursor - cursor);
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedInt().CreateWithContext(this);
			}
			try
			{
				return int.Parse(text);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext(this, text);
			}
		}

		public long ReadLong()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			string text = String.Substring(cursor, Cursor - cursor);
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedLong().CreateWithContext(this);
			}
			try
			{
				return long.Parse(text);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidLong().CreateWithContext(this, text);
			}
		}

		public double ReadDouble()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			string text = String.Substring(cursor, Cursor - cursor);
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedDouble().CreateWithContext(this);
			}
			try
			{
				return double.Parse(text);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidDouble().CreateWithContext(this, text);
			}
		}

		public float ReadFloat()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			string text = String.Substring(cursor, Cursor - cursor);
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedFloat().CreateWithContext(this);
			}
			try
			{
				return float.Parse(text);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext(this, text);
			}
		}

		public static bool IsAllowedInUnquotedString(char c)
		{
			if ((c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && c != '_' && c != '-' && c != '.')
			{
				return c == '+';
			}
			return true;
		}

		public string ReadUnquotedString()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedInUnquotedString(Peek()))
			{
				Skip();
			}
			return String.Substring(cursor, Cursor - cursor);
		}

		public string ReadQuotedString()
		{
			if (!CanRead())
			{
				return "";
			}
			char c = Peek();
			if (!IsQuotedStringStart(c))
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedStartOfQuote().CreateWithContext(this);
			}
			Skip();
			return ReadStringUntil(c);
		}

		private string ReadStringUntil(char terminator)
		{
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = false;
			while (CanRead())
			{
				char c = Next();
				if (flag)
				{
					if (c != terminator && c != SyntaxEscape)
					{
						Cursor--;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidEscape().CreateWithContext(this, c.ToString());
					}
					stringBuilder.Append(c);
					flag = false;
				}
				else if (c == SyntaxEscape)
				{
					flag = true;
				}
				else
				{
					if (c == terminator)
					{
						return stringBuilder.ToString();
					}
					stringBuilder.Append(c);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedEndOfQuote().CreateWithContext(this);
		}

		public string ReadString()
		{
			if (!CanRead())
			{
				return "";
			}
			char c = Peek();
			if (IsQuotedStringStart(c))
			{
				Skip();
				return ReadStringUntil(c);
			}
			return ReadUnquotedString();
		}

		public bool ReadBoolean()
		{
			int cursor = Cursor;
			string text = ReadString();
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedBool().CreateWithContext(this);
			}
			if (text.Equals("true"))
			{
				return true;
			}
			if (text.Equals("false"))
			{
				return false;
			}
			Cursor = cursor;
			throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidBool().CreateWithContext(this, text);
		}

		public void Expect(char c)
		{
			if (!CanRead() || Peek() != c)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedSymbol().CreateWithContext(this, c.ToString());
			}
			Skip();
		}
	}
}
namespace Brigadier.NET.Util
{
	internal struct HashCode
	{
		private readonly int _value;

		public static HashCode Start { get; } = new HashCode(17);


		private HashCode(int value)
		{
			_value = value;
		}

		public static implicit operator int(HashCode hash)
		{
			return hash._value;
		}

		public HashCode Hash<T>(T obj)
		{
			int hashCode = EqualityComparer<T>.Default.GetHashCode(obj);
			return new HashCode((_value * 397) ^ hashCode);
		}

		public override int GetHashCode()
		{
			return _value;
		}
	}
}
namespace Brigadier.NET.Tree
{
	public abstract class ArgumentCommandNode<TSource> : CommandNode<TSource>
	{
		protected ArgumentCommandNode(Command<TSource> command, Predicate<TSource> requirement, CommandNode<TSource> redirect, RedirectModifier<TSource> modifier, bool forks)
			: base(command, requirement, redirect, modifier, forks)
		{
		}
	}
	public class ArgumentCommandNode<TSource, T> : ArgumentCommandNode<TSource>, IEquatable<ArgumentCommandNode<TSource, T>>
	{
		private const string UsageArgumentOpen = "<";

		private const string UsageArgumentClose = ">";

		private readonly string _name;

		public ArgumentType<T> Type { get; }

		public override string Name => _name;

		public override string UsageText => "<" + Name + ">";

		public SuggestionProvider<TSource> CustomSuggestions { get; }

		protected override string SortedKey => _name;

		public override IEnumerable<string> Examples => Type.Examples;

		public ArgumentCommandNode(string name, ArgumentType<T> type, Command<TSource> command, Predicate<TSource> requirement, CommandNode<TSource> redirect, RedirectModifier<TSource> modifier, bool forks, SuggestionProvider<TSource> customSuggestions)
			: base(command, requirement, redirect, modifier, forks)
		{
			_name = name;
			Type = type;
			CustomSuggestions = customSuggestions;
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
			int cursor = reader.Cursor;
			T result = Type.Parse(reader);
			ParsedArgument<TSource, T> parsedArgument = new ParsedArgument<TSource, T>(cursor, reader.Cursor, result);
			contextBuilder.WithArgument(_name, parsedArgument);
			contextBuilder.WithNode(this, parsedArgument.Range);
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			if (CustomSuggestions == null)
			{
				return Type.ListSuggestions(context, builder);
			}
			return CustomSuggestions(context, builder);
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			RequiredArgumentBuilder<TSource, T> requiredArgumentBuilder = RequiredArgumentBuilder<TSource, T>.RequiredArgument(_name, Type);
			requiredArgumentBuilder.Requires(base.Requirement);
			requiredArgumentBuilder.Forward(base.Redirect, base.RedirectModifier, base.IsFork);
			requiredArgumentBuilder.Suggests(CustomSuggestions);
			if (base.Command != null)
			{
				requiredArgumentBuilder.Executes(base.Command);
			}
			return requiredArgumentBuilder;
		}

		protected override bool IsValidInput(string input)
		{
			try
			{
				StringReader stringReader = new StringReader(input);
				Type.Parse(stringReader);
				return !stringReader.CanRead() || stringReader.Peek() == ' ';
			}
			catch (CommandSyntaxException)
			{
				return false;
			}
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is ArgumentCommandNode<TSource, T> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(ArgumentCommandNode<TSource, T> other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (string.Equals(_name, other._name))
			{
				return object.Equals(Type, other.Type);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(_name).Hash(Type);
		}

		public override string ToString()
		{
			return $"<argument {_name}:{Type}>";
		}
	}
	public abstract class CommandNode<TSource> : IComparable<CommandNode<TSource>>, IEnumerable<CommandNode<TSource>>, IEnumerable
	{
		private readonly IDictionary<string, CommandNode<TSource>> _children = new Dictionary<string, CommandNode<TSource>>();

		private readonly IDictionary<string, LiteralCommandNode<TSource>> _literals = new Dictionary<string, LiteralCommandNode<TSource>>();

		private readonly IDictionary<string, ArgumentCommandNode<TSource>> _arguments = new Dictionary<string, ArgumentCommandNode<TSource>>();

		public Command<TSource> Command { get; set; }

		public ICollection<CommandNode<TSource>> Children => _children.Values;

		public CommandNode<TSource> Redirect { get; }

		public RedirectModifier<TSource> RedirectModifier { get; }

		public Predicate<TSource> Requirement { get; }

		public abstract string Name { get; }

		public abstract string UsageText { get; }

		protected abstract string SortedKey { get; }

		public bool IsFork { get; }

		public abstract IEnumerable<string> Examples { get; }

		protected CommandNode(Command<TSource> command, Predicate<TSource> requirement, CommandNode<TSource> redirect, RedirectModifier<TSource> modifier, bool forks)
		{
			Command = command;
			Requirement = requirement;
			Redirect = redirect;
			RedirectModifier = modifier;
			IsFork = forks;
		}

		public CommandNode<TSource> GetChild(string name)
		{
			if (!_children.TryGetValue(name, out var value))
			{
				return null;
			}
			return value;
		}

		public bool CanUse(TSource source)
		{
			return Requirement(source);
		}

		public void Add(CommandNode<TSource> node)
		{
			AddChild(node);
		}

		public void Add(params CommandNode<TSource>[] nodes)
		{
			foreach (CommandNode<TSource> node in nodes)
			{
				AddChild(node);
			}
		}

		public void AddChild(CommandNode<TSource> node)
		{
			if (node is RootCommandNode<TSource>)
			{
				throw new InvalidOperationException("Cannot add a RootCommandNode as a child to any other CommandNode");
			}
			if (_children.TryGetValue(node.Name, out var value))
			{
				if (node.Command != null)
				{
					value.Command = node.Command;
				}
				{
					foreach (CommandNode<TSource> child in node.Children)
					{
						value.AddChild(child);
					}
					return;
				}
			}
			_children.Add(node.Name, node);
			if (node is LiteralCommandNode<TSource> value2)
			{
				_literals.Add(node.Name, value2);
			}
			else if (node is ArgumentCommandNode<TSource> value3)
			{
				_arguments.Add(node.Name, value3);
			}
		}

		public void FindAmbiguities(AmbiguityConsumer<TSource> consumer)
		{
			HashSet<string> hashSet = new HashSet<string>();
			foreach (CommandNode<TSource> value in _children.Values)
			{
				foreach (CommandNode<TSource> value2 in _children.Values)
				{
					if (value == value2)
					{
						continue;
					}
					foreach (string example in value.Examples)
					{
						if (value2.IsValidInput(example))
						{
							hashSet.Add(example);
						}
					}
					if (hashSet.Count > 0)
					{
						consumer(this, value, value2, hashSet);
						hashSet = new HashSet<string>();
					}
				}
				value.FindAmbiguities(consumer);
			}
		}

		protected abstract bool IsValidInput(string input);

		public abstract void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder);

		public abstract Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder);

		public abstract IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder();

		public IEnumerable<CommandNode<TSource>> GetRelevantNodes(StringReader input)
		{
			if (_literals.Count > 0)
			{
				int cursor = input.Cursor;
				while (input.CanRead() && input.Peek() != ' ')
				{
					input.Skip();
				}
				string key = input.String.Substring(cursor, input.Cursor - cursor);
				input.Cursor = cursor;
				if (_literals.TryGetValue(key, out var value))
				{
					yield return value;
					yield break;
				}
				foreach (ArgumentCommandNode<TSource> value2 in _arguments.Values)
				{
					yield return value2;
				}
				yield break;
			}
			foreach (ArgumentCommandNode<TSource> value3 in _arguments.Values)
			{
				yield return value3;
			}
		}

		public int CompareTo(CommandNode<TSource> o)
		{
			if (this is LiteralCommandNode<TSource> == o is LiteralCommandNode<TSource>)
			{
				return string.Compare(SortedKey, o.SortedKey, StringComparison.Ordinal);
			}
			if (!(o is LiteralCommandNode<TSource>))
			{
				return -1;
			}
			return 1;
		}

		public IEnumerator<CommandNode<TSource>> GetEnumerator()
		{
			return _children.Values.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	public class LiteralCommandNode<TSource> : CommandNode<TSource>, IEquatable<LiteralCommandNode<TSource>>
	{
		public string Literal { get; }

		public string LiteralLowerCase { get; }

		public override string Name => Literal;

		public override string UsageText => Literal;

		protected override string SortedKey => Literal;

		public override IEnumerable<string> Examples => new string[1] { Literal };

		public LiteralCommandNode(string literal, Command<TSource> command, Predicate<TSource> requirement, CommandNode<TSource> redirect, RedirectModifier<TSource> modifier, bool forks)
			: base(command, requirement, redirect, modifier, forks)
		{
			Literal = literal;
			LiteralLowerCase = literal.ToLowerInvariant();
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
			int cursor = reader.Cursor;
			int num = Parse(reader);
			if (num > -1)
			{
				contextBuilder.WithNode(this, StringRange.Between(cursor, num));
				return;
			}
			throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, Literal);
		}

		private int Parse(StringReader reader)
		{
			int cursor = reader.Cursor;
			if (reader.CanRead(Literal.Length))
			{
				int num = cursor + Literal.Length;
				if (reader.String.Substring(cursor, num - cursor).Equals(Literal))
				{
					reader.Cursor = num;
					if (!reader.CanRead() || reader.Peek() == ' ')
					{
						return num;
					}
					reader.Cursor = cursor;
				}
			}
			return -1;
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			if (Literal.ToLower().StartsWith(builder.RemainingLowerCase))
			{
				return builder.Suggest(Literal).BuildFuture();
			}
			return Suggestions.Empty();
		}

		protected override bool IsValidInput(string input)
		{
			return Parse(new StringReader(input)) > -1;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is LiteralCommandNode<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(LiteralCommandNode<TSource> other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			return string.Equals(Literal, other.Literal);
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Literal);
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			LiteralArgumentBuilder<TSource> literalArgumentBuilder = LiteralArgumentBuilder<TSource>.LiteralArgument(Literal);
			literalArgumentBuilder.Requires(base.Requirement);
			literalArgumentBuilder.Forward(base.Redirect, base.RedirectModifier, base.IsFork);
			if (base.Command != null)
			{
				literalArgumentBuilder.Executes(base.Command);
			}
			return literalArgumentBuilder;
		}
	}
	public class RootCommandNode<TSource> : CommandNode<TSource>, IEquatable<RootCommandNode<TSource>>
	{
		public override string Name => string.Empty;

		public override string UsageText => string.Empty;

		protected override string SortedKey => string.Empty;

		public override IEnumerable<string> Examples => new string[0];

		public RootCommandNode()
			: base((Command<TSource>)null, (Predicate<TSource>)((TSource c) => true), (CommandNode<TSource>)null, (RedirectModifier<TSource>)((CommandContext<TSource> s) => new TSource[1] { s.Source }), forks: false)
		{
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			return Suggestions.Empty();
		}

		protected override bool IsValidInput(string input)
		{
			return false;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is RootCommandNode<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(RootCommandNode<TSource> other)
		{
			return true;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start;
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			throw new InvalidOperationException("Cannot convert root into a builder");
		}

		public override string ToString()
		{
			return "<root>";
		}
	}
}
namespace Brigadier.NET.Suggestion
{
	public class IntegerSuggestion : Suggestion, IEquatable<IntegerSuggestion>
	{
		public int Value { get; }

		public IntegerSuggestion(StringRange range, int value, IMessage tooltip = null)
			: base(range, value.ToString(), tooltip)
		{
			Value = value;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is IntegerSuggestion other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(IntegerSuggestion other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (Value == other.Value)
			{
				return Equals((Suggestion)other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Value);
		}

		public override string ToString()
		{
			return $"IntegerSuggestion{{value={Value}, range={base.Range}, text='{base.Text}', tooltip='{base.Tooltip}'}}";
		}

		public override int CompareTo(Suggestion o)
		{
			if (o is IntegerSuggestion integerSuggestion)
			{
				return integerSuggestion.Value.CompareTo(Value);
			}
			return base.CompareTo(o);
		}

		public override int CompareToIgnoreCase(Suggestion b)
		{
			return CompareTo(b);
		}
	}
	public class Suggestion : IComparable<Suggestion>, IEquatable<Suggestion>
	{
		public StringRange Range { get; }

		public string Text { get; }

		public IMessage Tooltip { get; }

		public Suggestion(StringRange range, string text, IMessage tooltip = null)
		{
			Range = range;
			Text = text;
			Tooltip = tooltip;
		}

		public string Apply(string input)
		{
			if (Range.Start == 0 && Range.End == input.Length)
			{
				return Text;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (Range.Start > 0)
			{
				stringBuilder.Append(input.Substring(0, Range.Start));
			}
			stringBuilder.Append(Text);
			if (Range.End < input.Length)
			{
				stringBuilder.Append(input.Substring(Range.End));
			}
			return stringBuilder.ToString();
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is Suggestion other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Suggestion other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (object.Equals(Range, other.Range) && string.Equals(Text, other.Text))
			{
				return object.Equals(Tooltip, other.Tooltip);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Range).Hash(Text).Hash(Tooltip);
		}

		public override string ToString()
		{
			return $"Suggestion{{range={Range}, text='{Text}', tooltip='{Tooltip}}}";
		}

		public virtual int CompareTo(Suggestion o)
		{
			return string.Compare(Text, o.Text, StringComparison.Ordinal);
		}

		public virtual int CompareToIgnoreCase(Suggestion b)
		{
			return string.Compare(Text, b.Text, StringComparison.OrdinalIgnoreCase);
		}

		public Suggestion Expand(string command, StringRange range)
		{
			if (range.Equals(Range))
			{
				return this;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (range.Start < Range.Start)
			{
				stringBuilder.Append(command.Substring(range.Start, Range.Start - range.Start));
			}
			stringBuilder.Append(Text);
			if (range.End > Range.End)
			{
				stringBuilder.Append(command.Substring(Range.End, range.End - Range.End));
			}
			return new Suggestion(range, stringBuilder.ToString(), Tooltip);
		}
	}
	public delegate Task<Suggestions> SuggestionProvider<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder);
	public class Suggestions : IEquatable<Suggestions>
	{
		private static readonly Suggestions NoSuggestions = new Suggestions(StringRange.At(0), new List<Suggestion>());

		public StringRange Range { get; }

		public List<Suggestion> List { get; }

		public Suggestions(StringRange range, List<Suggestion> suggestions)
		{
			Range = range;
			List = suggestions;
		}

		public bool IsEmpty()
		{
			return List.Count == 0;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is Suggestions other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Suggestions other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (object.Equals(Range, other.Range))
			{
				return object.Equals(List, other.List);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Range).Hash(List);
		}

		public override string ToString()
		{
			return $"Suggestions{{range={Range}, suggestions={List}}}";
		}

		public static Task<Suggestions> Empty()
		{
			return Task.FromResult(NoSuggestions);
		}

		public static Suggestions Merge(string command, ICollection<Suggestions> input)
		{
			if (input.Count == 0)
			{
				return NoSuggestions;
			}
			if (input.Count == 1)
			{
				return input.Single();
			}
			ISet<Suggestion> set = new HashSet<Suggestion>();
			foreach (Suggestions item in input)
			{
				foreach (Suggestion item2 in item.List)
				{
					set.Add(item2);
				}
			}
			return Create(command, set.ToArray());
		}

		public static Suggestions Create(string command, Suggestion[] suggestions)
		{
			if (suggestions.Length == 0)
			{
				return NoSuggestions;
			}
			int num = int.MaxValue;
			int num2 = int.MinValue;
			Suggestion[] array = suggestions;
			foreach (Suggestion obj in array)
			{
				num = Math.Min(obj.Range.Start, num);
				num2 = Math.Max(obj.Range.End, num2);
			}
			StringRange range = new StringRange(num, num2);
			HashSet<Suggestion> hashSet = new HashSet<Suggestion>();
			array = suggestions;
			foreach (Suggestion suggestion in array)
			{
				hashSet.Add(suggestion.Expand(command, range));
			}
			List<Suggestion> list = new List<Suggestion>(hashSet);
			list.Sort((Suggestion a, Suggestion b) => a.CompareToIgnoreCase(b));
			return new Suggestions(range, list);
		}
	}
	public class SuggestionsBuilder
	{
		private readonly List<Suggestion> _result = new List<Suggestion>();

		public string Input { get; }

		public string InputLowerCase { get; }

		public int Start { get; }

		public string Remaining { get; }

		public string RemainingLowerCase { get; set; }

		public SuggestionsBuilder(string input, string inputLowerCase, int start)
		{
			Input = input;
			InputLowerCase = inputLowerCase;
			Start = start;
			Remaining = input.Substring(start);
			RemainingLowerCase = inputLowerCase.Substring(start);
		}

		public SuggestionsBuilder(string input, int start)
			: this(input, input.ToLowerInvariant(), start)
		{
		}

		public Suggestions Build()
		{
			return Suggestions.Create(Input, _result.ToArray());
		}

		public Task<Suggestions> BuildFuture()
		{
			return Task.FromResult(Build());
		}

		public SuggestionsBuilder Suggest(string text)
		{
			if (text.Equals(Remaining))
			{
				return this;
			}
			_result.Add(new Suggestion(StringRange.Between(Start, Input.Length), text));
			return this;
		}

		public SuggestionsBuilder Suggest(string text, IMessage tooltip)
		{
			if (text.Equals(Remaining))
			{
				return this;
			}
			_result.Add(new Suggestion(StringRange.Between(Start, Input.Length), text, tooltip));
			return this;
		}

		public SuggestionsBuilder Suggest(int value)
		{
			_result.Add(new IntegerSuggestion(StringRange.Between(Start, Input.Length), value));
			return this;
		}

		public SuggestionsBuilder Suggest(int value, IMessage tooltip)
		{
			_result.Add(new IntegerSuggestion(StringRange.Between(Start, Input.Length), value, tooltip));
			return this;
		}

		public SuggestionsBuilder Add(SuggestionsBuilder other)
		{
			_result.AddRange(other._result);
			return this;
		}

		public SuggestionsBuilder CreateOffset(int start)
		{
			return new SuggestionsBuilder(Input, InputLowerCase, start);
		}

		public SuggestionsBuilder Restart()
		{
			return CreateOffset(Start);
		}
	}
}
namespace Brigadier.NET.Exceptions
{
	public interface IBuiltInExceptionProvider
	{
		Dynamic2CommandExceptionType DoubleTooLow();

		Dynamic2CommandExceptionType DoubleTooHigh();

		Dynamic2CommandExceptionType FloatTooLow();

		Dynamic2CommandExceptionType FloatTooHigh();

		Dynamic2CommandExceptionType IntegerTooLow();

		Dynamic2CommandExceptionType IntegerTooHigh();

		Dynamic2CommandExceptionType LongTooLow();

		Dynamic2CommandExceptionType LongTooHigh();

		DynamicCommandExceptionType LiteralIncorrect();

		SimpleCommandExceptionType ReaderExpectedStartOfQuote();

		SimpleCommandExceptionType ReaderExpectedEndOfQuote();

		DynamicCommandExceptionType ReaderInvalidEscape();

		DynamicCommandExceptionType ReaderInvalidBool();

		DynamicCommandExceptionType ReaderInvalidInt();

		SimpleCommandExceptionType ReaderExpectedInt();

		DynamicCommandExceptionType ReaderInvalidLong();

		SimpleCommandExceptionType ReaderExpectedLong();

		DynamicCommandExceptionType ReaderInvalidDouble();

		SimpleCommandExceptionType ReaderExpectedDouble();

		DynamicCommandExceptionType ReaderInvalidFloat();

		SimpleCommandExceptionType ReaderExpectedFloat();

		SimpleCommandExceptionType ReaderExpectedBool();

		DynamicCommandExceptionType ReaderExpectedSymbol();

		SimpleCommandExceptionType DispatcherUnknownCommand();

		SimpleCommandExceptionType DispatcherUnknownArgument();

		SimpleCommandExceptionType DispatcherExpectedArgumentSeparator();

		DynamicCommandExceptionType DispatcherParseException();
	}
	public class BuiltInExceptions : IBuiltInExceptionProvider
	{
		private static readonly Dynamic2CommandExceptionType DOUBLE_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Double must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType DOUBLE_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Double must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType FLOAT_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Float must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType FLOAT_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Float must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType INTEGER_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Integer must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType INTEGER_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Integer must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType LONG_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Long must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType LONG_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Long must not be more than {max}, found {found}"));

		private static readonly DynamicCommandExceptionType LITERAL_INCORRECT = new DynamicCommandExceptionType((object expected) => new LiteralMessage($"Expected literal {expected}"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_START_OF_QUOTE = new SimpleCommandExceptionType(new LiteralMessage("Expected quote to start a string"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_END_OF_QUOTE = new SimpleCommandExceptionType(new LiteralMessage("Unclosed quoted string"));

		private static readonly DynamicCommandExceptionType READER_INVALID_ESCAPE = new DynamicCommandExceptionType((object character) => new LiteralMessage($"Invalid escape sequence '{character}' in quoted string"));

		private static readonly DynamicCommandExceptionType READER_INVALID_BOOL = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid bool, expected true or false but found '{value}'"));

		private static readonly DynamicCommandExceptionType READER_INVALID_INT = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid integer '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_INT = new SimpleCommandExceptionType(new LiteralMessage("Expected integer"));

		private static readonly DynamicCommandExceptionType READER_INVALID_LONG = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid long '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_LONG = new SimpleCommandExceptionType(new LiteralMessage("Expected long"));

		private static readonly DynamicCommandExceptionType READER_INVALID_DOUBLE = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid double '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_DOUBLE = new SimpleCommandExceptionType(new LiteralMessage("Expected double"));

		private static readonly DynamicCommandExceptionType READER_INVALID_FLOAT = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid float '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_FLOAT = new SimpleCommandExceptionType(new LiteralMessage("Expected float"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_BOOL = new SimpleCommandExceptionType(new LiteralMessage("Expected bool"));

		private static readonly DynamicCommandExceptionType READER_EXPECTED_SYMBOL = new DynamicCommandExceptionType((object symbol) => new LiteralMessage($"Expected '{symbol}'"));

		private static readonly SimpleCommandExceptionType DISPATCHER_UNKNOWN_COMMAND = new SimpleCommandExceptionType(new LiteralMessage("Unknown command"));

		private static readonly SimpleCommandExceptionType DISPATCHER_UNKNOWN_ARGUMENT = new SimpleCommandExceptionType(new LiteralMessage("Incorrect argument for command"));

		private static readonly SimpleCommandExceptionType DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR = new SimpleCommandExceptionType(new LiteralMessage("Expected whitespace to end one argument, but found trailing data"));

		private static readonly DynamicCommandExceptionType DISPATCHER_PARSE_EXCEPTION = new DynamicCommandExceptionType((object message) => new LiteralMessage($"Could not parse command: {message}"));

		public Dynamic2CommandExceptionType DoubleTooLow()
		{
			return DOUBLE_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType DoubleTooHigh()
		{
			return DOUBLE_TOO_BIG;
		}

		public Dynamic2CommandExceptionType FloatTooLow()
		{
			return FLOAT_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType FloatTooHigh()
		{
			return FLOAT_TOO_BIG;
		}

		public Dynamic2CommandExceptionType IntegerTooLow()
		{
			return INTEGER_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType IntegerTooHigh()
		{
			return INTEGER_TOO_BIG;
		}

		public Dynamic2CommandExceptionType LongTooLow()
		{
			return LONG_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType LongTooHigh()
		{
			return LONG_TOO_BIG;
		}

		public DynamicCommandExceptionType LiteralIncorrect()
		{
			return LITERAL_INCORRECT;
		}

		public SimpleCommandExceptionType ReaderExpectedStartOfQuote()
		{
			return READER_EXPECTED_START_OF_QUOTE;
		}

		public SimpleCommandExceptionType ReaderExpectedEndOfQuote()
		{
			return READER_EXPECTED_END_OF_QUOTE;
		}

		public DynamicCommandExceptionType ReaderInvalidEscape()
		{
			return READER_INVALID_ESCAPE;
		}

		public DynamicCommandExceptionType ReaderInvalidBool()
		{
			return READER_INVALID_BOOL;
		}

		public DynamicCommandExceptionType ReaderInvalidInt()
		{
			return READER_INVALID_INT;
		}

		public SimpleCommandExceptionType ReaderExpectedInt()
		{
			return READER_EXPECTED_INT;
		}

		public DynamicCommandExceptionType ReaderInvalidLong()
		{
			return READER_INVALID_LONG;
		}

		public SimpleCommandExceptionType ReaderExpectedLong()
		{
			return READER_EXPECTED_LONG;
		}

		public DynamicCommandExceptionType ReaderInvalidDouble()
		{
			return READER_INVALID_DOUBLE;
		}

		public SimpleCommandExceptionType ReaderExpectedDouble()
		{
			return READER_EXPECTED_DOUBLE;
		}

		public DynamicCommandExceptionType ReaderInvalidFloat()
		{
			return READER_INVALID_FLOAT;
		}

		public SimpleCommandExceptionType ReaderExpectedFloat()
		{
			return READER_EXPECTED_FLOAT;
		}

		public SimpleCommandExceptionType ReaderExpectedBool()
		{
			return READER_EXPECTED_BOOL;
		}

		public DynamicCommandExceptionType ReaderExpectedSymbol()
		{
			return READER_EXPECTED_SYMBOL;
		}

		public SimpleCommandExceptionType DispatcherUnknownCommand()
		{
			return DISPATCHER_UNKNOWN_COMMAND;
		}

		public SimpleCommandExceptionType DispatcherUnknownArgument()
		{
			return DISPATCHER_UNKNOWN_ARGUMENT;
		}

		public SimpleCommandExceptionType DispatcherExpectedArgumentSeparator()
		{
			return DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR;
		}

		public DynamicCommandExceptionType DispatcherParseException()
		{
			return DISPATCHER_PARSE_EXCEPTION;
		}
	}
	public class CommandSyntaxException : Exception
	{
		public static readonly int ContextAmount = 10;

		public static readonly IBuiltInExceptionProvider BuiltInExceptions = new BuiltInExceptions();

		private readonly IMessage _message;

		public override string Message
		{
			get
			{
				string text = _message.String;
				string context = Context;
				if (context != null)
				{
					text += $" at position {Cursor}: {context}";
				}
				return text;
			}
		}

		public string Context
		{
			get
			{
				if (Input == null || Cursor < 0)
				{
					return null;
				}
				StringBuilder stringBuilder = new StringBuilder();
				int num = Math.Min(Input.Length, Cursor);
				if (num > ContextAmount)
				{
					stringBuilder.Append("...");
				}
				int num2 = Math.Max(0, num - ContextAmount);
				stringBuilder.Append(Input.Substring(num2, num - num2));
				stringBuilder.Append("<--[HERE]");
				return stringBuilder.ToString();
			}
		}

		public ICommandExceptionType Type { get; }

		public string Input { get; }

		public int Cursor { get; }

		public CommandSyntaxException(ICommandExceptionType type, IMessage message)
			: base(message.String, null)
		{
			Type = type;
			_message = message;
			Input = null;
			Cursor = -1;
		}

		public CommandSyntaxException(ICommandExceptionType type, IMessage message, string input, int cursor)
			: base(message.String, null)
		{
			Type = type;
			_message = message;
			Input = input;
			Cursor = cursor;
		}

		public IMessage RawMessage()
		{
			return _message;
		}
	}
	public class Dynamic2CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b);

		private readonly Function _function;

		public Dynamic2CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b)
		{
			return new CommandSyntaxException(this, _function(a, b));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b)
		{
			return new CommandSyntaxException(this, _function(a, b), reader.String, reader.Cursor);
		}
	}
	public class Dynamic3CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b, object c);

		private readonly Function _function;

		public Dynamic3CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b, object c)
		{
			return new CommandSyntaxException(this, _function(a, b, c));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b, object c)
		{
			return new CommandSyntaxException(this, _function(a, b, c), reader.String, reader.Cursor);
		}
	}
	public class Dynamic4CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b, object c, object d);

		private readonly Function _function;

		public Dynamic4CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b, object c, object d)
		{
			return new CommandSyntaxException(this, _function(a, b, c, d));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b, object c, object d)
		{
			return new CommandSyntaxException(this, _function(a, b, c, d), reader.String, reader.Cursor);
		}
	}
	public class DynamicCommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a);

		private readonly Function _function;

		public DynamicCommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a)
		{
			return new CommandSyntaxException(this, _function(a));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a)
		{
			return new CommandSyntaxException(this, _function(a), reader.String, reader.Cursor);
		}
	}
	public class DynamicNCommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object[] args);

		private readonly Function _function;

		public DynamicNCommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(params object[] args)
		{
			return new CommandSyntaxException(this, _function(args));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, params object[] args)
		{
			return new CommandSyntaxException(this, _function(args), reader.String, reader.Cursor);
		}
	}
	public interface ICommandExceptionType
	{
	}
	public class SimpleCommandExceptionType : ICommandExceptionType
	{
		private readonly IMessage _message;

		public SimpleCommandExceptionType(IMessage message)
		{
			_message = message;
		}

		public CommandSyntaxException Create()
		{
			return new CommandSyntaxException(this, _message);
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader)
		{
			return new CommandSyntaxException(this, _message, reader.String, reader.Cursor);
		}

		public override string ToString()
		{
			return _message.String;
		}
	}
}
namespace Brigadier.NET.Context
{
	public class CommandContext<TSource> : IEquatable<CommandContext<TSource>>
	{
		private readonly IDictionary<string, IParsedArgument> _arguments;

		private readonly bool _forks;

		public CommandContext<TSource> Child { get; }

		public CommandContext<TSource> LastChild
		{
			get
			{
				CommandContext<TSource> commandContext = this;
				while (commandContext.Child != null)
				{
					commandContext = commandContext.Child;
				}
				return commandContext;
			}
		}

		public Command<TSource> Command { get; }

		public TSource Source { get; }

		public RedirectModifier<TSource> RedirectModifier { get; }

		public StringRange Range { get; }

		public string Input { get; }

		public CommandNode<TSource> RootNode { get; }

		public List<ParsedCommandNode<TSource>> Nodes { get; }

		public CommandContext(TSource source, string input, IDictionary<string, IParsedArgument> arguments, Command<TSource> command, CommandNode<TSource> rootNode, List<ParsedCommandNode<TSource>> nodes, StringRange range, CommandContext<TSource> child, RedirectModifier<TSource> modifier, bool forks)
		{
			Source = source;
			Input = input;
			_arguments = arguments;
			Command = command;
			RootNode = rootNode;
			Nodes = nodes;
			Range = range;
			Child = child;
			RedirectModifier = modifier;
			_forks = forks;
		}

		public CommandContext<TSource> CopyFor(TSource source)
		{
			if (Source.Equals(source))
			{
				return this;
			}
			return new CommandContext<TSource>(source, Input, _arguments, Command, RootNode, Nodes, Range, Child, RedirectModifier, _forks);
		}

		public T GetArgument<T>(string name)
		{
			if (!_arguments.TryGetValue(name, out var value))
			{
				throw new InvalidOperationException("No such argument '" + name + "' exists on this command");
			}
			object result = value.Result;
			if (result is T)
			{
				return (T)result;
			}
			throw new InvalidOperationException("Argument " + name + "' is defined as " + result.GetType().Name + ", not " + typeof(T).Name);
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is CommandContext<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(CommandContext<TSource> other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (_arguments.SequenceEqual(other._arguments) && object.Equals(RootNode, other.RootNode) && Nodes.SequenceEqual(other.Nodes) && object.Equals(Command, other.Command) && EqualityComparer<TSource>.Default.Equals(Source, other.Source))
			{
				return object.Equals(Child, other.Child);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Source).Hash(_arguments).Hash(Command)
				.Hash(RootNode)
				.Hash(Nodes)
				.Hash(Child);
		}

		public bool HasNodes()
		{
			return Nodes.Count > 0;
		}

		public bool IsForked()
		{
			return _forks;
		}
	}
	public class CommandContextBuilder<TSource>
	{
		private readonly IDictionary<string, IParsedArgument> _arguments;

		private RedirectModifier<TSource> _modifier;

		private bool _forks;

		public TSource Source { get; private set; }

		public CommandNode<TSource> RootNode { get; }

		public CommandContextBuilder<TSource> Child { get; private set; }

		public CommandContextBuilder<TSource> LastChild
		{
			get
			{
				CommandContextBuilder<TSource> commandContextBuilder = this;
				while (commandContextBuilder.Child != null)
				{
					commandContextBuilder = commandContextBuilder.Child;
				}
				return commandContextBuilder;
			}
		}

		public Command<TSource> Command { get; private set; }

		public List<ParsedCommandNode<TSource>> Nodes { get; }

		public CommandDispatcher<TSource> Dispatcher { get; }

		public StringRange Range { get; private set; }

		public CommandContextBuilder(CommandDispatcher<TSource> dispatcher, TSource source, CommandNode<TSource> rootNode, int start)
		{
			RootNode = rootNode;
			Dispatcher = dispatcher;
			Source = source;
			Range = StringRange.At(start);
			_arguments = new Dictionary<string, IParsedArgument>();
			Nodes = new List<ParsedCommandNode<TSource>>();
		}

		public CommandContextBuilder(CommandDispatcher<TSource> dispatcher, TSource source, CommandNode<TSource> rootNode, StringRange range, IDictionary<string, IParsedArgument> arguments, List<ParsedCommandNode<TSource>> nodes)
		{
			Dispatcher = dispatcher;
			Source = source;
			RootNode = rootNode;
			Range = range;
			_arguments = new Dictionary<string, IParsedArgument>(arguments);
			Nodes = new List<ParsedCommandNode<TSource>>(nodes);
		}

		public CommandContextBuilder<TSource> WithSource(TSource source)
		{
			Source = source;
			return this;
		}

		public CommandContextBuilder<TSource> WithArgument(string name, IParsedArgument argument)
		{
			_arguments.Add(name, argument);
			return this;
		}

		public IDictionary<string, IParsedArgument> GetArguments()
		{
			return _arguments;
		}

		public CommandContextBuilder<TSource> WithCommand(Command<TSource> command)
		{
			Command = command;
			return this;
		}

		public CommandContextBuilder<TSource> WithNode(CommandNode<TSource> node, StringRange range)
		{
			Nodes.Add(new ParsedCommandNode<TSource>(node, range));
			Range = StringRange.Encompassing(Range, range);
			_modifier = node.RedirectModifier;
			_forks = node.IsFork;
			return this;
		}

		public CommandContextBuilder<TSource> Copy()
		{
			return new CommandContextBuilder<TSource>(Dispatcher, Source, RootNode, Range, _arguments, Nodes)
			{
				Command = Command,
				Child = Child,
				_forks = _forks
			};
		}

		public CommandContextBuilder<TSource> WithChild(CommandContextBuilder<TSource> child)
		{
			Child = child;
			return this;
		}

		public CommandContext<TSource> Build(string input)
		{
			return new CommandContext<TSource>(Source, input, _arguments, Command, RootNode, Nodes, Range, Child?.Build(input), _modifier, _forks);
		}

		public SuggestionContext<TSource> FindSuggestionContext(int cursor)
		{
			if (Range.Start <= cursor)
			{
				if (Range.End < cursor)
				{
					if (Child != null)
					{
						return Child.FindSuggestionContext(cursor);
					}
					if (Nodes.Count > 0)
					{
						ParsedCommandNode<TSource> parsedCommandNode = Nodes[Nodes.Count - 1];
						return new SuggestionContext<TSource>(parsedCommandNode.Node, parsedCommandNode.Range.End + 1);
					}
					return new SuggestionContext<TSource>(RootNode, Range.Start);
				}
				CommandNode<TSource> commandNode = RootNode;
				foreach (ParsedCommandNode<TSource> node in Nodes)
				{
					StringRange range = node.Range;
					if (range.Start <= cursor && cursor <= range.End)
					{
						return new SuggestionContext<TSource>(commandNode, range.Start);
					}
					commandNode = node.Node;
				}
				if (commandNode == null)
				{
					throw new InvalidOperationException("Can't find node before cursor");
				}
				return new SuggestionContext<TSource>(commandNode, Range.Start);
			}
			throw new InvalidOperationException("Can't find node before cursor");
		}
	}
	public interface IParsedArgument
	{
		object Result { get; }
	}
	public struct ParsedArgument<TSource, T> : IParsedArgument, IEquatable<ParsedArgument<TSource, T>>
	{
		private readonly T _result;

		public StringRange Range { get; }

		public object Result => _result;

		public ParsedArgument(int start, int end, T result)
		{
			Range = StringRange.Between(start, end);
			_result = result;
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if ((object)this == obj)
			{
				return true;
			}
			if (obj is ParsedArgument<TSource, T> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(ParsedArgument<TSource, T> other)
		{
			if ((object)other == null)
			{
				return false;
			}
			if ((object)this == (object)other)
			{
				return true;
			}
			if (object.Equals(Range, other.Range))
			{
				return EqualityComparer<T>.Default.Equals(_result, other._result);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Range).Hash(_result);
		}
	}
	public class ParsedCommandNode<TSource> : IEquatable<ParsedCommandNode<TSource>>
	{
		public CommandNode<TSource> Node { get; }

		public StringRange Range { get; }

		public ParsedCommandNode(CommandNode<TSource> node, StringRange range)
		{
			Node = node;
			Range = range;
		}

		public override string ToString()
		{
			return $"{Node}@{Range}";
		}

		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is ParsedCommandNode<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(ParsedCommandNode<TSource> other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (object.Equals(Node, other.Node))
			{
				return object.Equals(Range, other.Range);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Node).Hash(Range);
		}
	}
	public struct StringRange
	{
		public int Start { get; }

		public int End { get; }

		public bool IsEmpty => Start == End;

		public int Length => End - Start;

		public StringRange(int start, int end)
		{
			Start = start;
			End = end;
		}

		public static StringRange At(int pos)
		{
			return new StringRange(pos, pos);
		}

		public static StringRange Between(int start, int end)
		{
			return new StringRange(start, end);
		}

		public static StringRange Encompassing(StringRange a, StringRange b)
		{
			return new StringRange(Math.Min(a.Start, b.Start), Math.Max(a.End, b.End));
		}

		public string Get(IImmutableStringReader reader)
		{
			return reader.String.Substring(Start, End - Start);
		}

		public string Get(string source)
		{
			return source.Substring(Start, End - Start);
		}

		public override bool Equals(object o)
		{
			if (!(o is StringRange stringRange))
			{
				return false;
			}
			if (Start == stringRange.Start)
			{
				return End == stringRange.End;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Brigadier.NET.Util.HashCode.Start.Hash(Start).Hash(End);
		}

		public override string ToString()
		{
			return $"StringRange{{start={Start}, end={End}}}";
		}
	}
	public class SuggestionContext<TSource>
	{
		public readonly CommandNode<TSource> Parent;

		public readonly int StartPos;

		public SuggestionContext(CommandNode<TSource> parent, int startPos)
		{
			Parent = parent;
			StartPos = startPos;
		}
	}
}
namespace Brigadier.NET.Builder
{
	public interface IArgumentBuilder<TSource, out TNode> where TNode : CommandNode<TSource>
	{
		TNode Build();
	}
	public abstract class ArgumentBuilder<TSource, TThis, TNode> : IArgumentBuilder<TSource, TNode> where TThis : ArgumentBuilder<TSource, TThis, TNode> where TNode : CommandNode<TSource>
	{
		private readonly RootCommandNode<TSource> _arguments = new RootCommandNode<TSource>();

		protected TThis This => (TThis)this;

		public IEnumerable<CommandNode<TSource>> Arguments => _arguments.Children;

		public Command<TSource> Command { get; private set; }

		public Predicate<TSource> Requirement { get; private set; } = (TSource s) => true;


		public CommandNode<TSource> RedirectTarget { get; private set; }

		public RedirectModifier<TSource> RedirectModifier { get; private set; }

		public bool IsFork { get; private set; }

		public TThis Then<TChildNode>(IArgumentBuilder<TSource, TChildNode> argument) where TChildNode : CommandNode<TSource>
		{
			if (RedirectTarget != null)
			{
				throw new InvalidOperationException("Cannot add children to a redirected node");
			}
			_arguments.AddChild(argument.Build());
			return This;
		}

		public TThis Then<TChildNode>(Func<IArgumentContext<TSource>, IArgumentBuilder<TSource, TChildNode>> argument) where TChildNode : CommandNode<TSource>
		{
			if (RedirectTarget != null)
			{
				throw new InvalidOperationException("Cannot add children to a redirected node");
			}
			_arguments.AddChild(argument(default(ArgumentContext<TSource>)).Build());
			return This;
		}

		public TThis Then(CommandNode<TSource> argument)
		{
			if (RedirectTarget != null)
			{
				throw new InvalidOperationException("Cannot add children to a redirected node");
			}
			_arguments.AddChild(argument);
			return This;
		}

		public TThis Executes(Command<TSource> command)
		{
			Command = command;
			return This;
		}

		public TThis Requires(Predicate<TSource> requirement)
		{
			Requirement = requirement;
			return This;
		}

		public TThis Redirect(CommandNode<TSource> target)
		{
			return Forward(target, null, fork: false);
		}

		public TThis Redirect(CommandNode<TSource> target, SingleRedirectModifier<TSource> modifier)
		{
			return Forward(target, (modifier == null) ? null : ((RedirectModifier<TSource>)((CommandContext<TSource> o) => new TSource[1] { modifier(o) })), fork: false);
		}

		public TThis Fork(CommandNode<TSource> target, RedirectModifier<TSource> modifier)
		{
			return Forward(target, modifier, fork: true);
		}

		public TThis Forward(CommandNode<TSource> target, RedirectModifier<TSource> modifier, bool fork)
		{
			if (_arguments.Children.Count > 0)
			{
				throw new InvalidOperationException("Cannot forward a node with children");
			}
			RedirectTarget = target;
			RedirectModifier = modifier;
			IsFork = fork;
			return This;
		}

		public abstract TNode Build();
	}
	public interface IArgumentContext<TSource>
	{
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct ArgumentContext<TSource> : IArgumentContext<TSource>
	{
	}
	public static class LiteralArgumentBuilderExtensions
	{
		public static LiteralArgumentBuilder<TSource> Literal<TSource>(this IArgumentContext<TSource> context, string name)
		{
			return new LiteralArgumentBuilder<TSource>(name);
		}
	}
	public class LiteralArgumentBuilder<TSource> : ArgumentBuilder<TSource, LiteralArgumentBuilder<TSource>, LiteralCommandNode<TSource>>
	{
		public string Literal { get; }

		public LiteralArgumentBuilder(string literal)
		{
			Literal = literal;
		}

		public static LiteralArgumentBuilder<TSource> LiteralArgument(string name)
		{
			return new LiteralArgumentBuilder<TSource>(name);
		}

		public override LiteralCommandNode<TSource> Build()
		{
			LiteralCommandNode<TSource> literalCommandNode = new LiteralCommandNode<TSource>(Literal, base.Command, base.Requirement, base.RedirectTarget, base.RedirectModifier, base.IsFork);
			foreach (CommandNode<TSource> argument in base.Arguments)
			{
				literalCommandNode.AddChild(argument);
			}
			return literalCommandNode;
		}
	}
	public static class RequiredArgumentBuilderExtensions
	{
		public static RequiredArgumentBuilder<TSource, T> Argument<TSource, T>(this IArgumentContext<TSource> context, string name, ArgumentType<T> type)
		{
			return RequiredArgumentBuilder<TSource, T>.RequiredArgument(name, type);
		}
	}
	public class RequiredArgumentBuilder<TSource, T> : ArgumentBuilder<TSource, RequiredArgumentBuilder<TSource, T>, ArgumentCommandNode<TSource, T>>
	{
		private SuggestionProvider<TSource> _suggestionsProvider;

		public ArgumentType<T> Type { get; }

		public string Name { get; }

		private RequiredArgumentBuilder(string name, ArgumentType<T> type)
		{
			Name = name;
			Type = type;
		}

		public static RequiredArgumentBuilder<TSource, T> RequiredArgument(string name, ArgumentType<T> type)
		{
			return new RequiredArgumentBuilder<TSource, T>(name, type);
		}

		public RequiredArgumentBuilder<TSource, T> Suggests(SuggestionProvider<TSource> provider)
		{
			_suggestionsProvider = provider;
			return base.This;
		}

		public override ArgumentCommandNode<TSource, T> Build()
		{
			ArgumentCommandNode<TSource, T> argumentCommandNode = new ArgumentCommandNode<TSource, T>(Name, Type, base.Command, base.Requirement, base.RedirectTarget, base.RedirectModifier, base.IsFork, _suggestionsProvider);
			foreach (CommandNode<TSource> argument in base.Arguments)
			{
				argumentCommandNode.AddChild(argument);
			}
			return argumentCommandNode;
		}
	}
}
namespace Brigadier.NET.ArgumentTypes
{
	public abstract class ArgumentType<T>
	{
		public virtual IEnumerable<string> Examples => new string[0];

		public abstract T Parse(IStringReader reader);

		public virtual Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			return Suggestions.Empty();
		}
	}
	public class BoolArgumentType : ArgumentType<bool>
	{
		private static readonly IEnumerable<string> BoolExamples = new string[2] { "true", "false" };

		public override IEnumerable<string> Examples => BoolExamples;

		internal BoolArgumentType()
		{
		}

		public override bool Parse(IStringReader reader)
		{
			return reader.ReadBoolean();
		}

		public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			if ("true".StartsWith(builder.RemainingLowerCase))
			{
				builder.Suggest("true");
			}
			if ("false".StartsWith(builder.RemainingLowerCase))
			{
				builder.Suggest("false");
			}
			return builder.BuildFuture();
		}
	}
	public class DoubleArgumentType : ArgumentType<double>
	{
		private static readonly IEnumerable<string> DoubleExamples = new string[6] { "0", "1.2", ".5", "-1", "-.5", "-1234.56" };

		public double Minimum { get; }

		public double Maximum { get; }

		public override IEnumerable<string> Examples => DoubleExamples;

		internal DoubleArgumentType(double minimum, double maximum)
		{
			Minimum = minimum;
			Maximum = maximum;
		}

		public override double Parse(IStringReader reader)
		{
			int cursor = reader.Cursor;
			double num = reader.ReadDouble();
			if (num < Minimum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.DoubleTooLow().CreateWithContext(reader, num, Minimum);
			}
			if (num > Maximum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.DoubleTooHigh().CreateWithContext(reader, num, Maximum);
			}
			return num;
		}

		public override bool Equals(object o)
		{
			if (this == o)
			{
				return true;
			}
			if (!(o is DoubleArgumentType))
			{
				return false;
			}
			DoubleArgumentType doubleArgumentType = (DoubleArgumentType)o;
			if (Maximum == doubleArgumentType.Maximum)
			{
				return Minimum == doubleArgumentType.Minimum;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return (int)(31.0 * Minimum + Maximum);
		}

		public override string ToString()
		{
			if (Minimum == double.MinValue && Maximum == double.MaxValue)
			{
				return "double()";
			}
			if (Maximum == double.MaxValue)
			{
				return $"double({Minimum:#.0})";
			}
			return $"double({Minimum:#.0}, {Maximum:#.0})";
		}
	}
	public class FloatArgumentType : ArgumentType<float>
	{
		private static readonly IEnumerable<string> FloatExamples = new string[6] { "0", "1.2", ".5", "-1", "-.5", "-1234.56" };

		private readonly float _minimum;

		private readonly float _maximum;

		public override IEnumerable<string> Examples => FloatExamples;

		internal FloatArgumentType(float minimum, float maximum)
		{
			_minimum = minimum;
			_maximum = maximum;
		}

		public float Minimum()
		{
			return _minimum;
		}

		public float Maximum()
		{
			return _maximum;
		}

		public override float Parse(IStringReader reader)
		{
			int cursor = reader.Cursor;
			float num = reader.ReadFloat();
			if (num < _minimum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooLow().CreateWithContext(reader, num, _minimum);
			}
			if (num > _maximum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.FloatTooHigh().CreateWithContext(reader, num, _maximum);
			}
			return num;
		}

		public override bool Equals(object o)
		{
			if (this == o)
			{
				return true;
			}
			if (!(o is FloatArgumentType))
			{
				return false;
			}
			FloatArgumentType floatArgumentType = (FloatArgumentType)o;
			if (_maximum == floatArgumentType._maximum)
			{
				return _minimum == floatArgumentType._minimum;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return (int)(31f * _minimum + _maximum);
		}

		public override string ToString()
		{
			if (_minimum == float.MinValue && _maximum == float.MaxValue)
			{
				return "float()";
			}
			if (_maximum == float.MaxValue)
			{
				return $"float({_minimum:#.0})";
			}
			return $"float({_minimum:#.0}, {_maximum:#.0})";
		}
	}
	public class IntegerArgumentType : ArgumentType<int>
	{
		private static readonly IEnumerable<string> IntegerExamples = new string[3] { "0", "123", "-123" };

		public int Minimum { get; }

		public int Maximum { get; }

		public override IEnumerable<string> Examples => IntegerExamples;

		internal IntegerArgumentType(int minimum, int maximum)
		{
			Minimum = minimum;
			Maximum = maximum;
		}

		public override int Parse(IStringReader reader)
		{
			int cursor = reader.Cursor;
			int num = reader.ReadInt();
			if (num < Minimum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.IntegerTooLow().CreateWithContext(reader, num, Minimum);
			}
			if (num > Maximum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.IntegerTooHigh().CreateWithContext(reader, num, Maximum);
			}
			return num;
		}

		public override bool Equals(object o)
		{
			if (this == o)
			{
				return true;
			}
			if (!(o is IntegerArgumentType))
			{
				return false;
			}
			IntegerArgumentType integerArgumentType = (IntegerArgumentType)o;
			if (Maximum == integerArgumentType.Maximum)
			{
				return Minimum == integerArgumentType.Minimum;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return 31 * Minimum + Maximum;
		}

		public override string ToString()
		{
			if (Minimum == int.MinValue && Maximum == int.MaxValue)
			{
				return "integer()";
			}
			if (Maximum == int.MaxValue)
			{
				return "integer(" + Minimum + ")";
			}
			return "integer(" + Minimum + ", " + Maximum + ")";
		}
	}
	public class LongArgumentType : ArgumentType<long>
	{
		private static readonly IEnumerable<string> LongExamples = new string[3] { "0", "123", "-123" };

		public long Minimum { get; }

		public long Maximum { get; }

		public override IEnumerable<string> Examples => LongExamples;

		internal LongArgumentType(long minimum, long maximum)
		{
			Minimum = minimum;
			Maximum = maximum;
		}

		public override long Parse(IStringReader reader)
		{
			int cursor = reader.Cursor;
			long num = reader.ReadLong();
			if (num < Minimum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.LongTooLow().CreateWithContext(reader, num, Minimum);
			}
			if (num > Maximum)
			{
				reader.Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.LongTooHigh().CreateWithContext(reader, num, Maximum);
			}
			return num;
		}

		public override bool Equals(object o)
		{
			if (this == o)
			{
				return true;
			}
			if (!(o is LongArgumentType))
			{
				return false;
			}
			LongArgumentType longArgumentType = (LongArgumentType)o;
			if (Maximum == longArgumentType.Maximum)
			{
				return Minimum == longArgumentType.Minimum;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return 31 * Minimum.GetHashCode() + Maximum.GetHashCode();
		}

		public override string ToString()
		{
			if (Minimum == long.MinValue && Maximum == long.MaxValue)
			{
				return "longArg()";
			}
			if (Maximum == long.MaxValue)
			{
				return $"longArg({Minimum})";
			}
			return $"longArg({Minimum}, {Maximum})";
		}
	}
	public enum StringArgType
	{
		SingleWord,
		QuotablePhrase,
		GreedyPhrase
	}
	public class StringArgumentType : ArgumentType<string>
	{
		private static readonly Dictionary<StringArgType, IEnumerable<string>> StringExamples = new Dictionary<StringArgType, IEnumerable<string>>
		{
			{
				StringArgType.SingleWord,
				new string[2] { "word", "words_with_underscores" }
			},
			{
				StringArgType.QuotablePhrase,
				new string[3] { "\"quoted phrase\"", "word", "\"\"" }
			},
			{
				StringArgType.GreedyPhrase,
				new string[3] { "word", "words with spaces", "\"and symbols\"" }
			}
		};

		public StringArgType Type { get; }

		public override IEnumerable<string> Examples => StringExamples[Type];

		internal StringArgumentType(StringArgType type)
		{
			Type = type;
		}

		public override string Parse(IStringReader reader)
		{
			if (Type == StringArgType.GreedyPhrase)
			{
				string remaining = reader.Remaining;
				reader.Cursor = reader.TotalLength;
				return remaining;
			}
			if (Type == StringArgType.SingleWord)
			{
				return reader.ReadUnquotedString();
			}
			return reader.ReadString();
		}

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

		public static string EscapeIfRequired(string input)
		{
			for (int i = 0; i < input.Length; i++)
			{
				if (!StringReader.IsAllowedInUnquotedString(input[i]))
				{
					return Escape(input);
				}
			}
			return input;
		}

		private static string Escape(string input)
		{
			StringBuilder stringBuilder = new StringBuilder("\"");
			foreach (char c in input)
			{
				if (c == '\\' || c == '"')
				{
					stringBuilder.Append('\\');
				}
				stringBuilder.Append(c);
			}
			stringBuilder.Append("\"");
			return stringBuilder.ToString();
		}
	}
}

System.Buffers.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using FxResources.System.Buffers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.Buffers")]
[assembly: AssemblyDescription("System.Buffers")]
[assembly: AssemblyDefaultAlias("System.Buffers")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.25519.03")]
[assembly: AssemblyInformationalVersion("4.6.25519.03 built by: dlab-DDVSOWINAGE013. Commit Hash: 8321c729934c0f8be754953439b88e6e1c120c24")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.2.0")]
[module: UnverifiableCode]
namespace FxResources.System.Buffers
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class SR
	{
		private static ResourceManager s_resourceManager;

		private const string s_resourcesName = "FxResources.System.Buffers.SR";

		private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType));

		internal static string ArgumentException_BufferNotFromPool => GetResourceString("ArgumentException_BufferNotFromPool", null);

		internal static Type ResourceType => typeof(SR);

		[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.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.All)]
	internal class __BlockReflectionAttribute : Attribute
	{
	}
}
namespace System.Buffers
{
	public abstract class ArrayPool<T>
	{
		private static ArrayPool<T> s_sharedInstance;

		public static ArrayPool<T> Shared
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return Volatile.Read(ref s_sharedInstance) ?? EnsureSharedCreated();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static ArrayPool<T> EnsureSharedCreated()
		{
			Interlocked.CompareExchange(ref s_sharedInstance, Create(), null);
			return s_sharedInstance;
		}

		public static ArrayPool<T> Create()
		{
			return new DefaultArrayPool<T>();
		}

		public static ArrayPool<T> Create(int maxArrayLength, int maxArraysPerBucket)
		{
			return new DefaultArrayPool<T>(maxArrayLength, maxArraysPerBucket);
		}

		public abstract T[] Rent(int minimumLength);

		public abstract void Return(T[] array, bool clearArray = false);
	}
	[EventSource(Name = "System.Buffers.ArrayPoolEventSource")]
	internal sealed class ArrayPoolEventSource : EventSource
	{
		internal enum BufferAllocatedReason
		{
			Pooled,
			OverMaximumSize,
			PoolExhausted
		}

		internal static readonly System.Buffers.ArrayPoolEventSource Log = new System.Buffers.ArrayPoolEventSource();

		[Event(1, Level = EventLevel.Verbose)]
		internal unsafe void BufferRented(int bufferId, int bufferSize, int poolId, int bucketId)
		{
			EventData* ptr = stackalloc EventData[4];
			ptr->Size = 4;
			ptr->DataPointer = (IntPtr)(&bufferId);
			ptr[1].Size = 4;
			ptr[1].DataPointer = (IntPtr)(&bufferSize);
			ptr[2].Size = 4;
			ptr[2].DataPointer = (IntPtr)(&poolId);
			ptr[3].Size = 4;
			ptr[3].DataPointer = (IntPtr)(&bucketId);
			WriteEventCore(1, 4, ptr);
		}

		[Event(2, Level = EventLevel.Informational)]
		internal unsafe void BufferAllocated(int bufferId, int bufferSize, int poolId, int bucketId, BufferAllocatedReason reason)
		{
			EventData* ptr = stackalloc EventData[5];
			ptr->Size = 4;
			ptr->DataPointer = (IntPtr)(&bufferId);
			ptr[1].Size = 4;
			ptr[1].DataPointer = (IntPtr)(&bufferSize);
			ptr[2].Size = 4;
			ptr[2].DataPointer = (IntPtr)(&poolId);
			ptr[3].Size = 4;
			ptr[3].DataPointer = (IntPtr)(&bucketId);
			ptr[4].Size = 4;
			ptr[4].DataPointer = (IntPtr)(&reason);
			WriteEventCore(2, 5, ptr);
		}

		[Event(3, Level = EventLevel.Verbose)]
		internal void BufferReturned(int bufferId, int bufferSize, int poolId)
		{
			WriteEvent(3, bufferId, bufferSize, poolId);
		}
	}
	internal sealed class DefaultArrayPool<T> : ArrayPool<T>
	{
		private sealed class Bucket
		{
			internal readonly int _bufferLength;

			private readonly T[][] _buffers;

			private readonly int _poolId;

			private SpinLock _lock;

			private int _index;

			internal int Id => GetHashCode();

			internal Bucket(int bufferLength, int numberOfBuffers, int poolId)
			{
				_lock = new SpinLock(Debugger.IsAttached);
				_buffers = new T[numberOfBuffers][];
				_bufferLength = bufferLength;
				_poolId = poolId;
			}

			internal T[] Rent()
			{
				T[][] buffers = _buffers;
				T[] array = null;
				bool lockTaken = false;
				bool flag = false;
				try
				{
					_lock.Enter(ref lockTaken);
					if (_index < buffers.Length)
					{
						array = buffers[_index];
						buffers[_index++] = null;
						flag = array == null;
					}
				}
				finally
				{
					if (lockTaken)
					{
						_lock.Exit(useMemoryBarrier: false);
					}
				}
				if (flag)
				{
					array = new T[_bufferLength];
					System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log;
					if (log.IsEnabled())
					{
						log.BufferAllocated(array.GetHashCode(), _bufferLength, _poolId, Id, System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.Pooled);
					}
				}
				return array;
			}

			internal void Return(T[] array)
			{
				if (array.Length != _bufferLength)
				{
					throw new ArgumentException(System.SR.ArgumentException_BufferNotFromPool, "array");
				}
				bool lockTaken = false;
				try
				{
					_lock.Enter(ref lockTaken);
					if (_index != 0)
					{
						_buffers[--_index] = array;
					}
				}
				finally
				{
					if (lockTaken)
					{
						_lock.Exit(useMemoryBarrier: false);
					}
				}
			}
		}

		private const int DefaultMaxArrayLength = 1048576;

		private const int DefaultMaxNumberOfArraysPerBucket = 50;

		private static T[] s_emptyArray;

		private readonly Bucket[] _buckets;

		private int Id => GetHashCode();

		internal DefaultArrayPool()
			: this(1048576, 50)
		{
		}

		internal DefaultArrayPool(int maxArrayLength, int maxArraysPerBucket)
		{
			if (maxArrayLength <= 0)
			{
				throw new ArgumentOutOfRangeException("maxArrayLength");
			}
			if (maxArraysPerBucket <= 0)
			{
				throw new ArgumentOutOfRangeException("maxArraysPerBucket");
			}
			if (maxArrayLength > 1073741824)
			{
				maxArrayLength = 1073741824;
			}
			else if (maxArrayLength < 16)
			{
				maxArrayLength = 16;
			}
			int id = Id;
			int num = System.Buffers.Utilities.SelectBucketIndex(maxArrayLength);
			Bucket[] array = new Bucket[num + 1];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Bucket(System.Buffers.Utilities.GetMaxSizeForBucket(i), maxArraysPerBucket, id);
			}
			_buckets = array;
		}

		public override T[] Rent(int minimumLength)
		{
			if (minimumLength < 0)
			{
				throw new ArgumentOutOfRangeException("minimumLength");
			}
			if (minimumLength == 0)
			{
				return s_emptyArray ?? (s_emptyArray = new T[0]);
			}
			System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log;
			T[] array = null;
			int num = System.Buffers.Utilities.SelectBucketIndex(minimumLength);
			if (num < _buckets.Length)
			{
				int num2 = num;
				do
				{
					array = _buckets[num2].Rent();
					if (array != null)
					{
						if (log.IsEnabled())
						{
							log.BufferRented(array.GetHashCode(), array.Length, Id, _buckets[num2].Id);
						}
						return array;
					}
				}
				while (++num2 < _buckets.Length && num2 != num + 2);
				array = new T[_buckets[num]._bufferLength];
			}
			else
			{
				array = new T[minimumLength];
			}
			if (log.IsEnabled())
			{
				int hashCode = array.GetHashCode();
				int bucketId = -1;
				log.BufferRented(hashCode, array.Length, Id, bucketId);
				log.BufferAllocated(hashCode, array.Length, Id, bucketId, (num >= _buckets.Length) ? System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.OverMaximumSize : System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.PoolExhausted);
			}
			return array;
		}

		public override void Return(T[] array, bool clearArray = false)
		{
			if (array == null)
			{
				throw new ArgumentNullException("array");
			}
			if (array.Length == 0)
			{
				return;
			}
			int num = System.Buffers.Utilities.SelectBucketIndex(array.Length);
			if (num < _buckets.Length)
			{
				if (clearArray)
				{
					Array.Clear(array, 0, array.Length);
				}
				_buckets[num].Return(array);
			}
			System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log;
			if (log.IsEnabled())
			{
				log.BufferReturned(array.GetHashCode(), array.Length, Id);
			}
		}
	}
	internal static class Utilities
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static int SelectBucketIndex(int bufferSize)
		{
			uint num = (uint)(bufferSize - 1) >> 4;
			int num2 = 0;
			if (num > 65535)
			{
				num >>= 16;
				num2 = 16;
			}
			if (num > 255)
			{
				num >>= 8;
				num2 += 8;
			}
			if (num > 15)
			{
				num >>= 4;
				num2 += 4;
			}
			if (num > 3)
			{
				num >>= 2;
				num2 += 2;
			}
			if (num > 1)
			{
				num >>= 1;
				num2++;
			}
			return num2 + (int)num;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static int GetMaxSizeForBucket(int binIndex)
		{
			return 16 << binIndex;
		}
	}
}

System.Memory.dll

Decompiled 3 hours ago
using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Buffers.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Numerics.Hashing;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using FxResources.System.Memory;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.Memory")]
[assembly: AssemblyDescription("System.Memory")]
[assembly: AssemblyDefaultAlias("System.Memory")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.26606.05")]
[assembly: AssemblyInformationalVersion("4.6.26606.05 @BuiltBy: dlab14-DDVSOWINAGE080 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/7ee84596d92e178bce54c986df31ccc52479e772")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.1.0")]
[module: UnverifiableCode]
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
	{
	}
}
namespace FxResources.System.Memory
{
	internal static class SR
	{
	}
}
namespace System
{
	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 HashHelpers.Combine(_object?.GetHashCode() ?? 0, _integer);
		}
	}
	internal static class ThrowHelper
	{
		internal static void ThrowArgumentNullException(System.ExceptionArgument argument)
		{
			throw CreateArgumentNullException(argument);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentNullException(System.ExceptionArgument argument)
		{
			return new ArgumentNullException(argument.ToString());
		}

		internal static void ThrowArrayTypeMismatchException()
		{
			throw CreateArrayTypeMismatchException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArrayTypeMismatchException()
		{
			return new ArrayTypeMismatchException();
		}

		internal static void ThrowArgumentException_InvalidTypeWithPointersNotSupported(Type type)
		{
			throw CreateArgumentException_InvalidTypeWithPointersNotSupported(type);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentException_InvalidTypeWithPointersNotSupported(Type type)
		{
			return new ArgumentException(System.SR.Format(System.SR.Argument_InvalidTypeWithPointersNotSupported, type));
		}

		internal static void ThrowArgumentException_DestinationTooShort()
		{
			throw CreateArgumentException_DestinationTooShort();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentException_DestinationTooShort()
		{
			return new ArgumentException(System.SR.Argument_DestinationTooShort);
		}

		internal static void ThrowIndexOutOfRangeException()
		{
			throw CreateIndexOutOfRangeException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateIndexOutOfRangeException()
		{
			return new IndexOutOfRangeException();
		}

		internal static void ThrowArgumentOutOfRangeException()
		{
			throw CreateArgumentOutOfRangeException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException()
		{
			return new ArgumentOutOfRangeException();
		}

		internal static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
		{
			throw CreateArgumentOutOfRangeException(argument);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException(System.ExceptionArgument argument)
		{
			return new ArgumentOutOfRangeException(argument.ToString());
		}

		internal static void ThrowArgumentOutOfRangeException_PrecisionTooLarge()
		{
			throw CreateArgumentOutOfRangeException_PrecisionTooLarge();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException_PrecisionTooLarge()
		{
			return new ArgumentOutOfRangeException("precision", System.SR.Format(System.SR.Argument_PrecisionTooLarge, (byte)99));
		}

		internal static void ThrowArgumentOutOfRangeException_SymbolDoesNotFit()
		{
			throw CreateArgumentOutOfRangeException_SymbolDoesNotFit();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException_SymbolDoesNotFit()
		{
			return new ArgumentOutOfRangeException("symbol", System.SR.Argument_BadFormatSpecifier);
		}

		internal static void ThrowInvalidOperationException()
		{
			throw CreateInvalidOperationException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateInvalidOperationException()
		{
			return new InvalidOperationException();
		}

		internal static void ThrowInvalidOperationException_OutstandingReferences()
		{
			throw CreateInvalidOperationException_OutstandingReferences();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateInvalidOperationException_OutstandingReferences()
		{
			return new InvalidOperationException(System.SR.OutstandingReferences);
		}

		internal static void ThrowInvalidOperationException_UnexpectedSegmentType()
		{
			throw CreateInvalidOperationException_UnexpectedSegmentType();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateInvalidOperationException_UnexpectedSegmentType()
		{
			return new InvalidOperationException(System.SR.UnexpectedSegmentType);
		}

		internal static void ThrowInvalidOperationException_EndPositionNotReached()
		{
			throw CreateInvalidOperationException_EndPositionNotReached();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateInvalidOperationException_EndPositionNotReached()
		{
			return new InvalidOperationException(System.SR.EndPositionNotReached);
		}

		internal static void ThrowArgumentOutOfRangeException_PositionOutOfRange()
		{
			throw CreateArgumentOutOfRangeException_PositionOutOfRange();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException_PositionOutOfRange()
		{
			return new ArgumentOutOfRangeException("position");
		}

		internal static void ThrowArgumentOutOfRangeException_OffsetOutOfRange()
		{
			throw CreateArgumentOutOfRangeException_OffsetOutOfRange();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentOutOfRangeException_OffsetOutOfRange()
		{
			return new ArgumentOutOfRangeException("offset");
		}

		internal static void ThrowObjectDisposedException_ArrayMemoryPoolBuffer()
		{
			throw CreateObjectDisposedException_ArrayMemoryPoolBuffer();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateObjectDisposedException_ArrayMemoryPoolBuffer()
		{
			return new ObjectDisposedException("ArrayMemoryPoolBuffer");
		}

		internal static void ThrowFormatException_BadFormatSpecifier()
		{
			throw CreateFormatException_BadFormatSpecifier();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateFormatException_BadFormatSpecifier()
		{
			return new FormatException(System.SR.Argument_BadFormatSpecifier);
		}

		internal static void ThrowArgumentException_OverlapAlignmentMismatch()
		{
			throw CreateArgumentException_OverlapAlignmentMismatch();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateArgumentException_OverlapAlignmentMismatch()
		{
			return new ArgumentException(System.SR.Argument_OverlapAlignmentMismatch);
		}

		internal static void ThrowNotSupportedException()
		{
			throw CreateThrowNotSupportedException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static Exception CreateThrowNotSupportedException()
		{
			return new NotSupportedException();
		}

		public static bool TryFormatThrowFormatException(out int bytesWritten)
		{
			bytesWritten = 0;
			ThrowFormatException_BadFormatSpecifier();
			return false;
		}

		public static bool TryParseThrowFormatException<T>(out T value, out int bytesConsumed)
		{
			value = default(T);
			bytesConsumed = 0;
			ThrowFormatException_BadFormatSpecifier();
			return false;
		}

		public static void ThrowArgumentValidationException<T>(ReadOnlySequenceSegment<T> startSegment, int startIndex, ReadOnlySequenceSegment<T> endSegment)
		{
			throw CreateArgumentValidationException(startSegment, startIndex, endSegment);
		}

		private static Exception CreateArgumentValidationException<T>(ReadOnlySequenceSegment<T> startSegment, int startIndex, ReadOnlySequenceSegment<T> endSegment)
		{
			if (startSegment == null)
			{
				return CreateArgumentNullException(System.ExceptionArgument.startSegment);
			}
			if (endSegment == null)
			{
				return CreateArgumentNullException(System.ExceptionArgument.endSegment);
			}
			if (startSegment != endSegment && startSegment.RunningIndex > endSegment.RunningIndex)
			{
				return CreateArgumentOutOfRangeException(System.ExceptionArgument.endSegment);
			}
			if ((uint)startSegment.Memory.Length < (uint)startIndex)
			{
				return CreateArgumentOutOfRangeException(System.ExceptionArgument.startIndex);
			}
			return CreateArgumentOutOfRangeException(System.ExceptionArgument.endIndex);
		}

		public static void ThrowArgumentValidationException(Array array, int start)
		{
			throw CreateArgumentValidationException(array, start);
		}

		private static Exception CreateArgumentValidationException(Array array, int start)
		{
			if (array == null)
			{
				return CreateArgumentNullException(System.ExceptionArgument.array);
			}
			if ((uint)start > (uint)array.Length)
			{
				return CreateArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return CreateArgumentOutOfRangeException(System.ExceptionArgument.length);
		}

		public static void ThrowStartOrEndArgumentValidationException(long start)
		{
			throw CreateStartOrEndArgumentValidationException(start);
		}

		private static Exception CreateStartOrEndArgumentValidationException(long start)
		{
			if (start < 0)
			{
				return CreateArgumentOutOfRangeException(System.ExceptionArgument.start);
			}
			return CreateArgumentOutOfRangeException(System.ExceptionArgument.length);
		}
	}
	internal enum ExceptionArgument
	{
		length,
		start,
		minimumBufferSize,
		elementIndex,
		comparable,
		comparer,
		destination,
		offset,
		startSegment,
		endSegment,
		startIndex,
		endIndex,
		array,
		culture,
		manager
	}
	internal static class DecimalDecCalc
	{
		private static uint D32DivMod1E9(uint hi32, ref uint lo32)
		{
			ulong num = ((ulong)hi32 << 32) | lo32;
			lo32 = (uint)(num / 1000000000);
			return (uint)(num % 1000000000);
		}

		internal static uint DecDivMod1E9(ref MutableDecimal value)
		{
			return D32DivMod1E9(D32DivMod1E9(D32DivMod1E9(0u, ref value.High), ref value.Mid), ref value.Low);
		}

		internal static void DecAddInt32(ref MutableDecimal value, uint i)
		{
			if (D32AddCarry(ref value.Low, i) && D32AddCarry(ref value.Mid, 1u))
			{
				D32AddCarry(ref value.High, 1u);
			}
		}

		private static bool D32AddCarry(ref uint value, uint i)
		{
			uint num = value;
			uint num2 = (value = num + i);
			if (num2 >= num)
			{
				return num2 < i;
			}
			return true;
		}

		internal static void DecMul10(ref MutableDecimal value)
		{
			MutableDecimal d = value;
			DecShiftLeft(ref value);
			DecShiftLeft(ref value);
			DecAdd(ref value, d);
			DecShiftLeft(ref value);
		}

		private static void DecShiftLeft(ref MutableDecimal value)
		{
			uint num = (((value.Low & 0x80000000u) != 0) ? 1u : 0u);
			uint num2 = (((value.Mid & 0x80000000u) != 0) ? 1u : 0u);
			value.Low <<= 1;
			value.Mid = (value.Mid << 1) | num;
			value.High = (value.High << 1) | num2;
		}

		private static void DecAdd(ref MutableDecimal value, MutableDecimal d)
		{
			if (D32AddCarry(ref value.Low, d.Low) && D32AddCarry(ref value.Mid, 1u))
			{
				D32AddCarry(ref value.High, 1u);
			}
			if (D32AddCarry(ref value.Mid, d.Mid))
			{
				D32AddCarry(ref value.High, 1u);
			}
			D32AddCarry(ref value.High, d.High);
		}
	}
	internal static class Number
	{
		private static class DoubleHelper
		{
			public unsafe static uint Exponent(double d)
			{
				return (*(uint*)((byte*)(&d) + 4) >> 20) & 0x7FFu;
			}

			public unsafe static ulong Mantissa(double d)
			{
				return *(uint*)(&d) | ((ulong)(uint)(*(int*)((byte*)(&d) + 4) & 0xFFFFF) << 32);
			}

			public unsafe static bool Sign(double d)
			{
				return *(uint*)((byte*)(&d) + 4) >> 31 != 0;
			}
		}

		internal const int DECIMAL_PRECISION = 29;

		private static readonly ulong[] s_rgval64Power10 = new ulong[30]
		{
			11529215046068469760uL, 14411518807585587200uL, 18014398509481984000uL, 11258999068426240000uL, 14073748835532800000uL, 17592186044416000000uL, 10995116277760000000uL, 13743895347200000000uL, 17179869184000000000uL, 10737418240000000000uL,
			13421772800000000000uL, 16777216000000000000uL, 10485760000000000000uL, 13107200000000000000uL, 16384000000000000000uL, 14757395258967641293uL, 11805916207174113035uL, 9444732965739290428uL, 15111572745182864686uL, 12089258196146291749uL,
			9671406556917033399uL, 15474250491067253438uL, 12379400392853802751uL, 9903520314283042201uL, 15845632502852867522uL, 12676506002282294018uL, 10141204801825835215uL, 16225927682921336344uL, 12980742146337069075uL, 10384593717069655260uL
		};

		private static readonly sbyte[] s_rgexp64Power10 = new sbyte[15]
		{
			4, 7, 10, 14, 17, 20, 24, 27, 30, 34,
			37, 40, 44, 47, 50
		};

		private static readonly ulong[] s_rgval64Power10By16 = new ulong[42]
		{
			10240000000000000000uL, 11368683772161602974uL, 12621774483536188886uL, 14012984643248170708uL, 15557538194652854266uL, 17272337110188889248uL, 9588073174409622172uL, 10644899600020376798uL, 11818212630765741798uL, 13120851772591970216uL,
			14567071740625403792uL, 16172698447808779622uL, 17955302187076837696uL, 9967194951097567532uL, 11065809325636130658uL, 12285516299433008778uL, 13639663065038175358uL, 15143067982934716296uL, 16812182738118149112uL, 9332636185032188787uL,
			10361307573072618722uL, 16615349947311448416uL, 14965776766268445891uL, 13479973333575319909uL, 12141680576410806707uL, 10936253623915059637uL, 9850501549098619819uL, 17745086042373215136uL, 15983352577617880260uL, 14396524142538228461uL,
			12967236152753103031uL, 11679847981112819795uL, 10520271803096747049uL, 9475818434452569218uL, 17070116948172427008uL, 15375394465392026135uL, 13848924157002783096uL, 12474001934591998882uL, 11235582092889474480uL, 10120112665365530972uL,
			18230774251475056952uL, 16420821625123739930uL
		};

		private static readonly short[] s_rgexp64Power10By16 = new short[21]
		{
			54, 107, 160, 213, 266, 319, 373, 426, 479, 532,
			585, 638, 691, 745, 798, 851, 904, 957, 1010, 1064,
			1117
		};

		public static void RoundNumber(ref NumberBuffer number, int pos)
		{
			Span<byte> digits = number.Digits;
			int i;
			for (i = 0; i < pos && digits[i] != 0; i++)
			{
			}
			if (i == pos && digits[i] >= 53)
			{
				while (i > 0 && digits[i - 1] == 57)
				{
					i--;
				}
				if (i > 0)
				{
					digits[i - 1]++;
				}
				else
				{
					number.Scale++;
					digits[0] = 49;
					i = 1;
				}
			}
			else
			{
				while (i > 0 && digits[i - 1] == 48)
				{
					i--;
				}
			}
			if (i == 0)
			{
				number.Scale = 0;
				number.IsNegative = false;
			}
			digits[i] = 0;
		}

		internal static bool NumberBufferToDouble(ref NumberBuffer number, out double value)
		{
			double num = NumberToDouble(ref number);
			uint num2 = DoubleHelper.Exponent(num);
			ulong num3 = DoubleHelper.Mantissa(num);
			switch (num2)
			{
			case 2047u:
				value = 0.0;
				return false;
			case 0u:
				if (num3 == 0L)
				{
					num = 0.0;
				}
				break;
			}
			value = num;
			return true;
		}

		public unsafe static bool NumberBufferToDecimal(ref NumberBuffer number, ref decimal value)
		{
			MutableDecimal source = default(MutableDecimal);
			byte* ptr = number.UnsafeDigits;
			int num = number.Scale;
			if (*ptr == 0)
			{
				if (num > 0)
				{
					num = 0;
				}
			}
			else
			{
				if (num > 29)
				{
					return false;
				}
				while ((num > 0 || (*ptr != 0 && num > -28)) && (source.High < 429496729 || (source.High == 429496729 && (source.Mid < 2576980377u || (source.Mid == 2576980377u && (source.Low < 2576980377u || (source.Low == 2576980377u && *ptr <= 53)))))))
				{
					DecimalDecCalc.DecMul10(ref source);
					if (*ptr != 0)
					{
						DecimalDecCalc.DecAddInt32(ref source, (uint)(*(ptr++) - 48));
					}
					num--;
				}
				if (*(ptr++) >= 53)
				{
					bool flag = true;
					if (*(ptr - 1) == 53 && *(ptr - 2) % 2 == 0)
					{
						int num2 = 20;
						while (*ptr == 48 && num2 != 0)
						{
							ptr++;
							num2--;
						}
						if (*ptr == 0 || num2 == 0)
						{
							flag = false;
						}
					}
					if (flag)
					{
						DecimalDecCalc.DecAddInt32(ref source, 1u);
						if ((source.High | source.Mid | source.Low) == 0)
						{
							source.High = 429496729u;
							source.Mid = 2576980377u;
							source.Low = 2576980378u;
							num++;
						}
					}
				}
			}
			if (num > 0)
			{
				return false;
			}
			if (num <= -29)
			{
				source.High = 0u;
				source.Low = 0u;
				source.Mid = 0u;
				source.Scale = 28;
			}
			else
			{
				source.Scale = -num;
			}
			source.IsNegative = number.IsNegative;
			value = Unsafe.As<MutableDecimal, decimal>(ref source);
			return true;
		}

		public static void DecimalToNumber(decimal value, ref NumberBuffer number)
		{
			ref MutableDecimal reference = ref Unsafe.As<decimal, MutableDecimal>(ref value);
			Span<byte> digits = number.Digits;
			number.IsNegative = reference.IsNegative;
			int num = 29;
			while ((reference.Mid != 0) | (reference.High != 0))
			{
				uint num2 = DecimalDecCalc.DecDivMod1E9(ref reference);
				for (int i = 0; i < 9; i++)
				{
					digits[--num] = (byte)(num2 % 10 + 48);
					num2 /= 10;
				}
			}
			for (uint num3 = reference.Low; num3 != 0; num3 /= 10)
			{
				digits[--num] = (byte)(num3 % 10 + 48);
			}
			int num4 = 29 - num;
			number.Scale = num4 - reference.Scale;
			Span<byte> digits2 = number.Digits;
			int index = 0;
			while (--num4 >= 0)
			{
				digits2[index++] = digits[num++];
			}
			digits2[index] = 0;
		}

		private static uint DigitsToInt(ReadOnlySpan<byte> digits, int count)
		{
			uint value;
			int bytesConsumed;
			bool flag = Utf8Parser.TryParse(digits.Slice(0, count), out value, out bytesConsumed, 'D');
			return value;
		}

		private static ulong Mul32x32To64(uint a, uint b)
		{
			return (ulong)a * (ulong)b;
		}

		private static ulong Mul64Lossy(ulong a, ulong b, ref int pexp)
		{
			ulong num = Mul32x32To64((uint)(a >> 32), (uint)(b >> 32)) + (Mul32x32To64((uint)(a >> 32), (uint)b) >> 32) + (Mul32x32To64((uint)a, (uint)(b >> 32)) >> 32);
			if ((num & 0x8000000000000000uL) == 0L)
			{
				num <<= 1;
				pexp--;
			}
			return num;
		}

		private static int abs(int value)
		{
			if (value < 0)
			{
				return -value;
			}
			return value;
		}

		private unsafe static double NumberToDouble(ref NumberBuffer number)
		{
			ReadOnlySpan<byte> digits = number.Digits;
			int i = 0;
			int numDigits = number.NumDigits;
			int num = numDigits;
			for (; digits[i] == 48; i++)
			{
				num--;
			}
			if (num == 0)
			{
				return 0.0;
			}
			int num2 = Math.Min(num, 9);
			num -= num2;
			ulong num3 = DigitsToInt(digits, num2);
			if (num > 0)
			{
				num2 = Math.Min(num, 9);
				num -= num2;
				uint b = (uint)(s_rgval64Power10[num2 - 1] >> 64 - s_rgexp64Power10[num2 - 1]);
				num3 = Mul32x32To64((uint)num3, b) + DigitsToInt(digits.Slice(9), num2);
			}
			int num4 = number.Scale - (numDigits - num);
			int num5 = abs(num4);
			if (num5 >= 352)
			{
				ulong num6 = ((num4 > 0) ? 9218868437227405312uL : 0);
				if (number.IsNegative)
				{
					num6 |= 0x8000000000000000uL;
				}
				return *(double*)(&num6);
			}
			int pexp = 64;
			if ((num3 & 0xFFFFFFFF00000000uL) == 0L)
			{
				num3 <<= 32;
				pexp -= 32;
			}
			if ((num3 & 0xFFFF000000000000uL) == 0L)
			{
				num3 <<= 16;
				pexp -= 16;
			}
			if ((num3 & 0xFF00000000000000uL) == 0L)
			{
				num3 <<= 8;
				pexp -= 8;
			}
			if ((num3 & 0xF000000000000000uL) == 0L)
			{
				num3 <<= 4;
				pexp -= 4;
			}
			if ((num3 & 0xC000000000000000uL) == 0L)
			{
				num3 <<= 2;
				pexp -= 2;
			}
			if ((num3 & 0x8000000000000000uL) == 0L)
			{
				num3 <<= 1;
				pexp--;
			}
			int num7 = num5 & 0xF;
			if (num7 != 0)
			{
				int num8 = s_rgexp64Power10[num7 - 1];
				pexp += ((num4 < 0) ? (-num8 + 1) : num8);
				ulong b2 = s_rgval64Power10[num7 + ((num4 < 0) ? 15 : 0) - 1];
				num3 = Mul64Lossy(num3, b2, ref pexp);
			}
			num7 = num5 >> 4;
			if (num7 != 0)
			{
				int num9 = s_rgexp64Power10By16[num7 - 1];
				pexp += ((num4 < 0) ? (-num9 + 1) : num9);
				ulong b3 = s_rgval64Power10By16[num7 + ((num4 < 0) ? 21 : 0) - 1];
				num3 = Mul64Lossy(num3, b3, ref pexp);
			}
			if (((uint)(int)num3 & 0x400u) != 0)
			{
				ulong num10 = num3 + 1023 + (ulong)(((int)num3 >> 11) & 1);
				if (num10 < num3)
				{
					num10 = (num10 >> 1) | 0x8000000000000000uL;
					pexp++;
				}
				num3 = num10;
			}
			pexp += 1022;
			num3 = ((pexp <= 0) ? ((pexp == -52 && num3 >= 9223372036854775896uL) ? 1 : ((pexp > -52) ? (num3 >> -pexp + 11 + 1) : 0)) : ((pexp < 2047) ? ((ulong)((long)pexp << 52) + ((num3 >> 11) & 0xFFFFFFFFFFFFFL)) : 9218868437227405312uL));
			if (number.IsNegative)
			{
				num3 |= 0x8000000000000000uL;
			}
			return *(double*)(&num3);
		}
	}
	internal ref struct NumberBuffer
	{
		public int Scale;

		public bool IsNegative;

		public const int BufferSize = 51;

		private byte _b0;

		private byte _b1;

		private byte _b2;

		private byte _b3;

		private byte _b4;

		private byte _b5;

		private byte _b6;

		private byte _b7;

		private byte _b8;

		private byte _b9;

		private byte _b10;

		private byte _b11;

		private byte _b12;

		private byte _b13;

		private byte _b14;

		private byte _b15;

		private byte _b16;

		private byte _b17;

		private byte _b18;

		private byte _b19;

		private byte _b20;

		private byte _b21;

		private byte _b22;

		private byte _b23;

		private byte _b24;

		private byte _b25;

		private byte _b26;

		private byte _b27;

		private byte _b28;

		private byte _b29;

		private byte _b30;

		private byte _b31;

		private byte _b32;

		private byte _b33;

		private byte _b34;

		private byte _b35;

		private byte _b36;

		private byte _b37;

		private byte _b38;

		private byte _b39;

		private byte _b40;

		private byte _b41;

		private byte _b42;

		private byte _b43;

		private byte _b44;

		private byte _b45;

		private byte _b46;

		private byte _b47;

		private byte _b48;

		private byte _b49;

		private byte _b50;

		public unsafe Span<byte> Digits => new Span<byte>(Unsafe.AsPointer(ref _b0), 51);

		public unsafe byte* UnsafeDigits => (byte*)Unsafe.AsPointer(ref _b0);

		public int NumDigits => Digits.IndexOf<byte>(0);

		[Conditional("DEBUG")]
		public void CheckConsistency()
		{
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append('[');
			stringBuilder.Append('"');
			Span<byte> digits = Digits;
			for (int i = 0; i < 51; i++)
			{
				byte b = digits[i];
				if (b == 0)
				{
					break;
				}
				stringBuilder.Append((char)b);
			}
			stringBuilder.Append('"');
			stringBuilder.Append(", Scale = " + Scale);
			stringBuilder.Append(", IsNegative   = " + IsNegative);
			stringBuilder.Append(']');
			return stringBuilder.ToString();
		}
	}
	[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>(Unsafe.As<Pinnable<T>>(text), MemoryExtensions.StringAdjustment, 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);
				void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
				return new MemoryHandle(pointer, handle);
			}
			if (_object is T[] array)
			{
				if (_length < 0)
				{
					void* pointer2 = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index);
					return new MemoryHandle(pointer2);
				}
				GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned);
				void* pointer3 = Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index);
				return new MemoryHandle(pointer3, 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;
			}
			int hashCode = _object.GetHashCode();
			int index = _index;
			int hashCode2 = index.GetHashCode();
			index = _length;
			return CombineHashCodes(hashCode, hashCode2, index.GetHashCode());
		}

		private static int CombineHashCodes(int left, int right)
		{
			return ((left << 5) + left) ^ right;
		}

		private static int CombineHashCodes(int h1, int h2, int h3)
		{
			return CombineHashCodes(CombineHashCodes(h1, h2), h3);
		}
	}
	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
	{
		internal static readonly IntPtr StringAdjustment = MeasureStringAdjustment();

		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)
		{
			ref T reference = ref MemoryMarshal.GetReference(span);
			int num = 0;
			int num2 = span.Length - 1;
			while (num < num2)
			{
				T val = Unsafe.Add(ref reference, num);
				Unsafe.Add(ref reference, num) = Unsafe.Add(ref reference, num2);
				Unsafe.Add(ref reference, num2) = val;
				num++;
				num2--;
			}
		}

		[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;
			}
			IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
			if (Unsafe.SizeOf<IntPtr>() == 4)
			{
				if ((uint)(int)intPtr >= (uint)(span.Length * Unsafe.SizeOf<T>()))
				{
					return (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>()));
				}
				return true;
			}
			if ((ulong)(long)intPtr >= (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()))
			{
				return (ulong)(long)intPtr > (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;
			}
			IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
			if (Unsafe.SizeOf<IntPtr>() == 4)
			{
				if ((uint)(int)intPtr < (uint)(span.Length * Unsafe.SizeOf<T>()) || (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>())))
				{
					if ((int)intPtr % Unsafe.SizeOf<T>() != 0)
					{
						System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch();
					}
					elementOffset = (int)intPtr / Unsafe.SizeOf<T>();
					return true;
				}
				elementOffset = 0;
				return false;
			}
			if ((ulong)(long)intPtr < (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()) || (ulong)(long)intPtr > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>())))
			{
				if ((long)intPtr % Unsafe.SizeOf<T>() != 0L)
				{
					System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch();
				}
				elementOffset = (int)((long)intPtr / 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 = (NUInt)1;
				return true;
			}
			if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort))
			{
				size = (NUInt)2;
				return true;
			}
			if (typeof(T) == typeof(int) || typeof(T) == typeof(uint))
			{
				size = (NUInt)4;
				return true;
			}
			if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong))
			{
				size = (NUInt)8;
				return true;
			}
			size = default(NUInt);
			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)
		{
			if (culture == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.culture);
			}
			if (destination.Length < source.Length)
			{
				return -1;
			}
			string text = source.ToString();
			string text2 = text.ToLower(culture);
			AsSpan(text2).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)
		{
			if (culture == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.culture);
			}
			if (destination.Length < source.Length)
			{
				return -1;
			}
			string text = source.ToString();
			string text2 = text.ToUpper(culture);
			AsSpan(text2).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>(Unsafe.As<Pinnable<char>>(text), StringAdjustment, 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>(Unsafe.As<Pinnable<char>>(text), StringAdjustment + 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>(Unsafe.As<Pinnable<char>>(text), StringAdjustment + 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);
		}

		private unsafe static IntPtr MeasureStringAdjustment()
		{
			string text = "a";
			fixed (char* source = text)
			{
				return Unsafe.ByteOffset(ref Unsafe.As<Pinnable<char>>(text).Data, ref Unsafe.AsRef<char>(source));
			}
		}
	}
	[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>(Unsafe.As<Pinnable<T>>(text), MemoryExtensions.StringAdjustment, 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);
				void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
				return new MemoryHandle(pointer, handle);
			}
			if (_object is T[] array)
			{
				if (_length < 0)
				{
					void* pointer2 = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index);
					return new MemoryHandle(pointer2);
				}
				GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned);
				void* pointer3 = Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index);
				return new MemoryHandle(pointer3, 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;
			}
			int hashCode = _object.GetHashCode();
			int index = _index;
			int hashCode2 = index.GetHashCode();
			index = _length;
			return CombineHashCodes(hashCode, hashCode2, index.GetHashCode());
		}

		private static int CombineHashCodes(int left, int right)
		{
			return ((left << 5) + left) ^ right;
		}

		private static int CombineHashCodes(int h1, int h2, int h3)
		{
			return CombineHashCodes(CombineHashCodes(h1, h2), h3);
		}

		[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}")]
	[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 Pinnable<T> _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 unsafe ref readonly T this[int index]
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if ((uint)index >= (uint)_length)
				{
					System.ThrowHelper.ThrowIndexOutOfRangeException();
				}
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					return ref Unsafe.Add(ref Unsafe.AsRef<T>(byteOffset.ToPointer()), index);
				}
				return ref Unsafe.Add(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset), index);
			}
		}

		internal Pinnable<T> 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(System.SR.NotSupported_CannotCallEqualsOnSpan);
		}

		[Obsolete("GetHashCode() on ReadOnlySpan will always throw an exception.")]
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override int GetHashCode()
		{
			throw new NotSupportedException(System.SR.NotSupported_CannotCallGetHashCodeOnSpan);
		}

		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, 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 = Unsafe.As<Pinnable<T>>(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 = Unsafe.As<Pinnable<T>>(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(Pinnable<T> pinnable, IntPtr byteOffset, int length)
		{
			_length = length;
			_pinnable = pinnable;
			_byteOffset = byteOffset;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public unsafe ref readonly T GetPinnableReference()
		{
			if (_length != 0)
			{
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					return ref Unsafe.AsRef<T>(byteOffset.ToPointer());
				}
				return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset);
			}
			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 == MemoryExtensions.StringAdjustment)
				{
					object obj = Unsafe.As<object>(_pinnable);
					if (obj 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)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		internal unsafe ref T DangerousGetPinnableReference()
		{
			if (_pinnable == null)
			{
				IntPtr byteOffset = _byteOffset;
				return ref Unsafe.AsRef<T>(byteOffset.ToPointer());
			}
			return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset);
		}
	}
	[DebuggerTypeProxy(typeof(System.SpanDebugView<>))]
	[DebuggerDisplay("{ToString(),raw}")]
	[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 Pinnable<T> _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 unsafe ref T this[int index]
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if ((uint)index >= (uint)_length)
				{
					System.ThrowHelper.ThrowIndexOutOfRangeException();
				}
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					return ref Unsafe.Add(ref Unsafe.AsRef<T>(byteOffset.ToPointer()), index);
				}
				return ref Unsafe.Add(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset), index);
			}
		}

		internal Pinnable<T> 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(System.SR.NotSupported_CannotCallEqualsOnSpan);
		}

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

		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 = Unsafe.As<Pinnable<T>>(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>(Unsafe.As<Pinnable<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 = Unsafe.As<Pinnable<T>>(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(Pinnable<T> pinnable, IntPtr byteOffset, int length)
		{
			_length = length;
			_pinnable = pinnable;
			_byteOffset = byteOffset;
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public unsafe ref T GetPinnableReference()
		{
			if (_length != 0)
			{
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					return ref Unsafe.AsRef<T>(byteOffset.ToPointer());
				}
				return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset);
			}
			return ref Unsafe.AsRef<T>(null);
		}

		public unsafe void Clear()
		{
			int length = _length;
			if (length == 0)
			{
				return;
			}
			UIntPtr 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 Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset)), byteLength);
				}
			}
			else if (System.SpanHelpers.IsReferenceOrContainsReferences<T>())
			{
				UIntPtr 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 unsafe void Fill(T value)
		{
			int length = _length;
			if (length == 0)
			{
				return;
			}
			if (Unsafe.SizeOf<T>() == 1)
			{
				byte value2 = Unsafe.As<T, byte>(ref value);
				if (_pinnable == null)
				{
					IntPtr byteOffset = _byteOffset;
					Unsafe.InitBlockUnaligned(byteOffset.ToPointer(), value2, (uint)length);
				}
				else
				{
					Unsafe.InitBlockUnaligned(ref Unsafe.As<T, byte>(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset)), 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)]
		[EditorBrowsable(EditorBrowsableState.Never)]
		internal unsafe ref T DangerousGetPinnableReference()
		{
			if (_pinnable == null)
			{
				IntPtr byteOffset = _byteOffset;
				return ref Unsafe.AsRef<T>(byteOffset.ToPointer());
			}
			return ref Unsafe.AddByteOffset(ref _pinnable.Data, _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 = new T[0];

			public static readonly IntPtr ArrayAdjustment = MeasureArrayAdjustment();

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

		private const ulong XorPowerOfTwoToHighByte = 283686952306184uL;

		private const ulong XorPowerOfTwoToHighChar = 4295098372uL;

		[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;
				int num4 = comparable.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 unsafe static int IndexOf(ref byte searchSpace, byte value, int length)
		{
			IntPtr intPtr = (IntPtr)0;
			IntPtr intPtr2 = (IntPtr)length;
			if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
			{
				int num = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
				intPtr2 = (IntPtr)((Vector<byte>.Count - num) & (Vector<byte>.Count - 1));
			}
			while (true)
			{
				if ((nuint)(void*)intPtr2 >= (nuint)8u)
				{
					intPtr2 -= 8;
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr))
					{
						goto IL_0242;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1))
					{
						goto IL_024a;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2))
					{
						goto IL_0258;
					}
					if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 3))
					{
						if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 4))
						{
							if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 5))
							{
								if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 6))
								{
									if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 7))
									{
										break;
									}
									intPtr += 8;
									continue;
								}
								return (int)(void*)(intPtr + 6);
							}
							return (int)(void*)(intPtr + 5);
						}
						return (int)(void*)(intPtr + 4);
					}
					goto IL_0266;
				}
				if ((nuint)(void*)intPtr2 >= (nuint)4u)
				{
					intPtr2 -= 4;
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr))
					{
						goto IL_0242;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1))
					{
						goto IL_024a;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2))
					{
						goto IL_0258;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 3))
					{
						goto IL_0266;
					}
					intPtr += 4;
				}
				while ((void*)intPtr2 != null)
				{
					intPtr2 -= 1;
					if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr))
					{
						intPtr += 1;
						continue;
					}
					goto IL_0242;
				}
				if (Vector.IsHardwareAccelerated && (int)(void*)intPtr < length)
				{
					intPtr2 = (IntPtr)((length - (int)(void*)intPtr) & ~(Vector<byte>.Count - 1));
					Vector<byte> vector = GetVector(value);
					for (; (void*)intPtr2 > (void*)intPtr; intPtr += Vector<byte>.Count)
					{
						Vector<byte> vector2 = Vector.Equals(vector, Unsafe.ReadUnaligned<Vector<byte>>(ref Unsafe.AddByteOffset(ref searchSpace, intPtr)));
						if (!Vector<byte>.Zero.Equals(vector2))
						{
							return (int)(void*)intPtr + LocateFirstFoundByte(vector2);
						}
					}
					if ((int)(void*)intPtr < length)
					{
						intPtr2 = (IntPtr)(length - (int)(void*)intPtr);
						continue;
					}
				}
				return -1;
				IL_0266:
				return (int)(void*)(intPtr + 3);
				IL_0242:
				return (int)(void*)intPtr;
				IL_0258:
				return (int)(void*)(intPtr + 2);
				IL_024a:
				return (int)(void*)(intPtr + 1);
			}
			return (int)(void*)(intPtr + 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 unsafe static int LastIndexOf(ref byte searchSpace, byte value, int length)
		{
			IntPtr intPtr = (IntPtr)length;
			IntPtr intPtr2 = (IntPtr)length;
			if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
			{
				int num = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
				intPtr2 = (IntPtr)(((length & (Vector<byte>.Count - 1)) + num) & (Vector<byte>.Count - 1));
			}
			while (true)
			{
				if ((nuint)(void*)intPtr2 >= (nuint)8u)
				{
					intPtr2 -= 8;
					intPtr -= 8;
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 7))
					{
						break;
					}
					if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 6))
					{
						if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 5))
						{
							if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 4))
							{
								if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 3))
								{
									if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 2))
									{
										if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 1))
										{
											if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr))
											{
												continue;
											}
											goto IL_0254;
										}
										goto IL_025c;
									}
									goto IL_026a;
								}
								goto IL_0278;
							}
							return (int)(void*)(intPtr + 4);
						}
						return (int)(void*)(intPtr + 5);
					}
					return (int)(void*)(intPtr + 6);
				}
				if ((nuint)(void*)intPtr2 >= (nuint)4u)
				{
					intPtr2 -= 4;
					intPtr -= 4;
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 3))
					{
						goto IL_0278;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2))
					{
						goto IL_026a;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1))
					{
						goto IL_025c;
					}
					if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr))
					{
						goto IL_0254;
					}
				}
				while ((void*)intPtr2 != null)
				{
					intPtr2 -= 1;
					intPtr -= 1;
					if (value != Un

System.Numerics.Vectors.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Numerics.Hashing;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using FxResources.System.Numerics.Vectors;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyTitle("System.Numerics.Vectors")]
[assembly: AssemblyDescription("System.Numerics.Vectors")]
[assembly: AssemblyDefaultAlias("System.Numerics.Vectors")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.25519.03")]
[assembly: AssemblyInformationalVersion("4.6.25519.03 built by: dlab-DDVSOWINAGE013. Commit Hash: 8321c729934c0f8be754953439b88e6e1c120c24")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.1.3.0")]
[assembly: TypeForwardedTo(typeof(Matrix3x2))]
[assembly: TypeForwardedTo(typeof(Matrix4x4))]
[assembly: TypeForwardedTo(typeof(Plane))]
[assembly: TypeForwardedTo(typeof(Quaternion))]
[assembly: TypeForwardedTo(typeof(Vector2))]
[assembly: TypeForwardedTo(typeof(Vector3))]
[assembly: TypeForwardedTo(typeof(Vector4))]
[module: UnverifiableCode]
namespace FxResources.System.Numerics.Vectors
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class MathF
	{
		public const float PI = 3.1415927f;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Abs(float x)
		{
			return Math.Abs(x);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Acos(float x)
		{
			return (float)Math.Acos(x);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Cos(float x)
		{
			return (float)Math.Cos(x);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float IEEERemainder(float x, float y)
		{
			return (float)Math.IEEERemainder(x, y);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Sin(float x)
		{
			return (float)Math.Sin(x);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Sqrt(float x)
		{
			return (float)Math.Sqrt(x);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static float Tan(float x)
		{
			return (float)Math.Tan(x);
		}
	}
	internal static class SR
	{
		private static ResourceManager s_resourceManager;

		private const string s_resourcesName = "FxResources.System.Numerics.Vectors.SR";

		private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType));

		internal static string Arg_ArgumentOutOfRangeException => GetResourceString("Arg_ArgumentOutOfRangeException", null);

		internal static string Arg_ElementsInSourceIsGreaterThanDestination => GetResourceString("Arg_ElementsInSourceIsGreaterThanDestination", null);

		internal static string Arg_NullArgumentNullRef => GetResourceString("Arg_NullArgumentNullRef", null);

		internal static string Arg_TypeNotSupported => GetResourceString("Arg_TypeNotSupported", null);

		internal static Type ResourceType => typeof(SR);

		[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
{
	internal class ConstantHelper
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static byte GetByteWithAllBitsSet()
		{
			byte result = 0;
			result = byte.MaxValue;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static sbyte GetSByteWithAllBitsSet()
		{
			sbyte result = 0;
			result = -1;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static ushort GetUInt16WithAllBitsSet()
		{
			ushort result = 0;
			result = ushort.MaxValue;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static short GetInt16WithAllBitsSet()
		{
			short result = 0;
			result = -1;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static uint GetUInt32WithAllBitsSet()
		{
			uint result = 0u;
			result = uint.MaxValue;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int GetInt32WithAllBitsSet()
		{
			int result = 0;
			result = -1;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static ulong GetUInt64WithAllBitsSet()
		{
			ulong result = 0uL;
			result = ulong.MaxValue;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static long GetInt64WithAllBitsSet()
		{
			long result = 0L;
			result = -1L;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe static float GetSingleWithAllBitsSet()
		{
			float result = 0f;
			*(int*)(&result) = -1;
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe static double GetDoubleWithAllBitsSet()
		{
			double result = 0.0;
			*(long*)(&result) = -1L;
			return result;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property)]
	internal class JitIntrinsicAttribute : Attribute
	{
	}
	[StructLayout(LayoutKind.Explicit)]
	internal struct Register
	{
		[FieldOffset(0)]
		internal byte byte_0;

		[FieldOffset(1)]
		internal byte byte_1;

		[FieldOffset(2)]
		internal byte byte_2;

		[FieldOffset(3)]
		internal byte byte_3;

		[FieldOffset(4)]
		internal byte byte_4;

		[FieldOffset(5)]
		internal byte byte_5;

		[FieldOffset(6)]
		internal byte byte_6;

		[FieldOffset(7)]
		internal byte byte_7;

		[FieldOffset(8)]
		internal byte byte_8;

		[FieldOffset(9)]
		internal byte byte_9;

		[FieldOffset(10)]
		internal byte byte_10;

		[FieldOffset(11)]
		internal byte byte_11;

		[FieldOffset(12)]
		internal byte byte_12;

		[FieldOffset(13)]
		internal byte byte_13;

		[FieldOffset(14)]
		internal byte byte_14;

		[FieldOffset(15)]
		internal byte byte_15;

		[FieldOffset(0)]
		internal sbyte sbyte_0;

		[FieldOffset(1)]
		internal sbyte sbyte_1;

		[FieldOffset(2)]
		internal sbyte sbyte_2;

		[FieldOffset(3)]
		internal sbyte sbyte_3;

		[FieldOffset(4)]
		internal sbyte sbyte_4;

		[FieldOffset(5)]
		internal sbyte sbyte_5;

		[FieldOffset(6)]
		internal sbyte sbyte_6;

		[FieldOffset(7)]
		internal sbyte sbyte_7;

		[FieldOffset(8)]
		internal sbyte sbyte_8;

		[FieldOffset(9)]
		internal sbyte sbyte_9;

		[FieldOffset(10)]
		internal sbyte sbyte_10;

		[FieldOffset(11)]
		internal sbyte sbyte_11;

		[FieldOffset(12)]
		internal sbyte sbyte_12;

		[FieldOffset(13)]
		internal sbyte sbyte_13;

		[FieldOffset(14)]
		internal sbyte sbyte_14;

		[FieldOffset(15)]
		internal sbyte sbyte_15;

		[FieldOffset(0)]
		internal ushort uint16_0;

		[FieldOffset(2)]
		internal ushort uint16_1;

		[FieldOffset(4)]
		internal ushort uint16_2;

		[FieldOffset(6)]
		internal ushort uint16_3;

		[FieldOffset(8)]
		internal ushort uint16_4;

		[FieldOffset(10)]
		internal ushort uint16_5;

		[FieldOffset(12)]
		internal ushort uint16_6;

		[FieldOffset(14)]
		internal ushort uint16_7;

		[FieldOffset(0)]
		internal short int16_0;

		[FieldOffset(2)]
		internal short int16_1;

		[FieldOffset(4)]
		internal short int16_2;

		[FieldOffset(6)]
		internal short int16_3;

		[FieldOffset(8)]
		internal short int16_4;

		[FieldOffset(10)]
		internal short int16_5;

		[FieldOffset(12)]
		internal short int16_6;

		[FieldOffset(14)]
		internal short int16_7;

		[FieldOffset(0)]
		internal uint uint32_0;

		[FieldOffset(4)]
		internal uint uint32_1;

		[FieldOffset(8)]
		internal uint uint32_2;

		[FieldOffset(12)]
		internal uint uint32_3;

		[FieldOffset(0)]
		internal int int32_0;

		[FieldOffset(4)]
		internal int int32_1;

		[FieldOffset(8)]
		internal int int32_2;

		[FieldOffset(12)]
		internal int int32_3;

		[FieldOffset(0)]
		internal ulong uint64_0;

		[FieldOffset(8)]
		internal ulong uint64_1;

		[FieldOffset(0)]
		internal long int64_0;

		[FieldOffset(8)]
		internal long int64_1;

		[FieldOffset(0)]
		internal float single_0;

		[FieldOffset(4)]
		internal float single_1;

		[FieldOffset(8)]
		internal float single_2;

		[FieldOffset(12)]
		internal float single_3;

		[FieldOffset(0)]
		internal double double_0;

		[FieldOffset(8)]
		internal double double_1;
	}
	public struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct
	{
		private struct VectorSizeHelper
		{
			internal Vector<T> _placeholder;

			internal byte _byte;
		}

		private System.Numerics.Register register;

		private static readonly int s_count = InitializeCount();

		private static readonly Vector<T> zero = new Vector<T>(GetZeroValue());

		private static readonly Vector<T> one = new Vector<T>(GetOneValue());

		private static readonly Vector<T> allOnes = new Vector<T>(GetAllBitsSetValue());

		[JitIntrinsic]
		public static int Count => s_count;

		[JitIntrinsic]
		public static Vector<T> Zero => zero;

		[JitIntrinsic]
		public static Vector<T> One => one;

		internal static Vector<T> AllOnes => allOnes;

		[JitIntrinsic]
		public unsafe T this[int index]
		{
			get
			{
				if (index >= Count || index < 0)
				{
					throw new IndexOutOfRangeException(System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, index));
				}
				if (typeof(T) == typeof(byte))
				{
					fixed (byte* ptr = &register.byte_0)
					{
						return (T)(object)ptr[index];
					}
				}
				if (typeof(T) == typeof(sbyte))
				{
					fixed (sbyte* ptr2 = &register.sbyte_0)
					{
						return (T)(object)ptr2[index];
					}
				}
				if (typeof(T) == typeof(ushort))
				{
					fixed (ushort* ptr3 = &register.uint16_0)
					{
						return (T)(object)ptr3[index];
					}
				}
				if (typeof(T) == typeof(short))
				{
					fixed (short* ptr4 = &register.int16_0)
					{
						return (T)(object)ptr4[index];
					}
				}
				if (typeof(T) == typeof(uint))
				{
					fixed (uint* ptr5 = &register.uint32_0)
					{
						return (T)(object)ptr5[index];
					}
				}
				if (typeof(T) == typeof(int))
				{
					fixed (int* ptr6 = &register.int32_0)
					{
						return (T)(object)ptr6[index];
					}
				}
				if (typeof(T) == typeof(ulong))
				{
					fixed (ulong* ptr7 = &register.uint64_0)
					{
						return (T)(object)ptr7[index];
					}
				}
				if (typeof(T) == typeof(long))
				{
					fixed (long* ptr8 = &register.int64_0)
					{
						return (T)(object)ptr8[index];
					}
				}
				if (typeof(T) == typeof(float))
				{
					fixed (float* ptr9 = &register.single_0)
					{
						return (T)(object)ptr9[index];
					}
				}
				if (typeof(T) == typeof(double))
				{
					fixed (double* ptr10 = &register.double_0)
					{
						return (T)(object)ptr10[index];
					}
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
		}

		private unsafe static int InitializeCount()
		{
			VectorSizeHelper vectorSizeHelper = default(VectorSizeHelper);
			byte* ptr = &vectorSizeHelper._placeholder.register.byte_0;
			byte* ptr2 = &vectorSizeHelper._byte;
			int num = (int)(ptr2 - ptr);
			int num2 = -1;
			if (typeof(T) == typeof(byte))
			{
				num2 = 1;
			}
			else if (typeof(T) == typeof(sbyte))
			{
				num2 = 1;
			}
			else if (typeof(T) == typeof(ushort))
			{
				num2 = 2;
			}
			else if (typeof(T) == typeof(short))
			{
				num2 = 2;
			}
			else if (typeof(T) == typeof(uint))
			{
				num2 = 4;
			}
			else if (typeof(T) == typeof(int))
			{
				num2 = 4;
			}
			else if (typeof(T) == typeof(ulong))
			{
				num2 = 8;
			}
			else if (typeof(T) == typeof(long))
			{
				num2 = 8;
			}
			else if (typeof(T) == typeof(float))
			{
				num2 = 4;
			}
			else
			{
				if (!(typeof(T) == typeof(double)))
				{
					throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
				}
				num2 = 8;
			}
			return num / num2;
		}

		[JitIntrinsic]
		public unsafe Vector(T value)
		{
			this = default(Vector<T>);
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					fixed (byte* ptr = &register.byte_0)
					{
						for (int i = 0; i < Count; i++)
						{
							ptr[i] = (byte)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(sbyte))
				{
					fixed (sbyte* ptr2 = &register.sbyte_0)
					{
						for (int j = 0; j < Count; j++)
						{
							ptr2[j] = (sbyte)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(ushort))
				{
					fixed (ushort* ptr3 = &register.uint16_0)
					{
						for (int k = 0; k < Count; k++)
						{
							ptr3[k] = (ushort)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(short))
				{
					fixed (short* ptr4 = &register.int16_0)
					{
						for (int l = 0; l < Count; l++)
						{
							ptr4[l] = (short)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(uint))
				{
					fixed (uint* ptr5 = &register.uint32_0)
					{
						for (int m = 0; m < Count; m++)
						{
							ptr5[m] = (uint)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(int))
				{
					fixed (int* ptr6 = &register.int32_0)
					{
						for (int n = 0; n < Count; n++)
						{
							ptr6[n] = (int)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(ulong))
				{
					fixed (ulong* ptr7 = &register.uint64_0)
					{
						for (int num = 0; num < Count; num++)
						{
							ptr7[num] = (ulong)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(long))
				{
					fixed (long* ptr8 = &register.int64_0)
					{
						for (int num2 = 0; num2 < Count; num2++)
						{
							ptr8[num2] = (long)(object)value;
						}
					}
				}
				else if (typeof(T) == typeof(float))
				{
					fixed (float* ptr9 = &register.single_0)
					{
						for (int num3 = 0; num3 < Count; num3++)
						{
							ptr9[num3] = (float)(object)value;
						}
					}
				}
				else
				{
					if (!(typeof(T) == typeof(double)))
					{
						return;
					}
					fixed (double* ptr10 = &register.double_0)
					{
						for (int num4 = 0; num4 < Count; num4++)
						{
							ptr10[num4] = (double)(object)value;
						}
					}
				}
			}
			else if (typeof(T) == typeof(byte))
			{
				register.byte_0 = (byte)(object)value;
				register.byte_1 = (byte)(object)value;
				register.byte_2 = (byte)(object)value;
				register.byte_3 = (byte)(object)value;
				register.byte_4 = (byte)(object)value;
				register.byte_5 = (byte)(object)value;
				register.byte_6 = (byte)(object)value;
				register.byte_7 = (byte)(object)value;
				register.byte_8 = (byte)(object)value;
				register.byte_9 = (byte)(object)value;
				register.byte_10 = (byte)(object)value;
				register.byte_11 = (byte)(object)value;
				register.byte_12 = (byte)(object)value;
				register.byte_13 = (byte)(object)value;
				register.byte_14 = (byte)(object)value;
				register.byte_15 = (byte)(object)value;
			}
			else if (typeof(T) == typeof(sbyte))
			{
				register.sbyte_0 = (sbyte)(object)value;
				register.sbyte_1 = (sbyte)(object)value;
				register.sbyte_2 = (sbyte)(object)value;
				register.sbyte_3 = (sbyte)(object)value;
				register.sbyte_4 = (sbyte)(object)value;
				register.sbyte_5 = (sbyte)(object)value;
				register.sbyte_6 = (sbyte)(object)value;
				register.sbyte_7 = (sbyte)(object)value;
				register.sbyte_8 = (sbyte)(object)value;
				register.sbyte_9 = (sbyte)(object)value;
				register.sbyte_10 = (sbyte)(object)value;
				register.sbyte_11 = (sbyte)(object)value;
				register.sbyte_12 = (sbyte)(object)value;
				register.sbyte_13 = (sbyte)(object)value;
				register.sbyte_14 = (sbyte)(object)value;
				register.sbyte_15 = (sbyte)(object)value;
			}
			else if (typeof(T) == typeof(ushort))
			{
				register.uint16_0 = (ushort)(object)value;
				register.uint16_1 = (ushort)(object)value;
				register.uint16_2 = (ushort)(object)value;
				register.uint16_3 = (ushort)(object)value;
				register.uint16_4 = (ushort)(object)value;
				register.uint16_5 = (ushort)(object)value;
				register.uint16_6 = (ushort)(object)value;
				register.uint16_7 = (ushort)(object)value;
			}
			else if (typeof(T) == typeof(short))
			{
				register.int16_0 = (short)(object)value;
				register.int16_1 = (short)(object)value;
				register.int16_2 = (short)(object)value;
				register.int16_3 = (short)(object)value;
				register.int16_4 = (short)(object)value;
				register.int16_5 = (short)(object)value;
				register.int16_6 = (short)(object)value;
				register.int16_7 = (short)(object)value;
			}
			else if (typeof(T) == typeof(uint))
			{
				register.uint32_0 = (uint)(object)value;
				register.uint32_1 = (uint)(object)value;
				register.uint32_2 = (uint)(object)value;
				register.uint32_3 = (uint)(object)value;
			}
			else if (typeof(T) == typeof(int))
			{
				register.int32_0 = (int)(object)value;
				register.int32_1 = (int)(object)value;
				register.int32_2 = (int)(object)value;
				register.int32_3 = (int)(object)value;
			}
			else if (typeof(T) == typeof(ulong))
			{
				register.uint64_0 = (ulong)(object)value;
				register.uint64_1 = (ulong)(object)value;
			}
			else if (typeof(T) == typeof(long))
			{
				register.int64_0 = (long)(object)value;
				register.int64_1 = (long)(object)value;
			}
			else if (typeof(T) == typeof(float))
			{
				register.single_0 = (float)(object)value;
				register.single_1 = (float)(object)value;
				register.single_2 = (float)(object)value;
				register.single_3 = (float)(object)value;
			}
			else if (typeof(T) == typeof(double))
			{
				register.double_0 = (double)(object)value;
				register.double_1 = (double)(object)value;
			}
		}

		[JitIntrinsic]
		public Vector(T[] values)
			: this(values, 0)
		{
		}

		public unsafe Vector(T[] values, int index)
		{
			this = default(Vector<T>);
			if (values == null)
			{
				throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef);
			}
			if (index < 0 || values.Length - index < Count)
			{
				throw new IndexOutOfRangeException();
			}
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					fixed (byte* ptr = &register.byte_0)
					{
						for (int i = 0; i < Count; i++)
						{
							ptr[i] = (byte)(object)values[i + index];
						}
					}
				}
				else if (typeof(T) == typeof(sbyte))
				{
					fixed (sbyte* ptr2 = &register.sbyte_0)
					{
						for (int j = 0; j < Count; j++)
						{
							ptr2[j] = (sbyte)(object)values[j + index];
						}
					}
				}
				else if (typeof(T) == typeof(ushort))
				{
					fixed (ushort* ptr3 = &register.uint16_0)
					{
						for (int k = 0; k < Count; k++)
						{
							ptr3[k] = (ushort)(object)values[k + index];
						}
					}
				}
				else if (typeof(T) == typeof(short))
				{
					fixed (short* ptr4 = &register.int16_0)
					{
						for (int l = 0; l < Count; l++)
						{
							ptr4[l] = (short)(object)values[l + index];
						}
					}
				}
				else if (typeof(T) == typeof(uint))
				{
					fixed (uint* ptr5 = &register.uint32_0)
					{
						for (int m = 0; m < Count; m++)
						{
							ptr5[m] = (uint)(object)values[m + index];
						}
					}
				}
				else if (typeof(T) == typeof(int))
				{
					fixed (int* ptr6 = &register.int32_0)
					{
						for (int n = 0; n < Count; n++)
						{
							ptr6[n] = (int)(object)values[n + index];
						}
					}
				}
				else if (typeof(T) == typeof(ulong))
				{
					fixed (ulong* ptr7 = &register.uint64_0)
					{
						for (int num = 0; num < Count; num++)
						{
							ptr7[num] = (ulong)(object)values[num + index];
						}
					}
				}
				else if (typeof(T) == typeof(long))
				{
					fixed (long* ptr8 = &register.int64_0)
					{
						for (int num2 = 0; num2 < Count; num2++)
						{
							ptr8[num2] = (long)(object)values[num2 + index];
						}
					}
				}
				else if (typeof(T) == typeof(float))
				{
					fixed (float* ptr9 = &register.single_0)
					{
						for (int num3 = 0; num3 < Count; num3++)
						{
							ptr9[num3] = (float)(object)values[num3 + index];
						}
					}
				}
				else
				{
					if (!(typeof(T) == typeof(double)))
					{
						return;
					}
					fixed (double* ptr10 = &register.double_0)
					{
						for (int num4 = 0; num4 < Count; num4++)
						{
							ptr10[num4] = (double)(object)values[num4 + index];
						}
					}
				}
			}
			else if (typeof(T) == typeof(byte))
			{
				fixed (byte* ptr11 = &register.byte_0)
				{
					*ptr11 = (byte)(object)values[index];
					ptr11[1] = (byte)(object)values[1 + index];
					ptr11[2] = (byte)(object)values[2 + index];
					ptr11[3] = (byte)(object)values[3 + index];
					ptr11[4] = (byte)(object)values[4 + index];
					ptr11[5] = (byte)(object)values[5 + index];
					ptr11[6] = (byte)(object)values[6 + index];
					ptr11[7] = (byte)(object)values[7 + index];
					ptr11[8] = (byte)(object)values[8 + index];
					ptr11[9] = (byte)(object)values[9 + index];
					ptr11[10] = (byte)(object)values[10 + index];
					ptr11[11] = (byte)(object)values[11 + index];
					ptr11[12] = (byte)(object)values[12 + index];
					ptr11[13] = (byte)(object)values[13 + index];
					ptr11[14] = (byte)(object)values[14 + index];
					ptr11[15] = (byte)(object)values[15 + index];
				}
			}
			else if (typeof(T) == typeof(sbyte))
			{
				fixed (sbyte* ptr12 = &register.sbyte_0)
				{
					*ptr12 = (sbyte)(object)values[index];
					ptr12[1] = (sbyte)(object)values[1 + index];
					ptr12[2] = (sbyte)(object)values[2 + index];
					ptr12[3] = (sbyte)(object)values[3 + index];
					ptr12[4] = (sbyte)(object)values[4 + index];
					ptr12[5] = (sbyte)(object)values[5 + index];
					ptr12[6] = (sbyte)(object)values[6 + index];
					ptr12[7] = (sbyte)(object)values[7 + index];
					ptr12[8] = (sbyte)(object)values[8 + index];
					ptr12[9] = (sbyte)(object)values[9 + index];
					ptr12[10] = (sbyte)(object)values[10 + index];
					ptr12[11] = (sbyte)(object)values[11 + index];
					ptr12[12] = (sbyte)(object)values[12 + index];
					ptr12[13] = (sbyte)(object)values[13 + index];
					ptr12[14] = (sbyte)(object)values[14 + index];
					ptr12[15] = (sbyte)(object)values[15 + index];
				}
			}
			else if (typeof(T) == typeof(ushort))
			{
				fixed (ushort* ptr13 = &register.uint16_0)
				{
					*ptr13 = (ushort)(object)values[index];
					ptr13[1] = (ushort)(object)values[1 + index];
					ptr13[2] = (ushort)(object)values[2 + index];
					ptr13[3] = (ushort)(object)values[3 + index];
					ptr13[4] = (ushort)(object)values[4 + index];
					ptr13[5] = (ushort)(object)values[5 + index];
					ptr13[6] = (ushort)(object)values[6 + index];
					ptr13[7] = (ushort)(object)values[7 + index];
				}
			}
			else if (typeof(T) == typeof(short))
			{
				fixed (short* ptr14 = &register.int16_0)
				{
					*ptr14 = (short)(object)values[index];
					ptr14[1] = (short)(object)values[1 + index];
					ptr14[2] = (short)(object)values[2 + index];
					ptr14[3] = (short)(object)values[3 + index];
					ptr14[4] = (short)(object)values[4 + index];
					ptr14[5] = (short)(object)values[5 + index];
					ptr14[6] = (short)(object)values[6 + index];
					ptr14[7] = (short)(object)values[7 + index];
				}
			}
			else if (typeof(T) == typeof(uint))
			{
				fixed (uint* ptr15 = &register.uint32_0)
				{
					*ptr15 = (uint)(object)values[index];
					ptr15[1] = (uint)(object)values[1 + index];
					ptr15[2] = (uint)(object)values[2 + index];
					ptr15[3] = (uint)(object)values[3 + index];
				}
			}
			else if (typeof(T) == typeof(int))
			{
				fixed (int* ptr16 = &register.int32_0)
				{
					*ptr16 = (int)(object)values[index];
					ptr16[1] = (int)(object)values[1 + index];
					ptr16[2] = (int)(object)values[2 + index];
					ptr16[3] = (int)(object)values[3 + index];
				}
			}
			else if (typeof(T) == typeof(ulong))
			{
				fixed (ulong* ptr17 = &register.uint64_0)
				{
					*ptr17 = (ulong)(object)values[index];
					ptr17[1] = (ulong)(object)values[1 + index];
				}
			}
			else if (typeof(T) == typeof(long))
			{
				fixed (long* ptr18 = &register.int64_0)
				{
					*ptr18 = (long)(object)values[index];
					ptr18[1] = (long)(object)values[1 + index];
				}
			}
			else if (typeof(T) == typeof(float))
			{
				fixed (float* ptr19 = &register.single_0)
				{
					*ptr19 = (float)(object)values[index];
					ptr19[1] = (float)(object)values[1 + index];
					ptr19[2] = (float)(object)values[2 + index];
					ptr19[3] = (float)(object)values[3 + index];
				}
			}
			else if (typeof(T) == typeof(double))
			{
				fixed (double* ptr20 = &register.double_0)
				{
					*ptr20 = (double)(object)values[index];
					ptr20[1] = (double)(object)values[1 + index];
				}
			}
		}

		internal unsafe Vector(void* dataPointer)
			: this(dataPointer, 0)
		{
		}

		internal unsafe Vector(void* dataPointer, int offset)
		{
			this = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				byte* ptr = (byte*)dataPointer;
				ptr += offset;
				fixed (byte* ptr2 = &register.byte_0)
				{
					for (int i = 0; i < Count; i++)
					{
						ptr2[i] = ptr[i];
					}
				}
				return;
			}
			if (typeof(T) == typeof(sbyte))
			{
				sbyte* ptr3 = (sbyte*)dataPointer;
				ptr3 += offset;
				fixed (sbyte* ptr4 = &register.sbyte_0)
				{
					for (int j = 0; j < Count; j++)
					{
						ptr4[j] = ptr3[j];
					}
				}
				return;
			}
			if (typeof(T) == typeof(ushort))
			{
				ushort* ptr5 = (ushort*)dataPointer;
				ptr5 += offset;
				fixed (ushort* ptr6 = &register.uint16_0)
				{
					for (int k = 0; k < Count; k++)
					{
						ptr6[k] = ptr5[k];
					}
				}
				return;
			}
			if (typeof(T) == typeof(short))
			{
				short* ptr7 = (short*)dataPointer;
				ptr7 += offset;
				fixed (short* ptr8 = &register.int16_0)
				{
					for (int l = 0; l < Count; l++)
					{
						ptr8[l] = ptr7[l];
					}
				}
				return;
			}
			if (typeof(T) == typeof(uint))
			{
				uint* ptr9 = (uint*)dataPointer;
				ptr9 += offset;
				fixed (uint* ptr10 = &register.uint32_0)
				{
					for (int m = 0; m < Count; m++)
					{
						ptr10[m] = ptr9[m];
					}
				}
				return;
			}
			if (typeof(T) == typeof(int))
			{
				int* ptr11 = (int*)dataPointer;
				ptr11 += offset;
				fixed (int* ptr12 = &register.int32_0)
				{
					for (int n = 0; n < Count; n++)
					{
						ptr12[n] = ptr11[n];
					}
				}
				return;
			}
			if (typeof(T) == typeof(ulong))
			{
				ulong* ptr13 = (ulong*)dataPointer;
				ptr13 += offset;
				fixed (ulong* ptr14 = &register.uint64_0)
				{
					for (int num = 0; num < Count; num++)
					{
						ptr14[num] = ptr13[num];
					}
				}
				return;
			}
			if (typeof(T) == typeof(long))
			{
				long* ptr15 = (long*)dataPointer;
				ptr15 += offset;
				fixed (long* ptr16 = &register.int64_0)
				{
					for (int num2 = 0; num2 < Count; num2++)
					{
						ptr16[num2] = ptr15[num2];
					}
				}
				return;
			}
			if (typeof(T) == typeof(float))
			{
				float* ptr17 = (float*)dataPointer;
				ptr17 += offset;
				fixed (float* ptr18 = &register.single_0)
				{
					for (int num3 = 0; num3 < Count; num3++)
					{
						ptr18[num3] = ptr17[num3];
					}
				}
				return;
			}
			if (typeof(T) == typeof(double))
			{
				double* ptr19 = (double*)dataPointer;
				ptr19 += offset;
				fixed (double* ptr20 = &register.double_0)
				{
					for (int num4 = 0; num4 < Count; num4++)
					{
						ptr20[num4] = ptr19[num4];
					}
				}
				return;
			}
			throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
		}

		private Vector(ref System.Numerics.Register existingRegister)
		{
			register = existingRegister;
		}

		[JitIntrinsic]
		public void CopyTo(T[] destination)
		{
			CopyTo(destination, 0);
		}

		[JitIntrinsic]
		public unsafe void CopyTo(T[] destination, int startIndex)
		{
			if (destination == null)
			{
				throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef);
			}
			if (startIndex < 0 || startIndex >= destination.Length)
			{
				throw new ArgumentOutOfRangeException("startIndex", System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, startIndex));
			}
			if (destination.Length - startIndex < Count)
			{
				throw new ArgumentException(System.SR.Format(System.SR.Arg_ElementsInSourceIsGreaterThanDestination, startIndex));
			}
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					fixed (byte* ptr = (byte[])(object)destination)
					{
						for (int i = 0; i < Count; i++)
						{
							ptr[startIndex + i] = (byte)(object)this[i];
						}
					}
				}
				else if (typeof(T) == typeof(sbyte))
				{
					fixed (sbyte* ptr2 = (sbyte[])(object)destination)
					{
						for (int j = 0; j < Count; j++)
						{
							ptr2[startIndex + j] = (sbyte)(object)this[j];
						}
					}
				}
				else if (typeof(T) == typeof(ushort))
				{
					fixed (ushort* ptr3 = (ushort[])(object)destination)
					{
						for (int k = 0; k < Count; k++)
						{
							ptr3[startIndex + k] = (ushort)(object)this[k];
						}
					}
				}
				else if (typeof(T) == typeof(short))
				{
					fixed (short* ptr4 = (short[])(object)destination)
					{
						for (int l = 0; l < Count; l++)
						{
							ptr4[startIndex + l] = (short)(object)this[l];
						}
					}
				}
				else if (typeof(T) == typeof(uint))
				{
					fixed (uint* ptr5 = (uint[])(object)destination)
					{
						for (int m = 0; m < Count; m++)
						{
							ptr5[startIndex + m] = (uint)(object)this[m];
						}
					}
				}
				else if (typeof(T) == typeof(int))
				{
					fixed (int* ptr6 = (int[])(object)destination)
					{
						for (int n = 0; n < Count; n++)
						{
							ptr6[startIndex + n] = (int)(object)this[n];
						}
					}
				}
				else if (typeof(T) == typeof(ulong))
				{
					fixed (ulong* ptr7 = (ulong[])(object)destination)
					{
						for (int num = 0; num < Count; num++)
						{
							ptr7[startIndex + num] = (ulong)(object)this[num];
						}
					}
				}
				else if (typeof(T) == typeof(long))
				{
					fixed (long* ptr8 = (long[])(object)destination)
					{
						for (int num2 = 0; num2 < Count; num2++)
						{
							ptr8[startIndex + num2] = (long)(object)this[num2];
						}
					}
				}
				else if (typeof(T) == typeof(float))
				{
					fixed (float* ptr9 = (float[])(object)destination)
					{
						for (int num3 = 0; num3 < Count; num3++)
						{
							ptr9[startIndex + num3] = (float)(object)this[num3];
						}
					}
				}
				else
				{
					if (!(typeof(T) == typeof(double)))
					{
						return;
					}
					fixed (double* ptr10 = (double[])(object)destination)
					{
						for (int num4 = 0; num4 < Count; num4++)
						{
							ptr10[startIndex + num4] = (double)(object)this[num4];
						}
					}
				}
			}
			else if (typeof(T) == typeof(byte))
			{
				fixed (byte* ptr11 = (byte[])(object)destination)
				{
					ptr11[startIndex] = register.byte_0;
					ptr11[startIndex + 1] = register.byte_1;
					ptr11[startIndex + 2] = register.byte_2;
					ptr11[startIndex + 3] = register.byte_3;
					ptr11[startIndex + 4] = register.byte_4;
					ptr11[startIndex + 5] = register.byte_5;
					ptr11[startIndex + 6] = register.byte_6;
					ptr11[startIndex + 7] = register.byte_7;
					ptr11[startIndex + 8] = register.byte_8;
					ptr11[startIndex + 9] = register.byte_9;
					ptr11[startIndex + 10] = register.byte_10;
					ptr11[startIndex + 11] = register.byte_11;
					ptr11[startIndex + 12] = register.byte_12;
					ptr11[startIndex + 13] = register.byte_13;
					ptr11[startIndex + 14] = register.byte_14;
					ptr11[startIndex + 15] = register.byte_15;
				}
			}
			else if (typeof(T) == typeof(sbyte))
			{
				fixed (sbyte* ptr12 = (sbyte[])(object)destination)
				{
					ptr12[startIndex] = register.sbyte_0;
					ptr12[startIndex + 1] = register.sbyte_1;
					ptr12[startIndex + 2] = register.sbyte_2;
					ptr12[startIndex + 3] = register.sbyte_3;
					ptr12[startIndex + 4] = register.sbyte_4;
					ptr12[startIndex + 5] = register.sbyte_5;
					ptr12[startIndex + 6] = register.sbyte_6;
					ptr12[startIndex + 7] = register.sbyte_7;
					ptr12[startIndex + 8] = register.sbyte_8;
					ptr12[startIndex + 9] = register.sbyte_9;
					ptr12[startIndex + 10] = register.sbyte_10;
					ptr12[startIndex + 11] = register.sbyte_11;
					ptr12[startIndex + 12] = register.sbyte_12;
					ptr12[startIndex + 13] = register.sbyte_13;
					ptr12[startIndex + 14] = register.sbyte_14;
					ptr12[startIndex + 15] = register.sbyte_15;
				}
			}
			else if (typeof(T) == typeof(ushort))
			{
				fixed (ushort* ptr13 = (ushort[])(object)destination)
				{
					ptr13[startIndex] = register.uint16_0;
					ptr13[startIndex + 1] = register.uint16_1;
					ptr13[startIndex + 2] = register.uint16_2;
					ptr13[startIndex + 3] = register.uint16_3;
					ptr13[startIndex + 4] = register.uint16_4;
					ptr13[startIndex + 5] = register.uint16_5;
					ptr13[startIndex + 6] = register.uint16_6;
					ptr13[startIndex + 7] = register.uint16_7;
				}
			}
			else if (typeof(T) == typeof(short))
			{
				fixed (short* ptr14 = (short[])(object)destination)
				{
					ptr14[startIndex] = register.int16_0;
					ptr14[startIndex + 1] = register.int16_1;
					ptr14[startIndex + 2] = register.int16_2;
					ptr14[startIndex + 3] = register.int16_3;
					ptr14[startIndex + 4] = register.int16_4;
					ptr14[startIndex + 5] = register.int16_5;
					ptr14[startIndex + 6] = register.int16_6;
					ptr14[startIndex + 7] = register.int16_7;
				}
			}
			else if (typeof(T) == typeof(uint))
			{
				fixed (uint* ptr15 = (uint[])(object)destination)
				{
					ptr15[startIndex] = register.uint32_0;
					ptr15[startIndex + 1] = register.uint32_1;
					ptr15[startIndex + 2] = register.uint32_2;
					ptr15[startIndex + 3] = register.uint32_3;
				}
			}
			else if (typeof(T) == typeof(int))
			{
				fixed (int* ptr16 = (int[])(object)destination)
				{
					ptr16[startIndex] = register.int32_0;
					ptr16[startIndex + 1] = register.int32_1;
					ptr16[startIndex + 2] = register.int32_2;
					ptr16[startIndex + 3] = register.int32_3;
				}
			}
			else if (typeof(T) == typeof(ulong))
			{
				fixed (ulong* ptr17 = (ulong[])(object)destination)
				{
					ptr17[startIndex] = register.uint64_0;
					ptr17[startIndex + 1] = register.uint64_1;
				}
			}
			else if (typeof(T) == typeof(long))
			{
				fixed (long* ptr18 = (long[])(object)destination)
				{
					ptr18[startIndex] = register.int64_0;
					ptr18[startIndex + 1] = register.int64_1;
				}
			}
			else if (typeof(T) == typeof(float))
			{
				fixed (float* ptr19 = (float[])(object)destination)
				{
					ptr19[startIndex] = register.single_0;
					ptr19[startIndex + 1] = register.single_1;
					ptr19[startIndex + 2] = register.single_2;
					ptr19[startIndex + 3] = register.single_3;
				}
			}
			else if (typeof(T) == typeof(double))
			{
				fixed (double* ptr20 = (double[])(object)destination)
				{
					ptr20[startIndex] = register.double_0;
					ptr20[startIndex + 1] = register.double_1;
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public override bool Equals(object obj)
		{
			if (!(obj is Vector<T>))
			{
				return false;
			}
			return Equals((Vector<T>)obj);
		}

		[JitIntrinsic]
		public bool Equals(Vector<T> other)
		{
			if (Vector.IsHardwareAccelerated)
			{
				for (int i = 0; i < Count; i++)
				{
					if (!ScalarEquals(this[i], other[i]))
					{
						return false;
					}
				}
				return true;
			}
			if (typeof(T) == typeof(byte))
			{
				if (register.byte_0 == other.register.byte_0 && register.byte_1 == other.register.byte_1 && register.byte_2 == other.register.byte_2 && register.byte_3 == other.register.byte_3 && register.byte_4 == other.register.byte_4 && register.byte_5 == other.register.byte_5 && register.byte_6 == other.register.byte_6 && register.byte_7 == other.register.byte_7 && register.byte_8 == other.register.byte_8 && register.byte_9 == other.register.byte_9 && register.byte_10 == other.register.byte_10 && register.byte_11 == other.register.byte_11 && register.byte_12 == other.register.byte_12 && register.byte_13 == other.register.byte_13 && register.byte_14 == other.register.byte_14)
				{
					return register.byte_15 == other.register.byte_15;
				}
				return false;
			}
			if (typeof(T) == typeof(sbyte))
			{
				if (register.sbyte_0 == other.register.sbyte_0 && register.sbyte_1 == other.register.sbyte_1 && register.sbyte_2 == other.register.sbyte_2 && register.sbyte_3 == other.register.sbyte_3 && register.sbyte_4 == other.register.sbyte_4 && register.sbyte_5 == other.register.sbyte_5 && register.sbyte_6 == other.register.sbyte_6 && register.sbyte_7 == other.register.sbyte_7 && register.sbyte_8 == other.register.sbyte_8 && register.sbyte_9 == other.register.sbyte_9 && register.sbyte_10 == other.register.sbyte_10 && register.sbyte_11 == other.register.sbyte_11 && register.sbyte_12 == other.register.sbyte_12 && register.sbyte_13 == other.register.sbyte_13 && register.sbyte_14 == other.register.sbyte_14)
				{
					return register.sbyte_15 == other.register.sbyte_15;
				}
				return false;
			}
			if (typeof(T) == typeof(ushort))
			{
				if (register.uint16_0 == other.register.uint16_0 && register.uint16_1 == other.register.uint16_1 && register.uint16_2 == other.register.uint16_2 && register.uint16_3 == other.register.uint16_3 && register.uint16_4 == other.register.uint16_4 && register.uint16_5 == other.register.uint16_5 && register.uint16_6 == other.register.uint16_6)
				{
					return register.uint16_7 == other.register.uint16_7;
				}
				return false;
			}
			if (typeof(T) == typeof(short))
			{
				if (register.int16_0 == other.register.int16_0 && register.int16_1 == other.register.int16_1 && register.int16_2 == other.register.int16_2 && register.int16_3 == other.register.int16_3 && register.int16_4 == other.register.int16_4 && register.int16_5 == other.register.int16_5 && register.int16_6 == other.register.int16_6)
				{
					return register.int16_7 == other.register.int16_7;
				}
				return false;
			}
			if (typeof(T) == typeof(uint))
			{
				if (register.uint32_0 == other.register.uint32_0 && register.uint32_1 == other.register.uint32_1 && register.uint32_2 == other.register.uint32_2)
				{
					return register.uint32_3 == other.register.uint32_3;
				}
				return false;
			}
			if (typeof(T) == typeof(int))
			{
				if (register.int32_0 == other.register.int32_0 && register.int32_1 == other.register.int32_1 && register.int32_2 == other.register.int32_2)
				{
					return register.int32_3 == other.register.int32_3;
				}
				return false;
			}
			if (typeof(T) == typeof(ulong))
			{
				if (register.uint64_0 == other.register.uint64_0)
				{
					return register.uint64_1 == other.register.uint64_1;
				}
				return false;
			}
			if (typeof(T) == typeof(long))
			{
				if (register.int64_0 == other.register.int64_0)
				{
					return register.int64_1 == other.register.int64_1;
				}
				return false;
			}
			if (typeof(T) == typeof(float))
			{
				if (register.single_0 == other.register.single_0 && register.single_1 == other.register.single_1 && register.single_2 == other.register.single_2)
				{
					return register.single_3 == other.register.single_3;
				}
				return false;
			}
			if (typeof(T) == typeof(double))
			{
				if (register.double_0 == other.register.double_0)
				{
					return register.double_1 == other.register.double_1;
				}
				return false;
			}
			throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
		}

		public override int GetHashCode()
		{
			int num = 0;
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					for (int i = 0; i < Count; i++)
					{
						num = HashHelpers.Combine(num, ((byte)(object)this[i]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(sbyte))
				{
					for (int j = 0; j < Count; j++)
					{
						num = HashHelpers.Combine(num, ((sbyte)(object)this[j]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(ushort))
				{
					for (int k = 0; k < Count; k++)
					{
						num = HashHelpers.Combine(num, ((ushort)(object)this[k]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(short))
				{
					for (int l = 0; l < Count; l++)
					{
						num = HashHelpers.Combine(num, ((short)(object)this[l]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(uint))
				{
					for (int m = 0; m < Count; m++)
					{
						num = HashHelpers.Combine(num, ((uint)(object)this[m]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(int))
				{
					for (int n = 0; n < Count; n++)
					{
						num = HashHelpers.Combine(num, ((int)(object)this[n]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(ulong))
				{
					for (int num2 = 0; num2 < Count; num2++)
					{
						num = HashHelpers.Combine(num, ((ulong)(object)this[num2]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(long))
				{
					for (int num3 = 0; num3 < Count; num3++)
					{
						num = HashHelpers.Combine(num, ((long)(object)this[num3]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(float))
				{
					for (int num4 = 0; num4 < Count; num4++)
					{
						num = HashHelpers.Combine(num, ((float)(object)this[num4]).GetHashCode());
					}
					return num;
				}
				if (typeof(T) == typeof(double))
				{
					for (int num5 = 0; num5 < Count; num5++)
					{
						num = HashHelpers.Combine(num, ((double)(object)this[num5]).GetHashCode());
					}
					return num;
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
			if (typeof(T) == typeof(byte))
			{
				num = HashHelpers.Combine(num, register.byte_0.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_1.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_2.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_3.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_4.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_5.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_6.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_7.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_8.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_9.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_10.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_11.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_12.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_13.GetHashCode());
				num = HashHelpers.Combine(num, register.byte_14.GetHashCode());
				return HashHelpers.Combine(num, register.byte_15.GetHashCode());
			}
			if (typeof(T) == typeof(sbyte))
			{
				num = HashHelpers.Combine(num, register.sbyte_0.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_1.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_2.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_3.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_4.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_5.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_6.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_7.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_8.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_9.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_10.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_11.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_12.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_13.GetHashCode());
				num = HashHelpers.Combine(num, register.sbyte_14.GetHashCode());
				return HashHelpers.Combine(num, register.sbyte_15.GetHashCode());
			}
			if (typeof(T) == typeof(ushort))
			{
				num = HashHelpers.Combine(num, register.uint16_0.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_1.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_2.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_3.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_4.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_5.GetHashCode());
				num = HashHelpers.Combine(num, register.uint16_6.GetHashCode());
				return HashHelpers.Combine(num, register.uint16_7.GetHashCode());
			}
			if (typeof(T) == typeof(short))
			{
				num = HashHelpers.Combine(num, register.int16_0.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_1.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_2.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_3.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_4.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_5.GetHashCode());
				num = HashHelpers.Combine(num, register.int16_6.GetHashCode());
				return HashHelpers.Combine(num, register.int16_7.GetHashCode());
			}
			if (typeof(T) == typeof(uint))
			{
				num = HashHelpers.Combine(num, register.uint32_0.GetHashCode());
				num = HashHelpers.Combine(num, register.uint32_1.GetHashCode());
				num = HashHelpers.Combine(num, register.uint32_2.GetHashCode());
				return HashHelpers.Combine(num, register.uint32_3.GetHashCode());
			}
			if (typeof(T) == typeof(int))
			{
				num = HashHelpers.Combine(num, register.int32_0.GetHashCode());
				num = HashHelpers.Combine(num, register.int32_1.GetHashCode());
				num = HashHelpers.Combine(num, register.int32_2.GetHashCode());
				return HashHelpers.Combine(num, register.int32_3.GetHashCode());
			}
			if (typeof(T) == typeof(ulong))
			{
				num = HashHelpers.Combine(num, register.uint64_0.GetHashCode());
				return HashHelpers.Combine(num, register.uint64_1.GetHashCode());
			}
			if (typeof(T) == typeof(long))
			{
				num = HashHelpers.Combine(num, register.int64_0.GetHashCode());
				return HashHelpers.Combine(num, register.int64_1.GetHashCode());
			}
			if (typeof(T) == typeof(float))
			{
				num = HashHelpers.Combine(num, register.single_0.GetHashCode());
				num = HashHelpers.Combine(num, register.single_1.GetHashCode());
				num = HashHelpers.Combine(num, register.single_2.GetHashCode());
				return HashHelpers.Combine(num, register.single_3.GetHashCode());
			}
			if (typeof(T) == typeof(double))
			{
				num = HashHelpers.Combine(num, register.double_0.GetHashCode());
				return HashHelpers.Combine(num, register.double_1.GetHashCode());
			}
			throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
		}

		public override string ToString()
		{
			return ToString("G", CultureInfo.CurrentCulture);
		}

		public string ToString(string format)
		{
			return ToString(format, CultureInfo.CurrentCulture);
		}

		public string ToString(string format, IFormatProvider formatProvider)
		{
			StringBuilder stringBuilder = new StringBuilder();
			string numberGroupSeparator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
			stringBuilder.Append('<');
			for (int i = 0; i < Count - 1; i++)
			{
				stringBuilder.Append(((IFormattable)(object)this[i]).ToString(format, formatProvider));
				stringBuilder.Append(numberGroupSeparator);
				stringBuilder.Append(' ');
			}
			stringBuilder.Append(((IFormattable)(object)this[Count - 1]).ToString(format, formatProvider));
			stringBuilder.Append('>');
			return stringBuilder.ToString();
		}

		public unsafe static Vector<T>operator +(Vector<T> left, Vector<T> right)
		{
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int i = 0; i < Count; i++)
					{
						ptr[i] = (byte)(object)ScalarAdd(left[i], right[i]);
					}
					return new Vector<T>(ptr);
				}
				if (typeof(T) == typeof(sbyte))
				{
					sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int j = 0; j < Count; j++)
					{
						ptr2[j] = (sbyte)(object)ScalarAdd(left[j], right[j]);
					}
					return new Vector<T>(ptr2);
				}
				if (typeof(T) == typeof(ushort))
				{
					ushort* ptr3 = stackalloc ushort[Count];
					for (int k = 0; k < Count; k++)
					{
						ptr3[k] = (ushort)(object)ScalarAdd(left[k], right[k]);
					}
					return new Vector<T>(ptr3);
				}
				if (typeof(T) == typeof(short))
				{
					short* ptr4 = stackalloc short[Count];
					for (int l = 0; l < Count; l++)
					{
						ptr4[l] = (short)(object)ScalarAdd(left[l], right[l]);
					}
					return new Vector<T>(ptr4);
				}
				if (typeof(T) == typeof(uint))
				{
					uint* ptr5 = stackalloc uint[Count];
					for (int m = 0; m < Count; m++)
					{
						ptr5[m] = (uint)(object)ScalarAdd(left[m], right[m]);
					}
					return new Vector<T>(ptr5);
				}
				if (typeof(T) == typeof(int))
				{
					int* ptr6 = stackalloc int[Count];
					for (int n = 0; n < Count; n++)
					{
						ptr6[n] = (int)(object)ScalarAdd(left[n], right[n]);
					}
					return new Vector<T>(ptr6);
				}
				if (typeof(T) == typeof(ulong))
				{
					ulong* ptr7 = stackalloc ulong[Count];
					for (int num = 0; num < Count; num++)
					{
						ptr7[num] = (ulong)(object)ScalarAdd(left[num], right[num]);
					}
					return new Vector<T>(ptr7);
				}
				if (typeof(T) == typeof(long))
				{
					long* ptr8 = stackalloc long[Count];
					for (int num2 = 0; num2 < Count; num2++)
					{
						ptr8[num2] = (long)(object)ScalarAdd(left[num2], right[num2]);
					}
					return new Vector<T>(ptr8);
				}
				if (typeof(T) == typeof(float))
				{
					float* ptr9 = stackalloc float[Count];
					for (int num3 = 0; num3 < Count; num3++)
					{
						ptr9[num3] = (float)(object)ScalarAdd(left[num3], right[num3]);
					}
					return new Vector<T>(ptr9);
				}
				if (typeof(T) == typeof(double))
				{
					double* ptr10 = stackalloc double[Count];
					for (int num4 = 0; num4 < Count; num4++)
					{
						ptr10[num4] = (double)(object)ScalarAdd(left[num4], right[num4]);
					}
					return new Vector<T>(ptr10);
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(left.register.byte_0 + right.register.byte_0);
				result.register.byte_1 = (byte)(left.register.byte_1 + right.register.byte_1);
				result.register.byte_2 = (byte)(left.register.byte_2 + right.register.byte_2);
				result.register.byte_3 = (byte)(left.register.byte_3 + right.register.byte_3);
				result.register.byte_4 = (byte)(left.register.byte_4 + right.register.byte_4);
				result.register.byte_5 = (byte)(left.register.byte_5 + right.register.byte_5);
				result.register.byte_6 = (byte)(left.register.byte_6 + right.register.byte_6);
				result.register.byte_7 = (byte)(left.register.byte_7 + right.register.byte_7);
				result.register.byte_8 = (byte)(left.register.byte_8 + right.register.byte_8);
				result.register.byte_9 = (byte)(left.register.byte_9 + right.register.byte_9);
				result.register.byte_10 = (byte)(left.register.byte_10 + right.register.byte_10);
				result.register.byte_11 = (byte)(left.register.byte_11 + right.register.byte_11);
				result.register.byte_12 = (byte)(left.register.byte_12 + right.register.byte_12);
				result.register.byte_13 = (byte)(left.register.byte_13 + right.register.byte_13);
				result.register.byte_14 = (byte)(left.register.byte_14 + right.register.byte_14);
				result.register.byte_15 = (byte)(left.register.byte_15 + right.register.byte_15);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 + right.register.sbyte_0);
				result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 + right.register.sbyte_1);
				result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 + right.register.sbyte_2);
				result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 + right.register.sbyte_3);
				result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 + right.register.sbyte_4);
				result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 + right.register.sbyte_5);
				result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 + right.register.sbyte_6);
				result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 + right.register.sbyte_7);
				result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 + right.register.sbyte_8);
				result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 + right.register.sbyte_9);
				result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 + right.register.sbyte_10);
				result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 + right.register.sbyte_11);
				result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 + right.register.sbyte_12);
				result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 + right.register.sbyte_13);
				result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 + right.register.sbyte_14);
				result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 + right.register.sbyte_15);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(left.register.uint16_0 + right.register.uint16_0);
				result.register.uint16_1 = (ushort)(left.register.uint16_1 + right.register.uint16_1);
				result.register.uint16_2 = (ushort)(left.register.uint16_2 + right.register.uint16_2);
				result.register.uint16_3 = (ushort)(left.register.uint16_3 + right.register.uint16_3);
				result.register.uint16_4 = (ushort)(left.register.uint16_4 + right.register.uint16_4);
				result.register.uint16_5 = (ushort)(left.register.uint16_5 + right.register.uint16_5);
				result.register.uint16_6 = (ushort)(left.register.uint16_6 + right.register.uint16_6);
				result.register.uint16_7 = (ushort)(left.register.uint16_7 + right.register.uint16_7);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(left.register.int16_0 + right.register.int16_0);
				result.register.int16_1 = (short)(left.register.int16_1 + right.register.int16_1);
				result.register.int16_2 = (short)(left.register.int16_2 + right.register.int16_2);
				result.register.int16_3 = (short)(left.register.int16_3 + right.register.int16_3);
				result.register.int16_4 = (short)(left.register.int16_4 + right.register.int16_4);
				result.register.int16_5 = (short)(left.register.int16_5 + right.register.int16_5);
				result.register.int16_6 = (short)(left.register.int16_6 + right.register.int16_6);
				result.register.int16_7 = (short)(left.register.int16_7 + right.register.int16_7);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = left.register.uint32_0 + right.register.uint32_0;
				result.register.uint32_1 = left.register.uint32_1 + right.register.uint32_1;
				result.register.uint32_2 = left.register.uint32_2 + right.register.uint32_2;
				result.register.uint32_3 = left.register.uint32_3 + right.register.uint32_3;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = left.register.int32_0 + right.register.int32_0;
				result.register.int32_1 = left.register.int32_1 + right.register.int32_1;
				result.register.int32_2 = left.register.int32_2 + right.register.int32_2;
				result.register.int32_3 = left.register.int32_3 + right.register.int32_3;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = left.register.uint64_0 + right.register.uint64_0;
				result.register.uint64_1 = left.register.uint64_1 + right.register.uint64_1;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = left.register.int64_0 + right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 + right.register.int64_1;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = left.register.single_0 + right.register.single_0;
				result.register.single_1 = left.register.single_1 + right.register.single_1;
				result.register.single_2 = left.register.single_2 + right.register.single_2;
				result.register.single_3 = left.register.single_3 + right.register.single_3;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = left.register.double_0 + right.register.double_0;
				result.register.double_1 = left.register.double_1 + right.register.double_1;
			}
			return result;
		}

		public unsafe static Vector<T>operator -(Vector<T> left, Vector<T> right)
		{
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int i = 0; i < Count; i++)
					{
						ptr[i] = (byte)(object)ScalarSubtract(left[i], right[i]);
					}
					return new Vector<T>(ptr);
				}
				if (typeof(T) == typeof(sbyte))
				{
					sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int j = 0; j < Count; j++)
					{
						ptr2[j] = (sbyte)(object)ScalarSubtract(left[j], right[j]);
					}
					return new Vector<T>(ptr2);
				}
				if (typeof(T) == typeof(ushort))
				{
					ushort* ptr3 = stackalloc ushort[Count];
					for (int k = 0; k < Count; k++)
					{
						ptr3[k] = (ushort)(object)ScalarSubtract(left[k], right[k]);
					}
					return new Vector<T>(ptr3);
				}
				if (typeof(T) == typeof(short))
				{
					short* ptr4 = stackalloc short[Count];
					for (int l = 0; l < Count; l++)
					{
						ptr4[l] = (short)(object)ScalarSubtract(left[l], right[l]);
					}
					return new Vector<T>(ptr4);
				}
				if (typeof(T) == typeof(uint))
				{
					uint* ptr5 = stackalloc uint[Count];
					for (int m = 0; m < Count; m++)
					{
						ptr5[m] = (uint)(object)ScalarSubtract(left[m], right[m]);
					}
					return new Vector<T>(ptr5);
				}
				if (typeof(T) == typeof(int))
				{
					int* ptr6 = stackalloc int[Count];
					for (int n = 0; n < Count; n++)
					{
						ptr6[n] = (int)(object)ScalarSubtract(left[n], right[n]);
					}
					return new Vector<T>(ptr6);
				}
				if (typeof(T) == typeof(ulong))
				{
					ulong* ptr7 = stackalloc ulong[Count];
					for (int num = 0; num < Count; num++)
					{
						ptr7[num] = (ulong)(object)ScalarSubtract(left[num], right[num]);
					}
					return new Vector<T>(ptr7);
				}
				if (typeof(T) == typeof(long))
				{
					long* ptr8 = stackalloc long[Count];
					for (int num2 = 0; num2 < Count; num2++)
					{
						ptr8[num2] = (long)(object)ScalarSubtract(left[num2], right[num2]);
					}
					return new Vector<T>(ptr8);
				}
				if (typeof(T) == typeof(float))
				{
					float* ptr9 = stackalloc float[Count];
					for (int num3 = 0; num3 < Count; num3++)
					{
						ptr9[num3] = (float)(object)ScalarSubtract(left[num3], right[num3]);
					}
					return new Vector<T>(ptr9);
				}
				if (typeof(T) == typeof(double))
				{
					double* ptr10 = stackalloc double[Count];
					for (int num4 = 0; num4 < Count; num4++)
					{
						ptr10[num4] = (double)(object)ScalarSubtract(left[num4], right[num4]);
					}
					return new Vector<T>(ptr10);
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(left.register.byte_0 - right.register.byte_0);
				result.register.byte_1 = (byte)(left.register.byte_1 - right.register.byte_1);
				result.register.byte_2 = (byte)(left.register.byte_2 - right.register.byte_2);
				result.register.byte_3 = (byte)(left.register.byte_3 - right.register.byte_3);
				result.register.byte_4 = (byte)(left.register.byte_4 - right.register.byte_4);
				result.register.byte_5 = (byte)(left.register.byte_5 - right.register.byte_5);
				result.register.byte_6 = (byte)(left.register.byte_6 - right.register.byte_6);
				result.register.byte_7 = (byte)(left.register.byte_7 - right.register.byte_7);
				result.register.byte_8 = (byte)(left.register.byte_8 - right.register.byte_8);
				result.register.byte_9 = (byte)(left.register.byte_9 - right.register.byte_9);
				result.register.byte_10 = (byte)(left.register.byte_10 - right.register.byte_10);
				result.register.byte_11 = (byte)(left.register.byte_11 - right.register.byte_11);
				result.register.byte_12 = (byte)(left.register.byte_12 - right.register.byte_12);
				result.register.byte_13 = (byte)(left.register.byte_13 - right.register.byte_13);
				result.register.byte_14 = (byte)(left.register.byte_14 - right.register.byte_14);
				result.register.byte_15 = (byte)(left.register.byte_15 - right.register.byte_15);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 - right.register.sbyte_0);
				result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 - right.register.sbyte_1);
				result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 - right.register.sbyte_2);
				result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 - right.register.sbyte_3);
				result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 - right.register.sbyte_4);
				result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 - right.register.sbyte_5);
				result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 - right.register.sbyte_6);
				result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 - right.register.sbyte_7);
				result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 - right.register.sbyte_8);
				result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 - right.register.sbyte_9);
				result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 - right.register.sbyte_10);
				result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 - right.register.sbyte_11);
				result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 - right.register.sbyte_12);
				result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 - right.register.sbyte_13);
				result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 - right.register.sbyte_14);
				result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 - right.register.sbyte_15);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(left.register.uint16_0 - right.register.uint16_0);
				result.register.uint16_1 = (ushort)(left.register.uint16_1 - right.register.uint16_1);
				result.register.uint16_2 = (ushort)(left.register.uint16_2 - right.register.uint16_2);
				result.register.uint16_3 = (ushort)(left.register.uint16_3 - right.register.uint16_3);
				result.register.uint16_4 = (ushort)(left.register.uint16_4 - right.register.uint16_4);
				result.register.uint16_5 = (ushort)(left.register.uint16_5 - right.register.uint16_5);
				result.register.uint16_6 = (ushort)(left.register.uint16_6 - right.register.uint16_6);
				result.register.uint16_7 = (ushort)(left.register.uint16_7 - right.register.uint16_7);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(left.register.int16_0 - right.register.int16_0);
				result.register.int16_1 = (short)(left.register.int16_1 - right.register.int16_1);
				result.register.int16_2 = (short)(left.register.int16_2 - right.register.int16_2);
				result.register.int16_3 = (short)(left.register.int16_3 - right.register.int16_3);
				result.register.int16_4 = (short)(left.register.int16_4 - right.register.int16_4);
				result.register.int16_5 = (short)(left.register.int16_5 - right.register.int16_5);
				result.register.int16_6 = (short)(left.register.int16_6 - right.register.int16_6);
				result.register.int16_7 = (short)(left.register.int16_7 - right.register.int16_7);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = left.register.uint32_0 - right.register.uint32_0;
				result.register.uint32_1 = left.register.uint32_1 - right.register.uint32_1;
				result.register.uint32_2 = left.register.uint32_2 - right.register.uint32_2;
				result.register.uint32_3 = left.register.uint32_3 - right.register.uint32_3;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = left.register.int32_0 - right.register.int32_0;
				result.register.int32_1 = left.register.int32_1 - right.register.int32_1;
				result.register.int32_2 = left.register.int32_2 - right.register.int32_2;
				result.register.int32_3 = left.register.int32_3 - right.register.int32_3;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = left.register.uint64_0 - right.register.uint64_0;
				result.register.uint64_1 = left.register.uint64_1 - right.register.uint64_1;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = left.register.int64_0 - right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 - right.register.int64_1;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = left.register.single_0 - right.register.single_0;
				result.register.single_1 = left.register.single_1 - right.register.single_1;
				result.register.single_2 = left.register.single_2 - right.register.single_2;
				result.register.single_3 = left.register.single_3 - right.register.single_3;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = left.register.double_0 - right.register.double_0;
				result.register.double_1 = left.register.double_1 - right.register.double_1;
			}
			return result;
		}

		public unsafe static Vector<T>operator *(Vector<T> left, Vector<T> right)
		{
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int i = 0; i < Count; i++)
					{
						ptr[i] = (byte)(object)ScalarMultiply(left[i], right[i]);
					}
					return new Vector<T>(ptr);
				}
				if (typeof(T) == typeof(sbyte))
				{
					sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int j = 0; j < Count; j++)
					{
						ptr2[j] = (sbyte)(object)ScalarMultiply(left[j], right[j]);
					}
					return new Vector<T>(ptr2);
				}
				if (typeof(T) == typeof(ushort))
				{
					ushort* ptr3 = stackalloc ushort[Count];
					for (int k = 0; k < Count; k++)
					{
						ptr3[k] = (ushort)(object)ScalarMultiply(left[k], right[k]);
					}
					return new Vector<T>(ptr3);
				}
				if (typeof(T) == typeof(short))
				{
					short* ptr4 = stackalloc short[Count];
					for (int l = 0; l < Count; l++)
					{
						ptr4[l] = (short)(object)ScalarMultiply(left[l], right[l]);
					}
					return new Vector<T>(ptr4);
				}
				if (typeof(T) == typeof(uint))
				{
					uint* ptr5 = stackalloc uint[Count];
					for (int m = 0; m < Count; m++)
					{
						ptr5[m] = (uint)(object)ScalarMultiply(left[m], right[m]);
					}
					return new Vector<T>(ptr5);
				}
				if (typeof(T) == typeof(int))
				{
					int* ptr6 = stackalloc int[Count];
					for (int n = 0; n < Count; n++)
					{
						ptr6[n] = (int)(object)ScalarMultiply(left[n], right[n]);
					}
					return new Vector<T>(ptr6);
				}
				if (typeof(T) == typeof(ulong))
				{
					ulong* ptr7 = stackalloc ulong[Count];
					for (int num = 0; num < Count; num++)
					{
						ptr7[num] = (ulong)(object)ScalarMultiply(left[num], right[num]);
					}
					return new Vector<T>(ptr7);
				}
				if (typeof(T) == typeof(long))
				{
					long* ptr8 = stackalloc long[Count];
					for (int num2 = 0; num2 < Count; num2++)
					{
						ptr8[num2] = (long)(object)ScalarMultiply(left[num2], right[num2]);
					}
					return new Vector<T>(ptr8);
				}
				if (typeof(T) == typeof(float))
				{
					float* ptr9 = stackalloc float[Count];
					for (int num3 = 0; num3 < Count; num3++)
					{
						ptr9[num3] = (float)(object)ScalarMultiply(left[num3], right[num3]);
					}
					return new Vector<T>(ptr9);
				}
				if (typeof(T) == typeof(double))
				{
					double* ptr10 = stackalloc double[Count];
					for (int num4 = 0; num4 < Count; num4++)
					{
						ptr10[num4] = (double)(object)ScalarMultiply(left[num4], right[num4]);
					}
					return new Vector<T>(ptr10);
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(left.register.byte_0 * right.register.byte_0);
				result.register.byte_1 = (byte)(left.register.byte_1 * right.register.byte_1);
				result.register.byte_2 = (byte)(left.register.byte_2 * right.register.byte_2);
				result.register.byte_3 = (byte)(left.register.byte_3 * right.register.byte_3);
				result.register.byte_4 = (byte)(left.register.byte_4 * right.register.byte_4);
				result.register.byte_5 = (byte)(left.register.byte_5 * right.register.byte_5);
				result.register.byte_6 = (byte)(left.register.byte_6 * right.register.byte_6);
				result.register.byte_7 = (byte)(left.register.byte_7 * right.register.byte_7);
				result.register.byte_8 = (byte)(left.register.byte_8 * right.register.byte_8);
				result.register.byte_9 = (byte)(left.register.byte_9 * right.register.byte_9);
				result.register.byte_10 = (byte)(left.register.byte_10 * right.register.byte_10);
				result.register.byte_11 = (byte)(left.register.byte_11 * right.register.byte_11);
				result.register.byte_12 = (byte)(left.register.byte_12 * right.register.byte_12);
				result.register.byte_13 = (byte)(left.register.byte_13 * right.register.byte_13);
				result.register.byte_14 = (byte)(left.register.byte_14 * right.register.byte_14);
				result.register.byte_15 = (byte)(left.register.byte_15 * right.register.byte_15);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 * right.register.sbyte_0);
				result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 * right.register.sbyte_1);
				result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 * right.register.sbyte_2);
				result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 * right.register.sbyte_3);
				result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 * right.register.sbyte_4);
				result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 * right.register.sbyte_5);
				result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 * right.register.sbyte_6);
				result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 * right.register.sbyte_7);
				result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 * right.register.sbyte_8);
				result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 * right.register.sbyte_9);
				result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 * right.register.sbyte_10);
				result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 * right.register.sbyte_11);
				result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 * right.register.sbyte_12);
				result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 * right.register.sbyte_13);
				result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 * right.register.sbyte_14);
				result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 * right.register.sbyte_15);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(left.register.uint16_0 * right.register.uint16_0);
				result.register.uint16_1 = (ushort)(left.register.uint16_1 * right.register.uint16_1);
				result.register.uint16_2 = (ushort)(left.register.uint16_2 * right.register.uint16_2);
				result.register.uint16_3 = (ushort)(left.register.uint16_3 * right.register.uint16_3);
				result.register.uint16_4 = (ushort)(left.register.uint16_4 * right.register.uint16_4);
				result.register.uint16_5 = (ushort)(left.register.uint16_5 * right.register.uint16_5);
				result.register.uint16_6 = (ushort)(left.register.uint16_6 * right.register.uint16_6);
				result.register.uint16_7 = (ushort)(left.register.uint16_7 * right.register.uint16_7);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(left.register.int16_0 * right.register.int16_0);
				result.register.int16_1 = (short)(left.register.int16_1 * right.register.int16_1);
				result.register.int16_2 = (short)(left.register.int16_2 * right.register.int16_2);
				result.register.int16_3 = (short)(left.register.int16_3 * right.register.int16_3);
				result.register.int16_4 = (short)(left.register.int16_4 * right.register.int16_4);
				result.register.int16_5 = (short)(left.register.int16_5 * right.register.int16_5);
				result.register.int16_6 = (short)(left.register.int16_6 * right.register.int16_6);
				result.register.int16_7 = (short)(left.register.int16_7 * right.register.int16_7);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = left.register.uint32_0 * right.register.uint32_0;
				result.register.uint32_1 = left.register.uint32_1 * right.register.uint32_1;
				result.register.uint32_2 = left.register.uint32_2 * right.register.uint32_2;
				result.register.uint32_3 = left.register.uint32_3 * right.register.uint32_3;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = left.register.int32_0 * right.register.int32_0;
				result.register.int32_1 = left.register.int32_1 * right.register.int32_1;
				result.register.int32_2 = left.register.int32_2 * right.register.int32_2;
				result.register.int32_3 = left.register.int32_3 * right.register.int32_3;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = left.register.uint64_0 * right.register.uint64_0;
				result.register.uint64_1 = left.register.uint64_1 * right.register.uint64_1;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = left.register.int64_0 * right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 * right.register.int64_1;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = left.register.single_0 * right.register.single_0;
				result.register.single_1 = left.register.single_1 * right.register.single_1;
				result.register.single_2 = left.register.single_2 * right.register.single_2;
				result.register.single_3 = left.register.single_3 * right.register.single_3;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = left.register.double_0 * right.register.double_0;
				result.register.double_1 = left.register.double_1 * right.register.double_1;
			}
			return result;
		}

		public static Vector<T>operator *(Vector<T> value, T factor)
		{
			if (Vector.IsHardwareAccelerated)
			{
				return new Vector<T>(factor) * value;
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor);
				result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor);
				result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor);
				result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor);
				result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor);
				result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor);
				result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor);
				result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor);
				result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor);
				result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor);
				result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor);
				result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor);
				result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor);
				result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor);
				result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor);
				result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor);
				result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor);
				result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor);
				result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor);
				result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor);
				result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor);
				result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor);
				result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor);
				result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor);
				result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor);
				result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor);
				result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor);
				result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor);
				result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor);
				result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor);
				result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor);
				result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor);
				result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor);
				result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor);
				result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor);
				result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor);
				result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor);
				result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor);
				result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor);
				result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor);
				result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor);
				result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor);
				result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor);
				result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor);
				result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor;
				result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor;
				result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor;
				result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = value.register.int32_0 * (int)(object)factor;
				result.register.int32_1 = value.register.int32_1 * (int)(object)factor;
				result.register.int32_2 = value.register.int32_2 * (int)(object)factor;
				result.register.int32_3 = value.register.int32_3 * (int)(object)factor;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor;
				result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = value.register.int64_0 * (long)(object)factor;
				result.register.int64_1 = value.register.int64_1 * (long)(object)factor;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = value.register.single_0 * (float)(object)factor;
				result.register.single_1 = value.register.single_1 * (float)(object)factor;
				result.register.single_2 = value.register.single_2 * (float)(object)factor;
				result.register.single_3 = value.register.single_3 * (float)(object)factor;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = value.register.double_0 * (double)(object)factor;
				result.register.double_1 = value.register.double_1 * (double)(object)factor;
			}
			return result;
		}

		public static Vector<T>operator *(T factor, Vector<T> value)
		{
			if (Vector.IsHardwareAccelerated)
			{
				return new Vector<T>(factor) * value;
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor);
				result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor);
				result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor);
				result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor);
				result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor);
				result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor);
				result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor);
				result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor);
				result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor);
				result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor);
				result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor);
				result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor);
				result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor);
				result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor);
				result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor);
				result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor);
				result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor);
				result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor);
				result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor);
				result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor);
				result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor);
				result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor);
				result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor);
				result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor);
				result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor);
				result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor);
				result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor);
				result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor);
				result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor);
				result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor);
				result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor);
				result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor);
				result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor);
				result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor);
				result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor);
				result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor);
				result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor);
				result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor);
				result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor);
				result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor);
				result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor);
				result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor);
				result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor);
				result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor);
				result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor;
				result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor;
				result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor;
				result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = value.register.int32_0 * (int)(object)factor;
				result.register.int32_1 = value.register.int32_1 * (int)(object)factor;
				result.register.int32_2 = value.register.int32_2 * (int)(object)factor;
				result.register.int32_3 = value.register.int32_3 * (int)(object)factor;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor;
				result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = value.register.int64_0 * (long)(object)factor;
				result.register.int64_1 = value.register.int64_1 * (long)(object)factor;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = value.register.single_0 * (float)(object)factor;
				result.register.single_1 = value.register.single_1 * (float)(object)factor;
				result.register.single_2 = value.register.single_2 * (float)(object)factor;
				result.register.single_3 = value.register.single_3 * (float)(object)factor;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = value.register.double_0 * (double)(object)factor;
				result.register.double_1 = value.register.double_1 * (double)(object)factor;
			}
			return result;
		}

		public unsafe static Vector<T>operator /(Vector<T> left, Vector<T> right)
		{
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int i = 0; i < Count; i++)
					{
						ptr[i] = (byte)(object)ScalarDivide(left[i], right[i]);
					}
					return new Vector<T>(ptr);
				}
				if (typeof(T) == typeof(sbyte))
				{
					sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int j = 0; j < Count; j++)
					{
						ptr2[j] = (sbyte)(object)ScalarDivide(left[j], right[j]);
					}
					return new Vector<T>(ptr2);
				}
				if (typeof(T) == typeof(ushort))
				{
					ushort* ptr3 = stackalloc ushort[Count];
					for (int k = 0; k < Count; k++)
					{
						ptr3[k] = (ushort)(object)ScalarDivide(left[k], right[k]);
					}
					return new Vector<T>(ptr3);
				}
				if (typeof(T) == typeof(short))
				{
					short* ptr4 = stackalloc short[Count];
					for (int l = 0; l < Count; l++)
					{
						ptr4[l] = (short)(object)ScalarDivide(left[l], right[l]);
					}
					return new Vector<T>(ptr4);
				}
				if (typeof(T) == typeof(uint))
				{
					uint* ptr5 = stackalloc uint[Count];
					for (int m = 0; m < Count; m++)
					{
						ptr5[m] = (uint)(object)ScalarDivide(left[m], right[m]);
					}
					return new Vector<T>(ptr5);
				}
				if (typeof(T) == typeof(int))
				{
					int* ptr6 = stackalloc int[Count];
					for (int n = 0; n < Count; n++)
					{
						ptr6[n] = (int)(object)ScalarDivide(left[n], right[n]);
					}
					return new Vector<T>(ptr6);
				}
				if (typeof(T) == typeof(ulong))
				{
					ulong* ptr7 = stackalloc ulong[Count];
					for (int num = 0; num < Count; num++)
					{
						ptr7[num] = (ulong)(object)ScalarDivide(left[num], right[num]);
					}
					return new Vector<T>(ptr7);
				}
				if (typeof(T) == typeof(long))
				{
					long* ptr8 = stackalloc long[Count];
					for (int num2 = 0; num2 < Count; num2++)
					{
						ptr8[num2] = (long)(object)ScalarDivide(left[num2], right[num2]);
					}
					return new Vector<T>(ptr8);
				}
				if (typeof(T) == typeof(float))
				{
					float* ptr9 = stackalloc float[Count];
					for (int num3 = 0; num3 < Count; num3++)
					{
						ptr9[num3] = (float)(object)ScalarDivide(left[num3], right[num3]);
					}
					return new Vector<T>(ptr9);
				}
				if (typeof(T) == typeof(double))
				{
					double* ptr10 = stackalloc double[Count];
					for (int num4 = 0; num4 < Count; num4++)
					{
						ptr10[num4] = (double)(object)ScalarDivide(left[num4], right[num4]);
					}
					return new Vector<T>(ptr10);
				}
				throw new NotSupportedException(System.SR.Arg_TypeNotSupported);
			}
			Vector<T> result = default(Vector<T>);
			if (typeof(T) == typeof(byte))
			{
				result.register.byte_0 = (byte)(left.register.byte_0 / right.register.byte_0);
				result.register.byte_1 = (byte)(left.register.byte_1 / right.register.byte_1);
				result.register.byte_2 = (byte)(left.register.byte_2 / right.register.byte_2);
				result.register.byte_3 = (byte)(left.register.byte_3 / right.register.byte_3);
				result.register.byte_4 = (byte)(left.register.byte_4 / right.register.byte_4);
				result.register.byte_5 = (byte)(left.register.byte_5 / right.register.byte_5);
				result.register.byte_6 = (byte)(left.register.byte_6 / right.register.byte_6);
				result.register.byte_7 = (byte)(left.register.byte_7 / right.register.byte_7);
				result.register.byte_8 = (byte)(left.register.byte_8 / right.register.byte_8);
				result.register.byte_9 = (byte)(left.register.byte_9 / right.register.byte_9);
				result.register.byte_10 = (byte)(left.register.byte_10 / right.register.byte_10);
				result.register.byte_11 = (byte)(left.register.byte_11 / right.register.byte_11);
				result.register.byte_12 = (byte)(left.register.byte_12 / right.register.byte_12);
				result.register.byte_13 = (byte)(left.register.byte_13 / right.register.byte_13);
				result.register.byte_14 = (byte)(left.register.byte_14 / right.register.byte_14);
				result.register.byte_15 = (byte)(left.register.byte_15 / right.register.byte_15);
			}
			else if (typeof(T) == typeof(sbyte))
			{
				result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 / right.register.sbyte_0);
				result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 / right.register.sbyte_1);
				result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 / right.register.sbyte_2);
				result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 / right.register.sbyte_3);
				result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 / right.register.sbyte_4);
				result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 / right.register.sbyte_5);
				result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 / right.register.sbyte_6);
				result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 / right.register.sbyte_7);
				result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 / right.register.sbyte_8);
				result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 / right.register.sbyte_9);
				result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 / right.register.sbyte_10);
				result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 / right.register.sbyte_11);
				result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 / right.register.sbyte_12);
				result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 / right.register.sbyte_13);
				result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 / right.register.sbyte_14);
				result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 / right.register.sbyte_15);
			}
			else if (typeof(T) == typeof(ushort))
			{
				result.register.uint16_0 = (ushort)(left.register.uint16_0 / right.register.uint16_0);
				result.register.uint16_1 = (ushort)(left.register.uint16_1 / right.register.uint16_1);
				result.register.uint16_2 = (ushort)(left.register.uint16_2 / right.register.uint16_2);
				result.register.uint16_3 = (ushort)(left.register.uint16_3 / right.register.uint16_3);
				result.register.uint16_4 = (ushort)(left.register.uint16_4 / right.register.uint16_4);
				result.register.uint16_5 = (ushort)(left.register.uint16_5 / right.register.uint16_5);
				result.register.uint16_6 = (ushort)(left.register.uint16_6 / right.register.uint16_6);
				result.register.uint16_7 = (ushort)(left.register.uint16_7 / right.register.uint16_7);
			}
			else if (typeof(T) == typeof(short))
			{
				result.register.int16_0 = (short)(left.register.int16_0 / right.register.int16_0);
				result.register.int16_1 = (short)(left.register.int16_1 / right.register.int16_1);
				result.register.int16_2 = (short)(left.register.int16_2 / right.register.int16_2);
				result.register.int16_3 = (short)(left.register.int16_3 / right.register.int16_3);
				result.register.int16_4 = (short)(left.register.int16_4 / right.register.int16_4);
				result.register.int16_5 = (short)(left.register.int16_5 / right.register.int16_5);
				result.register.int16_6 = (short)(left.register.int16_6 / right.register.int16_6);
				result.register.int16_7 = (short)(left.register.int16_7 / right.register.int16_7);
			}
			else if (typeof(T) == typeof(uint))
			{
				result.register.uint32_0 = left.register.uint32_0 / right.register.uint32_0;
				result.register.uint32_1 = left.register.uint32_1 / right.register.uint32_1;
				result.register.uint32_2 = left.register.uint32_2 / right.register.uint32_2;
				result.register.uint32_3 = left.register.uint32_3 / right.register.uint32_3;
			}
			else if (typeof(T) == typeof(int))
			{
				result.register.int32_0 = left.register.int32_0 / right.register.int32_0;
				result.register.int32_1 = left.register.int32_1 / right.register.int32_1;
				result.register.int32_2 = left.register.int32_2 / right.register.int32_2;
				result.register.int32_3 = left.register.int32_3 / right.register.int32_3;
			}
			else if (typeof(T) == typeof(ulong))
			{
				result.register.uint64_0 = left.register.uint64_0 / right.register.uint64_0;
				result.register.uint64_1 = left.register.uint64_1 / right.register.uint64_1;
			}
			else if (typeof(T) == typeof(long))
			{
				result.register.int64_0 = left.register.int64_0 / right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 / right.register.int64_1;
			}
			else if (typeof(T) == typeof(float))
			{
				result.register.single_0 = left.register.single_0 / right.register.single_0;
				result.register.single_1 = left.register.single_1 / right.register.single_1;
				result.register.single_2 = left.register.single_2 / right.register.single_2;
				result.register.single_3 = left.register.single_3 / right.register.single_3;
			}
			else if (typeof(T) == typeof(double))
			{
				result.register.double_0 = left.register.double_0 / right.register.double_0;
				result.register.double_1 = left.register.double_1 / right.register.double_1;
			}
			return result;
		}

		public static Vector<T>operator -(Vector<T> value)
		{
			return Zero - value;
		}

		[JitIntrinsic]
		public unsafe static Vector<T>operator &(Vector<T> left, Vector<T> right)
		{
			Vector<T> result = default(Vector<T>);
			if (Vector.IsHardwareAccelerated)
			{
				long* ptr = &result.register.int64_0;
				long* ptr2 = &left.register.int64_0;
				long* ptr3 = &right.register.int64_0;
				for (int i = 0; i < Vector<long>.Count; i++)
				{
					ptr[i] = ptr2[i] & ptr3[i];
				}
			}
			else
			{
				result.register.int64_0 = left.register.int64_0 & right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 & right.register.int64_1;
			}
			return result;
		}

		[JitIntrinsic]
		public unsafe static Vector<T>operator |(Vector<T> left, Vector<T> right)
		{
			Vector<T> result = default(Vector<T>);
			if (Vector.IsHardwareAccelerated)
			{
				long* ptr = &result.register.int64_0;
				long* ptr2 = &left.register.int64_0;
				long* ptr3 = &right.register.int64_0;
				for (int i = 0; i < Vector<long>.Count; i++)
				{
					ptr[i] = ptr2[i] | ptr3[i];
				}
			}
			else
			{
				result.register.int64_0 = left.register.int64_0 | right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 | right.register.int64_1;
			}
			return result;
		}

		[JitIntrinsic]
		public unsafe static Vector<T>operator ^(Vector<T> left, Vector<T> right)
		{
			Vector<T> result = default(Vector<T>);
			if (Vector.IsHardwareAccelerated)
			{
				long* ptr = &result.register.int64_0;
				long* ptr2 = &left.register.int64_0;
				long* ptr3 = &right.register.int64_0;
				for (int i = 0; i < Vector<long>.Count; i++)
				{
					ptr[i] = ptr2[i] ^ ptr3[i];
				}
			}
			else
			{
				result.register.int64_0 = left.register.int64_0 ^ right.register.int64_0;
				result.register.int64_1 = left.register.int64_1 ^ right.register.int64_1;
			}
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static Vector<T>operator ~(Vector<T> value)
		{
			return allOnes ^ value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool operator ==(Vector<T> left, Vector<T> right)
		{
			return left.Equals(right);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool operator !=(Vector<T> left, Vector<T> right)
		{
			return !(left == right);
		}

		[JitIntrinsic]
		public static explicit operator Vector<byte>(Vector<T> value)
		{
			return new Vector<byte>(ref value.register);
		}

		[CLSCompliant(false)]
		[JitIntrinsic]
		public static explicit operator Vector<sbyte>(Vector<T> value)
		{
			return new Vector<sbyte>(ref value.register);
		}

		[CLSCompliant(false)]
		[JitIntrinsic]
		public static explicit operator Vector<ushort>(Vector<T> value)
		{
			return new Vector<ushort>(ref value.register);
		}

		[JitIntrinsic]
		public static explicit operator Vector<short>(Vector<T> value)
		{
			return new Vector<short>(ref value.register);
		}

		[CLSCompliant(false)]
		[JitIntrinsic]
		public static explicit operator Vector<uint>(Vector<T> value)
		{
			return new Vector<uint>(ref value.register);
		}

		[JitIntrinsic]
		public static explicit operator Vector<int>(Vector<T> value)
		{
			return new Vector<int>(ref value.register);
		}

		[CLSCompliant(false)]
		[JitIntrinsic]
		public static explicit operator Vector<ulong>(Vector<T> value)
		{
			return new Vector<ulong>(ref value.register);
		}

		[JitIntrinsic]
		public static explicit operator Vector<long>(Vector<T> value)
		{
			return new Vector<long>(ref value.register);
		}

		[JitIntrinsic]
		public static explicit operator Vector<float>(Vector<T> value)
		{
			return new Vector<float>(ref value.register);
		}

		[JitIntrinsic]
		public static explicit operator Vector<double>(Vector<T> value)
		{
			return new Vector<double>(ref value.register);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[JitIntrinsic]
		internal unsafe static Vector<T> Equals(Vector<T> left, Vector<T> right)
		{
			if (Vector.IsHardwareAccelerated)
			{
				if (typeof(T) == typeof(byte))
				{
					byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int i = 0; i < Count; i++)
					{
						ptr[i] = (byte)(ScalarEquals(left[i], right[i]) ? ConstantHelper.GetByteWithAllBitsSet() : 0);
					}
					return new Vector<T>(ptr);
				}
				if (typeof(T) == typeof(sbyte))
				{
					sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)];
					for (int j = 0; j < Count; j++)
					{
						ptr2[j] = (sbyte)(ScalarEquals(left[j], right[j]) ? ConstantHelper.GetSByteWithAllBitsSet() : 0);
					}
					return new Vector<T>(ptr2);
				}
				if (typeof(T) == typeof(ushort))
				{
					ushort* ptr3 = stackalloc ushort[Count];
					for (int k = 0; k < Count; k++)
					{
						ptr3[k] =