Decompiled source of YoutubeBoomBox v1.0.6

plugins/AngleSharp.dll

Decompiled 7 months ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Attributes;
using AngleSharp.Browser;
using AngleSharp.Browser.Dom;
using AngleSharp.Browser.Dom.Events;
using AngleSharp.Common;
using AngleSharp.Css;
using AngleSharp.Css.Dom;
using AngleSharp.Css.Parser;
using AngleSharp.Dom;
using AngleSharp.Dom.Events;
using AngleSharp.Html;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Dom.Events;
using AngleSharp.Html.Forms;
using AngleSharp.Html.Forms.Submitters;
using AngleSharp.Html.Forms.Submitters.Json;
using AngleSharp.Html.InputTypes;
using AngleSharp.Html.LinkRels;
using AngleSharp.Html.Parser;
using AngleSharp.Html.Parser.Tokens;
using AngleSharp.Io;
using AngleSharp.Io.Dom;
using AngleSharp.Io.Processors;
using AngleSharp.Mathml;
using AngleSharp.Mathml.Dom;
using AngleSharp.Media;
using AngleSharp.Media.Dom;
using AngleSharp.Scripting;
using AngleSharp.Svg;
using AngleSharp.Svg.Dom;
using AngleSharp.Text;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCopyright("Copyright © AngleSharp, 2013-2023")]
[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("AngleSharp.Core.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001adf274fa2b375134e8e4558d606f1a0f96f5cd0c6b99970f7cce9887477209d7c29f814e2508d8bd2526e99e8cd273bd1158a3984f1ea74830ec5329a77c6ff201a15edeb8b36ab046abd1bce211fe8dbb076d7d806f46b15bfda44def04ead0669971e96c5f666c9eda677f28824fff7aa90d32929ed91d529a7a41699893")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("AngleSharp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("AngleSharp is the ultimate angle brackets parser library. It parses HTML5, CSS3, and XML to construct a DOM based on the official W3C specification.")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyInformationalVersion("1.0.7+44cebe134e597d91b3d53fdf3a8fb3897710c09c")]
[assembly: AssemblyProduct("AngleSharp")]
[assembly: AssemblyTitle("AngleSharp")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AngleSharp/AngleSharp")]
[assembly: AssemblyVersion("1.0.7.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AngleSharp
{
	public sealed class BrowsingContext : EventTarget, IBrowsingContext, IEventTarget, IDisposable
	{
		private readonly IEnumerable<object> _originalServices;

		private readonly List<object> _services;

		private readonly Sandboxes _security;

		private readonly IBrowsingContext? _parent;

		private readonly IDocument? _creator;

		private readonly IHistory? _history;

		private readonly Dictionary<string, WeakReference<IBrowsingContext>> _children;

		public IDocument? Active { get; set; }

		public IDocument? Creator => _creator;

		public IEnumerable<object> OriginalServices => _originalServices;

		public IWindow? Current => Active?.DefaultView;

		public IBrowsingContext? Parent => _parent;

		public IHistory? SessionHistory => _history;

		public Sandboxes Security => _security;

		public BrowsingContext(IConfiguration? configuration = null)
			: this((configuration ?? Configuration.Default).Services, Sandboxes.None)
		{
		}

		private BrowsingContext(Sandboxes security)
		{
			_services = new List<object>();
			_originalServices = _services;
			_security = security;
			_children = new Dictionary<string, WeakReference<IBrowsingContext>>();
		}

		internal BrowsingContext(IEnumerable<object> services, Sandboxes security)
			: this(security)
		{
			_services.AddRange(services);
			_originalServices = services;
			_history = GetService<IHistory>();
		}

		internal BrowsingContext(IBrowsingContext parent, Sandboxes security)
			: this(parent.OriginalServices, security)
		{
			_parent = parent;
			_creator = _parent.Active;
		}

		public T? GetService<T>() where T : class
		{
			int count = _services.Count;
			int num = 0;
			while (num < count)
			{
				object obj = _services[num];
				T val = obj as T;
				if (val == null)
				{
					if (!(obj is Func<IBrowsingContext, T> func))
					{
						num++;
						continue;
					}
					val = func(this);
					_services[num] = val;
				}
				return val;
			}
			return null;
		}

		public IEnumerable<T> GetServices<T>() where T : class
		{
			int count = _services.Count;
			for (int i = 0; i < count; i++)
			{
				object obj = _services[i];
				T val = obj as T;
				if (val == null)
				{
					if (!(obj is Func<IBrowsingContext, T> func))
					{
						continue;
					}
					val = func(this);
					_services[i] = val;
				}
				yield return val;
			}
		}

		public IBrowsingContext CreateChild(string? name, Sandboxes security)
		{
			BrowsingContext browsingContext = new BrowsingContext(this, security);
			if (name != null && name.Length > 0)
			{
				_children[name] = new WeakReference<IBrowsingContext>(browsingContext);
			}
			return browsingContext;
		}

		public IBrowsingContext? FindChild(string name)
		{
			IBrowsingContext target = null;
			if (!string.IsNullOrEmpty(name) && _children.TryGetValue(name, out WeakReference<IBrowsingContext> value))
			{
				value.TryGetTarget(out target);
			}
			return target;
		}

		public static IBrowsingContext New(IConfiguration? configuration = null)
		{
			if (configuration == null)
			{
				configuration = Configuration.Default;
			}
			return new BrowsingContext(configuration.Services, Sandboxes.None);
		}

		public static IBrowsingContext NewFrom<TService>(TService instance)
		{
			return new BrowsingContext(Configuration.Default.WithOnly(instance).Services, Sandboxes.None);
		}

		void IDisposable.Dispose()
		{
			Active?.Dispose();
			Active = null;
		}
	}
	public static class BrowsingContextExtensions
	{
		public static Task<IDocument> OpenNewAsync(this IBrowsingContext context, string? url = null, CancellationToken cancellation = default(CancellationToken))
		{
			string url2 = url;
			return context.OpenAsync(delegate(VirtualResponse m)
			{
				m.Address(url2 ?? "http://localhost/");
			}, cancellation);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, IResponse response, CancellationToken cancel = default(CancellationToken))
		{
			response = response ?? throw new ArgumentNullException("response");
			if (context == null)
			{
				context = BrowsingContext.New();
			}
			Encoding defaultEncoding = context.GetDefaultEncoding();
			IDocumentFactory factory = context.GetFactory<IDocumentFactory>();
			CreateDocumentOptions options = new CreateDocumentOptions(response, defaultEncoding);
			return factory.CreateAsync(context, options, cancel);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, DocumentRequest request, CancellationToken cancel = default(CancellationToken))
		{
			request = request ?? throw new ArgumentNullException("request");
			if (context == null)
			{
				context = BrowsingContext.New();
			}
			return context.NavigateToAsync(request, cancel);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, Url url, CancellationToken cancel = default(CancellationToken))
		{
			url = url ?? throw new ArgumentNullException("url");
			return context.OpenAsync(DocumentRequest.Get(url, null, context?.Active?.DocumentUri), cancel);
		}

		public static async Task<IDocument> OpenAsync(this IBrowsingContext context, Action<VirtualResponse> request, CancellationToken cancel = default(CancellationToken))
		{
			request = request ?? throw new ArgumentNullException("request");
			using IResponse response = VirtualResponse.Create(request);
			return await context.OpenAsync(response, cancel).ConfigureAwait(continueOnCapturedContext: false);
		}

		public static Task<IDocument> OpenAsync(this IBrowsingContext context, string address, CancellationToken cancellation = default(CancellationToken))
		{
			address = address ?? throw new ArgumentNullException("address");
			return context.OpenAsync(Url.Create(address), cancellation);
		}

		internal static Task<IDocument> NavigateToAsync(this IBrowsingContext context, DocumentRequest request, CancellationToken cancel = default(CancellationToken))
		{
			return context.GetNavigationHandler(request.Target)?.NavigateAsync(request, cancel) ?? Task.FromResult<IDocument>(null);
		}

		public static void NavigateTo(this IBrowsingContext context, IDocument document)
		{
			context.SessionHistory?.PushState(document, document.Title, document.Url);
			context.Active = document;
		}

		public static INavigationHandler? GetNavigationHandler(this IBrowsingContext context, Url url)
		{
			Url url2 = url;
			return context.GetServices<INavigationHandler>().FirstOrDefault((INavigationHandler m) => m.SupportsProtocol(url2.Scheme));
		}

		public static Encoding GetDefaultEncoding(this IBrowsingContext context)
		{
			IEncodingProvider? provider = context.GetProvider<IEncodingProvider>();
			string language = context.GetLanguage();
			return provider?.Suggest(language) ?? Encoding.UTF8;
		}

		public static CultureInfo GetCulture(this IBrowsingContext context)
		{
			return context.GetService<CultureInfo>() ?? CultureInfo.CurrentUICulture;
		}

		public static CultureInfo GetCultureFrom(this IBrowsingContext context, string language)
		{
			try
			{
				return new CultureInfo(language);
			}
			catch (CultureNotFoundException ex)
			{
				context.TrackError(ex);
				return context.GetCulture();
			}
		}

		public static string GetLanguage(this IBrowsingContext context)
		{
			return context.GetCulture().Name;
		}

		public static TFactory GetFactory<TFactory>(this IBrowsingContext context) where TFactory : class
		{
			return context.GetServices<TFactory>().Single();
		}

		public static TProvider? GetProvider<TProvider>(this IBrowsingContext context) where TProvider : class
		{
			return context.GetServices<TProvider>().SingleOrDefault();
		}

		public static IResourceService<TResource>? GetResourceService<TResource>(this IBrowsingContext context, string type) where TResource : IResourceInfo
		{
			foreach (IResourceService<TResource> service in context.GetServices<IResourceService<TResource>>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static string GetCookie(this IBrowsingContext context, Url url)
		{
			return context.GetProvider<ICookieProvider>()?.GetCookie(url) ?? string.Empty;
		}

		public static void SetCookie(this IBrowsingContext context, Url url, string value)
		{
			context.GetProvider<ICookieProvider>()?.SetCookie(url, value);
		}

		public static ISpellCheckService? GetSpellCheck(this IBrowsingContext context, string language)
		{
			ISpellCheckService spellCheckService = null;
			IEnumerable<ISpellCheckService> services = context.GetServices<ISpellCheckService>();
			CultureInfo cultureFrom = context.GetCultureFrom(language);
			string twoLetterISOLanguageName = cultureFrom.TwoLetterISOLanguageName;
			foreach (ISpellCheckService item in services)
			{
				CultureInfo culture = item.Culture;
				if (culture != null)
				{
					string twoLetterISOLanguageName2 = culture.TwoLetterISOLanguageName;
					if (culture.Equals(cultureFrom))
					{
						return item;
					}
					if (spellCheckService == null && twoLetterISOLanguageName2.Is(twoLetterISOLanguageName))
					{
						spellCheckService = item;
					}
				}
			}
			return spellCheckService;
		}

		public static IStylingService? GetCssStyling(this IBrowsingContext context)
		{
			return context.GetStyling(MimeTypeNames.Css);
		}

		public static IStylingService? GetStyling(this IBrowsingContext context, string type)
		{
			foreach (IStylingService service in context.GetServices<IStylingService>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static bool IsScripting(this IBrowsingContext context)
		{
			return context.GetServices<IScriptingService>().Any();
		}

		public static IScriptingService? GetJsScripting(this IBrowsingContext context)
		{
			return context.GetScripting(MimeTypeNames.DefaultJavaScript);
		}

		public static IScriptingService? GetScripting(this IBrowsingContext context, string type)
		{
			foreach (IScriptingService service in context.GetServices<IScriptingService>())
			{
				if (service.SupportsType(type))
				{
					return service;
				}
			}
			return null;
		}

		public static ICommand? GetCommand(this IBrowsingContext context, string commandId)
		{
			return context.GetProvider<ICommandProvider>()?.GetCommand(commandId);
		}

		public static void TrackError(this IBrowsingContext context, Exception ex)
		{
			AngleSharp.Browser.Dom.Events.TrackEvent eventData = new AngleSharp.Browser.Dom.Events.TrackEvent("error", ex);
			context.Fire(eventData);
		}

		public static Task InteractAsync<T>(this IBrowsingContext context, string eventName, T data)
		{
			InteractivityEvent<T> interactivityEvent = new InteractivityEvent<T>(eventName, data);
			context.Fire(interactivityEvent);
			return interactivityEvent.Result ?? Task.FromResult(result: false);
		}

		public static IBrowsingContext ResolveTargetContext(this IBrowsingContext context, string? target)
		{
			bool flag = false;
			IBrowsingContext browsingContext = context;
			if (target != null && target.Length > 0)
			{
				browsingContext = context.FindChildFor(target);
				flag = browsingContext == null;
			}
			if (flag)
			{
				browsingContext = context.CreateChildFor(target);
			}
			return browsingContext;
		}

		public static IBrowsingContext CreateChildFor(this IBrowsingContext context, string? target)
		{
			Sandboxes security = Sandboxes.None;
			if (target == "_blank")
			{
				target = null;
			}
			return context.CreateChild(target, security);
		}

		public static IBrowsingContext? FindChildFor(this IBrowsingContext context, string target)
		{
			if (!string.IsNullOrEmpty(target))
			{
				switch (target)
				{
				case "_self":
					break;
				case "_parent":
					return context.Parent ?? context;
				case "_top":
					return context;
				default:
					return context.FindChild(target);
				}
			}
			return context;
		}

		public static IEnumerable<Task> GetDownloads<T>(this IBrowsingContext context) where T : INode
		{
			IResourceLoader service = context.GetService<IResourceLoader>();
			if (service == null)
			{
				return Array.Empty<Task>();
			}
			return from m in service.GetDownloads()
				where m.Source is T
				select m.Task;
		}
	}
	public class Configuration : IConfiguration
	{
		private readonly IEnumerable<object> _services;

		public static IConfiguration Default => new Configuration();

		public IEnumerable<object> Services => _services;

		private static T Instance<T>(T instance)
		{
			return instance;
		}

		private static Func<IBrowsingContext, T> Creator<T>(Func<IBrowsingContext, T> creator)
		{
			return creator;
		}

		public Configuration(IEnumerable<object>? services = null)
		{
			_services = services ?? new object[16]
			{
				Instance((IElementFactory<Document, HtmlElement>)new HtmlElementFactory()),
				Instance((IElementFactory<Document, MathElement>)new MathElementFactory()),
				Instance((IElementFactory<Document, SvgElement>)new SvgElementFactory()),
				Instance((IEventFactory)new DefaultEventFactory()),
				Instance((IInputTypeFactory)new DefaultInputTypeFactory()),
				Instance((IAttributeSelectorFactory)new DefaultAttributeSelectorFactory()),
				Instance((IPseudoElementSelectorFactory)new DefaultPseudoElementSelectorFactory()),
				Instance((IPseudoClassSelectorFactory)new DefaultPseudoClassSelectorFactory()),
				Instance((ILinkRelationFactory)new DefaultLinkRelationFactory()),
				Instance((IDocumentFactory)new DefaultDocumentFactory()),
				Instance((IAttributeObserver)new DefaultAttributeObserver()),
				Instance((IMetaHandler)new EncodingMetaHandler()),
				Instance((IHtmlEncoder)new DefaultHtmlEncoder()),
				Creator((Func<IBrowsingContext, ICssSelectorParser>)((IBrowsingContext ctx) => new CssSelectorParser(ctx))),
				Creator((Func<IBrowsingContext, IHtmlParser>)((IBrowsingContext ctx) => new HtmlParser(ctx))),
				Creator((Func<IBrowsingContext, INavigationHandler>)((IBrowsingContext ctx) => new DefaultNavigationHandler(ctx)))
			};
		}
	}
	public static class ConfigurationExtensions
	{
		public static IConfiguration With(this IConfiguration configuration, object service)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			service = service ?? throw new ArgumentNullException("service");
			return new Configuration(configuration.Services.Concat(service));
		}

		public static IConfiguration WithOnly<TService>(this IConfiguration configuration, TService service)
		{
			if (service == null)
			{
				throw new ArgumentNullException("service");
			}
			return configuration.Without<TService>().With(service);
		}

		public static IConfiguration WithOnly<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)
		{
			creator = creator ?? throw new ArgumentNullException("creator");
			return configuration.Without<TService>().With(creator);
		}

		public static IConfiguration Without(this IConfiguration configuration, object service)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			service = service ?? throw new ArgumentNullException("service");
			return new Configuration(configuration.Services.Except(service));
		}

		public static IConfiguration With(this IConfiguration configuration, IEnumerable<object> services)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			services = services ?? throw new ArgumentNullException("services");
			return new Configuration(services.Concat(configuration.Services));
		}

		public static IConfiguration Without(this IConfiguration configuration, IEnumerable<object> services)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			services = services ?? throw new ArgumentNullException("services");
			return new Configuration(configuration.Services.Except(services));
		}

		public static IConfiguration With<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)
		{
			creator = creator ?? throw new ArgumentNullException("creator");
			return configuration.With((object)creator);
		}

		public static IConfiguration Without<TService>(this IConfiguration configuration)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			IEnumerable<object> services = configuration.Services.OfType<TService>().Cast<object>();
			IEnumerable<Func<IBrowsingContext, TService>> services2 = configuration.Services.OfType<Func<IBrowsingContext, TService>>();
			return configuration.Without(services).Without(services2);
		}

		public static bool Has<TService>(this IConfiguration configuration)
		{
			configuration = configuration ?? throw new ArgumentNullException("configuration");
			if (!configuration.Services.OfType<TService>().Any())
			{
				return configuration.Services.OfType<Func<IBrowsingContext, TService>>().Any();
			}
			return true;
		}

		public static IConfiguration WithDefaultLoader(this IConfiguration configuration, LoaderOptions? setup = null)
		{
			LoaderOptions config = setup ?? new LoaderOptions();
			if (!configuration.Has<IRequester>())
			{
				configuration = configuration.With(new DefaultHttpRequester());
			}
			if (!config.IsNavigationDisabled)
			{
				configuration = configuration.With((Func<IBrowsingContext, IDocumentLoader>)((IBrowsingContext ctx) => new DefaultDocumentLoader(ctx, config.Filter)));
			}
			if (config.IsResourceLoadingEnabled)
			{
				configuration = configuration.With((Func<IBrowsingContext, IResourceLoader>)((IBrowsingContext ctx) => new DefaultResourceLoader(ctx, config.Filter)));
			}
			return configuration;
		}

		public static IConfiguration WithCulture(this IConfiguration configuration, string name)
		{
			CultureInfo culture = new CultureInfo(name);
			return configuration.WithCulture(culture);
		}

		public static IConfiguration WithCulture(this IConfiguration configuration, CultureInfo culture)
		{
			return configuration.With(culture);
		}

		public static IConfiguration WithMetaRefresh(this IConfiguration configuration, Predicate<Url>? shouldRefresh = null)
		{
			RefreshMetaHandler service = new RefreshMetaHandler(shouldRefresh);
			return configuration.With(service);
		}

		public static IConfiguration WithLocaleBasedEncoding(this IConfiguration configuration)
		{
			LocaleEncodingProvider service = new LocaleEncodingProvider();
			return configuration.With(service);
		}

		public static IConfiguration WithDefaultCookies(this IConfiguration configuration)
		{
			MemoryCookieProvider service = new MemoryCookieProvider();
			return configuration.With(service);
		}
	}
	public static class FormatExtensions
	{
		public static string ToCss(this IStyleFormattable style)
		{
			return style.ToCss(CssStyleFormatter.Instance);
		}

		public static string ToCss(this IStyleFormattable style, IStyleFormatter formatter)
		{
			StringBuilder sb = StringBuilderPool.Obtain();
			using (StringWriter writer = new StringWriter(sb))
			{
				style.ToCss(writer, formatter);
			}
			return sb.ToPool();
		}

		public static void ToCss(this IStyleFormattable style, TextWriter writer)
		{
			style.ToCss(writer, CssStyleFormatter.Instance);
		}

		public static Task ToCssAsync(this IStyleFormattable style, TextWriter writer)
		{
			return writer.WriteAsync(style.ToCss());
		}

		public static async Task ToCssAsync(this IStyleFormattable style, Stream stream)
		{
			using StreamWriter writer = new StreamWriter(stream);
			await style.ToCssAsync(writer).ConfigureAwait(continueOnCapturedContext: false);
		}

		public static string ToHtml(this IMarkupFormattable markup)
		{
			return markup.ToHtml(HtmlMarkupFormatter.Instance);
		}

		public static string ToHtml(this IMarkupFormattable markup, IMarkupFormatter formatter)
		{
			StringBuilder sb = StringBuilderPool.Obtain();
			using (StringWriter writer = new StringWriter(sb))
			{
				markup.ToHtml(writer, formatter);
			}
			return sb.ToPool();
		}

		public static void ToHtml(this IMarkupFormattable markup, TextWriter writer)
		{
			markup.ToHtml(writer, HtmlMarkupFormatter.Instance);
		}

		public static string Minify(this IMarkupFormattable markup)
		{
			return markup.ToHtml(new MinifyMarkupFormatter());
		}

		public static string Prettify(this IMarkupFormattable markup)
		{
			return markup.ToHtml(new PrettyMarkupFormatter());
		}

		public static Task ToHtmlAsync(this IMarkupFormattable markup, TextWriter writer)
		{
			return writer.WriteAsync(markup.ToHtml());
		}

		public static async Task ToHtmlAsync(this IMarkupFormattable markup, Stream stream)
		{
			using StreamWriter writer = new StreamWriter(stream);
			await markup.ToHtmlAsync(writer).ConfigureAwait(continueOnCapturedContext: false);
		}
	}
	public interface IBrowsingContext : IEventTarget, IDisposable
	{
		IWindow? Current { get; }

		IDocument? Active { get; set; }

		IHistory? SessionHistory { get; }

		Sandboxes Security { get; }

		IBrowsingContext? Parent { get; }

		IDocument? Creator { get; }

		IEnumerable<object> OriginalServices { get; }

		T? GetService<T>() where T : class;

		IEnumerable<T> GetServices<T>() where T : class;

		IBrowsingContext CreateChild(string? name, Sandboxes security);

		IBrowsingContext? FindChild(string name);
	}
	public interface IConfiguration
	{
		IEnumerable<object> Services { get; }
	}
	public interface IMarkupFormattable
	{
		void ToHtml(TextWriter writer, IMarkupFormatter formatter);
	}
	public interface IMarkupFormatter
	{
		string Text(ICharacterData text);

		string LiteralText(ICharacterData text);

		string Comment(IComment comment);

		string Processing(IProcessingInstruction processing);

		string Doctype(IDocumentType doctype);

		string OpenTag(IElement element, bool selfClosing);

		string CloseTag(IElement element, bool selfClosing);
	}
	public interface IStyleFormattable
	{
		void ToCss(TextWriter writer, IStyleFormatter formatter);
	}
	public interface IStyleFormatter
	{
		string Sheet(IEnumerable<IStyleFormattable> rules);

		string Declaration(string name, string value, bool important);

		string BlockDeclarations(IEnumerable<IStyleFormattable> declarations);

		string Rule(string name, string value);

		string Rule(string name, string prelude, string rules);

		string BlockRules(IEnumerable<IStyleFormattable> rules);

		string Comment(string data);
	}
}
namespace AngleSharp.Xhtml
{
	public class XhtmlMarkupFormatter : IMarkupFormatter
	{
		public static readonly IMarkupFormatter Instance = new XhtmlMarkupFormatter();

		private readonly bool _emptyTagsToSelfClosing;

		public bool IsSelfClosingEmptyTags => _emptyTagsToSelfClosing;

		public XhtmlMarkupFormatter()
			: this(emptyTagsToSelfClosing: true)
		{
		}

		public XhtmlMarkupFormatter(bool emptyTagsToSelfClosing)
		{
			_emptyTagsToSelfClosing = emptyTagsToSelfClosing;
		}

		public virtual string CloseTag(IElement element, bool selfClosing)
		{
			string prefix = element.Prefix;
			string localName = element.LocalName;
			string text = ((!string.IsNullOrEmpty(prefix)) ? (prefix + ":" + localName) : localName);
			if (!selfClosing && (!_emptyTagsToSelfClosing || element.HasChildNodes))
			{
				return "</" + text + ">";
			}
			return string.Empty;
		}

		public virtual string Comment(IComment comment)
		{
			return "<!--" + comment.Data + "-->";
		}

		public virtual string Doctype(IDocumentType doctype)
		{
			string publicIdentifier = doctype.PublicIdentifier;
			string systemIdentifier = doctype.SystemIdentifier;
			string text = ((string.IsNullOrEmpty(publicIdentifier) && string.IsNullOrEmpty(systemIdentifier)) ? string.Empty : (" " + (string.IsNullOrEmpty(publicIdentifier) ? ("SYSTEM \"" + systemIdentifier + "\"") : ("PUBLIC \"" + publicIdentifier + "\" \"" + systemIdentifier + "\""))));
			return "<!DOCTYPE " + doctype.Name + text + ">";
		}

		public virtual string OpenTag(IElement element, bool selfClosing)
		{
			string prefix = element.Prefix;
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			stringBuilder.Append('<');
			if (!string.IsNullOrEmpty(prefix))
			{
				stringBuilder.Append(prefix).Append(':');
			}
			stringBuilder.Append(element.LocalName);
			foreach (IAttr attribute in element.Attributes)
			{
				stringBuilder.Append(' ').Append(Attribute(attribute));
			}
			if (selfClosing || (_emptyTagsToSelfClosing && !element.HasChildNodes))
			{
				stringBuilder.Append(" /");
			}
			stringBuilder.Append('>');
			return stringBuilder.ToPool();
		}

		public virtual string Processing(IProcessingInstruction processing)
		{
			string text = processing.Target + " " + processing.Data;
			return "<?" + text + "?>";
		}

		public virtual string LiteralText(ICharacterData text)
		{
			return text.Data;
		}

		public virtual string Text(ICharacterData text)
		{
			return EscapeText(text.Data);
		}

		protected virtual string Attribute(IAttr attribute)
		{
			string namespaceUri = attribute.NamespaceUri;
			string localName = attribute.LocalName;
			string value = attribute.Value;
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			if (string.IsNullOrEmpty(namespaceUri))
			{
				stringBuilder.Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XmlUri))
			{
				stringBuilder.Append(NamespaceNames.XmlPrefix).Append(':').Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XLinkUri))
			{
				stringBuilder.Append(NamespaceNames.XLinkPrefix).Append(':').Append(localName);
			}
			else if (namespaceUri.Is(NamespaceNames.XmlNsUri))
			{
				stringBuilder.Append(XmlNamespaceLocalName(localName));
			}
			else
			{
				stringBuilder.Append(attribute.Name);
			}
			stringBuilder.Append('=').Append('"');
			for (int i = 0; i < value.Length; i++)
			{
				switch (value[i])
				{
				case '&':
					stringBuilder.Append("&amp;");
					break;
				case '\u00a0':
					stringBuilder.Append("&#160;");
					break;
				case '<':
					stringBuilder.Append("&lt;");
					break;
				case '"':
					stringBuilder.Append("&quot;");
					break;
				default:
					stringBuilder.Append(value[i]);
					break;
				}
			}
			return stringBuilder.Append('"').ToPool();
		}

		public static string EscapeText(string content)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			for (int i = 0; i < content.Length; i++)
			{
				switch (content[i])
				{
				case '&':
					stringBuilder.Append("&amp;");
					break;
				case '\u00a0':
					stringBuilder.Append("&#160;");
					break;
				case '>':
					stringBuilder.Append("&gt;");
					break;
				case '<':
					stringBuilder.Append("&lt;");
					break;
				default:
					stringBuilder.Append(content[i]);
					break;
				}
			}
			return stringBuilder.ToPool();
		}

		public static string XmlNamespaceLocalName(string localName)
		{
			if (localName.Is(NamespaceNames.XmlNsPrefix))
			{
				return localName;
			}
			return NamespaceNames.XmlNsPrefix + ':' + localName;
		}
	}
}
namespace AngleSharp.Text
{
	public static class CharExtensions
	{
		public static int FromHex(this char c)
		{
			if (!c.IsDigit())
			{
				return c - (c.IsLowercaseAscii() ? 87 : 55);
			}
			return c - 48;
		}

		public static string ToHex(this byte num)
		{
			char[] array = new char[2];
			int num2 = num >> 4;
			array[0] = (char)(num2 + ((num2 < 10) ? 48 : 55));
			num2 = num - 16 * num2;
			array[1] = (char)(num2 + ((num2 < 10) ? 48 : 55));
			return new string(array);
		}

		public static string ToHex(this char character)
		{
			int num = character;
			return num.ToString("x");
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInRange(this char c, int lower, int upper)
		{
			if (c >= lower)
			{
				return c <= upper;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNormalQueryCharacter(this char c)
		{
			if (c.IsInRange(33, 126) && c != '"' && c != '`' && c != '#' && c != '<')
			{
				return c != '>';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNormalPathCharacter(this char c)
		{
			if (c.IsInRange(32, 126) && c != '"' && c != '`' && c != '#' && c != '<' && c != '>' && c != ' ')
			{
				return c != '?';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsUppercaseAscii(this char c)
		{
			if (c >= 'A')
			{
				return c <= 'Z';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLowercaseAscii(this char c)
		{
			if (c >= 'a')
			{
				return c <= 'z';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsAlphanumericAscii(this char c)
		{
			if (!c.IsDigit() && !c.IsUppercaseAscii())
			{
				return c.IsLowercaseAscii();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHex(this char c)
		{
			if (!c.IsDigit() && (c < 'A' || c > 'F'))
			{
				if (c >= 'a')
				{
					return c <= 'f';
				}
				return false;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNonAscii(this char c)
		{
			if (c != '\uffff')
			{
				return c >= '\u0080';
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNonPrintable(this char c)
		{
			if ((c < '\0' || c > '\b') && (c < '\u000e' || c > '\u001f'))
			{
				if (c >= '\u007f')
				{
					return c <= '\u009f';
				}
				return false;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLetter(this char c)
		{
			if (!c.IsUppercaseAscii())
			{
				return c.IsLowercaseAscii();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsName(this char c)
		{
			if (!c.IsNonAscii() && !c.IsLetter() && c != '_' && c != '-')
			{
				return c.IsDigit();
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsCustomElementName(this char c)
		{
			if (c != '_' && c != '-' && c != '.' && !c.IsDigit() && !c.IsLowercaseAscii() && c != '·' && !c.IsInRange(192, 214) && !c.IsInRange(216, 246) && !c.IsInRange(248, 893) && !c.IsInRange(895, 8191) && !c.IsInRange(8204, 8205) && !c.IsInRange(8255, 8256) && !c.IsInRange(8304, 8591) && !c.IsInRange(11264, 12271) && !c.IsInRange(12289, 55295) && !c.IsInRange(63744, 64975) && !c.IsInRange(65008, 65533))
			{
				return c.IsInRange(65536, 2031615);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsNameStart(this char c)
		{
			if (!c.IsNonAscii() && !c.IsUppercaseAscii() && !c.IsLowercaseAscii())
			{
				return c == '_';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLineBreak(this char c)
		{
			if (c != '\n')
			{
				return c == '\r';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsSpaceCharacter(this char c)
		{
			if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
			{
				return c == '\f';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsWhiteSpaceCharacter(this char c)
		{
			if (!c.IsInRange(9, 13) && c != ' ' && c != '\u0085' && c != '\u00a0' && c != '\u1680' && c != '\u180e' && !c.IsInRange(8192, 8202) && c != '\u2028' && c != '\u2029' && c != '\u202f' && c != '\u205f')
			{
				return c == '\u3000';
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsDigit(this char c)
		{
			if (c >= '0')
			{
				return c <= '9';
			}
			return false;
		}

		public static bool IsUrlCodePoint(this char c)
		{
			if (!c.IsAlphanumericAscii() && c != '!' && c != '$' && c != '&' && c != '\'' && c != '(' && c != ')' && c != '*' && c != '+' && c != '-' && c != ',' && c != '.' && c != '/' && c != ':' && c != ';' && c != '=' && c != '?' && c != '@' && c != '_' && c != '~' && !c.IsInRange(160, 55295) && !c.IsInRange(57344, 64975) && !c.IsInRange(65008, 65533) && !c.IsInRange(65536, 131069) && !c.IsInRange(131072, 196605) && !c.IsInRange(196608, 262141) && !c.IsInRange(262144, 327677) && !c.IsInRange(327680, 393213) && !c.IsInRange(393216, 458749) && !c.IsInRange(458752, 524285) && !c.IsInRange(524288, 589821) && !c.IsInRange(589824, 655357) && !c.IsInRange(655360, 720893) && !c.IsInRange(720896, 786429) && !c.IsInRange(786432, 851965) && !c.IsInRange(851968, 917501) && !c.IsInRange(917504, 983037) && !c.IsInRange(983040, 1048573))
			{
				return c.IsInRange(1048576, 1114109);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInvalid(this int c)
		{
			if (c != 0 && c <= 1114111)
			{
				if (c > 55296)
				{
					return c < 57343;
				}
				return false;
			}
			return true;
		}
	}
	public static class Punycode
	{
		private const int PunycodeBase = 36;

		private const int Tmin = 1;

		private const int Tmax = 26;

		private static readonly string acePrefix = "xn--";

		private static readonly char[] possibleDots = new char[4] { '.', '。', '.', '。' };

		public static IDictionary<char, char> Symbols = new Dictionary<char, char>
		{
			{ '。', '.' },
			{ '.', '.' },
			{ 'G', 'g' },
			{ 'o', 'o' },
			{ 'c', 'c' },
			{ 'X', 'x' },
			{ '0', '0' },
			{ '1', '1' },
			{ '2', '2' },
			{ '5', '5' },
			{ '⁰', '0' },
			{ '¹', '1' },
			{ '²', '2' },
			{ '³', '3' },
			{ '⁴', '4' },
			{ '⁵', '5' },
			{ '⁶', '6' },
			{ '⁷', '7' },
			{ '⁸', '8' },
			{ '⁹', '9' },
			{ '₀', '0' },
			{ '₁', '1' },
			{ '₂', '2' },
			{ '₃', '3' },
			{ '₄', '4' },
			{ '₅', '5' },
			{ '₆', '6' },
			{ '₇', '7' },
			{ '₈', '8' },
			{ '₉', '9' },
			{ 'ᵃ', 'a' },
			{ 'ᵇ', 'b' },
			{ 'ᶜ', 'c' },
			{ 'ᵈ', 'd' },
			{ 'ᵉ', 'e' },
			{ 'ᶠ', 'f' },
			{ 'ᵍ', 'g' },
			{ 'ʰ', 'h' },
			{ 'ⁱ', 'i' },
			{ 'ʲ', 'j' },
			{ 'ᵏ', 'k' },
			{ 'ˡ', 'l' },
			{ 'ᵐ', 'm' },
			{ 'ⁿ', 'n' },
			{ 'ᵒ', 'o' },
			{ 'ᵖ', 'p' },
			{ 'ʳ', 'r' },
			{ 'ˢ', 's' },
			{ 'ᵗ', 't' },
			{ 'ᵘ', 'u' },
			{ 'ᵛ', 'v' },
			{ 'ʷ', 'w' },
			{ 'ˣ', 'x' },
			{ 'ʸ', 'y' },
			{ 'ᶻ', 'z' },
			{ 'ᴬ', 'A' },
			{ 'ᴮ', 'B' },
			{ 'ᴰ', 'D' },
			{ 'ᴱ', 'E' },
			{ 'ᴳ', 'G' },
			{ 'ᴴ', 'H' },
			{ 'ᴵ', 'I' },
			{ 'ᴶ', 'J' },
			{ 'ᴷ', 'K' },
			{ 'ᴸ', 'L' },
			{ 'ᴹ', 'M' },
			{ 'ᴺ', 'N' },
			{ 'ᴼ', 'O' },
			{ 'ᴾ', 'P' },
			{ 'ᴿ', 'R' },
			{ 'ᵀ', 'T' },
			{ 'ᵁ', 'U' },
			{ 'ⱽ', 'V' },
			{ 'ᵂ', 'W' }
		};

		public static string Encode(string text)
		{
			if (text.Length == 0)
			{
				return text;
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length);
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			while (num < text.Length)
			{
				num = text.IndexOfAny(possibleDots, num2);
				if (num < 0)
				{
					num = text.Length;
				}
				if (num == num2)
				{
					break;
				}
				stringBuilder.Append(acePrefix);
				int num4 = 0;
				int num5 = 0;
				for (num4 = num2; num4 < num; num4++)
				{
					if (text[num4] < '\u0080')
					{
						stringBuilder.Append(EncodeBasic(text[num4]));
						num5++;
					}
					else if (char.IsSurrogatePair(text, num4))
					{
						num4++;
					}
				}
				int num6 = num5;
				if (num6 == num - num2)
				{
					stringBuilder.Remove(num3, acePrefix.Length);
				}
				else
				{
					if (text.Length - num2 >= acePrefix.Length && text.Substring(num2, acePrefix.Length).Isi(acePrefix))
					{
						break;
					}
					int num7 = 0;
					if (num6 > 0)
					{
						stringBuilder.Append('-');
					}
					int num8 = 128;
					int num9 = 0;
					int num10 = 72;
					while (num5 < num - num2)
					{
						int num11 = 0;
						int num12 = 0;
						int num13 = 0;
						num12 = 134217727;
						for (num11 = num2; num11 < num; num11 += ((!IsSupplementary(num13)) ? 1 : 2))
						{
							num13 = char.ConvertToUtf32(text, num11);
							if (num13 >= num8 && num13 < num12)
							{
								num12 = num13;
							}
						}
						num9 += (num12 - num8) * (num5 - num7 + 1);
						num8 = num12;
						for (num11 = num2; num11 < num; num11 += ((!IsSupplementary(num13)) ? 1 : 2))
						{
							num13 = char.ConvertToUtf32(text, num11);
							if (num13 < num8)
							{
								num9++;
							}
							else
							{
								if (num13 != num8)
								{
									continue;
								}
								int num14 = num9;
								int num15 = 36;
								while (true)
								{
									int num16 = ((num15 <= num10) ? 1 : ((num15 >= num10 + 26) ? 26 : (num15 - num10)));
									if (num14 < num16)
									{
										break;
									}
									stringBuilder.Append(EncodeDigit(num16 + (num14 - num16) % (36 - num16)));
									num14 = (num14 - num16) / (36 - num16);
									num15 += 36;
								}
								stringBuilder.Append(EncodeDigit(num14));
								num10 = AdaptChar(num9, num5 - num7 + 1, num5 == num6);
								num9 = 0;
								num5++;
								if (IsSupplementary(num12))
								{
									num5++;
									num7++;
								}
							}
						}
						num9++;
						num8++;
					}
				}
				if (stringBuilder.Length - num3 > 63)
				{
					throw new ArgumentException();
				}
				if (num != text.Length)
				{
					stringBuilder.Append(possibleDots[0]);
				}
				num2 = num + 1;
				num3 = stringBuilder.Length;
			}
			int num17 = ((!IsDot(text[text.Length - 1])) ? 1 : 0);
			int num18 = 255 - num17;
			if (stringBuilder.Length > num18)
			{
				stringBuilder.Remove(num18, stringBuilder.Length - num18);
			}
			return stringBuilder.ToString();
		}

		private static bool IsSupplementary(int test)
		{
			return test >= 65536;
		}

		private static bool IsDot(char c)
		{
			for (int i = 0; i < possibleDots.Length; i++)
			{
				if (possibleDots[i] == c)
				{
					return true;
				}
			}
			return false;
		}

		private static char EncodeDigit(int digit)
		{
			if (digit > 25)
			{
				return (char)(digit + 22);
			}
			return (char)(digit + 97);
		}

		private static char EncodeBasic(char character)
		{
			if (char.IsUpper(character))
			{
				character = (char)(character + 32);
			}
			return character;
		}

		private static int AdaptChar(int delta, int numPoints, bool firstTime)
		{
			uint num = 0u;
			delta = (firstTime ? (delta / 700) : (delta / 2));
			delta += delta / numPoints;
			num = 0u;
			while (delta > 455)
			{
				delta /= 35;
				num += 36;
			}
			return (int)(num + 36 * delta / (delta + 38));
		}
	}
	public static class StringBuilderPool
	{
		private static readonly Stack<StringBuilder> _builder = new Stack<StringBuilder>();

		private static readonly object _lock = new object();

		private static int _count = 4;

		private static int _limit = 85000;

		public static int MaxCount
		{
			get
			{
				return _count;
			}
			set
			{
				_count = Math.Max(1, value);
			}
		}

		public static int SizeLimit
		{
			get
			{
				return _limit;
			}
			set
			{
				_limit = Math.Max(1024, value);
			}
		}

		public static StringBuilder Obtain()
		{
			lock (_lock)
			{
				if (_builder.Count == 0)
				{
					return new StringBuilder(1024);
				}
				return _builder.Pop().Clear();
			}
		}

		public static string ToPool(this StringBuilder sb)
		{
			string result = sb.ToString();
			sb.ReturnToPool();
			return result;
		}

		internal static void ReturnToPool(this StringBuilder sb)
		{
			lock (_lock)
			{
				int count = _builder.Count;
				if (sb.Capacity <= _limit)
				{
					if (count == _count)
					{
						DropMinimum(sb);
					}
					else if (count < Math.Min(2, _count) || _builder.Peek().Capacity < sb.Capacity)
					{
						_builder.Push(sb);
					}
				}
			}
		}

		private static void DropMinimum(StringBuilder sb)
		{
			int capacity = sb.Capacity;
			StringBuilder[] instances = _builder.ToArray();
			int num = FindIndex(instances, capacity);
			if (num > -1)
			{
				RebuildPool(sb, instances, num);
			}
		}

		private static void RebuildPool(StringBuilder sb, StringBuilder[] instances, int index)
		{
			_builder.Clear();
			int num = instances.Length - 1;
			while (num > index)
			{
				_builder.Push(instances[num--]);
			}
			while (num > 0)
			{
				_builder.Push(instances[--num]);
			}
			_builder.Push(sb);
		}

		private static int FindIndex(StringBuilder[] instances, int minimum)
		{
			int result = -1;
			for (int i = 0; i < instances.Length; i++)
			{
				int capacity = instances[i].Capacity;
				if (capacity < minimum)
				{
					minimum = capacity;
					result = i;
				}
			}
			return result;
		}
	}
	public static class StringExtensions
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Has([NotNullWhen(true)] this string? value, char chr, int index = 0)
		{
			if (value != null && value.Length > index)
			{
				return value[index] == chr;
			}
			return false;
		}

		internal static string GetCompatiblity(this QuirksMode mode)
		{
			string result = "CSS1Compat";
			string text = mode.ToString();
			if (text != null)
			{
				FieldInfo field = typeof(QuirksMode).GetField(text);
				if (field != null)
				{
					DomDescriptionAttribute customAttribute = field.GetCustomAttribute<DomDescriptionAttribute>();
					if (customAttribute != null)
					{
						result = customAttribute.Description;
					}
				}
			}
			return result;
		}

		public static string HtmlLower(this string value)
		{
			int length = value.Length;
			for (int i = 0; i < length; i++)
			{
				char c = value[i];
				if (!c.IsUppercaseAscii())
				{
					continue;
				}
				char[] array = new char[length];
				for (int j = 0; j < i; j++)
				{
					array[j] = value[j];
				}
				array[i] = char.ToLowerInvariant(c);
				for (int k = i + 1; k < length; k++)
				{
					c = value[k];
					if (c.IsUppercaseAscii())
					{
						c = char.ToLowerInvariant(c);
					}
					array[k] = c;
				}
				return new string(array);
			}
			return value;
		}

		public static Sandboxes ParseSecuritySettings(this string value, bool allowFullscreen = false)
		{
			string[] list = value.SplitSpaces();
			Sandboxes sandboxes = Sandboxes.Navigation | Sandboxes.Plugins | Sandboxes.DocumentDomain;
			if (!list.Contains("allow-popups", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.AuxiliaryNavigation;
			}
			if (!list.Contains("allow-top-navigation", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.TopLevelNavigation;
			}
			if (!list.Contains("allow-same-origin", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Origin;
			}
			if (!list.Contains("allow-forms", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Forms;
			}
			if (!list.Contains("allow-pointer-lock", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.PointerLock;
			}
			if (!list.Contains("allow-scripts", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Scripts;
				sandboxes |= Sandboxes.AutomaticFeatures;
			}
			if (!list.Contains("allow-presentation", StringComparison.OrdinalIgnoreCase))
			{
				sandboxes |= Sandboxes.Presentation;
			}
			if (!allowFullscreen)
			{
				sandboxes |= Sandboxes.Fullscreen;
			}
			return sandboxes;
		}

		public static T ToEnum<T>(this string? value, T defaultValue) where T : struct, Enum
		{
			if (!string.IsNullOrEmpty(value) && Enum.TryParse<T>(value, ignoreCase: true, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static double ToDouble(this string? value, double defaultValue = 0.0)
		{
			if (!string.IsNullOrEmpty(value) && double.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static int ToInteger(this string? value, int defaultValue = 0)
		{
			if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static uint ToInteger(this string? value, uint defaultValue = 0u)
		{
			if (!string.IsNullOrEmpty(value) && uint.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static bool ToBoolean(this string? value, bool defaultValue = false)
		{
			if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static string ReplaceFirst(this string text, string search, string replace)
		{
			int num = text.IndexOf(search);
			if (num < 0)
			{
				return text;
			}
			return text.Substring(0, num) + replace + text.Substring(num + search.Length);
		}

		public static string CollapseAndStrip(this string str)
		{
			if (str.Length == 0)
			{
				return str;
			}
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			bool flag = true;
			int num = 0;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i].IsSpaceCharacter())
				{
					if (!flag)
					{
						flag = true;
						array[num++] = ' ';
					}
				}
				else
				{
					flag = false;
					array[num++] = str[i];
				}
			}
			if (flag && num > 0)
			{
				num--;
			}
			string result = new string(array, 0, num);
			ArrayPool<char>.Shared.Return(array);
			return result;
		}

		public static string Collapse(this string str)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			bool flag = false;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i].IsSpaceCharacter())
				{
					if (!flag)
					{
						stringBuilder.Append(' ');
						flag = true;
					}
				}
				else
				{
					flag = false;
					stringBuilder.Append(str[i]);
				}
			}
			return stringBuilder.ToPool();
		}

		public static bool Contains(this string[] list, string element, StringComparison comparison = StringComparison.Ordinal)
		{
			int num = list.Length;
			for (int i = 0; i < num; i++)
			{
				if (list[i].Equals(element, comparison))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsCustomElement(this string tag)
		{
			if (tag.IndexOf('-') != -1 && !TagNames.DisallowedCustomElementNames.Contains(tag))
			{
				int length = tag.Length;
				for (int i = 0; i < length; i++)
				{
					if (!tag[i].IsCustomElementName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Is(this string? current, string? other)
		{
			return string.Equals(current, other, StringComparison.Ordinal);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool Isi(this string? current, string? other)
		{
			return string.Equals(current, other, StringComparison.OrdinalIgnoreCase);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string? element, string item1, string item2)
		{
			if (!element.Is(item1))
			{
				return element.Is(item2);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3)
		{
			if (!element.Is(item1) && !element.Is(item2))
			{
				return element.Is(item3);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4)
		{
			if (!element.Is(item1) && !element.Is(item2) && !element.Is(item3))
			{
				return element.Is(item4);
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsOneOf(this string element, string item1, string item2, string item3, string item4, string item5)
		{
			if (!element.Is(item1) && !element.Is(item2) && !element.Is(item3) && !element.Is(item4))
			{
				return element.Is(item5);
			}
			return true;
		}

		public static string StripLineBreaks(this string str)
		{
			char[] array = str.ToCharArray();
			int num = 0;
			int num2 = array.Length;
			int num3 = 0;
			while (num3 < num2)
			{
				array[num3] = array[num3 + num];
				if (array[num3].IsLineBreak())
				{
					num++;
					num2--;
				}
				else
				{
					num3++;
				}
			}
			return new string(array, 0, num2);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string StripLeadingTrailingSpaces(this string str)
		{
			int i = 0;
			int num = str.Length - 1;
			for (; i < str.Length && str[i].IsSpaceCharacter(); i++)
			{
			}
			while (num > i && str[num].IsSpaceCharacter())
			{
				num--;
			}
			return str.Substring(i, 1 + num - i);
		}

		public static string[] SplitWithoutTrimming(this string str, char c)
		{
			List<string> list = new List<string>();
			int num = 0;
			int length = str.Length;
			for (int i = 0; i < length; i++)
			{
				if (str[i] == c)
				{
					if (i > num)
					{
						list.Add(str.Substring(num, i - num));
					}
					num = i + 1;
				}
			}
			if (length > num)
			{
				list.Add(str.Substring(num, length - num));
			}
			return list.ToArray();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string[] SplitCommas(this string str)
		{
			return str.SplitWithTrimming(',');
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool HasHyphen(this string str, string value, StringComparison comparison = StringComparison.Ordinal)
		{
			if (!string.Equals(str, value, comparison))
			{
				if (str.Length > value.Length && str.StartsWith(value, comparison))
				{
					return str[value.Length] == '-';
				}
				return false;
			}
			return true;
		}

		public static string[] SplitSpaces(this string str)
		{
			List<string> list = new List<string>();
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			int num = 0;
			for (int i = 0; i <= str.Length; i++)
			{
				if (i == str.Length || str[i].IsSpaceCharacter())
				{
					if (num > 0)
					{
						string text = new string(array, 0, num).StripLeadingTrailingSpaces();
						if (text.Length != 0)
						{
							list.Add(text);
						}
						num = 0;
					}
				}
				else
				{
					array[num] = str[i];
					num++;
				}
			}
			ArrayPool<char>.Shared.Return(array);
			return list.ToArray();
		}

		public static string[] SplitWithTrimming(this string str, char ch)
		{
			List<string> list = new List<string>();
			char[] array = ArrayPool<char>.Shared.Rent(str.Length);
			int num = 0;
			for (int i = 0; i <= str.Length; i++)
			{
				if (i == str.Length || str[i] == ch)
				{
					if (num > 0)
					{
						string text = new string(array, 0, num).StripLeadingTrailingSpaces();
						if (text.Length != 0)
						{
							list.Add(text);
						}
						num = 0;
					}
				}
				else
				{
					array[num] = str[i];
					num++;
				}
			}
			ArrayPool<char>.Shared.Return(array);
			return list.ToArray();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromHex(this string s)
		{
			return int.Parse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromDec(this string s)
		{
			return int.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static string HtmlEncode(this string value, Encoding encoding)
		{
			return value;
		}

		public static string CssString(this string value)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			stringBuilder.Append('"');
			if (!string.IsNullOrEmpty(value))
			{
				int length = value.Length;
				for (int i = 0; i < length; i++)
				{
					char c = value[i];
					switch (c)
					{
					case '\0':
						stringBuilder.ReturnToPool();
						throw new DomException(DomError.InvalidCharacter);
					case '"':
					case '\\':
						stringBuilder.Append('\\').Append(c);
						continue;
					}
					if (c.IsInRange(1, 31) || c == '{')
					{
						stringBuilder.Append('\\').Append(c.ToHex()).Append((i + 1 != length) ? " " : "");
					}
					else
					{
						stringBuilder.Append(c);
					}
				}
			}
			stringBuilder.Append('"');
			return stringBuilder.ToPool();
		}

		public static string CssFunction(this string value, string argument)
		{
			return value + "(" + argument + ")";
		}

		public static string UrlEncode(this byte[] content)
		{
			StringBuilder stringBuilder = StringBuilderPool.Obtain();
			int num = content.Length;
			for (int i = 0; i < num; i++)
			{
				char c = (char)content[i];
				switch (c)
				{
				case ' ':
					stringBuilder.Append('+');
					break;
				default:
					if (!c.IsAlphanumericAscii())
					{
						stringBuilder.Append('%').Append(content[i].ToString("X2"));
						break;
					}
					goto case '*';
				case '*':
				case '-':
				case '.':
				case '_':
				case '~':
					stringBuilder.Append(c);
					break;
				}
			}
			return stringBuilder.ToPool();
		}

		public static byte[] UrlDecode(this string value)
		{
			MemoryStream memoryStream = new MemoryStream();
			int length = value.Length;
			for (int i = 0; i < length; i++)
			{
				char c = value[i];
				switch (c)
				{
				case '+':
				{
					byte value4 = 32;
					memoryStream.WriteByte(value4);
					break;
				}
				case '%':
				{
					if (i + 2 >= length)
					{
						throw new FormatException();
					}
					byte value3 = (byte)(16 * value[++i].FromHex() + value[++i].FromHex());
					memoryStream.WriteByte(value3);
					break;
				}
				default:
				{
					byte value2 = (byte)c;
					memoryStream.WriteByte(value2);
					break;
				}
				}
			}
			return memoryStream.ToArray();
		}

		public static string NormalizeLineEndings(this string value)
		{
			if (!string.IsNullOrEmpty(value))
			{
				StringBuilder stringBuilder = StringBuilderPool.Obtain();
				bool flag = false;
				int length = value.Length;
				for (int i = 0; i < length; i++)
				{
					char c = value[i];
					bool flag2 = c == '\n';
					if (flag && !flag2)
					{
						stringBuilder.Append('\n');
					}
					else if (!flag && flag2)
					{
						stringBuilder.Append('\r');
					}
					flag = c == '\r';
					stringBuilder.Append(c);
				}
				if (flag)
				{
					stringBuilder.Append('\n');
				}
				return stringBuilder.ToPool();
			}
			return value;
		}

		public static string? ToEncodingType(this string? encType)
		{
			if (!encType.Isi(MimeTypeNames.Plain) && !encType.Isi(MimeTypeNames.MultipartForm) && !encType.Isi(MimeTypeNames.ApplicationJson))
			{
				return null;
			}
			return encType?.ToLowerInvariant();
		}

		public static string? ToFormMethod(this string? method)
		{
			if (!method.Isi(FormMethodNames.Get) && !method.Isi(FormMethodNames.Post) && !method.Isi(FormMethodNames.Dialog))
			{
				return null;
			}
			return method?.ToLowerInvariant();
		}
	}
	public sealed class StringSource
	{
		private readonly string _content;

		private readonly int _last;

		private int _index;

		private char _current;

		public char Current => _current;

		public bool IsDone => _current == '\uffff';

		public int Index => _index;

		public string Content => _content;

		public StringSource(string content)
		{
			_content = content ?? string.Empty;
			_last = _content.Length - 1;
			_index = 0;
			_current = ((_last == -1) ? '\uffff' : content[0]);
		}

		public char Next()
		{
			if (_index == _last)
			{
				_current = '\uffff';
				_index = _content.Length;
			}
			else if (_index < _content.Length)
			{
				_current = _content[++_index];
			}
			return _current;
		}

		public char Back()
		{
			if (_index > 0)
			{
				_current = _content[--_index];
			}
			return _current;
		}
	}
	public static class StringSourceExtensions
	{
		public static char SkipSpaces(this StringSource source)
		{
			char c = source.Current;
			while (c.IsSpaceCharacter())
			{
				c = source.Next();
			}
			return c;
		}

		public static char Next(this StringSource source, int n)
		{
			for (int i = 0; i < n; i++)
			{
				source.Next();
			}
			return source.Current;
		}

		public static char Back(this StringSource source, int n)
		{
			for (int i = 0; i < n; i++)
			{
				source.Back();
			}
			return source.Current;
		}

		public static char Peek(this StringSource source)
		{
			char result = source.Next();
			source.Back();
			return result;
		}
	}
	public static class Symbols
	{
		public const char EndOfFile = '\uffff';

		public const char Tilde = '~';

		public const char Pipe = '|';

		public const char Null = '\0';

		public const char Ampersand = '&';

		public const char Num = '#';

		public const char Dollar = '$';

		public const char Semicolon = ';';

		public const char Asterisk = '*';

		public const char Equality = '=';

		public const char Plus = '+';

		public const char Minus = '-';

		public const char Comma = ',';

		public const char Dot = '.';

		public const char Accent = '^';

		public const char At = '@';

		public const char LessThan = '<';

		public const char GreaterThan = '>';

		public const char SingleQuote = '\'';

		public const char DoubleQuote = '"';

		public const char CurvedQuote = '`';

		public const char QuestionMark = '?';

		public const char Tab = '\t';

		public const char LineFeed = '\n';

		public const char CarriageReturn = '\r';

		public const char FormFeed = '\f';

		public const char Space = ' ';

		public const char Solidus = '/';

		public const char NoBreakSpace = '\u00a0';

		public const char ReverseSolidus = '\\';

		public const char Colon = ':';

		public const char ExclamationMark = '!';

		public const char Replacement = '\ufffd';

		public const char Underscore = '_';

		public const char RoundBracketOpen = '(';

		public const char RoundBracketClose = ')';

		public const char SquareBracketOpen = '[';

		public const char SquareBracketClose = ']';

		public const char CurlyBracketOpen = '{';

		public const char CurlyBracketClose = '}';

		public const char Percent = '%';

		public const int MaximumCodepoint = 1114111;
	}
	public static class TextEncoding
	{
		public static readonly Encoding Utf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

		public static readonly Encoding Utf16Be = new UnicodeEncoding(bigEndian: true, byteOrderMark: false);

		public static readonly Encoding Utf16Le = new UnicodeEncoding(bigEndian: false, byteOrderMark: false);

		public static readonly Encoding Utf32Le = GetEncoding("UTF-32LE");

		public static readonly Encoding Utf32Be = GetEncoding("UTF-32BE");

		public static readonly Encoding Gb18030 = GetEncoding("GB18030");

		public static readonly Encoding Big5 = GetEncoding("big5");

		public static readonly Encoding Windows874 = GetEncoding("windows-874");

		public static readonly Encoding Windows1250 = GetEncoding("windows-1250");

		public static readonly Encoding Windows1251 = GetEncoding("windows-1251");

		public static readonly Encoding Windows1252 = GetEncoding("windows-1252");

		public static readonly Encoding Windows1253 = GetEncoding("windows-1253");

		public static readonly Encoding Windows1254 = GetEncoding("windows-1254");

		public static readonly Encoding Windows1255 = GetEncoding("windows-1255");

		public static readonly Encoding Windows1256 = GetEncoding("windows-1256");

		public static readonly Encoding Windows1257 = GetEncoding("windows-1257");

		public static readonly Encoding Windows1258 = GetEncoding("windows-1258");

		public static readonly Encoding Latin2 = GetEncoding("iso-8859-2");

		public static readonly Encoding Latin3 = GetEncoding("iso-8859-3");

		public static readonly Encoding Latin4 = GetEncoding("iso-8859-4");

		public static readonly Encoding Latin5 = GetEncoding("iso-8859-5");

		public static readonly Encoding Latin13 = GetEncoding("iso-8859-13");

		public static readonly Encoding UsAscii = GetEncoding("us-ascii");

		public static readonly Encoding Korean = GetEncoding("ks_c_5601-1987");

		private static readonly Dictionary<string, Encoding> encodings = CreateEncodings();

		public static bool IsUnicode(this Encoding encoding)
		{
			if (encoding != Utf16Be)
			{
				return encoding == Utf16Le;
			}
			return true;
		}

		public static Encoding? Parse(string content)
		{
			string charset = string.Empty;
			int num = 0;
			for (int i = num; i < content.Length - 7; i++)
			{
				if (content.Substring(i).StartsWith(AttributeNames.Charset, StringComparison.OrdinalIgnoreCase))
				{
					num = i + 7;
					break;
				}
			}
			if (num > 0 && num < content.Length)
			{
				for (int j = num; j < content.Length - 1 && content[j].IsSpaceCharacter(); j++)
				{
					num++;
				}
				if (content[num] != '=')
				{
					return Parse(content.Substring(num));
				}
				num++;
				for (int k = num; k < content.Length && content[k].IsSpaceCharacter(); k++)
				{
					num++;
				}
				if (num < content.Length)
				{
					if (content[num] == '"')
					{
						content = content.Substring(num + 1);
						int num2 = content.IndexOf('"');
						if (num2 != -1)
						{
							charset = content.Substring(0, num2);
						}
					}
					else if (content[num] == '\'')
					{
						content = content.Substring(num + 1);
						int num3 = content.IndexOf('\'');
						if (num3 != -1)
						{
							charset = content.Substring(0, num3);
						}
					}
					else
					{
						content = content.Substring(num);
						int num4 = 0;
						for (int l = 0; l < content.Length && !content[l].IsSpaceCharacter() && content[l] != ';'; l++)
						{
							num4++;
						}
						charset = content.Substring(0, num4);
					}
				}
			}
			if (!IsSupported(charset))
			{
				return null;
			}
			return Resolve(charset);
		}

		public static bool IsSupported(string charset)
		{
			return encodings.ContainsKey(charset);
		}

		public static Encoding Resolve(string? charset)
		{
			if (charset != null && encodings.TryGetValue(charset, out Encoding value))
			{
				return value;
			}
			return Utf8;
		}

		private static Encoding GetEncoding(string name, Encoding? fallback = null)
		{
			try
			{
				return Encoding.GetEncoding(name);
			}
			catch (Exception)
			{
				return fallback ?? Utf8;
			}
		}

		private static Dictionary<string, Encoding> CreateEncodings()
		{
			Dictionary<string, Encoding> obj = new Dictionary<string, Encoding>(StringComparer.OrdinalIgnoreCase)
			{
				{ "unicode-1-1-utf-8", Utf8 },
				{ "utf-8", Utf8 },
				{ "utf8", Utf8 },
				{ "utf-16be", Utf16Be },
				{ "utf-16", Utf16Le },
				{ "utf-16le", Utf16Le },
				{ "dos-874", Windows874 },
				{ "iso-8859-11", Windows874 },
				{ "iso8859-11", Windows874 },
				{ "iso885911", Windows874 },
				{ "tis-620", Windows874 },
				{ "windows-874", Windows874 },
				{ "cp1250", Windows1250 },
				{ "windows-1250", Windows1250 },
				{ "x-cp1250", Windows1250 },
				{ "cp1251", Windows1251 },
				{ "windows-1251", Windows1251 },
				{ "x-cp1251", Windows1251 },
				{ "x-user-defined", Windows1252 },
				{ "ansi_x3.4-1968", Windows1252 },
				{ "ascii", Windows1252 },
				{ "cp1252", Windows1252 },
				{ "cp819", Windows1252 },
				{ "csisolatin1", Windows1252 },
				{ "ibm819", Windows1252 },
				{ "iso-8859-1", Windows1252 },
				{ "iso-ir-100", Windows1252 },
				{ "iso8859-1", Windows1252 },
				{ "iso88591", Windows1252 },
				{ "iso_8859-1", Windows1252 },
				{ "iso_8859-1:1987", Windows1252 },
				{ "l1", Windows1252 },
				{ "latin1", Windows1252 },
				{ "us-ascii", Windows1252 },
				{ "windows-1252", Windows1252 },
				{ "x-cp1252", Windows1252 },
				{ "cp1253", Windows1253 },
				{ "windows-1253", Windows1253 },
				{ "x-cp1253", Windows1253 },
				{ "cp1254", Windows1254 },
				{ "csisolatin5", Windows1254 },
				{ "iso-8859-9", Windows1254 },
				{ "iso-ir-148", Windows1254 },
				{ "iso8859-9", Windows1254 },
				{ "iso88599", Windows1254 },
				{ "iso_8859-9", Windows1254 },
				{ "iso_8859-9:1989", Windows1254 },
				{ "l5", Windows1254 },
				{ "latin5", Windows1254 },
				{ "windows-1254", Windows1254 },
				{ "x-cp1254", Windows1254 },
				{ "cp1255", Windows1255 },
				{ "windows-1255", Windows1255 },
				{ "x-cp1255", Windows1255 },
				{ "cp1256", Windows1256 },
				{ "windows-1256", Windows1256 },
				{ "x-cp1256", Windows1256 },
				{ "cp1257", Windows1257 },
				{ "windows-1257", Windows1257 },
				{ "x-cp1257", Windows1257 },
				{ "cp1258", Windows1258 },
				{ "windows-1258", Windows1258 },
				{ "x-cp1258", Windows1258 }
			};
			Encoding encoding = GetEncoding("macintosh");
			obj.Add("csmacintosh", encoding);
			obj.Add("mac", encoding);
			obj.Add("macintosh", encoding);
			obj.Add("x-mac-roman", encoding);
			Encoding encoding2 = GetEncoding("x-mac-cyrillic");
			obj.Add("x-mac-cyrillic", encoding2);
			obj.Add("x-mac-ukrainian", encoding2);
			Encoding encoding3 = GetEncoding("cp866");
			obj.Add("866", encoding3);
			obj.Add("cp866", encoding3);
			obj.Add("csibm866", encoding3);
			obj.Add("ibm866", encoding3);
			obj.Add("csisolatin2", Latin2);
			obj.Add("iso-8859-2", Latin2);
			obj.Add("iso-ir-101", Latin2);
			obj.Add("iso8859-2", Latin2);
			obj.Add("iso88592", Latin2);
			obj.Add("iso_8859-2", Latin2);
			obj.Add("iso_8859-2:1987", Latin2);
			obj.Add("l2", Latin2);
			obj.Add("latin2", Latin2);
			obj.Add("csisolatin3", Latin3);
			obj.Add("iso-8859-3", Latin3);
			obj.Add("iso-ir-109", Latin3);
			obj.Add("iso8859-3", Latin3);
			obj.Add("iso88593", Latin3);
			obj.Add("iso_8859-3", Latin3);
			obj.Add("iso_8859-3:1988", Latin3);
			obj.Add("l3", Latin3);
			obj.Add("latin3", Latin3);
			obj.Add("csisolatin4", Latin4);
			obj.Add("iso-8859-4", Latin4);
			obj.Add("iso-ir-110", Latin4);
			obj.Add("iso8859-4", Latin4);
			obj.Add("iso88594", Latin4);
			obj.Add("iso_8859-4", Latin4);
			obj.Add("iso_8859-4:1988", Latin4);
			obj.Add("l4", Latin4);
			obj.Add("latin4", Latin4);
			obj.Add("csisolatincyrillic", Latin5);
			obj.Add("cyrillic", Latin5);
			obj.Add("iso-8859-5", Latin5);
			obj.Add("iso-ir-144", Latin5);
			obj.Add("iso8859-5", Latin5);
			obj.Add("iso88595", Latin5);
			obj.Add("iso_8859-5", Latin5);
			obj.Add("iso_8859-5:1988", Latin5);
			Encoding encoding4 = GetEncoding("iso-8859-6");
			obj.Add("arabic", encoding4);
			obj.Add("asmo-708", encoding4);
			obj.Add("csiso88596e", encoding4);
			obj.Add("csiso88596i", encoding4);
			obj.Add("csisolatinarabic", encoding4);
			obj.Add("ecma-114", encoding4);
			obj.Add("iso-8859-6", encoding4);
			obj.Add("iso-8859-6-e", encoding4);
			obj.Add("iso-8859-6-i", encoding4);
			obj.Add("iso-ir-127", encoding4);
			obj.Add("iso8859-6", encoding4);
			obj.Add("iso88596", encoding4);
			obj.Add("iso_8859-6", encoding4);
			obj.Add("iso_8859-6:1987", encoding4);
			Encoding encoding5 = GetEncoding("iso-8859-7");
			obj.Add("csisolatingreek", encoding5);
			obj.Add("ecma-118", encoding5);
			obj.Add("elot_928", encoding5);
			obj.Add("greek", encoding5);
			obj.Add("greek8", encoding5);
			obj.Add("iso-8859-7", encoding5);
			obj.Add("iso-ir-126", encoding5);
			obj.Add("iso8859-7", encoding5);
			obj.Add("iso88597", encoding5);
			obj.Add("iso_8859-7", encoding5);
			obj.Add("iso_8859-7:1987", encoding5);
			obj.Add("sun_eu_greek", encoding5);
			Encoding encoding6 = GetEncoding("iso-8859-8");
			obj.Add("csiso88598e", encoding6);
			obj.Add("csisolatinhebrew", encoding6);
			obj.Add("hebrew", encoding6);
			obj.Add("iso-8859-8", encoding6);
			obj.Add("iso-8859-8-e", encoding6);
			obj.Add("iso-ir-138", encoding6);
			obj.Add("iso8859-8", encoding6);
			obj.Add("iso88598", encoding6);
			obj.Add("iso_8859-8", encoding6);
			obj.Add("iso_8859-8:1988", encoding6);
			obj.Add("visual", encoding6);
			Encoding encoding7 = GetEncoding("iso-8859-8-i");
			obj.Add("csiso88598i", encoding7);
			obj.Add("iso-8859-8-i", encoding7);
			obj.Add("logical", encoding7);
			Encoding encoding8 = GetEncoding("iso-8859-13");
			obj.Add("iso-8859-13", encoding8);
			obj.Add("iso8859-13", encoding8);
			obj.Add("iso885913", encoding8);
			Encoding encoding9 = GetEncoding("iso-8859-15");
			obj.Add("csisolatin9", encoding9);
			obj.Add("iso-8859-15", encoding9);
			obj.Add("iso8859-15", encoding9);
			obj.Add("iso885915", encoding9);
			obj.Add("iso_8859-15", encoding9);
			obj.Add("l9", encoding9);
			Encoding encoding10 = GetEncoding("koi8-r");
			obj.Add("cskoi8r", encoding10);
			obj.Add("koi", encoding10);
			obj.Add("koi8", encoding10);
			obj.Add("koi8-r", encoding10);
			obj.Add("koi8_r", encoding10);
			obj.Add("koi8-u", GetEncoding("koi8-u"));
			Encoding encoding11 = GetEncoding("GB18030", GetEncoding("x-cp20936"));
			obj.Add("chinese", encoding11);
			obj.Add("csgb2312", encoding11);
			obj.Add("csiso58gb231280", encoding11);
			obj.Add("gb2312", encoding11);
			obj.Add("gb_2312", encoding11);
			obj.Add("gb_2312-80", encoding11);
			obj.Add("gbk", encoding11);
			obj.Add("iso-ir-58", encoding11);
			obj.Add("x-gbk", encoding11);
			obj.Add("hz-gb-2312", GetEncoding("hz-gb-2312"));
			obj.Add("gb18030", Gb18030);
			Encoding encoding12 = GetEncoding("x-cp50227");
			obj.Add("x-cp50227", encoding12);
			obj.Add("iso-22-cn", encoding12);
			obj.Add("big5", Big5);
			obj.Add("big5-hkscs", Big5);
			obj.Add("cn-big5", Big5);
			obj.Add("csbig5", Big5);
			obj.Add("x-x-big5", Big5);
			Encoding encoding13 = GetEncoding("iso-2022-jp");
			obj.Add("csiso2022jp", encoding13);
			obj.Add("iso-2022-jp", encoding13);
			Encoding encoding14 = GetEncoding("iso-2022-kr");
			obj.Add("csiso2022kr", encoding14);
			obj.Add("iso-2022-kr", encoding14);
			Encoding encoding15 = GetEncoding("iso-2022-cn");
			obj.Add("iso-2022-cn", encoding15);
			obj.Add("iso-2022-cn-ext", encoding15);
			obj.Add("shift_jis", GetEncoding("shift_jis"));
			Encoding encoding16 = GetEncoding("euc-jp");
			obj.Add("euc-jp", encoding16);
			Encoding encoding17 = GetEncoding("euc-kr");
			obj.Add("euc-kr", encoding17);
			return obj;
		}
	}
	public readonly struct TextPosition : IEquatable<TextPosition>, IComparable<TextPosition>
	{
		public static readonly TextPosition Empty;

		private readonly ushort _line;

		private readonly ushort _column;

		private readonly int _position;

		public int Line => _line;

		public int Column => _column;

		public int Position => _position;

		public int Index => _position - 1;

		public TextPosition(ushort line, ushort column, int position)
		{
			_line = line;
			_column = column;
			_position = position;
		}

		public TextPosition Shift(int columns)
		{
			return new TextPosition(_line, (ushort)(_column + columns), _position + columns);
		}

		public TextPosition After(char chr)
		{
			ushort num = _line;
			ushort num2 = _column;
			if (chr == '\n')
			{
				num++;
				num2 = 0;
			}
			return new TextPosition(num, ++num2, _position + 1);
		}

		public TextPosition After(string str)
		{
			ushort num = _line;
			ushort num2 = _column;
			for (int i = 0; i < str.Length; i++)
			{
				if (str[i] == '\n')
				{
					num++;
					num2 = 0;
				}
				num2++;
			}
			return new TextPosition(num, num2, _position + str.Length);
		}

		public override string ToString()
		{
			return $"Ln {_line}, Col {_column}, Pos {_position}";
		}

		public override int GetHashCode()
		{
			return _position ^ ((_line | _column) + _line);
		}

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

		public bool Equals(TextPosition other)
		{
			if (_position == other._position && _column == other._column)
			{
				return _line == other._line;
			}
			return false;
		}

		public static bool operator >(TextPosition a, TextPosition b)
		{
			return a._position > b._position;
		}

		public static bool operator <(TextPosition a, TextPosition b)
		{
			return a._position < b._position;
		}

		public int CompareTo(TextPosition other)
		{
			if (!Equals(other))
			{
				if (!(this > other))
				{
					return -1;
				}
				return 1;
			}
			return 0;
		}
	}
	[DebuggerStepThrough]
	public readonly struct TextRange : IEquatable<TextRange>, IComparable<TextRange>
	{
		private readonly TextPosition _start;

		private readonly TextPosition _end;

		public TextPosition Start => _start;

		public TextPosition End => _end;

		public TextRange(TextPosition start, TextPosition end)
		{
			_start = start;
			_end = end;
		}

		public override string ToString()
		{
			return $"({_start}) -- ({_end})";
		}

		public override int GetHashCode()
		{
			return _end.GetHashCode() ^ _start.GetHashCode();
		}

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

		public bool Equals(TextRange other)
		{
			if (_start.Equals(other._start))
			{
				return _end.Equals(other._end);
			}
			return false;
		}

		public static bool operator >(TextRange a, TextRange b)
		{
			return a._start > b._end;
		}

		public static bool operator <(TextRange a, TextRange b)
		{
			return a._end < b._start;
		}

		public int CompareTo(TextRange other)
		{
			if (this > other)
			{
				return 1;
			}
			if (other > this)
			{
				return -1;
			}
			return 0;
		}
	}
	public sealed class TextSource : IDisposable
	{
		private enum EncodingConfidence : byte
		{
			Tentative,
			Certain,
			Irrelevant
		}

		private const int BufferSize = 4096;

		private readonly Stream _baseStream;

		private readonly MemoryStream _raw;

		private readonly byte[] _buffer;

		private readonly char[] _chars;

		private StringBuilder _content;

		private EncodingConfidence _confidence;

		private bool _finished;

		private Encoding _encoding;

		private Decoder _decoder;

		private int _index;

		[MemberNotNull("_content")]
		public string Text
		{
			[MemberNotNull("_content")]
			get
			{
				return _content.ToString();
			}
		}

		public char this[int index] => Replace(_content[index]);

		public int Length => _content.Length;

		public Encoding CurrentEncoding
		{
			get
			{
				return _encoding;
			}
			set
			{
				if (_confidence != 0)
				{
					return;
				}
				if (_encoding.IsUnicode())
				{
					_confidence = EncodingConfidence.Certain;
					return;
				}
				if (value.IsUnicode())
				{
					value = TextEncoding.Utf8;
				}
				if (value == _encoding)
				{
					_confidence = EncodingConfidence.Certain;
					return;
				}
				_encoding = value;
				_decoder = value.GetDecoder();
				byte[] array = _raw.ToArray();
				char[] array2 = new char[_encoding.GetMaxCharCount(array.Length)];
				int chars = _decoder.GetChars(array, 0, array.Length, array2, 0);
				string text = new string(array2, 0, chars);
				int num = Math.Min(_index, text.Length);
				if (text.Substring(0, num).Is(_content.ToString(0, num)))
				{
					_confidence = EncodingConfidence.Certain;
					_content.Remove(num, _content.Length - num);
					_content.Append(text.Substring(num));
					return;
				}
				_index = 0;
				_content.Clear().Append(text);
				throw new NotSupportedException();
			}
		}

		public int Index
		{
			get
			{
				return _index;
			}
			set
			{
				_index = value;
			}
		}

		private TextSource(Encoding encoding, bool allocateBuffers)
		{
			if (allocateBuffers)
			{
				_buffer = new byte[4096];
				_chars = new char[4097];
			}
			_raw = new MemoryStream();
			_index = 0;
			_encoding = encoding ?? TextEncoding.Utf8;
			_decoder = _encoding.GetDecoder();
		}

		public TextSource(string source)
			: this(null, TextEncoding.Utf8)
		{
			_finished = true;
			_content.Append(source);
			_confidence = EncodingConfidence.Irrelevant;
		}

		public TextSource(Stream baseStream, Encoding encoding = null)
			: this(encoding, baseStream != null)
		{
			_baseStream = baseStream;
			_content = StringBuilderPool.Obtain();
			_confidence = EncodingConfidence.Tentative;
		}

		public void Dispose()
		{
			if (_content != null)
			{
				_raw.Dispose();
				_content.Clear().ReturnToPool();
				_content = null;
			}
		}

		public char ReadCharacter()
		{
			if (_index < _content.Length)
			{
				return Replace(_content[_index++]);
			}
			ExpandBuffer(4096L);
			int num = _index++;
			if (num >= _content.Length)
			{
				return '\uffff';
			}
			return Replace(_content[num]);
		}

		public string ReadCharacters(int characters)
		{
			int index = _index;
			if (index + characters <= _content.Length)
			{
				_index += characters;
				return _content.ToString(index, characters);
			}
			ExpandBuffer(Math.Max(4096, characters));
			_index += characters;
			characters = Math.Min(characters, _content.Length - index);
			return _content.ToString(index, characters);
		}

		public Task PrefetchAsync(int length, CancellationToken cancellationToken)
		{
			return ExpandBufferAsync(length, cancellationToken);
		}

		public async Task PrefetchAllAsync(CancellationToken cancellationToken)
		{
			if (_baseStream != null && _content.Length == 0)
			{
				await DetectByteOrderMarkAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			while (!_finished)
			{
				await ReadIntoBufferAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		public void InsertText(string content)
		{
			if (_index >= 0 && _index < _content.Length)
			{
				_content.Insert(_index, content);
			}
			else
			{
				_content.Append(content);
			}
			_index += content.Length;
		}

		private static char Replace(char c)
		{
			if (c != '\uffff')
			{
				return c;
			}
			return '\ufffd';
		}

		private async Task DetectByteOrderMarkAsync(CancellationToken cancellationToken)
		{
			int num = await _baseStream.ReadAsync(_buffer, 0, 4096).ConfigureAwait(continueOnCapturedContext: false);
			int num2 = 0;
			if (num > 2 && _buffer[0] == 239 && _buffer[1] == 187 && _buffer[2] == 191)
			{
				_encoding = TextEncoding.Utf8;
				num2 = 3;
			}
			else if (num > 3 && _buffer[0] == byte.MaxValue && _buffer[1] == 254 && _buffer[2] == 0 && _buffer[3] == 0)
			{
				_encoding = TextEncoding.Utf32Le;
				num2 = 4;
			}
			else if (num > 3 && _buffer[0] == 0 && _buffer[1] == 0 && _buffer[2] == 254 && _buffer[3] == byte.MaxValue)
			{
				_encoding = TextEncoding.Utf32Be;
				num2 = 4;
			}
			else if (num > 1 && _buffer[0] == 254 && _buffer[1] == byte.MaxValue)
			{
				_encoding = TextEncoding.Utf16Be;
				num2 = 2;
			}
			else if (num > 1 && _buffer[0] == byte.MaxValue && _buffer[1] == 254)
			{
				_encoding = TextEncoding.Utf16Le;
				num2 = 2;
			}
			else if (num > 3 && _buffer[0] == 132 && _buffer[1] == 49 && _buffer[2] == 149 && _buffer[3] == 51)
			{
				_encoding = TextEncoding.Gb18030;
				num2 = 4;
			}
			if (num2 > 0)
			{
				num -= num2;
				Array.Copy(_buffer, num2, _buffer, 0, num);
				_decoder = _encoding.GetDecoder();
				_confidence = EncodingConfidence.Certain;
			}
			AppendContentFromBuffer(num);
		}

		private async Task ExpandBufferAsync(long size, CancellationToken cancellationToken)
		{
			if (!_finished && _content.Length == 0)
			{
				await DetectByteOrderMarkAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			while (!_finished && size + _index > _content.Length)
			{
				await ReadIntoBufferAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		private async Task ReadIntoBufferAsync(CancellationToken cancellationToken)
		{
			AppendContentFromBuffer(await _baseStream.ReadAsync(_buffer, 0, 4096, cancellationToken).ConfigureAwait(continueOnCapturedContext: false));
		}

		private void ExpandBuffer(long size)
		{
			if (!_finished && _content.Length == 0)
			{
				DetectByteOrderMarkAsync(CancellationToken.None).Wait();
			}
			while (!_finished && size + _index > _content.Length)
			{
				ReadIntoBuffer();
			}
		}

		private void ReadIntoBuffer()
		{
			int size = _baseStream.Read(_buffer, 0, 4096);
			AppendContentFromBuffer(size);
		}

		private void AppendContentFromBuffer(int size)
		{
			_finished = size == 0;
			int chars = _decoder.GetChars(_buffer, 0, size, _chars, 0);
			if (_confidence != EncodingConfidence.Certain)
			{
				_raw.Write(_buffer, 0, size);
			}
			_content.Append(_chars, 0, chars);
		}
	}
	public class TextView
	{
		private readonly TextSource _source;

		private readonly TextRange _range;

		public TextRange Range => _range;

		public string Text
		{
			get
			{
				int num = Math.Max(_range.Start.Position - 1, 0);
				int num2 = _range.End.Position + 1 - _range.Start.Position;
				string text = _source.Text;
				if (num + num2 > text.Length)
				{
					num2 = text.Length - num;
				}
				return text.Substring(num, num2);
			}
		}

		public TextView(TextSource source, TextRange range)
		{
			_source = source;
			_range = range;
		}
	}
	public static class XmlExtensions
	{
		public static bool IsPubidChar(this char c)
		{
			if (!c.IsAlphanumericAscii() && c != '-' && c != '\'' && c != '+' && c != ',' && c != '.' && c != '/' && c != ':' && c != '?' && c != '=' && c != '!' && c != '*' && c != '#' && c != '@' && c != '$' && c != '_' && c != '(' && c != ')' && c != ';' && c != '%')
			{
				return c.IsSpaceCharacter();
			}
			return true;
		}

		public static bool IsXmlNameStart(this char c)
		{
			if (!c.IsLetter() && c != ':' && c != '_' && !c.IsInRange(192, 214) && !c.IsInRange(216, 246) && !c.IsInRange(248, 767) && !c.IsInRange(880, 893) && !c.IsInRange(895, 8191) && !c.IsInRange(8204, 8205) && !c.IsInRange(8304, 8591) && !c.IsInRange(11264, 12271) && !c.IsInRange(12289, 55295) && !c.IsInRange(63744, 64975) && !c.IsInRange(65008, 65533))
			{
				return c.IsInRange(65536, 983039);
			}
			return true;
		}

		public static bool IsXmlName(this char c)
		{
			if (!c.IsXmlNameStart() && !c.IsDigit() && c != '-' && c != '.' && c != '·' && !c.IsInRange(768, 879))
			{
				return c.IsInRange(8255, 8256);
			}
			return true;
		}

		public static bool IsXmlName(this string str)
		{
			if (str.Length > 0 && str[0].IsXmlNameStart())
			{
				for (int i = 1; i < str.Length; i++)
				{
					if (!str[i].IsXmlName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		public static bool IsQualifiedName(this string str)
		{
			int num = str.IndexOf(':');
			if (num == -1)
			{
				return str.IsXmlName();
			}
			if (num > 0 && str[0].IsXmlNameStart())
			{
				for (int i = 1; i < num; i++)
				{
					if (!str[i].IsXmlName())
					{
						return false;
					}
				}
				num++;
			}
			if (str.Length > num && str[num++].IsXmlNameStart())
			{
				for (int j = num; j < str.Length; j++)
				{
					if (str[j] == ':' || !str[j].IsXmlName())
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}

		public static bool IsXmlChar(this char chr)
		{
			if (chr != '\t' && chr != '\n' && chr != '\r' && (chr < ' ' || chr > '\ud7ff'))
			{
				if (chr >= '\ue000')
				{
					return chr <= '\ufffd';
				}
				return false;
			}
			return true;
		}

		public static bool IsValidAsCharRef(this int chr)
		{
			if (chr != 9 && chr != 10 && chr != 13 && (chr < 32 || chr > 55295) && (chr < 57344 || chr > 65533))
			{
				if (chr >= 65536)
				{
					return chr <= 1114111;
				}
				return false;
			}
			return true;
		}
	}
}
namespace AngleSharp.Svg
{
	internal sealed class SvgElementFactory : IElementFactory<Document, SvgElement>
	{
		private delegate SvgElement Creator(Document owner, string? prefix);

		private readonly Dictionary<string, Creator> creators = new Dictionary<string, Creator>(StringComparer.OrdinalIgnoreCase)
		{
			{
				TagNames.Svg,
				(Document document, string? prefix) => new SvgSvgElement(document, prefix)
			},
			{
				TagNames.Circle,
				(Document document, string? prefix) => new SvgCircleElement(document, prefix)
			},
			{
				TagNames.Desc,
				(Document document, string? prefix) => new SvgDescElement(document, prefix)
			},
			{
				TagNames.ForeignObject,
				(Document document, string? prefix) => new SvgForeignObjectElement(document, prefix)
			},
			{
				TagNames.Title,
				(Document document, string? prefix) => new SvgTitleElement(document, prefix)
			}
		};

		public SvgElement Create(Document document, string localName, string? prefix = null, NodeFlags flags = NodeFlags.None)
		{
			if (creators.TryGetValue(localName, out Creator value))
			{
				return value(document, prefix);
			}
			return new SvgElement(document, localName, prefix, flags);
		}
	}
}
namespace AngleSharp.Svg.Dom
{
	internal sealed class SvgCircleElement : SvgElement, ISvgCircleElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgCircleElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Circle, prefix)
		{
		}
	}
	internal sealed class SvgDescElement : SvgElement, ISvgDescriptionElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgDescElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Desc, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTip)
		{
		}
	}
	public class SvgElement : Element, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgElement(Document owner, string name, string? prefix = null, NodeFlags flags = NodeFlags.None)
			: base(owner, name, prefix, NamespaceNames.SvgUri, flags | NodeFlags.SvgMember)
		{
		}

		public override IElement ParseSubtree(string html)
		{
			return this.ParseHtmlSubtree(html);
		}

		public override Node Clone(Document owner, bool deep)
		{
			SvgElement svgElement = base.Context.GetFactory<IElementFactory<Document, SvgElement>>().Create(owner, base.LocalName, base.Prefix);
			CloneElement(svgElement, owner, deep);
			return svgElement;
		}
	}
	internal sealed class SvgForeignObjectElement : SvgElement, ISvgForeignObjectElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgForeignObjectElement(Document owner, string? prefix = null)
			: base(owner, TagNames.ForeignObject, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTip)
		{
		}
	}
	internal sealed class SvgSvgElement : SvgElement, ISvgSvgElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgSvgElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Svg, prefix)
		{
		}
	}
	internal sealed class SvgTitleElement : SvgElement, ISvgTitleElement, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
		public SvgTitleElement(Document owner, string? prefix = null)
			: base(owner, TagNames.Title, prefix, NodeFlags.Special | NodeFlags.Scoped | NodeFlags.HtmlTip)
		{
		}
	}
	[DomName("SVGCircleElement")]
	public interface ISvgCircleElement : ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
	[DomName("SVGDescElement")]
	public interface ISvgDescriptionElement : ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
	[DomName("SVGElement")]
	public interface ISvgElement : IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
	[DomName("SVGForeignObjectElement")]
	public interface ISvgForeignObjectElement : ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
	[DomName("SVGSVGElement")]
	public interface ISvgSvgElement : ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
	[DomName("SVGTitleElement")]
	public interface ISvgTitleElement : ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode
	{
	}
}
namespace AngleSharp.Scripting
{
	public interface IScriptingService
	{
		bool SupportsType(string mimeType);

		Task EvaluateScriptAsync(IResponse response, ScriptOptions options, CancellationToken cancel);
	}
	public sealed class ScriptOptions
	{
		public IEventLoop EventLoop { get; }

		public IDocument Document { get; }

		public IHtmlScriptElement? Element { get; set; }

		public Encoding? Encoding { get; set; }

		public ScriptOptions(IDocument document, IEventLoop loop)
		{
			Document = document;
			EventLoop = loop;
		}
	}
}
namespace AngleSharp.Media
{
	public interface IAudioInfo : IMediaInfo, IResourceInfo
	{
	}
	public interface IImageInfo : IResourceInfo
	{
		int Width { get; }

		int Height { get; }
	}
	public interface IMediaInfo : IResourceInfo
	{
		IMediaController Controller { get; }
	}
	public interface IObjectInfo : IResourceInfo
	{
		int Width { get; }

		int Height { get; }
	}
	public interface IResourceInfo
	{
		Url Source { get; set; }
	}
	public interface IResourceService<TResource> where TResource : IResourceInfo
	{
		bool SupportsType(string mimeType);

		Task<TResource> CreateAsync(IResponse response, CancellationToken cancel);
	}
	public interface IVideoInfo : IMediaInfo, IResourceInfo
	{
		int Width { get; }

		int Height { get; }
	}
}
namespace AngleSharp.Media.Dom
{
	[DomName("AudioTrack")]
	public interface IAudioTrack
	{
		[DomName("id")]
		string? Id { get; }

		[DomName("kind")]
		string? Kind { get; }

		[DomName("label")]
		string? Label { get; }

		[DomName("language")]
		string? Language { get; }

		[DomName("enabled")]
		bool IsEnabled { get; set; }
	}
	[DomName("AudioTrackList")]
	public interface IAudioTrackList : IEventTarget, IEnumerable<IAudioTrack>, IEnumerable
	{
		[DomName("length")]
		int Length { get; }

		[DomAccessor(Accessors.Getter)]
		IAudioTrack this[int index] { get; }

		[DomName("onchange")]
		event DomEventHandler Changed;

		[DomName("onaddtrack")]
		event DomEventHandler TrackAdded;

		[DomName("onremovetrack")]
		event DomEventHandler TrackRemoved;

		[DomName("getTrackById")]
		IAudioTrack GetTrackById(string id);
	}
	[DomName("CanvasRenderingContext2D")]
	public interface ICanvasRenderingContext2D : IRenderingContext
	{
		[DomName("canvas")]
		IHtmlCanvasElement Canvas { get; }

		[DomName("width")]
		int Width { get; set; }

		[DomName("height")]
		int Height { get; set; }

		[DomName("save")]
		void SaveState();

		[DomName("restore")]
		void RestoreState();
	}
	[DomName("MediaController")]
	public interface IMediaController
	{
		[DomName("buffered")]
		ITimeRanges? BufferedTime { get; }

		[DomName("seekable")]
		ITimeRanges? SeekableTime { get; }

		[DomName("played")]
		ITimeRanges? PlayedTime { get; }

		[DomName("duration")]
		double Duration { get; }

		[DomName("currentTime")]
		double CurrentTime { get; set; }

		[DomName("defaultPlaybackRate")]
		double DefaultPlaybackRate { get; set; }

		[DomName("playbackRate")]
		double PlaybackRate { get; set; }

		[DomName("volume")]
		double Volume { get; set; }

		[DomName("muted")]
		bool IsMuted { get; set; }

		[DomName("paused")]
		bool IsPaused { get; }

		[DomName("readyState")]
		MediaReadyState ReadyState { get; }

		[DomName("playbackState")]
		MediaControllerPlaybackState PlaybackState { get; }

		[DomName("onemptied")]
		event DomEventHandler Emptied;

		[DomName("onloadedmetadata")]
		event DomEventHandler LoadedMetadata;

		[DomName("onloadeddata")]
		event DomEventHandler LoadedData;

		[DomName("oncanplay")]
		event DomEventHandler CanPlay;

		[DomName("oncanplaythrough")]
		event DomEventHandler CanPlayThrough;

		[DomName("onended")]
		event DomEventHandler Ended;

		[DomName("onwaiting")]
		event DomEventHandler Waiting;

		[DomName("ondurationchange")]
		event DomEventHandler DurationChanged;

		[DomName("ontimeupdate")]
		event DomEventHandler TimeUpdated;

		[DomName("onpause")]
		event DomEventHandler Paused;

		[DomName("onplay")]
		event DomEventHandler Played;

		[DomName("onplaying")]
		event DomEventHandler Playing;

		[DomName("onratechange")]
		event DomEventHandler RateChanged;

		[DomName("onvolumechange")]
		event DomEventHandler VolumeChanged;

		[DomName("play")]
		void Play();

		[DomName("pause")]
		void Pause();
	}
	[DomName("MediaError")]
	public interface IMediaError
	{
		[DomName("code")]
		MediaErrorCode Code { get; }
	}
	[DomName("RenderingContext")]
	public interface IRenderingContext
	{
		string ContextId { get; }

		bool IsFixed { get; }

		IHtmlCanvasElement Host { get; }

		byte[] ToImage(string type);
	}
	public interface IRenderingService
	{
		bool IsSupportingContext(string contextId);

		IRenderingContext CreateContext(IHtmlCanvasElement host, string contextId);
	}
	[DomName("TextTrack")]
	public interface ITextTrack : IEventTarget
	{
		[DomName("kind")]
		string? Kind { get; }

		[DomName("label")]
		string? Label { get; }

		[DomName("language")]
		string? Language { get; }

		[DomName("mode")]
		TextTrackMode Mode { get; set; }

		[DomName("cues")]
		ITextTrackCueList Cues { get; }

		[DomName("activeCues")]
		ITextTrackCueList ActiveCues { get; }

		[DomName("oncuechange")]
		event DomEventHandler CueChanged;

		[DomName("addCue")]
		void Add(ITextTrackCue cue);

		[DomName("removeCue")]
		void Remove(ITextTrackCue cue);
	}
	[DomName("TextTrackCue")]
	public interface ITextTrackCue : IEventTarget
	{
		[DomName("id")]
		string Id { get; set; }

		[DomName("track")]
		ITextTrack Track { get; }

		[DomName("startTime")]
		double StartTime { get; set; }

		[DomName("endTime")]
		double EndTime { get; set; }

		[DomName("pauseOnExit")]
		bool IsPausedOnExit { get; set; }

		[DomName("vertical")]
		string Vertical { get; set; }

		[DomName("snapToLines")]
		bool IsSnappedToLines { get; set; }

		[DomName("line")]
		int Line { get; set; }

		[DomName("position")]
		int Position { get; set; }

		[DomName("size")]
		int Size { get; set; }

		[DomName("align")]
		string Alignment { get; set; }

		[DomName("text")]
		string Text { get; set; }

		[DomName("onenter")]
		DomEventHandler Entered { get; set; }

		[DomName("onexit")]
		DomEventHandler Exited { get; set; }

		[DomName("getCueAsHTML")]
		IDocumentFragment AsHtml();
	}
	[DomName("TextTrackCueList")]
	public interface ITextTrackCueList : IEnumerable<ITextTrackCue>, IEnumerable
	{
		[DomName("length")]
		int Length { get; }

		ITextTrackCue this[int index] { get; }

		[DomName("getCueById")]
		IVideoTrack GetCueById(string id);
	}
	[DomName("TextTrackList")]
	public interface ITextTrackList : IEventTarget, IEnumerable<ITextTrack>, IEnumerable
	{
		[DomName("length")]
		int Length { get; }

		[DomAccessor(Accessors.Getter)]
		ITextTrack this[int index] { get; }

		[DomName("onaddtrack")]
		event DomEventHandler TrackAdded;

		[DomName("onremovetrack")]
		event DomEventHandler TrackRemoved;
	}
	[DomName("TimeRanges")]
	public interface ITimeRanges
	{
		[DomName("length")]
		int Length { get; }

		[DomName("start")]
		double Start(int index);

		[DomName("end")]
		double End(int index);
	}
	[DomName("VideoTrack")]
	public interface IVideoTrack
	{
		[DomName("id")]
		string? Id { get; }

		[DomName("kind")]
		string? Kind { get; }

		[DomName("label")]
		string? Label { get; }

		[DomName("language")]
		string? Language { get; }

		[DomName("selected")]
		bool IsSelected { get; set; }
	}
	[DomName("VideoTrackList")]
	public interface IVideoTrackList : IEventTarget, IEnumerable<IVideoTrack>, IEnumerable
	{
		[DomName("length")]
		int Length { get; }

		[DomName("selectedIndex")]
		int SelectedIndex { get; }

		[DomAccessor(Accessors.Getter)]
		IVideoTrack this[int index] { get; }

		[DomName("onchange")]
		event DomEventHandler Changed;

		[DomName("onaddtrack")]
		event DomEventHandler TrackAdded;

		[DomName("onremovetrack")]
		event DomEventHandler TrackRemoved;

		[DomName("getTrackById")]
		IVideoTrack GetTrackById(string id);
	}
	[DomName("MediaControllerPlaybackState")]
	public enum MediaControllerPlaybackState : byte
	{
		[DomName("waiting")]
		Waiting,
		[DomName("playing")]
		Playing,
		[DomName("ended")]
		Ended
	}
	[DomName("MediaError")]
	public enum MediaErrorCode : byte
	{
		[DomName("MEDIA_ERR_ABORTED")]
		Aborted = 1,
		[DomName("MEDIA_ERR_NETWORK")]
		Network,
		[DomName("MEDIA_ERR_DECODE")]
		Decode,
		[DomName("MEDIA_ERR_SRC_NOT_SUPPORTED")]
		SourceNotSupported
	}
	[DomName("HTMLMediaElement")]
	public enum MediaNetworkState : byte
	{
		[DomName("NETWORK_EMPTY")]
		Empty,
		[DomName("NETWORK_IDLE")]
		Idle,
		[DomName("NETWORK_LOADING")]
		Loading,
		[DomName("NETWORK_NO_SOURCE")]
		NoSource
	}
	[DomName("HTMLMediaElement")]
	public enum MediaReadyState : byte
	{
		[DomName("HAVE_NOTHING")]
		Nothing,
		[DomName("HAVE_METADATA")]
		Metadata,
		[DomName("HAVE_CURRENT_DATA")]
		CurrentData,
		[DomName("HAVE_FUTURE_DATA")]
		FutureData,
		[DomName("HAVE_ENOUGH_DATA")]
		EnoughData
	}
	[DomName("TextTrackMode")]
	public enum TextTrackMode : byte
	{
		[DomName("disabled")]
		Disabled,
		[DomName("hidden")]
		Hidden,
		[DomName("showing")]
		Showing
	}
}
namespace AngleSharp.Mathml
{
	internal sealed class MathElementFactory : IElementFactory<Document, MathElement>
	{
		private delegate MathElement Creator(Document owner, string? prefix);

		private readonly Dictionary<string, Creator> creators = new Dictionary<string, Creator>(StringComparer.OrdinalIgnoreCase)
		{
			{
				TagNames.Mn,
				(Document document, string? prefix) => new MathNumberElement(document, prefix)
			},
			{
				TagNames.Mo,
				(Document document, string? prefix) => new MathOperatorElement(document, prefix)
			},
			{
				TagNames.Mi,
				(Document document, string? prefix) => new MathIdentifierElement(document, prefix)
			},
			{
				TagNames.Ms,
				(Document document, string? prefix) => new MathStringElement(document, prefix)
			},
			{
				TagNames.Mtext,
				(Document document, string? prefix) => new MathTextElement(document, prefix)
			},
			{
				TagNames.AnnotationXml,
				(Document document, string? prefix) => new MathAnnotationXmlElement(document, prefix)
			}
		};

		public MathElement Create(Document document, string localName, string? prefix = null, NodeFlags flags = NodeFlags.None)
		{
			if (creators.TryGetValue(localName, out Creator value))
			{
				return value(document, prefix);

plugins/CliWrap.dll

Decompiled 7 months ago
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.Http;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CliWrap.Builders;
using CliWrap.Exceptions;
using CliWrap.Utils;
using CliWrap.Utils.Extensions;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tyrrrz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (C) Oleksii Holub")]
[assembly: AssemblyDescription("Library for interacting with external command-line interfaces")]
[assembly: AssemblyFileVersion("3.6.4.0")]
[assembly: AssemblyInformationalVersion("3.6.4+77a9f6d5692718555f040ad4603916ce0bdb0715")]
[assembly: AssemblyProduct("CliWrap")]
[assembly: AssemblyTitle("CliWrap")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Tyrrrz/CliWrap")]
[assembly: AssemblyVersion("3.6.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class PolyfillExtensions
{
	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			HttpResponseMessage obj = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			obj.EnsureSuccessStatusCode();
			return await ReadAsStreamAsync(obj.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStreamAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsByteArrayAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetByteArrayAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsStringAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStringAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<Stream> ReadAsStreamAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStreamAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> ReadAsByteArrayAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> ReadAsStringAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default(CancellationToken))
	{
		TaskCompletionSource<object?> tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
		try
		{
			process.EnableRaisingEvents = true;
		}
		catch when (process.HasExited)
		{
			return;
		}
		process.Exited += HandleExited;
		try
		{
			using (cancellationToken.Register(delegate
			{
				tcs.TrySetCanceled(cancellationToken);
			}))
			{
				await tcs.Task;
			}
		}
		finally
		{
			process.Exited -= HandleExited;
		}
		void HandleExited(object? sender, EventArgs args)
		{
			tcs.TrySetResult(null);
		}
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
	}

	public static async Task WaitAsync(this Task task, CancellationToken cancellationToken)
	{
		await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout)
	{
		await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
		return task.Result;
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, CancellationToken cancellationToken)
	{
		return await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout)
	{
		return await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer, i, Math.Min(minimumBytes, buffer.Length - i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, byte[] buffer, int offset, int count)
	{
		int num;
		for (int i = 0; i < count; i += num)
		{
			num = stream.Read(buffer, offset + i, count - i);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static void ReadExactly(this Stream stream, byte[] buffer)
	{
		stream.ReadExactly(buffer, 0, buffer.Length);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, totalBytesRead, Math.Min(minimumBytes, buffer.Length - totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
	{
		int num;
		for (int totalBytesRead = 0; totalBytesRead < count; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, offset + totalBytesRead, count - totalBytesRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		await stream.ReadExactlyAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer.Slice(i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, Span<byte> buffer)
	{
		byte[] array = buffer.ToArray();
		stream.ReadExactly(array, 0, array.Length);
		array.CopyTo(buffer);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer.Slice(totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		byte[] bufferArray = buffer.ToArray();
		await stream.ReadExactlyAsync(bufferArray, 0, bufferArray.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		bufferArray.CopyTo(buffer);
	}

	private static void KillProcessTree(int processId)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		ManagementObjectSearcher val = new ManagementObjectSearcher($"SELECT * FROM Win32_Process WHERE ParentProcessID={processId}");
		try
		{
			ManagementObjectCollection val2 = val.Get();
			try
			{
				try
				{
					using Process process = Process.GetProcessById(processId);
					if (!process.HasExited)
					{
						process.Kill();
					}
				}
				catch
				{
				}
				foreach (ManagementObject item in ((IEnumerable)val2).Cast<ManagementObject>())
				{
					KillProcessTree(Convert.ToInt32(((ManagementBaseObject)item)["ProcessID"]));
				}
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
	}

	public static void Kill(this Process process, bool entireProcessTree)
	{
		if (!entireProcessTree)
		{
			process.Kill();
		}
		else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
		{
			process.Kill();
		}
		else
		{
			KillProcessTree(process.Id);
		}
	}
}
namespace CliWrap
{
	public static class Cli
	{
		public static Command Wrap(string targetFilePath)
		{
			return new Command(targetFilePath);
		}
	}
	public class Command : ICommandConfiguration
	{
		public string TargetFilePath { get; }

		public string Arguments { get; }

		public string WorkingDirPath { get; }

		public Credentials Credentials { get; }

		public IReadOnlyDictionary<string, string?> EnvironmentVariables { get; }

		public CommandResultValidation Validation { get; }

		public PipeSource StandardInputPipe { get; }

		public PipeTarget StandardOutputPipe { get; }

		public PipeTarget StandardErrorPipe { get; }

		public Command(string targetFilePath, string arguments, string workingDirPath, Credentials credentials, IReadOnlyDictionary<string, string?> environmentVariables, CommandResultValidation validation, PipeSource standardInputPipe, PipeTarget standardOutputPipe, PipeTarget standardErrorPipe)
		{
			TargetFilePath = targetFilePath;
			Arguments = arguments;
			WorkingDirPath = workingDirPath;
			Credentials = credentials;
			EnvironmentVariables = environmentVariables;
			Validation = validation;
			StandardInputPipe = standardInputPipe;
			StandardOutputPipe = standardOutputPipe;
			StandardErrorPipe = standardErrorPipe;
		}

		public Command(string targetFilePath)
			: this(targetFilePath, string.Empty, Directory.GetCurrentDirectory(), CliWrap.Credentials.Default, new Dictionary<string, string>(), CommandResultValidation.ZeroExitCode, PipeSource.Null, PipeTarget.Null, PipeTarget.Null)
		{
		}

		public Command WithTargetFile(string targetFilePath)
		{
			return new Command(targetFilePath, Arguments, WorkingDirPath, Credentials, EnvironmentVariables, Validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithArguments(string arguments)
		{
			return new Command(TargetFilePath, arguments, WorkingDirPath, Credentials, EnvironmentVariables, Validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithArguments(IEnumerable<string> arguments, bool escape)
		{
			IEnumerable<string> arguments2 = arguments;
			return WithArguments(delegate(ArgumentsBuilder args)
			{
				args.Add(arguments2, escape);
			});
		}

		public Command WithArguments(IEnumerable<string> arguments)
		{
			return WithArguments(arguments, escape: true);
		}

		public Command WithArguments(Action<ArgumentsBuilder> configure)
		{
			ArgumentsBuilder argumentsBuilder = new ArgumentsBuilder();
			configure(argumentsBuilder);
			return WithArguments(argumentsBuilder.Build());
		}

		public Command WithWorkingDirectory(string workingDirPath)
		{
			return new Command(TargetFilePath, Arguments, workingDirPath, Credentials, EnvironmentVariables, Validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithCredentials(Credentials credentials)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, credentials, EnvironmentVariables, Validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithCredentials(Action<CredentialsBuilder> configure)
		{
			CredentialsBuilder credentialsBuilder = new CredentialsBuilder();
			configure(credentialsBuilder);
			return WithCredentials(credentialsBuilder.Build());
		}

		public Command WithEnvironmentVariables(IReadOnlyDictionary<string, string?> environmentVariables)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, Credentials, environmentVariables, Validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithEnvironmentVariables(Action<EnvironmentVariablesBuilder> configure)
		{
			EnvironmentVariablesBuilder environmentVariablesBuilder = new EnvironmentVariablesBuilder();
			configure(environmentVariablesBuilder);
			return WithEnvironmentVariables(environmentVariablesBuilder.Build());
		}

		public Command WithValidation(CommandResultValidation validation)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, Credentials, EnvironmentVariables, validation, StandardInputPipe, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithStandardInputPipe(PipeSource source)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, Credentials, EnvironmentVariables, Validation, source, StandardOutputPipe, StandardErrorPipe);
		}

		public Command WithStandardOutputPipe(PipeTarget target)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, Credentials, EnvironmentVariables, Validation, StandardInputPipe, target, StandardErrorPipe);
		}

		public Command WithStandardErrorPipe(PipeTarget target)
		{
			return new Command(TargetFilePath, Arguments, WorkingDirPath, Credentials, EnvironmentVariables, Validation, StandardInputPipe, StandardOutputPipe, target);
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return TargetFilePath + " " + Arguments;
		}

		private string GetOptimallyQualifiedTargetFilePath()
		{
			if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				return TargetFilePath;
			}
			if (Path.IsPathRooted(TargetFilePath) || !string.IsNullOrWhiteSpace(Path.GetExtension(TargetFilePath)))
			{
				return TargetFilePath;
			}
			return (from probeDirPath in GetProbeDirectoryPaths()
				where Directory.Exists(probeDirPath)
				select Path.Combine(probeDirPath, TargetFilePath) into baseFilePath
				from extension in new string[3] { "exe", "cmd", "bat" }
				select Path.ChangeExtension(baseFilePath, extension)).FirstOrDefault(File.Exists) ?? TargetFilePath;
			static IEnumerable<string> GetProbeDirectoryPaths()
			{
				if (!string.IsNullOrWhiteSpace(EnvironmentEx.ProcessPath))
				{
					string directoryName = Path.GetDirectoryName(EnvironmentEx.ProcessPath);
					if (!string.IsNullOrWhiteSpace(directoryName))
					{
						yield return directoryName;
					}
				}
				yield return Directory.GetCurrentDirectory();
				string[] array = Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator);
				if (array != null)
				{
					string[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						yield return array2[i];
					}
				}
			}
		}

		private ProcessStartInfo CreateStartInfo()
		{
			ProcessStartInfo processStartInfo = new ProcessStartInfo
			{
				FileName = GetOptimallyQualifiedTargetFilePath(),
				Arguments = Arguments,
				WorkingDirectory = WorkingDirPath,
				RedirectStandardInput = true,
				RedirectStandardOutput = true,
				RedirectStandardError = true,
				UseShellExecute = false,
				CreateNoWindow = true
			};
			try
			{
				if (Credentials.Domain != null)
				{
					processStartInfo.Domain = Credentials.Domain;
				}
				if (Credentials.UserName != null)
				{
					processStartInfo.UserName = Credentials.UserName;
				}
				if (Credentials.Password != null)
				{
					processStartInfo.Password = Credentials.Password.ToSecureString();
				}
				if (Credentials.LoadUserProfile)
				{
					processStartInfo.LoadUserProfile = Credentials.LoadUserProfile;
				}
			}
			catch (NotSupportedException innerException)
			{
				throw new NotSupportedException("Cannot start a process using the provided credentials. Setting custom domain, password, or loading user profile is only supported on Windows.", innerException);
			}
			foreach (var (key, text3) in EnvironmentVariables)
			{
				if (text3 != null)
				{
					processStartInfo.Environment[key] = text3;
				}
				else
				{
					processStartInfo.Environment.Remove(key);
				}
			}
			return processStartInfo;
		}

		private async Task PipeStandardInputAsync(ProcessEx process, CancellationToken cancellationToken = default(CancellationToken))
		{
			await using (process.StandardInput.ToAsyncDisposable())
			{
				try
				{
					await PolyfillExtensions.WaitAsync(StandardInputPipe.CopyToAsync(process.StandardInput, cancellationToken), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
				catch (IOException ex) when (ex.GetType() == typeof(IOException))
				{
				}
			}
		}

		private async Task PipeStandardOutputAsync(ProcessEx process, CancellationToken cancellationToken = default(CancellationToken))
		{
			await using (process.StandardOutput.ToAsyncDisposable())
			{
				await StandardOutputPipe.CopyFromAsync(process.StandardOutput, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		private async Task PipeStandardErrorAsync(ProcessEx process, CancellationToken cancellationToken = default(CancellationToken))
		{
			await using (process.StandardError.ToAsyncDisposable())
			{
				await StandardErrorPipe.CopyFromAsync(process.StandardError, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		private async Task<CommandResult> ExecuteAsync(ProcessEx process, CancellationToken forcefulCancellationToken = default(CancellationToken), CancellationToken gracefulCancellationToken = default(CancellationToken))
		{
			using (process)
			{
				CancellationTokenSource waitTimeoutCts = new CancellationTokenSource();
				try
				{
					CommandResult result;
					await using (forcefulCancellationToken.Register(delegate
					{
						waitTimeoutCts.CancelAfter(TimeSpan.FromSeconds(3.0));
					}).ToAsyncDisposable())
					{
						using CancellationTokenSource stdInCts = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { forcefulCancellationToken });
						CommandResult commandResult2;
						await using (forcefulCancellationToken.Register(process.Kill).ToAsyncDisposable())
						{
							CommandResult commandResult;
							await using (gracefulCancellationToken.Register(process.Interrupt).ToAsyncDisposable())
							{
								Task pipingTask = Task.WhenAll(PipeStandardInputAsync(process, stdInCts.Token), PipeStandardOutputAsync(process, forcefulCancellationToken), PipeStandardErrorAsync(process, forcefulCancellationToken));
								try
								{
									await process.WaitUntilExitAsync(waitTimeoutCts.Token).ConfigureAwait(continueOnCapturedContext: false);
									stdInCts.Cancel();
									await pipingTask.ConfigureAwait(continueOnCapturedContext: false);
								}
								catch (OperationCanceledException ex) when (ex.CancellationToken == forcefulCancellationToken || ex.CancellationToken == gracefulCancellationToken || ex.CancellationToken == waitTimeoutCts.Token || ex.CancellationToken == stdInCts.Token)
								{
								}
								forcefulCancellationToken.ThrowIfCancellationRequested("Command execution canceled. " + $"Underlying process ({process.Name}#{process.Id}) was forcefully terminated.");
								gracefulCancellationToken.ThrowIfCancellationRequested("Command execution canceled. " + $"Underlying process ({process.Name}#{process.Id}) was gracefully terminated.");
								if (process.ExitCode != 0 && Validation.IsZeroExitCodeValidationEnabled())
								{
									throw new CommandExecutionException(this, process.ExitCode, $"Command execution failed because the underlying process ({process.Name}#{process.Id}) returned a non-zero exit code ({process.ExitCode}).\r\n\r\nCommand:\r\n{TargetFilePath} {Arguments}\r\n\r\nYou can suppress this validation by calling `WithValidation(CommandResultValidation.None)` on the command.");
								}
								commandResult = new CommandResult(process.ExitCode, process.StartTime, process.ExitTime);
							}
							commandResult2 = commandResult;
						}
						result = commandResult2;
					}
					return result;
				}
				finally
				{
					if (waitTimeoutCts != null)
					{
						((IDisposable)waitTimeoutCts).Dispose();
					}
				}
			}
		}

		public CommandTask<CommandResult> ExecuteAsync(CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken)
		{
			ProcessEx processEx = new ProcessEx(CreateStartInfo());
			processEx.Start();
			int id = processEx.Id;
			return new CommandTask<CommandResult>(ExecuteAsync(processEx, forcefulCancellationToken, gracefulCancellationToken), id);
		}

		public CommandTask<CommandResult> ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return ExecuteAsync(cancellationToken, CancellationToken.None);
		}

		public static Command operator |(Command source, PipeTarget target)
		{
			return source.WithStandardOutputPipe(target);
		}

		public static Command operator |(Command source, Stream target)
		{
			return source | PipeTarget.ToStream(target);
		}

		public static Command operator |(Command source, StringBuilder target)
		{
			return source | PipeTarget.ToStringBuilder(target);
		}

		public static Command operator |(Command source, Func<string, CancellationToken, Task> target)
		{
			return source | PipeTarget.ToDelegate(target);
		}

		public static Command operator |(Command source, Func<string, Task> target)
		{
			return source | PipeTarget.ToDelegate(target);
		}

		public static Command operator |(Command source, Action<string> target)
		{
			return source | PipeTarget.ToDelegate(target);
		}

		public static Command operator |(Command source, (PipeTarget stdOut, PipeTarget stdErr) targets)
		{
			return source.WithStandardOutputPipe(targets.stdOut).WithStandardErrorPipe(targets.stdErr);
		}

		public static Command operator |(Command source, (Stream stdOut, Stream stdErr) targets)
		{
			return source | (PipeTarget.ToStream(targets.stdOut), PipeTarget.ToStream(targets.stdErr));
		}

		public static Command operator |(Command source, (StringBuilder stdOut, StringBuilder stdErr) targets)
		{
			return source | (PipeTarget.ToStringBuilder(targets.stdOut), PipeTarget.ToStringBuilder(targets.stdErr));
		}

		public static Command operator |(Command source, (Func<string, CancellationToken, Task> stdOut, Func<string, CancellationToken, Task> stdErr) targets)
		{
			return source | (PipeTarget.ToDelegate(targets.stdOut), PipeTarget.ToDelegate(targets.stdErr));
		}

		public static Command operator |(Command source, (Func<string, Task> stdOut, Func<string, Task> stdErr) targets)
		{
			return source | (PipeTarget.ToDelegate(targets.stdOut), PipeTarget.ToDelegate(targets.stdErr));
		}

		public static Command operator |(Command source, (Action<string> stdOut, Action<string> stdErr) targets)
		{
			return source | (PipeTarget.ToDelegate(targets.stdOut), PipeTarget.ToDelegate(targets.stdErr));
		}

		public static Command operator |(PipeSource source, Command target)
		{
			return target.WithStandardInputPipe(source);
		}

		public static Command operator |(Stream source, Command target)
		{
			return PipeSource.FromStream(source) | target;
		}

		public static Command operator |(ReadOnlyMemory<byte> source, Command target)
		{
			return PipeSource.FromBytes(source) | target;
		}

		public static Command operator |(byte[] source, Command target)
		{
			return PipeSource.FromBytes(source) | target;
		}

		public static Command operator |(string source, Command target)
		{
			return PipeSource.FromString(source) | target;
		}

		public static Command operator |(Command source, Command target)
		{
			return PipeSource.FromCommand(source) | target;
		}
	}
	public class CommandResult
	{
		public int ExitCode { get; }

		public DateTimeOffset StartTime { get; }

		public DateTimeOffset ExitTime { get; }

		public TimeSpan RunTime => ExitTime - StartTime;

		public CommandResult(int exitCode, DateTimeOffset startTime, DateTimeOffset exitTime)
		{
			ExitCode = exitCode;
			StartTime = startTime;
			ExitTime = exitTime;
		}
	}
	[Flags]
	public enum CommandResultValidation
	{
		None = 0,
		ZeroExitCode = 1
	}
	internal static class CommandResultValidationExtensions
	{
		public static bool IsZeroExitCodeValidationEnabled(this CommandResultValidation validation)
		{
			return (validation & CommandResultValidation.ZeroExitCode) != 0;
		}
	}
	public class CommandTask<TResult> : IDisposable
	{
		public Task<TResult> Task { get; }

		public int ProcessId { get; }

		public CommandTask(Task<TResult> task, int processId)
		{
			Task = task;
			ProcessId = processId;
		}

		internal CommandTask<T> Bind<T>(Func<Task<TResult>, Task<T>> transform)
		{
			return new CommandTask<T>(transform(Task), ProcessId);
		}

		public CommandTask<T> Select<T>(Func<TResult, T> transform)
		{
			Func<TResult, T> transform2 = transform;
			return Bind((Task<TResult> task) => task.Select(transform2));
		}

		public TaskAwaiter<TResult> GetAwaiter()
		{
			return Task.GetAwaiter();
		}

		public ConfiguredTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext)
		{
			return Task.ConfigureAwait(continueOnCapturedContext);
		}

		public void Dispose()
		{
			Task.Dispose();
		}

		public static implicit operator Task<TResult>(CommandTask<TResult> commandTask)
		{
			return commandTask.Task;
		}
	}
	public class Credentials
	{
		public string? Domain { get; }

		public string? UserName { get; }

		public string? Password { get; }

		public bool LoadUserProfile { get; }

		public static Credentials Default { get; } = new Credentials();


		public Credentials(string? domain = null, string? userName = null, string? password = null, bool loadUserProfile = false)
		{
			Domain = domain;
			UserName = userName;
			Password = password;
			LoadUserProfile = loadUserProfile;
		}

		[ExcludeFromCodeCoverage]
		public Credentials(string? domain, string? username, string? password)
			: this(domain, username, password, loadUserProfile: false)
		{
		}
	}
	public interface ICommandConfiguration
	{
		string TargetFilePath { get; }

		string Arguments { get; }

		string WorkingDirPath { get; }

		Credentials Credentials { get; }

		IReadOnlyDictionary<string, string?> EnvironmentVariables { get; }

		CommandResultValidation Validation { get; }

		PipeSource StandardInputPipe { get; }

		PipeTarget StandardOutputPipe { get; }

		PipeTarget StandardErrorPipe { get; }
	}
	public abstract class PipeSource
	{
		public static PipeSource Null { get; } = Create((Stream _, CancellationToken cancellationToken) => cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : Task.CompletedTask);


		public abstract Task CopyToAsync(Stream destination, CancellationToken cancellationToken = default(CancellationToken));

		public static PipeSource Create(Func<Stream, CancellationToken, Task> handlePipeAsync)
		{
			return new <PipeSource>F612AD58C26E22862AC9C5A7F308FD80EC164600953573616E18105DA95EAF684__AnonymousPipeSource(handlePipeAsync);
		}

		public static PipeSource Create(Action<Stream> handlePipe)
		{
			Action<Stream> handlePipe2 = handlePipe;
			return Create(delegate(Stream destination, CancellationToken _)
			{
				handlePipe2(destination);
				return Task.CompletedTask;
			});
		}

		public static PipeSource FromStream(Stream stream, bool autoFlush)
		{
			Stream stream2 = stream;
			return Create(async delegate(Stream destination, CancellationToken cancellationToken)
			{
				await stream2.CopyToAsync(destination, autoFlush, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			});
		}

		public static PipeSource FromStream(Stream stream)
		{
			return FromStream(stream, autoFlush: true);
		}

		public static PipeSource FromFile(string filePath)
		{
			string filePath2 = filePath;
			return Create(async delegate(Stream destination, CancellationToken cancellationToken)
			{
				FileStream fileStream = File.OpenRead(filePath2);
				await using (fileStream.ToAsyncDisposable())
				{
					await fileStream.CopyToAsync(destination, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
			});
		}

		public static PipeSource FromBytes(ReadOnlyMemory<byte> data)
		{
			return Create(async delegate(Stream destination, CancellationToken cancellationToken)
			{
				await destination.WriteAsync(data, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			});
		}

		public static PipeSource FromBytes(byte[] data)
		{
			return FromBytes((ReadOnlyMemory<byte>)data);
		}

		[Obsolete("Use FromBytes(ReadOnlyMemory<byte>) instead")]
		[ExcludeFromCodeCoverage]
		public static PipeSource FromMemory(ReadOnlyMemory<byte> data)
		{
			return FromBytes(data);
		}

		public static PipeSource FromString(string str, Encoding encoding)
		{
			return FromBytes(encoding.GetBytes(str));
		}

		public static PipeSource FromString(string str)
		{
			return FromString(str, Console.InputEncoding);
		}

		public static PipeSource FromCommand(Command command)
		{
			Command command2 = command;
			return Create(async delegate(Stream destination, CancellationToken cancellationToken)
			{
				await command2.WithStandardOutputPipe(PipeTarget.ToStream(destination)).ExecuteAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			});
		}
	}
	internal class <PipeSource>F612AD58C26E22862AC9C5A7F308FD80EC164600953573616E18105DA95EAF684__AnonymousPipeSource : PipeSource
	{
		private readonly Func<Stream, CancellationToken, Task> _copyToAsync;

		public <PipeSource>F612AD58C26E22862AC9C5A7F308FD80EC164600953573616E18105DA95EAF684__AnonymousPipeSource(Func<Stream, CancellationToken, Task> copyToAsync)
		{
			_copyToAsync = copyToAsync;
		}

		public override async Task CopyToAsync(Stream destination, CancellationToken cancellationToken = default(CancellationToken))
		{
			await _copyToAsync(destination, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
	}
	public abstract class PipeTarget
	{
		public static PipeTarget Null { get; } = Create((Stream _, CancellationToken cancellationToken) => cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : Task.CompletedTask);


		public abstract Task CopyFromAsync(Stream origin, CancellationToken cancellationToken = default(CancellationToken));

		public static PipeTarget Create(Func<Stream, CancellationToken, Task> handlePipeAsync)
		{
			return new <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AnonymousPipeTarget(handlePipeAsync);
		}

		public static PipeTarget Create(Action<Stream> handlePipe)
		{
			Action<Stream> handlePipe2 = handlePipe;
			return Create(delegate(Stream origin, CancellationToken _)
			{
				handlePipe2(origin);
				return Task.CompletedTask;
			});
		}

		public static PipeTarget ToStream(Stream stream, bool autoFlush)
		{
			Stream stream2 = stream;
			return Create(async delegate(Stream origin, CancellationToken cancellationToken)
			{
				await origin.CopyToAsync(stream2, autoFlush, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			});
		}

		public static PipeTarget ToStream(Stream stream)
		{
			return ToStream(stream, autoFlush: true);
		}

		public static PipeTarget ToFile(string filePath)
		{
			string filePath2 = filePath;
			return Create(async delegate(Stream origin, CancellationToken cancellationToken)
			{
				FileStream fileStream = File.Create(filePath2);
				await using (fileStream.ToAsyncDisposable())
				{
					await origin.CopyToAsync(fileStream, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
			});
		}

		public static PipeTarget ToStringBuilder(StringBuilder stringBuilder, Encoding encoding)
		{
			Encoding encoding2 = encoding;
			StringBuilder stringBuilder2 = stringBuilder;
			return Create(async delegate(Stream origin, CancellationToken cancellationToken)
			{
				using StreamReader reader = new StreamReader(origin, encoding2, detectEncodingFromByteOrderMarks: false, 1024, leaveOpen: true);
				using IMemoryOwner<char> buffer = MemoryPool<char>.Shared.Rent(1024);
				while (true)
				{
					int num = await reader.ReadAsync(buffer.Memory, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
					if (num <= 0)
					{
						break;
					}
					stringBuilder2.Append((object?)buffer.Memory.Slice(0, num));
				}
			});
		}

		public static PipeTarget ToStringBuilder(StringBuilder stringBuilder)
		{
			return ToStringBuilder(stringBuilder, Console.OutputEncoding);
		}

		public static PipeTarget ToDelegate(Func<string, CancellationToken, Task> handleLineAsync, Encoding encoding)
		{
			Encoding encoding2 = encoding;
			Func<string, CancellationToken, Task> handleLineAsync2 = handleLineAsync;
			return Create(async delegate(Stream origin, CancellationToken cancellationToken)
			{
				using StreamReader reader = new StreamReader(origin, encoding2, detectEncodingFromByteOrderMarks: false, 1024, leaveOpen: true);
				await foreach (string item in reader.ReadAllLinesAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
				{
					await handleLineAsync2(item, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
			});
		}

		public static PipeTarget ToDelegate(Func<string, CancellationToken, Task> handleLineAsync)
		{
			return ToDelegate(handleLineAsync, Console.OutputEncoding);
		}

		public static PipeTarget ToDelegate(Func<string, Task> handleLineAsync, Encoding encoding)
		{
			Func<string, Task> handleLineAsync2 = handleLineAsync;
			return ToDelegate(async delegate(string line, CancellationToken _)
			{
				await handleLineAsync2(line).ConfigureAwait(continueOnCapturedContext: false);
			}, encoding);
		}

		public static PipeTarget ToDelegate(Func<string, Task> handleLineAsync)
		{
			return ToDelegate(handleLineAsync, Console.OutputEncoding);
		}

		public static PipeTarget ToDelegate(Action<string> handleLine, Encoding encoding)
		{
			Action<string> handleLine2 = handleLine;
			return ToDelegate(delegate(string line)
			{
				handleLine2(line);
				return Task.CompletedTask;
			}, encoding);
		}

		public static PipeTarget ToDelegate(Action<string> handleLine)
		{
			return ToDelegate(handleLine, Console.OutputEncoding);
		}

		public static PipeTarget Merge(IEnumerable<PipeTarget> targets)
		{
			IReadOnlyList<PipeTarget> readOnlyList = OptimizeTargets(targets);
			if (readOnlyList.Count == 1)
			{
				return readOnlyList.Single();
			}
			if (readOnlyList.Count == 0)
			{
				return Null;
			}
			return new <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget(readOnlyList);
			static void FlattenTargets(IEnumerable<PipeTarget> targets, ICollection<PipeTarget> output)
			{
				foreach (PipeTarget target in targets)
				{
					if (target is <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget2)
					{
						FlattenTargets(<PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget2.Targets, output);
					}
					else
					{
						output.Add(target);
					}
				}
			}
			static IReadOnlyList<PipeTarget> OptimizeTargets(IEnumerable<PipeTarget> targets)
			{
				List<PipeTarget> list = new List<PipeTarget>();
				FlattenTargets(targets, list);
				list.RemoveAll((PipeTarget t) => t == Null);
				return list;
			}
		}

		public static PipeTarget Merge(params PipeTarget[] targets)
		{
			return Merge((IEnumerable<PipeTarget>)targets);
		}
	}
	internal class <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AnonymousPipeTarget : PipeTarget
	{
		private readonly Func<Stream, CancellationToken, Task> _copyFromAsync;

		public <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AnonymousPipeTarget(Func<Stream, CancellationToken, Task> copyFromAsync)
		{
			_copyFromAsync = copyFromAsync;
		}

		public override async Task CopyFromAsync(Stream origin, CancellationToken cancellationToken = default(CancellationToken))
		{
			await _copyFromAsync(origin, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
	}
	internal class <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget : PipeTarget
	{
		public IReadOnlyList<PipeTarget> Targets { get; }

		public <PipeTarget>F825283E4191C5E3065EA9B63A9E400DE4BF8A70F67D820C9074D40C0E517F81E__AggregatePipeTarget(IReadOnlyList<PipeTarget> targets)
		{
			Targets = targets;
		}

		public override async Task CopyFromAsync(Stream origin, CancellationToken cancellationToken = default(CancellationToken))
		{
			CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { cancellationToken });
			try
			{
				Dictionary<PipeTarget, SimplexStream> targetSubStreams = new Dictionary<PipeTarget, SimplexStream>();
				foreach (PipeTarget target in Targets)
				{
					targetSubStreams[target] = new SimplexStream();
				}
				PipeTarget key;
				SimplexStream value;
				try
				{
					Task readingTask = Task.WhenAll(targetSubStreams.Select<KeyValuePair<PipeTarget, SimplexStream>, Task>(async delegate(KeyValuePair<PipeTarget, SimplexStream> targetSubStream)
					{
						KeyValuePair<PipeTarget, SimplexStream> keyValuePair = targetSubStream;
						var (pipeTarget2, origin2) = (KeyValuePair<PipeTarget, SimplexStream>)(ref keyValuePair);
						try
						{
							await pipeTarget2.CopyFromAsync(origin2, cts.Token).ConfigureAwait(continueOnCapturedContext: false);
						}
						catch
						{
							cts.Cancel();
							throw;
						}
					}));
					try
					{
						using IMemoryOwner<byte> buffer = MemoryPool<byte>.Shared.Rent(81920);
						while (true)
						{
							int bytesRead = await origin.ReadAsync(buffer.Memory, cts.Token).ConfigureAwait(continueOnCapturedContext: false);
							if (bytesRead <= 0)
							{
								break;
							}
							foreach (KeyValuePair<PipeTarget, SimplexStream> item in targetSubStreams)
							{
								item.Deconstruct(out key, out value);
								await value.WriteAsync(buffer.Memory.Slice(0, bytesRead), cts.Token).ConfigureAwait(continueOnCapturedContext: false);
							}
						}
						foreach (KeyValuePair<PipeTarget, SimplexStream> item2 in targetSubStreams)
						{
							item2.Deconstruct(out key, out value);
							await value.ReportCompletionAsync(cts.Token).ConfigureAwait(continueOnCapturedContext: false);
						}
					}
					finally
					{
						await readingTask.ConfigureAwait(continueOnCapturedContext: false);
					}
				}
				finally
				{
					foreach (KeyValuePair<PipeTarget, SimplexStream> item3 in targetSubStreams)
					{
						item3.Deconstruct(out key, out value);
						await value.ToAsyncDisposable().DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
					}
				}
			}
			finally
			{
				if (cts != null)
				{
					((IDisposable)cts).Dispose();
				}
			}
		}
	}
}
namespace CliWrap.Utils
{
	internal static class BufferSizes
	{
		public const int Stream = 81920;

		public const int StreamReader = 1024;
	}
	internal class Channel<T> : IDisposable
	{
		private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);

		private readonly SemaphoreSlim _readLock = new SemaphoreSlim(0, 1);

		private bool _isItemAvailable;

		private T _item;

		public async Task PublishAsync(T item, CancellationToken cancellationToken = default(CancellationToken))
		{
			await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			_item = item;
			_isItemAvailable = true;
			_readLock.Release();
		}

		public async IAsyncEnumerable<T> ReceiveAsync([EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			while (true)
			{
				await _readLock.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				if (!_isItemAvailable)
				{
					break;
				}
				yield return _item;
				_isItemAvailable = false;
				_writeLock.Release();
			}
		}

		public async Task ReportCompletionAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			_item = default(T);
			_isItemAvailable = false;
			_readLock.Release();
		}

		public void Dispose()
		{
			_writeLock.Dispose();
			_readLock.Dispose();
		}
	}
	internal class Disposable : IDisposable
	{
		private readonly Action _dispose;

		public static IDisposable Null { get; } = Create(delegate
		{
		});


		public Disposable(Action dispose)
		{
			_dispose = dispose;
		}

		public void Dispose()
		{
			_dispose();
		}

		public static IDisposable Create(Action dispose)
		{
			return new Disposable(dispose);
		}
	}
	internal static class EnvironmentEx
	{
		private static readonly Lazy<string?> ProcessPathLazy = new Lazy<string>(delegate
		{
			using Process process = Process.GetCurrentProcess();
			return process.MainModule?.FileName;
		});

		public static string? ProcessPath => ProcessPathLazy.Value;
	}
	internal static class NativeMethods
	{
		public static class Unix
		{
			[DllImport("libc", EntryPoint = "kill", SetLastError = true)]
			public static extern int Kill(int pid, int sig);
		}
	}
	internal class <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__SynchronizedObserver<T> : IObserver<T>
	{
		private readonly IObserver<T> _observer;

		private readonly object _syncRoot;

		public <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__SynchronizedObserver(IObserver<T> observer, object? syncRoot = null)
		{
			_observer = observer;
			_syncRoot = syncRoot ?? new object();
		}

		public void OnCompleted()
		{
			lock (_syncRoot)
			{
				_observer.OnCompleted();
			}
		}

		public void OnError(Exception error)
		{
			lock (_syncRoot)
			{
				_observer.OnError(error);
			}
		}

		public void OnNext(T value)
		{
			lock (_syncRoot)
			{
				_observer.OnNext(value);
			}
		}
	}
	internal class <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__Observable<T> : IObservable<T>
	{
		private readonly Func<IObserver<T>, IDisposable> _subscribe;

		public <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__Observable(Func<IObserver<T>, IDisposable> subscribe)
		{
			_subscribe = subscribe;
		}

		public IDisposable Subscribe(IObserver<T> observer)
		{
			return _subscribe(new <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__SynchronizedObserver<T>(observer));
		}
	}
	internal static class Observable
	{
		public static IObservable<T> Create<T>(Func<IObserver<T>, IDisposable> subscribe)
		{
			return new <Observable>F9A56BC066C1C55331A426EEC55B608B3C789C113870FC381D9D496607E7DCF71__Observable<T>(subscribe);
		}
	}
	internal class ProcessEx : IDisposable
	{
		private readonly Process _nativeProcess;

		private readonly TaskCompletionSource<object?> _exitTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);

		public int Id => _nativeProcess.Id;

		public string Name => Path.GetFileName(_nativeProcess.StartInfo.FileName);

		public Stream StandardInput => _nativeProcess.StandardInput.BaseStream;

		public Stream StandardOutput => _nativeProcess.StandardOutput.BaseStream;

		public Stream StandardError => _nativeProcess.StandardError.BaseStream;

		public DateTimeOffset StartTime { get; private set; }

		public DateTimeOffset ExitTime { get; private set; }

		public int ExitCode => _nativeProcess.ExitCode;

		public ProcessEx(ProcessStartInfo startInfo)
		{
			_nativeProcess = new Process
			{
				StartInfo = startInfo
			};
		}

		public void Start()
		{
			_nativeProcess.EnableRaisingEvents = true;
			_nativeProcess.Exited += delegate
			{
				ExitTime = DateTimeOffset.Now;
				_exitTcs.TrySetResult(null);
			};
			try
			{
				if (!_nativeProcess.Start())
				{
					throw new InvalidOperationException("Failed to start a process with file path '" + _nativeProcess.StartInfo.FileName + "'. Target file is not an executable or lacks execute permissions.");
				}
				StartTime = DateTimeOffset.Now;
			}
			catch (Win32Exception innerException)
			{
				throw new Win32Exception("Failed to start a process with file path '" + _nativeProcess.StartInfo.FileName + "'. Target file or working directory doesn't exist, or the provided credentials are invalid.", innerException);
			}
		}

		public void Interrupt()
		{
			if (!TryInterrupt())
			{
				Kill();
			}
			bool TryInterrupt()
			{
				try
				{
					if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
					{
						using (WindowsSignaler windowsSignaler = WindowsSignaler.Deploy())
						{
							return windowsSignaler.TrySend(_nativeProcess.Id, 0);
						}
					}
					if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
					{
						return NativeMethods.Unix.Kill(_nativeProcess.Id, 2) == 0;
					}
					return false;
				}
				catch
				{
					return false;
				}
			}
		}

		public void Kill()
		{
			try
			{
				PolyfillExtensions.Kill(_nativeProcess, entireProcessTree: true);
			}
			catch when (_nativeProcess.HasExited)
			{
			}
			catch
			{
			}
		}

		public async Task WaitUntilExitAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			await using (cancellationToken.Register(delegate
			{
				_exitTcs.TrySetCanceled(cancellationToken);
			}).ToAsyncDisposable())
			{
				await _exitTcs.Task.ConfigureAwait(continueOnCapturedContext: false);
			}
		}

		public void Dispose()
		{
			_nativeProcess.Dispose();
		}
	}
	internal class SimplexStream : Stream
	{
		private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);

		private readonly SemaphoreSlim _readLock = new SemaphoreSlim(0, 1);

		private IMemoryOwner<byte> _sharedBuffer = MemoryPool<byte>.Shared.Rent(81920);

		private int _sharedBufferBytes;

		private int _sharedBufferBytesRead;

		[ExcludeFromCodeCoverage]
		public override bool CanRead => true;

		[ExcludeFromCodeCoverage]
		public override bool CanSeek => false;

		[ExcludeFromCodeCoverage]
		public override bool CanWrite => true;

		[ExcludeFromCodeCoverage]
		public override long Position { get; set; }

		[ExcludeFromCodeCoverage]
		public override long Length
		{
			get
			{
				throw new NotSupportedException();
			}
		}

		public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
		{
			await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (_sharedBuffer.Memory.Length < count)
			{
				_sharedBuffer.Dispose();
				_sharedBuffer = MemoryPool<byte>.Shared.Rent(count);
			}
			buffer.AsSpan(offset, count).CopyTo(_sharedBuffer.Memory.Span);
			_sharedBufferBytes = count;
			_sharedBufferBytesRead = 0;
			_readLock.Release();
		}

		public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
		{
			await _readLock.WaitAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			int num = Math.Min(count, _sharedBufferBytes - _sharedBufferBytesRead);
			_sharedBuffer.Memory.Slice(_sharedBufferBytesRead, num).CopyTo(buffer.AsMemory(offset, num));
			_sharedBufferBytesRead += num;
			if (_sharedBufferBytesRead >= _sharedBufferBytes)
			{
				_writeLock.Release();
			}
			else
			{
				_readLock.Release();
			}
			return num;
		}

		public async Task ReportCompletionAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			await WriteAsync(Array.Empty<byte>(), 0, 0, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				_readLock.Dispose();
				_writeLock.Dispose();
				_sharedBuffer.Dispose();
			}
			base.Dispose(disposing);
		}

		[ExcludeFromCodeCoverage]
		public override int Read(byte[] buffer, int offset, int count)
		{
			return ReadAsync(buffer, offset, count).GetAwaiter().GetResult();
		}

		[ExcludeFromCodeCoverage]
		public override void Write(byte[] buffer, int offset, int count)
		{
			WriteAsync(buffer, offset, count).GetAwaiter().GetResult();
		}

		[ExcludeFromCodeCoverage]
		public override void Flush()
		{
			throw new NotSupportedException();
		}

		[ExcludeFromCodeCoverage]
		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotSupportedException();
		}

		[ExcludeFromCodeCoverage]
		public override void SetLength(long value)
		{
			throw new NotSupportedException();
		}
	}
	internal class WindowsSignaler : IDisposable
	{
		private readonly string _filePath;

		public WindowsSignaler(string filePath)
		{
			_filePath = filePath;
		}

		public bool TrySend(int processId, int signalId)
		{
			Process process = new Process();
			ProcessStartInfo processStartInfo = new ProcessStartInfo();
			processStartInfo.FileName = _filePath;
			processStartInfo.Arguments = processId.ToString(CultureInfo.InvariantCulture) + " " + signalId.ToString(CultureInfo.InvariantCulture);
			processStartInfo.CreateNoWindow = true;
			processStartInfo.UseShellExecute = false;
			processStartInfo.Environment["COMPLUS_OnlyUseLatestCLR"] = "1";
			process.StartInfo = processStartInfo;
			using Process process2 = process;
			if (!process2.Start())
			{
				return false;
			}
			if (!process2.WaitForExit(30000))
			{
				return false;
			}
			return process2.ExitCode == 0;
		}

		public void Dispose()
		{
			try
			{
				File.Delete(_filePath);
			}
			catch
			{
			}
		}

		public static WindowsSignaler Deploy()
		{
			string text = Path.ChangeExtension(Path.GetTempFileName(), "exe");
			Assembly.GetExecutingAssembly().ExtractManifestResource("CliWrap.Signaler.exe", text);
			return new WindowsSignaler(text);
		}
	}
}
namespace CliWrap.Utils.Extensions
{
	internal static class AssemblyExtensions
	{
		public static void ExtractManifestResource(this Assembly assembly, string resourceName, string destFilePath)
		{
			Stream stream = assembly.GetManifestResourceStream(resourceName) ?? throw new MissingManifestResourceException("Could not find resource '" + resourceName + "'.");
			using FileStream destination = File.Create(destFilePath);
			stream.CopyTo(destination);
		}
	}
	internal static class AsyncDisposableExtensions
	{
		private readonly struct AsyncDisposableAdapter : IAsyncDisposable
		{
			private readonly IDisposable _target;

			public AsyncDisposableAdapter(IDisposable target)
			{
				_target = target;
			}

			public async ValueTask DisposeAsync()
			{
				if (_target is IAsyncDisposable asyncDisposable)
				{
					await asyncDisposable.DisposeAsync().ConfigureAwait(continueOnCapturedContext: false);
				}
				else
				{
					_target.Dispose();
				}
			}
		}

		public static IAsyncDisposable ToAsyncDisposable(this IDisposable disposable)
		{
			return new AsyncDisposableAdapter(disposable);
		}
	}
	internal static class CancellationTokenExtensions
	{
		public static void ThrowIfCancellationRequested(this CancellationToken cancellationToken, string message)
		{
			if (!cancellationToken.IsCancellationRequested)
			{
				return;
			}
			throw new OperationCanceledException(message, cancellationToken);
		}
	}
	internal static class ExceptionExtensions
	{
		public static Exception? TryGetSingle(this AggregateException exception)
		{
			ReadOnlyCollection<Exception> innerExceptions = exception.Flatten().InnerExceptions;
			if (innerExceptions.Count != 1)
			{
				return null;
			}
			return innerExceptions.Single();
		}
	}
	internal static class StreamExtensions
	{
		public static async Task CopyToAsync(this Stream source, Stream destination, bool autoFlush, CancellationToken cancellationToken = default(CancellationToken))
		{
			using IMemoryOwner<byte> buffer = MemoryPool<byte>.Shared.Rent(81920);
			while (true)
			{
				int num = await source.ReadAsync(buffer.Memory, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				if (num <= 0)
				{
					break;
				}
				await destination.WriteAsync(buffer.Memory.Slice(0, num), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				if (autoFlush)
				{
					await destination.FlushAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}
			}
		}

		public static async IAsyncEnumerable<string> ReadAllLinesAsync(this StreamReader reader, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			StringBuilder lineBuffer = new StringBuilder();
			using IMemoryOwner<char> buffer = MemoryPool<char>.Shared.Rent(1024);
			bool isLastCaretReturn = false;
			while (true)
			{
				int charsRead = await reader.ReadAsync(buffer.Memory, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				if (charsRead <= 0)
				{
					break;
				}
				for (int i = 0; i < charsRead; i++)
				{
					char c = buffer.Memory.Span[i];
					if (isLastCaretReturn && c == '\n')
					{
						isLastCaretReturn = false;
						continue;
					}
					char c2 = c;
					if ((c2 == '\n' || c2 == '\r') ? true : false)
					{
						yield return lineBuffer.ToString();
						lineBuffer.Clear();
					}
					else
					{
						lineBuffer.Append(c);
					}
					isLastCaretReturn = c == '\r';
				}
			}
			if (lineBuffer.Length > 0)
			{
				yield return lineBuffer.ToString();
			}
		}
	}
	internal static class StringExtensions
	{
		public static SecureString ToSecureString(this string str)
		{
			SecureString secureString = new SecureString();
			foreach (char c in str)
			{
				secureString.AppendChar(c);
			}
			secureString.MakeReadOnly();
			return secureString;
		}
	}
	internal static class TaskExtensions
	{
		public static async Task<TDestination> Select<TSource, TDestination>(this Task<TSource> task, Func<TSource, TDestination> transform)
		{
			return transform(await task.ConfigureAwait(continueOnCapturedContext: false));
		}
	}
}
namespace CliWrap.Exceptions
{
	public abstract class CliWrapException : Exception
	{
		protected CliWrapException(string message, Exception? innerException)
			: base(message, innerException)
		{
		}

		[ExcludeFromCodeCoverage]
		protected CliWrapException(string message)
			: this(message, null)
		{
		}
	}
	public class CommandExecutionException : CliWrapException
	{
		public ICommandConfiguration Command { get; }

		public int ExitCode { get; }

		public CommandExecutionException(ICommandConfiguration command, int exitCode, string message, Exception? innerException)
			: base(message, innerException)
		{
			Command = command;
			ExitCode = exitCode;
		}

		[ExcludeFromCodeCoverage]
		public CommandExecutionException(ICommandConfiguration command, int exitCode, string message)
			: this(command, exitCode, message, null)
		{
		}
	}
}
namespace CliWrap.EventStream
{
	public abstract class CommandEvent
	{
	}
	public class StartedCommandEvent : CommandEvent
	{
		public int ProcessId { get; }

		public StartedCommandEvent(int processId)
		{
			ProcessId = processId;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Process ID: {ProcessId}";
		}
	}
	public class StandardOutputCommandEvent : CommandEvent
	{
		public string Text { get; }

		public StandardOutputCommandEvent(string text)
		{
			Text = text;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return Text;
		}
	}
	public class StandardErrorCommandEvent : CommandEvent
	{
		public string Text { get; }

		public StandardErrorCommandEvent(string text)
		{
			Text = text;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return Text;
		}
	}
	public class ExitedCommandEvent : CommandEvent
	{
		public int ExitCode { get; }

		public ExitedCommandEvent(int exitCode)
		{
			ExitCode = exitCode;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Exit code: {ExitCode}";
		}
	}
	public static class EventStreamCommandExtensions
	{
		public static async IAsyncEnumerable<CommandEvent> ListenAsync(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, [EnumeratorCancellation] CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken)
		{
			Channel<CommandEvent> channel = new Channel<CommandEvent>();
			try
			{
				PipeTarget target = PipeTarget.Merge(command.StandardOutputPipe, PipeTarget.ToDelegate(async delegate(string line, CancellationToken innerCancellationToken)
				{
					await channel.PublishAsync(new StandardOutputCommandEvent(line), innerCancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}, standardOutputEncoding));
				PipeTarget target2 = PipeTarget.Merge(command.StandardErrorPipe, PipeTarget.ToDelegate(async delegate(string line, CancellationToken innerCancellationToken)
				{
					await channel.PublishAsync(new StandardErrorCommandEvent(line), innerCancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}, standardErrorEncoding));
				Command command2 = command.WithStandardOutputPipe(target).WithStandardErrorPipe(target2);
				CommandTask<CommandResult> commandTask = command2.ExecuteAsync(forcefulCancellationToken, gracefulCancellationToken);
				yield return new StartedCommandEvent(commandTask.ProcessId);
				commandTask.Task.ContinueWith((Func<Task<CommandResult>, Task>)async delegate
				{
					await channel.ReportCompletionAsync(forcefulCancellationToken).ConfigureAwait(continueOnCapturedContext: false);
				}, TaskContinuationOptions.None);
				await foreach (CommandEvent item in channel.ReceiveAsync(forcefulCancellationToken).ConfigureAwait(continueOnCapturedContext: false))
				{
					yield return item;
				}
				yield return new ExitedCommandEvent(await commandTask.Select((CommandResult r) => r.ExitCode).ConfigureAwait(continueOnCapturedContext: false));
			}
			finally
			{
				if (channel != null)
				{
					((IDisposable)channel).Dispose();
				}
			}
		}

		public static IAsyncEnumerable<CommandEvent> ListenAsync(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ListenAsync(standardOutputEncoding, standardErrorEncoding, cancellationToken, CancellationToken.None);
		}

		public static IAsyncEnumerable<CommandEvent> ListenAsync(this Command command, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ListenAsync(encoding, encoding, cancellationToken);
		}

		public static IAsyncEnumerable<CommandEvent> ListenAsync(this Command command, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ListenAsync(Console.OutputEncoding, cancellationToken);
		}

		public static IObservable<CommandEvent> Observe(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken)
		{
			Command command2 = command;
			Encoding standardOutputEncoding2 = standardOutputEncoding;
			Encoding standardErrorEncoding2 = standardErrorEncoding;
			return Observable.Create(delegate(IObserver<CommandEvent> observer)
			{
				IObserver<CommandEvent> observer2 = observer;
				PipeTarget target = PipeTarget.Merge(command2.StandardOutputPipe, PipeTarget.ToDelegate(delegate(string line)
				{
					observer2.OnNext(new StandardOutputCommandEvent(line));
				}, standardOutputEncoding2));
				PipeTarget target2 = PipeTarget.Merge(command2.StandardErrorPipe, PipeTarget.ToDelegate(delegate(string line)
				{
					observer2.OnNext(new StandardErrorCommandEvent(line));
				}, standardErrorEncoding2));
				CommandTask<CommandResult> commandTask = command2.WithStandardOutputPipe(target).WithStandardErrorPipe(target2).ExecuteAsync(forcefulCancellationToken, gracefulCancellationToken);
				observer2.OnNext(new StartedCommandEvent(commandTask.ProcessId));
				commandTask.Task.ContinueWith(delegate(Task<CommandResult> t)
				{
					if (t.IsCanceled)
					{
						observer2.OnError(new TaskCanceledException(t));
					}
					else if (t.Exception != null)
					{
						observer2.OnError(t.Exception.TryGetSingle() ?? t.Exception);
					}
					else
					{
						observer2.OnNext(new ExitedCommandEvent(t.Result.ExitCode));
						observer2.OnCompleted();
					}
				}, TaskContinuationOptions.None);
				return Disposable.Null;
			});
		}

		public static IObservable<CommandEvent> Observe(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.Observe(standardOutputEncoding, standardErrorEncoding, cancellationToken, CancellationToken.None);
		}

		public static IObservable<CommandEvent> Observe(this Command command, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.Observe(encoding, encoding, cancellationToken);
		}

		public static IObservable<CommandEvent> Observe(this Command command, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.Observe(Console.OutputEncoding, cancellationToken);
		}
	}
}
namespace CliWrap.Builders
{
	public class ArgumentsBuilder
	{
		private static readonly IFormatProvider DefaultFormatProvider = CultureInfo.InvariantCulture;

		private readonly StringBuilder _buffer = new StringBuilder();

		public ArgumentsBuilder Add(string value, bool escape)
		{
			if (_buffer.Length > 0)
			{
				_buffer.Append(' ');
			}
			_buffer.Append(escape ? Escape(value) : value);
			return this;
		}

		public ArgumentsBuilder Add(string value)
		{
			return Add(value, escape: true);
		}

		public ArgumentsBuilder Add(IEnumerable<string> values, bool escape)
		{
			foreach (string value in values)
			{
				Add(value, escape);
			}
			return this;
		}

		public ArgumentsBuilder Add(IEnumerable<string> values)
		{
			return Add(values, escape: true);
		}

		public ArgumentsBuilder Add(IFormattable value, IFormatProvider formatProvider, bool escape = true)
		{
			return Add(value.ToString(null, formatProvider), escape);
		}

		public ArgumentsBuilder Add(IFormattable value, CultureInfo cultureInfo, bool escape)
		{
			return Add(value, (IFormatProvider)cultureInfo, escape);
		}

		public ArgumentsBuilder Add(IFormattable value, CultureInfo cultureInfo)
		{
			return Add(value, cultureInfo, escape: true);
		}

		public ArgumentsBuilder Add(IFormattable value, bool escape)
		{
			return Add(value, DefaultFormatProvider, escape);
		}

		public ArgumentsBuilder Add(IFormattable value)
		{
			return Add(value, escape: true);
		}

		public ArgumentsBuilder Add(IEnumerable<IFormattable> values, IFormatProvider formatProvider, bool escape = true)
		{
			foreach (IFormattable value in values)
			{
				Add(value, formatProvider, escape);
			}
			return this;
		}

		public ArgumentsBuilder Add(IEnumerable<IFormattable> values, CultureInfo cultureInfo, bool escape)
		{
			return Add(values, (IFormatProvider)cultureInfo, escape);
		}

		public ArgumentsBuilder Add(IEnumerable<IFormattable> values, CultureInfo cultureInfo)
		{
			return Add(values, cultureInfo, escape: true);
		}

		public ArgumentsBuilder Add(IEnumerable<IFormattable> values, bool escape)
		{
			return Add(values, DefaultFormatProvider, escape);
		}

		public ArgumentsBuilder Add(IEnumerable<IFormattable> values)
		{
			return Add(values, escape: true);
		}

		public string Build()
		{
			return _buffer.ToString();
		}

		private static string Escape(string argument)
		{
			if (argument.Length > 0 && argument.All((char c) => !char.IsWhiteSpace(c) && c != '"'))
			{
				return argument;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append('"');
			int i = 0;
			while (i < argument.Length)
			{
				char c2 = argument[i++];
				switch (c2)
				{
				case '\\':
				{
					int num = 1;
					for (; i < argument.Length && argument[i] == '\\'; i++)
					{
						num++;
					}
					if (i == argument.Length)
					{
						stringBuilder.Append('\\', num * 2);
					}
					else if (argument[i] == '"')
					{
						stringBuilder.Append('\\', num * 2 + 1).Append('"');
						i++;
					}
					else
					{
						stringBuilder.Append('\\', num);
					}
					break;
				}
				case '"':
					stringBuilder.Append('\\').Append('"');
					break;
				default:
					stringBuilder.Append(c2);
					break;
				}
			}
			stringBuilder.Append('"');
			return stringBuilder.ToString();
		}
	}
	public class CredentialsBuilder
	{
		private string? _domain;

		private string? _userName;

		private string? _password;

		private bool _loadUserProfile;

		public CredentialsBuilder SetDomain(string? domain)
		{
			_domain = domain;
			return this;
		}

		public CredentialsBuilder SetUserName(string? userName)
		{
			_userName = userName;
			return this;
		}

		public CredentialsBuilder SetPassword(string? password)
		{
			_password = password;
			return this;
		}

		public CredentialsBuilder LoadUserProfile(bool loadUserProfile = true)
		{
			_loadUserProfile = loadUserProfile;
			return this;
		}

		public Credentials Build()
		{
			return new Credentials(_domain, _userName, _password, _loadUserProfile);
		}
	}
	public class EnvironmentVariablesBuilder
	{
		private readonly Dictionary<string, string?> _envVars = new Dictionary<string, string>(StringComparer.Ordinal);

		public EnvironmentVariablesBuilder Set(string name, string? value)
		{
			_envVars[name] = value;
			return this;
		}

		public EnvironmentVariablesBuilder Set(IEnumerable<KeyValuePair<string, string?>> variables)
		{
			foreach (var (name, value) in variables)
			{
				Set(name, value);
			}
			return this;
		}

		public EnvironmentVariablesBuilder Set(IReadOnlyDictionary<string, string?> variables)
		{
			return Set((IEnumerable<KeyValuePair<string, string?>>)variables);
		}

		public IReadOnlyDictionary<string, string?> Build()
		{
			return new Dictionary<string, string>(_envVars, _envVars.Comparer);
		}
	}
}
namespace CliWrap.Buffered
{
	public static class BufferedCommandExtensions
	{
		public static CommandTask<BufferedCommandResult> ExecuteBufferedAsync(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken)
		{
			StringBuilder stdOutBuffer = new StringBuilder();
			StringBuilder stdErrBuffer = new StringBuilder();
			PipeTarget target = PipeTarget.Merge(command.StandardOutputPipe, PipeTarget.ToStringBuilder(stdOutBuffer, standardOutputEncoding));
			PipeTarget target2 = PipeTarget.Merge(command.StandardErrorPipe, PipeTarget.ToStringBuilder(stdErrBuffer, standardErrorEncoding));
			return command.WithStandardOutputPipe(target).WithStandardErrorPipe(target2).ExecuteAsync(forcefulCancellationToken, gracefulCancellationToken)
				.Bind(async delegate(Task<CommandResult> task)
				{
					try
					{
						CommandResult commandResult = await task;
						return new BufferedCommandResult(commandResult.ExitCode, commandResult.StartTime, commandResult.ExitTime, stdOutBuffer.ToString(), stdErrBuffer.ToString());
					}
					catch (CommandExecutionException ex)
					{
						throw new CommandExecutionException(ex.Command, ex.ExitCode, "Command execution failed, see the inner exception for details.\r\n\r\nStandard error:\r\n" + stdErrBuffer.ToString().Trim(), ex);
					}
				});
		}

		public static CommandTask<BufferedCommandResult> ExecuteBufferedAsync(this Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ExecuteBufferedAsync(standardOutputEncoding, standardErrorEncoding, cancellationToken, CancellationToken.None);
		}

		public static CommandTask<BufferedCommandResult> ExecuteBufferedAsync(this Command command, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ExecuteBufferedAsync(encoding, encoding, cancellationToken);
		}

		public static CommandTask<BufferedCommandResult> ExecuteBufferedAsync(this Command command, CancellationToken cancellationToken = default(CancellationToken))
		{
			return command.ExecuteBufferedAsync(Console.OutputEncoding, cancellationToken);
		}
	}
	public class BufferedCommandResult : CommandResult
	{
		public string StandardOutput { get; }

		public string StandardError { get; }

		public BufferedCommandResult(int exitCode, DateTimeOffset startTime, DateTimeOffset exitTime, string standardOutput, string standardError)
			: base(exitCode, startTime, exitTime)
		{
			StandardOutput = standardOutput;
			StandardError = standardError;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Constructor)]
	[ExcludeFromCodeCoverage]
	internal class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	[ExcludeFromCodeCoverage]
	internal class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}

		public StringSyntaxAttribute(string syntax)
			: this(syntax, new object[0])
		{
		}
	}
}
namespace System.Linq
{
	internal static class PolyfillExtensions
	{
		public static T ElementAt<T>(this IEnumerable<T> source, Index index)
		{
			if (index.IsFromEnd)
			{
				ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
				return collection.ElementAt(collection.Count - index.Value);
			}
			return source.ElementAt(index.Value);
		}

		public static T? ElementAtOrDefault<T>(this IEnumerable<T> source, Index index)
		{
			if (index.IsFromEnd)
			{
				ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
				return collection.ElementAtOrDefault(collection.Count - index.Value);
			}
			return source.ElementAtOrDefault(index.Value);
		}

		public static T FirstOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			using IEnumerator<T> enumerator = source.GetEnumerator();
			if (enumerator.MoveNext())
			{
				return enumerator.Current;
			}
			return defaultValue;
		}

		public static T FirstOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			foreach (T item in source)
			{
				if (predicate(item))
				{
					return item;
				}
			}
			return defaultValue;
		}

		public static T LastOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			T result = defaultValue;
			foreach (T item in source)
			{
				result = item;
			}
			return result;
		}

		public static T LastOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			T result = defaultValue;
			foreach (T item in source)
			{
				if (predicate(item))
				{
					result = item;
				}
			}
			return result;
		}

		public static T SingleOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			T result = defaultValue;
			bool flag = false;
			foreach (T item in source)
			{
				if (flag)
				{
					throw new InvalidOperationException("Sequence contains more than one element.");
				}
				result = item;
				flag = true;
			}
			return result;
		}

		public static T SingleOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			T result = defaultValue;
			bool flag = false;
			foreach (T item in source)
			{
				if (predicate(item))
				{
					if (flag)
					{
						throw new InvalidOperationException("Sequence contains more than one element.");
					}
					result = item;
					flag = true;
				}
			}
			return result;
		}

		public static IEnumerable<T> Take<T>(this IEnumerable<T> source, Range range)
		{
			ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
			var (count, count2) = range.GetOffsetAndLength(collection.Count);
			return collection.Skip(count).Take(count2);
		}

		public static T? Min<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderBy((T x) => x, comparer).FirstOrDefault();
		}

		public static T? MinBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer)
		{
			return source.OrderBy(keySelector, comparer).FirstOrDefault();
		}

		public static T? MinBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return MinBy(source, keySelector, Comparer<TKey>.Default);
		}

		public static T? Max<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderByDescending((T x) => x, comparer).FirstOrDefault();
		}

		public static T? MaxBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer)
		{
			return source.OrderByDescending(keySelector, comparer).FirstOrDefault();
		}

		public static T? MaxBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return MaxBy(source, keySelector, Comparer<TKey>.Default);
		}

		public static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			return from x in source.GroupBy(keySelector, comparer)
				select x.First();
		}

		public static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return DistinctBy(source, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> ExceptBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(other, comparer);
			foreach (T item in source)
			{
				if (!set.Contains(keySelector(item)))
				{
					yield return item;
				}
			}
		}

		public static IEnumerable<T> ExceptBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector)
		{
			return ExceptBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> IntersectBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(other, comparer);
			foreach (T item in source)
			{
				if (set.Contains(keySelector(item)))
				{
					yield return item;
				}
			}
		}

		public static IEnumerable<T> IntersectBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector)
		{
			return IntersectBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> UnionBy<T, TKey>(this IEnumerable<T> source, IEnumerable<T> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(comparer);
			foreach (T item in source)
			{
				if (set.Add(keySelector(item)))
				{
					yield return item;
				}
			}
			foreach (T item2 in other)
			{
				if (set.Add(keySelector(item2)))
				{
					yield return item2;
				}
			}
		}

		public static IEnumerable<T> UnionBy<T, TKey>(this IEnumerable<T> source, IEnumerable<T> other, Func<T, TKey> keySelector)
		{
			return UnionBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T[]> Chunk<T>(this IEnumerable<T> source, int size)
		{
			List<T> chunk = new List<T>(size);
			foreach (T item in source)
			{
				chunk.Add(item);
				if (chunk.Count == size)
				{
					yield return chunk.ToArray();
					chunk.Clear();
				}
			}
			if (chunk.Count > 0)
			{
				yield return chunk.ToArray();
			}
		}

		public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderBy((T x) => x, comparer);
		}

		public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source)
		{
			return source.Order(Comparer<T>.Default);
		}

		public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderByDescending((T x) => x, comparer);
		}

		public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source)
		{
			return source.OrderDescending(Comparer<T>.Default);
		}

		public static IEnumerable<(TFirst left, TSecond right)> Zip<TFirst, TSecond>(this IEnumerable<TFirst> first, IEnumerable<TSecond> second)
		{
			return first.Zip(second, (TFirst x, TSecond y) => (x, y));
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string? EntryPoint { get; init; }

		public bool SetLastError { get; init; }

		public StringMarshalling StringMarshalling { get; init; }

		public Type? StringMarshallingCustomType { get; init; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Runtime.CompilerServices
{
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class SkipLocalsInitAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; init; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	[ExcludeFromCodeCoverage]
	internal class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
}
namespace System.Threading.Tasks
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.Net.Http
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.Management
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.IO
{
	internal static class PolyfillExtensions
	{
	}
}

plugins/System.Buffers.dll

Decompiled 7 months 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.28619.01")]
[assembly: AssemblyInformationalVersion("4.6.28619.01 @BuiltBy: dlab14-DDVSOWINAGE069 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/7601f4f6225089ffb291dc7d58293c7bbf5c5d4f")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.3.0")]
[module: UnverifiableCode]
namespace FxResources.System.Buffers
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class SR
	{
		private static ResourceManager s_resourceManager;

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

		internal static Type ResourceType { get; } = typeof(SR);


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

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static bool UsingResourceKeys()
		{
			return false;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string text = null;
			try
			{
				text = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal))
			{
				return defaultString;
			}
			return text;
		}

		internal static string Format(string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + string.Join(", ", args);
				}
				return string.Format(resourceFormat, args);
			}
			return resourceFormat;
		}

		internal static string Format(string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(resourceFormat, p1);
		}

		internal static string Format(string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(resourceFormat, p1, p2);
		}

		internal static string Format(string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(resourceFormat, p1, p2, p3);
		}
	}
}
namespace System.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 = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&bufferId)
			};
			ptr[1] = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&bufferSize)
			};
			ptr[2] = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&poolId)
			};
			ptr[3] = new EventData
			{
				Size = 4,
				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 = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&bufferId)
			};
			ptr[1] = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&bufferSize)
			};
			ptr[2] = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&poolId)
			};
			ptr[3] = new EventData
			{
				Size = 4,
				DataPointer = (IntPtr)(&bucketId)
			};
			ptr[4] = new EventData
			{
				Size = 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;
		}
	}
}

plugins/System.Management.dll

Decompiled 7 months ago
using System;
using System.CodeDom;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FxResources.System.Management;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyMetadata("NotSupported", "True")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyDefaultAlias("System.Management")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: SupportedOSPlatform("windows")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure.\r\n\r\nCommonly Used Types:\r\nSystem.Management.ManagementClass\r\nSystem.Management.ManagementObject\r\nSystem.Management.SelectQuery")]
[assembly: AssemblyFileVersion("7.0.723.27404")]
[assembly: AssemblyInformationalVersion("7.0.7+5b20af47d99620150c53eaf5db8636fdf730b126")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Management")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FxResources.System.Management
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string InvalidQuery => GetResourceString("InvalidQuery");

		internal static string InvalidQueryDuplicatedToken => GetResourceString("InvalidQueryDuplicatedToken");

		internal static string InvalidQueryNullToken => GetResourceString("InvalidQueryNullToken");

		internal static string WorkerThreadWakeupFailed => GetResourceString("WorkerThreadWakeupFailed");

		internal static string ClassNameNotInitializedException => GetResourceString("ClassNameNotInitializedException");

		internal static string ClassNameNotFoundException => GetResourceString("ClassNameNotFoundException");

		internal static string CommentAttributeProperty => GetResourceString("CommentAttributeProperty");

		internal static string CommentAutoCommitProperty => GetResourceString("CommentAutoCommitProperty");

		internal static string CommentClassBegin => GetResourceString("CommentClassBegin");

		internal static string CommentConstructors => GetResourceString("CommentConstructors");

		internal static string CommentCreatedClass => GetResourceString("CommentCreatedClass");

		internal static string CommentCreatedWmiNamespace => GetResourceString("CommentCreatedWmiNamespace");

		internal static string CommentCurrentObject => GetResourceString("CommentCurrentObject");

		internal static string CommentDateConversionFunction => GetResourceString("CommentDateConversionFunction");

		internal static string CommentEmbeddedObject => GetResourceString("CommentEmbeddedObject");

		internal static string CommentEnumeratorImplementation => GetResourceString("CommentEnumeratorImplementation");

		internal static string CommentFlagForEmbedded => GetResourceString("CommentFlagForEmbedded");

		internal static string CommentGetInstances => GetResourceString("CommentGetInstances");

		internal static string CommentIsPropNull => GetResourceString("CommentIsPropNull");

		internal static string CommentLateBoundObject => GetResourceString("CommentLateBoundObject");

		internal static string CommentLateBoundProperty => GetResourceString("CommentLateBoundProperty");

		internal static string CommentManagementPath => GetResourceString("CommentManagementPath");

		internal static string CommentManagementScope => GetResourceString("CommentManagementScope");

		internal static string CommentOriginNamespace => GetResourceString("CommentOriginNamespace");

		internal static string CommentPrivateAutoCommit => GetResourceString("CommentPrivateAutoCommit");

		internal static string CommentPrototypeConverter => GetResourceString("CommentPrototypeConverter");

		internal static string CommentResetProperty => GetResourceString("CommentResetProperty");

		internal static string CommentShouldSerialize => GetResourceString("CommentShouldSerialize");

		internal static string CommentStaticManagementScope => GetResourceString("CommentStaticManagementScope");

		internal static string CommentStaticScopeProperty => GetResourceString("CommentStaticScopeProperty");

		internal static string CommentSystemObject => GetResourceString("CommentSystemObject");

		internal static string CommentSystemPropertiesClass => GetResourceString("CommentSystemPropertiesClass");

		internal static string CommentTimeSpanConversionFunction => GetResourceString("CommentTimeSpanConversionFunction");

		internal static string CommentToDateTime => GetResourceString("CommentToDateTime");

		internal static string CommentToDmtfDateTime => GetResourceString("CommentToDmtfDateTime");

		internal static string CommentToDmtfTimeInterval => GetResourceString("CommentToDmtfTimeInterval");

		internal static string CommentToTimeSpan => GetResourceString("CommentToTimeSpan");

		internal static string EmbeddedComment => GetResourceString("EmbeddedComment");

		internal static string EmbeddedComment2 => GetResourceString("EmbeddedComment2");

		internal static string EmbeddedComment3 => GetResourceString("EmbeddedComment3");

		internal static string EmbeddedComment4 => GetResourceString("EmbeddedComment4");

		internal static string EmbeddedComment5 => GetResourceString("EmbeddedComment5");

		internal static string EmbeddedComment6 => GetResourceString("EmbeddedComment6");

		internal static string EmbeddedComment7 => GetResourceString("EmbeddedComment7");

		internal static string EmbeddedComment8 => GetResourceString("EmbeddedComment8");

		internal static string EmbeddedCSharpComment1 => GetResourceString("EmbeddedCSharpComment1");

		internal static string EmbeddedCSharpComment10 => GetResourceString("EmbeddedCSharpComment10");

		internal static string EmbeddedCSharpComment11 => GetResourceString("EmbeddedCSharpComment11");

		internal static string EmbeddedCSharpComment12 => GetResourceString("EmbeddedCSharpComment12");

		internal static string EmbeddedCSharpComment13 => GetResourceString("EmbeddedCSharpComment13");

		internal static string EmbeddedCSharpComment14 => GetResourceString("EmbeddedCSharpComment14");

		internal static string EmbeddedCSharpComment15 => GetResourceString("EmbeddedCSharpComment15");

		internal static string EmbeddedCSharpComment2 => GetResourceString("EmbeddedCSharpComment2");

		internal static string EmbeddedCSharpComment3 => GetResourceString("EmbeddedCSharpComment3");

		internal static string EmbeddedCSharpComment4 => GetResourceString("EmbeddedCSharpComment4");

		internal static string EmbeddedCSharpComment5 => GetResourceString("EmbeddedCSharpComment5");

		internal static string EmbeddedCSharpComment6 => GetResourceString("EmbeddedCSharpComment6");

		internal static string EmbeddedCSharpComment7 => GetResourceString("EmbeddedCSharpComment7");

		internal static string EmbeddedCSharpComment8 => GetResourceString("EmbeddedCSharpComment8");

		internal static string EmbeddedCSharpComment9 => GetResourceString("EmbeddedCSharpComment9");

		internal static string EmbeddedVisualBasicComment1 => GetResourceString("EmbeddedVisualBasicComment1");

		internal static string EmbeddedVisualBasicComment10 => GetResourceString("EmbeddedVisualBasicComment10");

		internal static string EmbeddedVisualBasicComment2 => GetResourceString("EmbeddedVisualBasicComment2");

		internal static string EmbeddedVisualBasicComment3 => GetResourceString("EmbeddedVisualBasicComment3");

		internal static string EmbeddedVisualBasicComment4 => GetResourceString("EmbeddedVisualBasicComment4");

		internal static string EmbeddedVisualBasicComment5 => GetResourceString("EmbeddedVisualBasicComment5");

		internal static string EmbeddedVisualBasicComment6 => GetResourceString("EmbeddedVisualBasicComment6");

		internal static string EmbeddedVisualBasicComment7 => GetResourceString("EmbeddedVisualBasicComment7");

		internal static string EmbeddedVisualBasicComment8 => GetResourceString("EmbeddedVisualBasicComment8");

		internal static string EmbeddedVisualBasicComment9 => GetResourceString("EmbeddedVisualBasicComment9");

		internal static string EmptyFilePathException => GetResourceString("EmptyFilePathException");

		internal static string NamespaceNotInitializedException => GetResourceString("NamespaceNotInitializedException");

		internal static string NullFilePathException => GetResourceString("NullFilePathException");

		internal static string UnableToCreateCodeGeneratorException => GetResourceString("UnableToCreateCodeGeneratorException");

		internal static string PlatformNotSupported_SystemManagement => GetResourceString("PlatformNotSupported_SystemManagement");

		internal static string PlatformNotSupported_FullFrameworkRequired => GetResourceString("PlatformNotSupported_FullFrameworkRequired");

		internal static string LoadLibraryFailed => GetResourceString("LoadLibraryFailed");

		internal static string PlatformNotSupported_FrameworkUpdatedRequired => GetResourceString("PlatformNotSupported_FrameworkUpdatedRequired");

		internal static string InvalidQueryTokenExpected => GetResourceString("InvalidQueryTokenExpected");

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		internal static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		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);
		}

		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(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
}
namespace System.Management
{
	public enum AuthenticationLevel
	{
		Unchanged = -1,
		Default,
		None,
		Connect,
		Call,
		Packet,
		PacketIntegrity,
		PacketPrivacy
	}
	public enum CimType
	{
		None = 0,
		SInt16 = 2,
		SInt32 = 3,
		Real32 = 4,
		Real64 = 5,
		String = 8,
		Boolean = 11,
		Object = 13,
		SInt8 = 16,
		UInt8 = 17,
		UInt16 = 18,
		UInt32 = 19,
		SInt64 = 20,
		UInt64 = 21,
		DateTime = 101,
		Reference = 102,
		Char16 = 103
	}
	public enum CodeLanguage
	{
		CSharp,
		JScript,
		VB,
		VJSharp,
		Mcpp
	}
	[Flags]
	public enum ComparisonSettings
	{
		IncludeAll = 0,
		IgnoreQualifiers = 1,
		IgnoreObjectSource = 2,
		IgnoreDefaultValues = 4,
		IgnoreClass = 8,
		IgnoreCase = 0x10,
		IgnoreFlavor = 0x20
	}
	public class CompletedEventArgs : ManagementEventArgs
	{
		public ManagementStatus Status
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementBaseObject StatusObject
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal CompletedEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void CompletedEventHandler(object sender, CompletedEventArgs e);
	public class ConnectionOptions : ManagementOptions
	{
		public AuthenticationLevel Authentication
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Authority
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool EnablePrivileges
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ImpersonationLevel Impersonation
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Locale
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Password
		{
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public SecureString SecurePassword
		{
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Username
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ConnectionOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ConnectionOptions(string locale, string username, SecureString password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, ManagementNamedValueCollection context, TimeSpan timeout)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ConnectionOptions(string locale, string username, string password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, ManagementNamedValueCollection context, TimeSpan timeout)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class DeleteOptions : ManagementOptions
	{
		public DeleteOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public DeleteOptions(ManagementNamedValueCollection context, TimeSpan timeout)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class EnumerationOptions : ManagementOptions
	{
		public int BlockSize
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool DirectRead
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool EnsureLocatable
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool EnumerateDeep
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool PrototypeOnly
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool ReturnImmediately
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool Rewindable
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool UseAmendedQualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public EnumerationOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public EnumerationOptions(ManagementNamedValueCollection context, TimeSpan timeout, int blockSize, bool rewindable, bool returnImmediatley, bool useAmendedQualifiers, bool ensureLocatable, bool prototypeOnly, bool directRead, bool enumerateDeep)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class EventArrivedEventArgs : ManagementEventArgs
	{
		public ManagementBaseObject NewEvent
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal EventArrivedEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void EventArrivedEventHandler(object sender, EventArrivedEventArgs e);
	public class EventQuery : ManagementQuery
	{
		public EventQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public EventQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public EventQuery(string language, string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class EventWatcherOptions : ManagementOptions
	{
		public int BlockSize
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public EventWatcherOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public EventWatcherOptions(ManagementNamedValueCollection context, TimeSpan timeout, int blockSize)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public enum ImpersonationLevel
	{
		Default,
		Anonymous,
		Identify,
		Impersonate,
		Delegate
	}
	public class InvokeMethodOptions : ManagementOptions
	{
		public InvokeMethodOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public InvokeMethodOptions(ManagementNamedValueCollection context, TimeSpan timeout)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[ToolboxItem(false)]
	public class ManagementBaseObject : Component, ICloneable, ISerializable
	{
		public virtual ManagementPath ClassPath
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object this[string propertyName]
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual PropertyDataCollection Properties
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual QualifierDataCollection Qualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual PropertyDataCollection SystemProperties
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		protected ManagementBaseObject(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public new void Dispose()
		{
		}

		public override bool Equals(object obj)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override int GetHashCode()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public object GetPropertyQualifierValue(string propertyName, string qualifierName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public object GetPropertyValue(string propertyName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public object GetQualifierValue(string qualifierName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public string GetText(TextFormat format)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public static explicit operator IntPtr(ManagementBaseObject managementObject)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void SetPropertyQualifierValue(string propertyName, string qualifierName, object qualifierValue)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void SetPropertyValue(string propertyName, object propertyValue)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void SetQualifierValue(string qualifierName, object qualifierValue)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementClass : ManagementObject
	{
		public StringCollection Derivation
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public MethodDataCollection Methods
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public override ManagementPath Path
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementClass()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(ManagementPath path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(ManagementPath path, ObjectGetOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(ManagementScope scope, ManagementPath path, ObjectGetOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected ManagementClass(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(string path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(string path, ObjectGetOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass(string scope, string path, ObjectGetOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject CreateInstance()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementClass Derive(string newClassName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetInstances()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetInstances(EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetInstances(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetInstances(ManagementOperationObserver watcher, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelatedClasses()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelatedClasses(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelatedClasses(ManagementOperationObserver watcher, string relatedClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelatedClasses(ManagementOperationObserver watcher, string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelatedClasses(string relatedClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelatedClasses(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationshipClasses()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationshipClasses(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationshipClasses(ManagementOperationObserver watcher, string relationshipClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationshipClasses(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationshipClasses(string relationshipClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationshipClasses(string relationshipClass, string relationshipQualifier, string thisRole, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public CodeTypeDeclaration GetStronglyTypedClassCode(bool includeSystemClassInClassDef, bool systemPropertyClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public bool GetStronglyTypedClassCode(CodeLanguage lang, string filePath, string classNamespace)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetSubclasses()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetSubclasses(EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetSubclasses(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetSubclasses(ManagementOperationObserver watcher, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public sealed class ManagementDateTimeConverter
	{
		internal ManagementDateTimeConverter()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public static DateTime ToDateTime(string dmtfDate)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public static string ToDmtfDateTime(DateTime date)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public static string ToDmtfTimeInterval(TimeSpan timespan)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public static TimeSpan ToTimeSpan(string dmtfTimespan)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public abstract class ManagementEventArgs : EventArgs
	{
		public object Context
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ManagementEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[ToolboxItem(false)]
	public class ManagementEventWatcher : Component
	{
		public EventWatcherOptions Options
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public EventQuery Query
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementScope Scope
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public event EventArrivedEventHandler EventArrived
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public event StoppedEventHandler Stopped
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementEventWatcher()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(EventQuery query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(ManagementScope scope, EventQuery query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(ManagementScope scope, EventQuery query, EventWatcherOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(string scope, string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementEventWatcher(string scope, string query, EventWatcherOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		~ManagementEventWatcher()
		{
		}

		public void Start()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Stop()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementBaseObject WaitForNextEvent()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementException : SystemException
	{
		public ManagementStatus ErrorCode
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementBaseObject ErrorInformation
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementException()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected ManagementException(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementException(string message)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementException(string message, Exception innerException)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementNamedValueCollection : NameObjectCollectionBase
	{
		public object this[string name]
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementNamedValueCollection()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected ManagementNamedValueCollection(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Add(string name, object value)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementNamedValueCollection Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Remove(string name)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void RemoveAll()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementObject : ManagementBaseObject, ICloneable
	{
		public override ManagementPath ClassPath
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ObjectGetOptions Options
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual ManagementPath Path
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementScope Scope
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementObject()
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(ManagementPath path)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(ManagementPath path, ObjectGetOptions options)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(ManagementScope scope, ManagementPath path, ObjectGetOptions options)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected ManagementObject(SerializationInfo info, StreamingContext context)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(string path)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(string path, ObjectGetOptions options)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObject(string scopeString, string pathString, ObjectGetOptions options)
			: base(null, default(StreamingContext))
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(ManagementOperationObserver watcher, ManagementPath path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(ManagementOperationObserver watcher, ManagementPath path, PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(ManagementOperationObserver watcher, string path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(ManagementOperationObserver watcher, string path, PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath CopyTo(ManagementPath path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath CopyTo(ManagementPath path, PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath CopyTo(string path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath CopyTo(string path, PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Delete()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Delete(DeleteOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Delete(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Delete(ManagementOperationObserver watcher, DeleteOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public new void Dispose()
		{
		}

		public void Get()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Get(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementBaseObject GetMethodParameters(string methodName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelated()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelated(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelated(ManagementOperationObserver watcher, string relatedClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelated(ManagementOperationObserver watcher, string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelated(string relatedClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelated(string relatedClass, string relationshipClass, string relationshipQualifier, string relatedQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationships()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationships(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationships(ManagementOperationObserver watcher, string relationshipClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void GetRelationships(ManagementOperationObserver watcher, string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationships(string relationshipClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection GetRelationships(string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void InvokeMethod(ManagementOperationObserver watcher, string methodName, ManagementBaseObject inParameters, InvokeMethodOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void InvokeMethod(ManagementOperationObserver watcher, string methodName, object[] args)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementBaseObject InvokeMethod(string methodName, ManagementBaseObject inParameters, InvokeMethodOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public object InvokeMethod(string methodName, object[] args)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath Put()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Put(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Put(ManagementOperationObserver watcher, PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath Put(PutOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override string ToString()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementObjectCollection : ICollection, IEnumerable, IDisposable
	{
		public class ManagementObjectEnumerator : IEnumerator, IDisposable
		{
			public ManagementBaseObject Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			internal ManagementObjectEnumerator()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public void Dispose()
			{
			}

			~ManagementObjectEnumerator()
			{
			}

			public bool MoveNext()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public void Reset()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public int Count
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSynchronized
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object SyncRoot
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ManagementObjectCollection()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(Array array, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(ManagementBaseObject[] objectCollection, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Dispose()
		{
		}

		~ManagementObjectCollection()
		{
		}

		public ManagementObjectEnumerator GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[ToolboxItem(false)]
	public class ManagementObjectSearcher : Component
	{
		public EnumerationOptions Options
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ObjectQuery Query
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementScope Scope
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementObjectSearcher()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(ManagementScope scope, ObjectQuery query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(ManagementScope scope, ObjectQuery query, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(ObjectQuery query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(string queryString)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(string scope, string queryString)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectSearcher(string scope, string queryString, EnumerationOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementObjectCollection Get()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Get(ManagementOperationObserver watcher)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ManagementOperationObserver
	{
		public event CompletedEventHandler Completed
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public event ObjectPutEventHandler ObjectPut
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public event ObjectReadyEventHandler ObjectReady
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public event ProgressEventHandler Progress
		{
			add
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			remove
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementOperationObserver()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Cancel()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public abstract class ManagementOptions : ICloneable
	{
		public static readonly TimeSpan InfiniteTimeout;

		public ManagementNamedValueCollection Context
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public TimeSpan Timeout
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ManagementOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public abstract object Clone();
	}
	[TypeConverter(typeof(ManagementPathConverter))]
	public class ManagementPath : ICloneable
	{
		[RefreshProperties(RefreshProperties.All)]
		public string ClassName
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public static ManagementPath DefaultPath
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsClass
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsInstance
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSingleton
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		[RefreshProperties(RefreshProperties.All)]
		public string NamespacePath
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		[RefreshProperties(RefreshProperties.All)]
		public string Path
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		[RefreshProperties(RefreshProperties.All)]
		public string RelativePath
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		[RefreshProperties(RefreshProperties.All)]
		public string Server
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementPath()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath(string path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementPath Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void SetAsClass()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void SetAsSingleton()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		object ICloneable.Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override string ToString()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[TypeConverter(typeof(ManagementQueryConverter))]
	public abstract class ManagementQuery : ICloneable
	{
		public virtual string QueryLanguage
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual string QueryString
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ManagementQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public abstract object Clone();

		protected internal virtual void ParseQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	[TypeConverter(typeof(ManagementScopeConverter))]
	public class ManagementScope : ICloneable
	{
		public bool IsConnected
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ConnectionOptions Options
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementPath Path
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementScope()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementScope(ManagementPath path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementScope(ManagementPath path, ConnectionOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementScope(string path)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementScope(string path, ConnectionOptions options)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ManagementScope Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Connect()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		object ICloneable.Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public enum ManagementStatus
	{
		Failed = -2147217407,
		NotFound = -2147217406,
		AccessDenied = -2147217405,
		ProviderFailure = -2147217404,
		TypeMismatch = -2147217403,
		OutOfMemory = -2147217402,
		InvalidContext = -2147217401,
		InvalidParameter = -2147217400,
		NotAvailable = -2147217399,
		CriticalError = -2147217398,
		InvalidStream = -2147217397,
		NotSupported = -2147217396,
		InvalidSuperclass = -2147217395,
		InvalidNamespace = -2147217394,
		InvalidObject = -2147217393,
		InvalidClass = -2147217392,
		ProviderNotFound = -2147217391,
		InvalidProviderRegistration = -2147217390,
		ProviderLoadFailure = -2147217389,
		InitializationFailure = -2147217388,
		TransportFailure = -2147217387,
		InvalidOperation = -2147217386,
		InvalidQuery = -2147217385,
		InvalidQueryType = -2147217384,
		AlreadyExists = -2147217383,
		OverrideNotAllowed = -2147217382,
		PropagatedQualifier = -2147217381,
		PropagatedProperty = -2147217380,
		Unexpected = -2147217379,
		IllegalOperation = -2147217378,
		CannotBeKey = -2147217377,
		IncompleteClass = -2147217376,
		InvalidSyntax = -2147217375,
		NondecoratedObject = -2147217374,
		ReadOnly = -2147217373,
		ProviderNotCapable = -2147217372,
		ClassHasChildren = -2147217371,
		ClassHasInstances = -2147217370,
		QueryNotImplemented = -2147217369,
		IllegalNull = -2147217368,
		InvalidQualifierType = -2147217367,
		InvalidPropertyType = -2147217366,
		ValueOutOfRange = -2147217365,
		CannotBeSingleton = -2147217364,
		InvalidCimType = -2147217363,
		InvalidMethod = -2147217362,
		InvalidMethodParameters = -2147217361,
		SystemProperty = -2147217360,
		InvalidProperty = -2147217359,
		CallCanceled = -2147217358,
		ShuttingDown = -2147217357,
		PropagatedMethod = -2147217356,
		UnsupportedParameter = -2147217355,
		MissingParameterID = -2147217354,
		InvalidParameterID = -2147217353,
		NonconsecutiveParameterIDs = -2147217352,
		ParameterIDOnRetval = -2147217351,
		InvalidObjectPath = -2147217350,
		OutOfDiskSpace = -2147217349,
		BufferTooSmall = -2147217348,
		UnsupportedPutExtension = -2147217347,
		UnknownObjectType = -2147217346,
		UnknownPacketType = -2147217345,
		MarshalVersionMismatch = -2147217344,
		MarshalInvalidSignature = -2147217343,
		InvalidQualifier = -2147217342,
		InvalidDuplicateParameter = -2147217341,
		TooMuchData = -2147217340,
		ServerTooBusy = -2147217339,
		InvalidFlavor = -2147217338,
		CircularReference = -2147217337,
		UnsupportedClassUpdate = -2147217336,
		CannotChangeKeyInheritance = -2147217335,
		CannotChangeIndexInheritance = -2147217328,
		TooManyProperties = -2147217327,
		UpdateTypeMismatch = -2147217326,
		UpdateOverrideNotAllowed = -2147217325,
		UpdatePropagatedMethod = -2147217324,
		MethodNotImplemented = -2147217323,
		MethodDisabled = -2147217322,
		RefresherBusy = -2147217321,
		UnparsableQuery = -2147217320,
		NotEventClass = -2147217319,
		MissingGroupWithin = -2147217318,
		MissingAggregationList = -2147217317,
		PropertyNotAnObject = -2147217316,
		AggregatingByObject = -2147217315,
		UninterpretableProviderQuery = -2147217313,
		BackupRestoreWinmgmtRunning = -2147217312,
		QueueOverflow = -2147217311,
		PrivilegeNotHeld = -2147217310,
		InvalidOperator = -2147217309,
		LocalCredentials = -2147217308,
		CannotBeAbstract = -2147217307,
		AmendedObject = -2147217306,
		ClientTooSlow = -2147217305,
		RegistrationTooBroad = -2147213311,
		RegistrationTooPrecise = -2147213310,
		NoError = 0,
		False = 1,
		ResetToDefault = 262146,
		Different = 262147,
		Timedout = 262148,
		NoMoreData = 262149,
		OperationCanceled = 262150,
		Pending = 262151,
		DuplicateObjects = 262152,
		PartialResults = 262160
	}
	public class MethodData
	{
		public ManagementBaseObject InParameters
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Name
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Origin
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ManagementBaseObject OutParameters
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public QualifierDataCollection Qualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal MethodData()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class MethodDataCollection : ICollection, IEnumerable
	{
		public class MethodDataEnumerator : IEnumerator
		{
			public MethodData Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			internal MethodDataEnumerator()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public bool MoveNext()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public void Reset()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public int Count
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSynchronized
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual MethodData this[string methodName]
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object SyncRoot
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal MethodDataCollection()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Add(string methodName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Add(string methodName, ManagementBaseObject inParameters, ManagementBaseObject outParameters)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(Array array, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(MethodData[] methodArray, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public MethodDataEnumerator GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Remove(string methodName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ObjectGetOptions : ManagementOptions
	{
		public bool UseAmendedQualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public ObjectGetOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ObjectGetOptions(ManagementNamedValueCollection context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ObjectGetOptions(ManagementNamedValueCollection context, TimeSpan timeout, bool useAmendedQualifiers)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ObjectPutEventArgs : ManagementEventArgs
	{
		public ManagementPath Path
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ObjectPutEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void ObjectPutEventHandler(object sender, ObjectPutEventArgs e);
	public class ObjectQuery : ManagementQuery
	{
		public ObjectQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ObjectQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public ObjectQuery(string language, string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class ObjectReadyEventArgs : ManagementEventArgs
	{
		public ManagementBaseObject NewObject
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ObjectReadyEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void ObjectReadyEventHandler(object sender, ObjectReadyEventArgs e);
	public class ProgressEventArgs : ManagementEventArgs
	{
		public int Current
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Message
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public int UpperBound
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal ProgressEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void ProgressEventHandler(object sender, ProgressEventArgs e);
	public class PropertyData
	{
		public bool IsArray
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsLocal
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Name
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Origin
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public QualifierDataCollection Qualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public CimType Type
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object Value
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal PropertyData()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class PropertyDataCollection : ICollection, IEnumerable
	{
		public class PropertyDataEnumerator : IEnumerator
		{
			public PropertyData Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			internal PropertyDataEnumerator()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public bool MoveNext()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public void Reset()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public int Count
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSynchronized
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual PropertyData this[string propertyName]
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object SyncRoot
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal PropertyDataCollection()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Add(string propertyName, CimType propertyType, bool isArray)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Add(string propertyName, object propertyValue)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void Add(string propertyName, object propertyValue, CimType propertyType)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(Array array, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(PropertyData[] propertyArray, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public PropertyDataEnumerator GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Remove(string propertyName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class PutOptions : ManagementOptions
	{
		public PutType Type
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool UseAmendedQualifiers
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public PutOptions()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public PutOptions(ManagementNamedValueCollection context)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public PutOptions(ManagementNamedValueCollection context, TimeSpan timeout, bool useAmendedQualifiers, PutType putType)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public enum PutType
	{
		None,
		UpdateOnly,
		CreateOnly,
		UpdateOrCreate
	}
	public class QualifierData
	{
		public bool IsAmended
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsLocal
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsOverridable
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Name
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool PropagatesToInstance
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool PropagatesToSubclass
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object Value
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal QualifierData()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class QualifierDataCollection : ICollection, IEnumerable
	{
		public class QualifierDataEnumerator : IEnumerator
		{
			public QualifierData Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			object IEnumerator.Current
			{
				get
				{
					throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
				}
			}

			internal QualifierDataEnumerator()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public bool MoveNext()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}

			public void Reset()
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public int Count
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSynchronized
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public virtual QualifierData this[string qualifierName]
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public object SyncRoot
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal QualifierDataCollection()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Add(string qualifierName, object qualifierValue)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Add(string qualifierName, object qualifierValue, bool isAmended, bool propagatesToInstance, bool propagatesToSubclass, bool isOverridable)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(Array array, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public void CopyTo(QualifierData[] qualifierArray, int index)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public QualifierDataEnumerator GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public virtual void Remove(string qualifierName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class RelatedObjectQuery : WqlObjectQuery
	{
		public bool ClassDefinitionsOnly
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSchemaQuery
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelatedClass
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelatedQualifier
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelatedRole
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelationshipClass
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelationshipQualifier
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string SourceObject
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string ThisRole
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public RelatedObjectQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelatedObjectQuery(bool isSchemaQuery, string sourceObject, string relatedClass, string relationshipClass, string relatedQualifier, string relationshipQualifier, string relatedRole, string thisRole)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelatedObjectQuery(string queryOrSourceObject)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelatedObjectQuery(string sourceObject, string relatedClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelatedObjectQuery(string sourceObject, string relatedClass, string relationshipClass, string relatedQualifier, string relationshipQualifier, string relatedRole, string thisRole, bool classDefinitionsOnly)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal void BuildQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal override void ParseQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class RelationshipQuery : WqlObjectQuery
	{
		public bool ClassDefinitionsOnly
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSchemaQuery
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelationshipClass
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string RelationshipQualifier
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string SourceObject
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string ThisRole
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public RelationshipQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelationshipQuery(bool isSchemaQuery, string sourceObject, string relationshipClass, string relationshipQualifier, string thisRole)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelationshipQuery(string queryOrSourceObject)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelationshipQuery(string sourceObject, string relationshipClass)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public RelationshipQuery(string sourceObject, string relationshipClass, string relationshipQualifier, string thisRole, bool classDefinitionsOnly)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal void BuildQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal override void ParseQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class SelectQuery : WqlObjectQuery
	{
		public string ClassName
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string Condition
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public bool IsSchemaQuery
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public override string QueryString
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public StringCollection SelectedProperties
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public SelectQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public SelectQuery(bool isSchemaQuery, string condition)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public SelectQuery(string queryOrClassName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public SelectQuery(string className, string condition)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public SelectQuery(string className, string condition, string[] selectedProperties)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal void BuildQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal override void ParseQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class StoppedEventArgs : ManagementEventArgs
	{
		public ManagementStatus Status
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		internal StoppedEventArgs()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public delegate void StoppedEventHandler(object sender, StoppedEventArgs e);
	public enum TextFormat
	{
		Mof,
		CimDtd20,
		WmiDtd20
	}
	public class WqlEventQuery : EventQuery
	{
		public string Condition
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string EventClassName
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public StringCollection GroupByPropertyList
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public TimeSpan GroupWithinInterval
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public string HavingCondition
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public override string QueryLanguage
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public override string QueryString
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public TimeSpan WithinInterval
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
			set
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public WqlEventQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string queryOrEventClassName)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, string condition)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, string condition, TimeSpan groupWithinInterval)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, string condition, TimeSpan groupWithinInterval, string[] groupByPropertyList)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, TimeSpan withinInterval)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, TimeSpan withinInterval, string condition)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlEventQuery(string eventClassName, TimeSpan withinInterval, string condition, TimeSpan groupWithinInterval, string[] groupByPropertyList, string havingCondition)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal void BuildQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		protected internal override void ParseQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	public class WqlObjectQuery : ObjectQuery
	{
		public override string QueryLanguage
		{
			get
			{
				throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
			}
		}

		public WqlObjectQuery()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public WqlObjectQuery(string query)
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}

		public override object Clone()
		{
			throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_SystemManagement);
		}
	}
	internal sealed class ManagementPathConverter
	{
	}
	internal sealed class ManagementQueryConverter
	{
	}
	internal sealed class ManagementScopeConverter
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotRetur

plugins/System.Memory.dll

Decompiled 7 months 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.31308.01")]
[assembly: AssemblyInformationalVersion("4.6.31308.01 @BuiltBy: cloudtest-841353dfc000000 @Branch: release/2.1-MSRC @SrcCode: https://github.com/dotnet/corefx/tree/32b491939fbd125f304031c35038b1e14b4e3958")]
[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.2")]
[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 (val

plugins/System.Numerics.Vectors.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Globalization;
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")]
[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.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.All)]
	internal class __BlockReflectionAttribute : Attribute
	{
	}
}
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] = (ushort)(ScalarEquals(left[k], right[k]) ? ConstantHelper.GetUInt16WithAllBitsSet() : 0);
					}
					return new Vector<T>(ptr3);
				}
				if (typeof(T) == typeof(short))
				{
					short* ptr4 

plugins/System.Runtime.CompilerServices.Unsafe.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;

[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: CLSCompliant(false)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")]
[assembly: AssemblyFileVersion("6.0.21.52210")]
[assembly: AssemblyInformationalVersion("6.0.0")]
[assembly: AssemblyTitle("System.Runtime.CompilerServices.Unsafe")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyVersion("6.0.0.0")]
namespace System.Runtime.CompilerServices
{
	public static class Unsafe
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static T Read<T>(void* source)
		{
			return Unsafe.Read<T>(source);
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[System.Runtime.Versioning.NonVersionable]
		public unsafe static ref T NullRef<T>()
		{
			return ref *(T*)null;
		}
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class NonVersionableAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

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

		public NativeIntegerAttribute(bool[] A_0)
		{
			TransformFlags = A_0;
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}

plugins/System.Text.Encoding.CodePages.dll

Decompiled 7 months ago
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using FxResources.System.Text.Encoding.CodePages;
using Microsoft.CodeAnalysis;
using Microsoft.Win32.SafeHandles;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyDefaultAlias("System.Text.Encoding.CodePages")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides support for code-page based encodings, including Windows-1252, Shift-JIS, and GB2312.\r\n\r\nCommonly Used Types:\r\nSystem.Text.CodePagesEncodingProvider")]
[assembly: AssemblyFileVersion("7.0.22.51805")]
[assembly: AssemblyInformationalVersion("7.0.0+d099f075e45d2aa6007a22b71b45a08758559f80")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Encoding.CodePages")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("7.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FxResources.System.Text.Encoding.CodePages
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string ArgumentOutOfRange_NeedNonNegNum => GetResourceString("ArgumentOutOfRange_NeedNonNegNum");

		internal static string ArgumentOutOfRange_IndexCount => GetResourceString("ArgumentOutOfRange_IndexCount");

		internal static string ArgumentOutOfRange_IndexCountBuffer => GetResourceString("ArgumentOutOfRange_IndexCountBuffer");

		internal static string NotSupported_NoCodepageData => GetResourceString("NotSupported_NoCodepageData");

		internal static string Argument_EncodingConversionOverflowBytes => GetResourceString("Argument_EncodingConversionOverflowBytes");

		internal static string Argument_InvalidCharSequenceNoIndex => GetResourceString("Argument_InvalidCharSequenceNoIndex");

		internal static string ArgumentOutOfRange_GetByteCountOverflow => GetResourceString("ArgumentOutOfRange_GetByteCountOverflow");

		internal static string Argument_EncodingConversionOverflowChars => GetResourceString("Argument_EncodingConversionOverflowChars");

		internal static string ArgumentOutOfRange_GetCharCountOverflow => GetResourceString("ArgumentOutOfRange_GetCharCountOverflow");

		internal static string Argument_EncoderFallbackNotEmpty => GetResourceString("Argument_EncoderFallbackNotEmpty");

		internal static string Argument_RecursiveFallback => GetResourceString("Argument_RecursiveFallback");

		internal static string Argument_RecursiveFallbackBytes => GetResourceString("Argument_RecursiveFallbackBytes");

		internal static string ArgumentOutOfRange_Range => GetResourceString("ArgumentOutOfRange_Range");

		internal static string Argument_CodepageNotSupported => GetResourceString("Argument_CodepageNotSupported");

		internal static string ArgumentOutOfRange_IndexMustBeLess => GetResourceString("ArgumentOutOfRange_IndexMustBeLess");

		internal static string ArgumentOutOfRange_IndexMustBeLessOrEqual => GetResourceString("ArgumentOutOfRange_IndexMustBeLessOrEqual");

		internal static string MissingEncodingNameResource => GetResourceString("MissingEncodingNameResource");

		internal static string Globalization_cp_37 => GetResourceString("Globalization_cp_37");

		internal static string Globalization_cp_437 => GetResourceString("Globalization_cp_437");

		internal static string Globalization_cp_500 => GetResourceString("Globalization_cp_500");

		internal static string Globalization_cp_708 => GetResourceString("Globalization_cp_708");

		internal static string Globalization_cp_720 => GetResourceString("Globalization_cp_720");

		internal static string Globalization_cp_737 => GetResourceString("Globalization_cp_737");

		internal static string Globalization_cp_775 => GetResourceString("Globalization_cp_775");

		internal static string Globalization_cp_850 => GetResourceString("Globalization_cp_850");

		internal static string Globalization_cp_852 => GetResourceString("Globalization_cp_852");

		internal static string Globalization_cp_855 => GetResourceString("Globalization_cp_855");

		internal static string Globalization_cp_857 => GetResourceString("Globalization_cp_857");

		internal static string Globalization_cp_858 => GetResourceString("Globalization_cp_858");

		internal static string Globalization_cp_860 => GetResourceString("Globalization_cp_860");

		internal static string Globalization_cp_861 => GetResourceString("Globalization_cp_861");

		internal static string Globalization_cp_862 => GetResourceString("Globalization_cp_862");

		internal static string Globalization_cp_863 => GetResourceString("Globalization_cp_863");

		internal static string Globalization_cp_864 => GetResourceString("Globalization_cp_864");

		internal static string Globalization_cp_865 => GetResourceString("Globalization_cp_865");

		internal static string Globalization_cp_866 => GetResourceString("Globalization_cp_866");

		internal static string Globalization_cp_869 => GetResourceString("Globalization_cp_869");

		internal static string Globalization_cp_870 => GetResourceString("Globalization_cp_870");

		internal static string Globalization_cp_874 => GetResourceString("Globalization_cp_874");

		internal static string Globalization_cp_875 => GetResourceString("Globalization_cp_875");

		internal static string Globalization_cp_932 => GetResourceString("Globalization_cp_932");

		internal static string Globalization_cp_936 => GetResourceString("Globalization_cp_936");

		internal static string Globalization_cp_949 => GetResourceString("Globalization_cp_949");

		internal static string Globalization_cp_950 => GetResourceString("Globalization_cp_950");

		internal static string Globalization_cp_1026 => GetResourceString("Globalization_cp_1026");

		internal static string Globalization_cp_1047 => GetResourceString("Globalization_cp_1047");

		internal static string Globalization_cp_1140 => GetResourceString("Globalization_cp_1140");

		internal static string Globalization_cp_1141 => GetResourceString("Globalization_cp_1141");

		internal static string Globalization_cp_1142 => GetResourceString("Globalization_cp_1142");

		internal static string Globalization_cp_1143 => GetResourceString("Globalization_cp_1143");

		internal static string Globalization_cp_1144 => GetResourceString("Globalization_cp_1144");

		internal static string Globalization_cp_1145 => GetResourceString("Globalization_cp_1145");

		internal static string Globalization_cp_1146 => GetResourceString("Globalization_cp_1146");

		internal static string Globalization_cp_1147 => GetResourceString("Globalization_cp_1147");

		internal static string Globalization_cp_1148 => GetResourceString("Globalization_cp_1148");

		internal static string Globalization_cp_1149 => GetResourceString("Globalization_cp_1149");

		internal static string Globalization_cp_1250 => GetResourceString("Globalization_cp_1250");

		internal static string Globalization_cp_1251 => GetResourceString("Globalization_cp_1251");

		internal static string Globalization_cp_1252 => GetResourceString("Globalization_cp_1252");

		internal static string Globalization_cp_1253 => GetResourceString("Globalization_cp_1253");

		internal static string Globalization_cp_1254 => GetResourceString("Globalization_cp_1254");

		internal static string Globalization_cp_1255 => GetResourceString("Globalization_cp_1255");

		internal static string Globalization_cp_1256 => GetResourceString("Globalization_cp_1256");

		internal static string Globalization_cp_1257 => GetResourceString("Globalization_cp_1257");

		internal static string Globalization_cp_1258 => GetResourceString("Globalization_cp_1258");

		internal static string Globalization_cp_1361 => GetResourceString("Globalization_cp_1361");

		internal static string Globalization_cp_10000 => GetResourceString("Globalization_cp_10000");

		internal static string Globalization_cp_10001 => GetResourceString("Globalization_cp_10001");

		internal static string Globalization_cp_10002 => GetResourceString("Globalization_cp_10002");

		internal static string Globalization_cp_10003 => GetResourceString("Globalization_cp_10003");

		internal static string Globalization_cp_10004 => GetResourceString("Globalization_cp_10004");

		internal static string Globalization_cp_10005 => GetResourceString("Globalization_cp_10005");

		internal static string Globalization_cp_10006 => GetResourceString("Globalization_cp_10006");

		internal static string Globalization_cp_10007 => GetResourceString("Globalization_cp_10007");

		internal static string Globalization_cp_10008 => GetResourceString("Globalization_cp_10008");

		internal static string Globalization_cp_10010 => GetResourceString("Globalization_cp_10010");

		internal static string Globalization_cp_10017 => GetResourceString("Globalization_cp_10017");

		internal static string Globalization_cp_10021 => GetResourceString("Globalization_cp_10021");

		internal static string Globalization_cp_10029 => GetResourceString("Globalization_cp_10029");

		internal static string Globalization_cp_10079 => GetResourceString("Globalization_cp_10079");

		internal static string Globalization_cp_10081 => GetResourceString("Globalization_cp_10081");

		internal static string Globalization_cp_10082 => GetResourceString("Globalization_cp_10082");

		internal static string Globalization_cp_20000 => GetResourceString("Globalization_cp_20000");

		internal static string Globalization_cp_20001 => GetResourceString("Globalization_cp_20001");

		internal static string Globalization_cp_20002 => GetResourceString("Globalization_cp_20002");

		internal static string Globalization_cp_20003 => GetResourceString("Globalization_cp_20003");

		internal static string Globalization_cp_20004 => GetResourceString("Globalization_cp_20004");

		internal static string Globalization_cp_20005 => GetResourceString("Globalization_cp_20005");

		internal static string Globalization_cp_20105 => GetResourceString("Globalization_cp_20105");

		internal static string Globalization_cp_20106 => GetResourceString("Globalization_cp_20106");

		internal static string Globalization_cp_20107 => GetResourceString("Globalization_cp_20107");

		internal static string Globalization_cp_20108 => GetResourceString("Globalization_cp_20108");

		internal static string Globalization_cp_20261 => GetResourceString("Globalization_cp_20261");

		internal static string Globalization_cp_20269 => GetResourceString("Globalization_cp_20269");

		internal static string Globalization_cp_20273 => GetResourceString("Globalization_cp_20273");

		internal static string Globalization_cp_20277 => GetResourceString("Globalization_cp_20277");

		internal static string Globalization_cp_20278 => GetResourceString("Globalization_cp_20278");

		internal static string Globalization_cp_20280 => GetResourceString("Globalization_cp_20280");

		internal static string Globalization_cp_20284 => GetResourceString("Globalization_cp_20284");

		internal static string Globalization_cp_20285 => GetResourceString("Globalization_cp_20285");

		internal static string Globalization_cp_20290 => GetResourceString("Globalization_cp_20290");

		internal static string Globalization_cp_20297 => GetResourceString("Globalization_cp_20297");

		internal static string Globalization_cp_20420 => GetResourceString("Globalization_cp_20420");

		internal static string Globalization_cp_20423 => GetResourceString("Globalization_cp_20423");

		internal static string Globalization_cp_20424 => GetResourceString("Globalization_cp_20424");

		internal static string Globalization_cp_20833 => GetResourceString("Globalization_cp_20833");

		internal static string Globalization_cp_20838 => GetResourceString("Globalization_cp_20838");

		internal static string Globalization_cp_20866 => GetResourceString("Globalization_cp_20866");

		internal static string Globalization_cp_20871 => GetResourceString("Globalization_cp_20871");

		internal static string Globalization_cp_20880 => GetResourceString("Globalization_cp_20880");

		internal static string Globalization_cp_20905 => GetResourceString("Globalization_cp_20905");

		internal static string Globalization_cp_20924 => GetResourceString("Globalization_cp_20924");

		internal static string Globalization_cp_20932 => GetResourceString("Globalization_cp_20932");

		internal static string Globalization_cp_20936 => GetResourceString("Globalization_cp_20936");

		internal static string Globalization_cp_20949 => GetResourceString("Globalization_cp_20949");

		internal static string Globalization_cp_21025 => GetResourceString("Globalization_cp_21025");

		internal static string Globalization_cp_21027 => GetResourceString("Globalization_cp_21027");

		internal static string Globalization_cp_21866 => GetResourceString("Globalization_cp_21866");

		internal static string Globalization_cp_28592 => GetResourceString("Globalization_cp_28592");

		internal static string Globalization_cp_28593 => GetResourceString("Globalization_cp_28593");

		internal static string Globalization_cp_28594 => GetResourceString("Globalization_cp_28594");

		internal static string Globalization_cp_28595 => GetResourceString("Globalization_cp_28595");

		internal static string Globalization_cp_28596 => GetResourceString("Globalization_cp_28596");

		internal static string Globalization_cp_28597 => GetResourceString("Globalization_cp_28597");

		internal static string Globalization_cp_28598 => GetResourceString("Globalization_cp_28598");

		internal static string Globalization_cp_28599 => GetResourceString("Globalization_cp_28599");

		internal static string Globalization_cp_28603 => GetResourceString("Globalization_cp_28603");

		internal static string Globalization_cp_28605 => GetResourceString("Globalization_cp_28605");

		internal static string Globalization_cp_29001 => GetResourceString("Globalization_cp_29001");

		internal static string Globalization_cp_38598 => GetResourceString("Globalization_cp_38598");

		internal static string Globalization_cp_50000 => GetResourceString("Globalization_cp_50000");

		internal static string Globalization_cp_50220 => GetResourceString("Globalization_cp_50220");

		internal static string Globalization_cp_50221 => GetResourceString("Globalization_cp_50221");

		internal static string Globalization_cp_50222 => GetResourceString("Globalization_cp_50222");

		internal static string Globalization_cp_50225 => GetResourceString("Globalization_cp_50225");

		internal static string Globalization_cp_50227 => GetResourceString("Globalization_cp_50227");

		internal static string Globalization_cp_50229 => GetResourceString("Globalization_cp_50229");

		internal static string Globalization_cp_50930 => GetResourceString("Globalization_cp_50930");

		internal static string Globalization_cp_50931 => GetResourceString("Globalization_cp_50931");

		internal static string Globalization_cp_50933 => GetResourceString("Globalization_cp_50933");

		internal static string Globalization_cp_50935 => GetResourceString("Globalization_cp_50935");

		internal static string Globalization_cp_50937 => GetResourceString("Globalization_cp_50937");

		internal static string Globalization_cp_50939 => GetResourceString("Globalization_cp_50939");

		internal static string Globalization_cp_51932 => GetResourceString("Globalization_cp_51932");

		internal static string Globalization_cp_51936 => GetResourceString("Globalization_cp_51936");

		internal static string Globalization_cp_51949 => GetResourceString("Globalization_cp_51949");

		internal static string Globalization_cp_52936 => GetResourceString("Globalization_cp_52936");

		internal static string Globalization_cp_54936 => GetResourceString("Globalization_cp_54936");

		internal static string Globalization_cp_57002 => GetResourceString("Globalization_cp_57002");

		internal static string Globalization_cp_57003 => GetResourceString("Globalization_cp_57003");

		internal static string Globalization_cp_57004 => GetResourceString("Globalization_cp_57004");

		internal static string Globalization_cp_57005 => GetResourceString("Globalization_cp_57005");

		internal static string Globalization_cp_57006 => GetResourceString("Globalization_cp_57006");

		internal static string Globalization_cp_57007 => GetResourceString("Globalization_cp_57007");

		internal static string Globalization_cp_57008 => GetResourceString("Globalization_cp_57008");

		internal static string Globalization_cp_57009 => GetResourceString("Globalization_cp_57009");

		internal static string Globalization_cp_57010 => GetResourceString("Globalization_cp_57010");

		internal static string Globalization_cp_57011 => GetResourceString("Globalization_cp_57011");

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		internal static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		internal static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		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);
		}

		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(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Runtime.Versioning
{
	internal abstract class OSPlatformAttribute : Attribute
	{
		public string PlatformName { get; }

		private protected OSPlatformAttribute(string platformName)
		{
			PlatformName = platformName;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
	internal sealed class TargetPlatformAttribute : OSPlatformAttribute
	{
		public TargetPlatformAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
	{
		public SupportedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class UnsupportedOSPlatformAttribute : OSPlatformAttribute
	{
		public string Message { get; }

		public UnsupportedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}

		public UnsupportedOSPlatformAttribute(string platformName, string message)
			: base(platformName)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class ObsoletedOSPlatformAttribute : OSPlatformAttribute
	{
		public string Message { get; }

		public string Url { get; set; }

		public ObsoletedOSPlatformAttribute(string platformName)
			: base(platformName)
		{
		}

		public ObsoletedOSPlatformAttribute(string platformName, string message)
			: base(platformName)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
	internal sealed class SupportedOSPlatformGuardAttribute : OSPlatformAttribute
	{
		public SupportedOSPlatformGuardAttribute(string platformName)
			: base(platformName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
	internal sealed class UnsupportedOSPlatformGuardAttribute : OSPlatformAttribute
	{
		public UnsupportedOSPlatformGuardAttribute(string platformName)
			: base(platformName)
		{
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string EntryPoint { get; set; }

		public StringMarshalling StringMarshalling { get; set; }

		public Type StringMarshallingCustomType { get; set; }

		public bool SetLastError { get; set; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Text
{
	internal abstract class BaseCodePageEncoding : EncodingNLS, ISerializable
	{
		[StructLayout(LayoutKind.Explicit)]
		internal struct CodePageDataFileHeader
		{
			[FieldOffset(0)]
			internal char TableName;

			[FieldOffset(32)]
			internal ushort Version;

			[FieldOffset(40)]
			internal short CodePageCount;

			[FieldOffset(42)]
			internal short unused1;
		}

		[StructLayout(LayoutKind.Explicit, Pack = 2)]
		internal struct CodePageIndex
		{
			[FieldOffset(0)]
			internal char CodePageName;

			[FieldOffset(32)]
			internal short CodePage;

			[FieldOffset(34)]
			internal short ByteCount;

			[FieldOffset(36)]
			internal int Offset;
		}

		[StructLayout(LayoutKind.Explicit)]
		internal struct CodePageHeader
		{
			[FieldOffset(0)]
			internal char CodePageName;

			[FieldOffset(32)]
			internal ushort VersionMajor;

			[FieldOffset(34)]
			internal ushort VersionMinor;

			[FieldOffset(36)]
			internal ushort VersionRevision;

			[FieldOffset(38)]
			internal ushort VersionBuild;

			[FieldOffset(40)]
			internal short CodePage;

			[FieldOffset(42)]
			internal short ByteCount;

			[FieldOffset(44)]
			internal char UnicodeReplace;

			[FieldOffset(46)]
			internal ushort ByteReplace;
		}

		internal const string CODE_PAGE_DATA_FILE_NAME = "codepages.nlp";

		protected int dataTableCodePage;

		protected int iExtraBytes;

		protected char[] arrayUnicodeBestFit;

		protected char[] arrayBytesBestFit;

		private const int CODEPAGE_DATA_FILE_HEADER_SIZE = 44;

		private const int CODEPAGE_HEADER_SIZE = 48;

		private static readonly byte[] s_codePagesDataHeader = new byte[44];

		protected static Stream s_codePagesEncodingDataStream = GetEncodingDataStream("codepages.nlp");

		protected static readonly object s_streamLock = new object();

		protected byte[] m_codePageHeader = new byte[48];

		protected int m_firstDataWordOffset;

		protected int m_dataSize;

		protected SafeAllocHHandle safeNativeMemoryHandle;

		internal BaseCodePageEncoding(int codepage)
			: this(codepage, codepage)
		{
		}

		internal BaseCodePageEncoding(int codepage, int dataCodePage)
			: base(codepage, new InternalEncoderBestFitFallback(null), new InternalDecoderBestFitFallback(null))
		{
			((InternalEncoderBestFitFallback)base.EncoderFallback).encoding = this;
			((InternalDecoderBestFitFallback)base.DecoderFallback).encoding = this;
			dataTableCodePage = dataCodePage;
			LoadCodePageTables();
		}

		internal BaseCodePageEncoding(int codepage, int dataCodePage, EncoderFallback enc, DecoderFallback dec)
			: base(codepage, enc, dec)
		{
			dataTableCodePage = dataCodePage;
			LoadCodePageTables();
		}

		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException();
		}

		private unsafe static void ReadCodePageDataFileHeader(Stream stream, byte[] codePageDataFileHeader)
		{
			int num = stream.Read(codePageDataFileHeader, 0, codePageDataFileHeader.Length);
			if (BitConverter.IsLittleEndian)
			{
				return;
			}
			fixed (byte* ptr = &codePageDataFileHeader[0])
			{
				CodePageDataFileHeader* ptr2 = (CodePageDataFileHeader*)ptr;
				char* ptr3 = &ptr2->TableName;
				for (int i = 0; i < 16; i++)
				{
					ptr3[i] = (char)BinaryPrimitives.ReverseEndianness(ptr3[i]);
				}
				ushort* ptr4 = &ptr2->Version;
				for (int j = 0; j < 4; j++)
				{
					ptr4[j] = BinaryPrimitives.ReverseEndianness(ptr4[j]);
				}
				ptr2->CodePageCount = BinaryPrimitives.ReverseEndianness(ptr2->CodePageCount);
			}
		}

		private unsafe static void ReadCodePageIndex(Stream stream, byte[] codePageIndex)
		{
			int num = stream.Read(codePageIndex, 0, codePageIndex.Length);
			if (BitConverter.IsLittleEndian)
			{
				return;
			}
			fixed (byte* ptr = &codePageIndex[0])
			{
				CodePageIndex* ptr2 = (CodePageIndex*)ptr;
				char* ptr3 = &ptr2->CodePageName;
				for (int i = 0; i < 16; i++)
				{
					ptr3[i] = (char)BinaryPrimitives.ReverseEndianness(ptr3[i]);
				}
				ptr2->CodePage = BinaryPrimitives.ReverseEndianness(ptr2->CodePage);
				ptr2->ByteCount = BinaryPrimitives.ReverseEndianness(ptr2->ByteCount);
				ptr2->Offset = BinaryPrimitives.ReverseEndianness(ptr2->Offset);
			}
		}

		private unsafe static void ReadCodePageHeader(Stream stream, byte[] codePageHeader)
		{
			int num = stream.Read(codePageHeader, 0, codePageHeader.Length);
			if (BitConverter.IsLittleEndian)
			{
				return;
			}
			fixed (byte* ptr = &codePageHeader[0])
			{
				CodePageHeader* ptr2 = (CodePageHeader*)ptr;
				char* ptr3 = &ptr2->CodePageName;
				for (int i = 0; i < 16; i++)
				{
					ptr3[i] = (char)BinaryPrimitives.ReverseEndianness(ptr3[i]);
				}
				ptr2->VersionMajor = BinaryPrimitives.ReverseEndianness(ptr2->VersionMajor);
				ptr2->VersionMinor = BinaryPrimitives.ReverseEndianness(ptr2->VersionMinor);
				ptr2->VersionRevision = BinaryPrimitives.ReverseEndianness(ptr2->VersionRevision);
				ptr2->VersionBuild = BinaryPrimitives.ReverseEndianness(ptr2->VersionBuild);
				ptr2->CodePage = BinaryPrimitives.ReverseEndianness(ptr2->CodePage);
				ptr2->ByteCount = BinaryPrimitives.ReverseEndianness(ptr2->ByteCount);
				ptr2->UnicodeReplace = (char)BinaryPrimitives.ReverseEndianness(ptr2->UnicodeReplace);
				ptr2->ByteReplace = BinaryPrimitives.ReverseEndianness(ptr2->ByteReplace);
			}
		}

		internal static Stream GetEncodingDataStream(string tableName)
		{
			Stream manifestResourceStream = typeof(CodePagesEncodingProvider).Assembly.GetManifestResourceStream(tableName);
			if (manifestResourceStream == null)
			{
				throw new InvalidOperationException();
			}
			ReadCodePageDataFileHeader(manifestResourceStream, s_codePagesDataHeader);
			return manifestResourceStream;
		}

		private void LoadCodePageTables()
		{
			if (!FindCodePage(dataTableCodePage))
			{
				throw new NotSupportedException(System.SR.Format(System.SR.NotSupported_NoCodepageData, CodePage));
			}
			LoadManagedCodePage();
		}

		private unsafe bool FindCodePage(int codePage)
		{
			byte[] array = new byte[sizeof(CodePageIndex)];
			lock (s_streamLock)
			{
				s_codePagesEncodingDataStream.Seek(44L, SeekOrigin.Begin);
				int codePageCount;
				fixed (byte* ptr = &s_codePagesDataHeader[0])
				{
					CodePageDataFileHeader* ptr2 = (CodePageDataFileHeader*)ptr;
					codePageCount = ptr2->CodePageCount;
				}
				fixed (byte* ptr3 = &array[0])
				{
					CodePageIndex* ptr4 = (CodePageIndex*)ptr3;
					for (int i = 0; i < codePageCount; i++)
					{
						ReadCodePageIndex(s_codePagesEncodingDataStream, array);
						if (ptr4->CodePage == codePage)
						{
							long position = s_codePagesEncodingDataStream.Position;
							s_codePagesEncodingDataStream.Seek(ptr4->Offset, SeekOrigin.Begin);
							ReadCodePageHeader(s_codePagesEncodingDataStream, m_codePageHeader);
							m_firstDataWordOffset = (int)s_codePagesEncodingDataStream.Position;
							if (i == codePageCount - 1)
							{
								m_dataSize = (int)(s_codePagesEncodingDataStream.Length - ptr4->Offset - m_codePageHeader.Length);
							}
							else
							{
								s_codePagesEncodingDataStream.Seek(position, SeekOrigin.Begin);
								int offset = ptr4->Offset;
								ReadCodePageIndex(s_codePagesEncodingDataStream, array);
								m_dataSize = ptr4->Offset - offset - m_codePageHeader.Length;
							}
							return true;
						}
					}
				}
			}
			return false;
		}

		internal unsafe static int GetCodePageByteSize(int codePage)
		{
			byte[] array = new byte[sizeof(CodePageIndex)];
			lock (s_streamLock)
			{
				s_codePagesEncodingDataStream.Seek(44L, SeekOrigin.Begin);
				int codePageCount;
				fixed (byte* ptr = &s_codePagesDataHeader[0])
				{
					CodePageDataFileHeader* ptr2 = (CodePageDataFileHeader*)ptr;
					codePageCount = ptr2->CodePageCount;
				}
				fixed (byte* ptr3 = &array[0])
				{
					CodePageIndex* ptr4 = (CodePageIndex*)ptr3;
					for (int i = 0; i < codePageCount; i++)
					{
						ReadCodePageIndex(s_codePagesEncodingDataStream, array);
						if (ptr4->CodePage == codePage)
						{
							return ptr4->ByteCount;
						}
					}
				}
			}
			return 0;
		}

		protected abstract void LoadManagedCodePage();

		protected unsafe byte* GetNativeMemory(int iSize)
		{
			if (safeNativeMemoryHandle == null)
			{
				byte* ptr = (byte*)(void*)Marshal.AllocHGlobal(iSize);
				safeNativeMemoryHandle = new SafeAllocHHandle((IntPtr)ptr);
			}
			return (byte*)(void*)safeNativeMemoryHandle.DangerousGetHandle();
		}

		protected abstract void ReadBestFitTable();

		internal char[] GetBestFitUnicodeToBytesData()
		{
			if (arrayUnicodeBestFit == null)
			{
				ReadBestFitTable();
			}
			return arrayUnicodeBestFit;
		}

		internal char[] GetBestFitBytesToUnicodeData()
		{
			if (arrayBytesBestFit == null)
			{
				ReadBestFitTable();
			}
			return arrayBytesBestFit;
		}

		internal void CheckMemorySection()
		{
			if (safeNativeMemoryHandle != null && safeNativeMemoryHandle.DangerousGetHandle() == IntPtr.Zero)
			{
				LoadManagedCodePage();
			}
		}
	}
	public sealed class CodePagesEncodingProvider : EncodingProvider
	{
		private static readonly EncodingProvider s_singleton = new CodePagesEncodingProvider();

		private readonly Dictionary<int, Encoding> _encodings = new Dictionary<int, Encoding>();

		private readonly ReaderWriterLockSlim _cacheLock = new ReaderWriterLockSlim();

		private const int ISCIIAssemese = 57006;

		private const int ISCIIBengali = 57003;

		private const int ISCIIDevanagari = 57002;

		private const int ISCIIGujarathi = 57010;

		private const int ISCIIKannada = 57008;

		private const int ISCIIMalayalam = 57009;

		private const int ISCIIOriya = 57007;

		private const int ISCIIPanjabi = 57011;

		private const int ISCIITamil = 57004;

		private const int ISCIITelugu = 57005;

		private const int ISOKorean = 50225;

		private const int ChineseHZ = 52936;

		private const int ISO2022JP = 50220;

		private const int ISO2022JPESC = 50221;

		private const int ISO2022JPSISO = 50222;

		private const int ISOSimplifiedCN = 50227;

		private const int EUCJP = 51932;

		private const int CodePageMacGB2312 = 10008;

		private const int CodePageMacKorean = 10003;

		private const int CodePageGB2312 = 20936;

		private const int CodePageDLLKorean = 20949;

		private const int GB18030 = 54936;

		private const int DuplicateEUCCN = 51936;

		private const int EUCKR = 51949;

		private const int EUCCN = 936;

		private const int ISO_8859_8I = 38598;

		private const int ISO_8859_8_Visual = 28598;

		public static EncodingProvider Instance => s_singleton;

		private static int SystemDefaultCodePage => 0;

		internal CodePagesEncodingProvider()
		{
		}

		public override Encoding? GetEncoding(int codepage)
		{
			if (codepage < 0 || codepage > 65535)
			{
				return null;
			}
			if (codepage == 0)
			{
				int systemDefaultCodePage = SystemDefaultCodePage;
				if (systemDefaultCodePage == 0)
				{
					return null;
				}
				return GetEncoding(systemDefaultCodePage);
			}
			Encoding value = null;
			_cacheLock.EnterUpgradeableReadLock();
			try
			{
				if (_encodings.TryGetValue(codepage, out value))
				{
					return value;
				}
				switch (BaseCodePageEncoding.GetCodePageByteSize(codepage))
				{
				case 1:
					value = new SBCSCodePageEncoding(codepage);
					break;
				case 2:
					value = new DBCSCodePageEncoding(codepage);
					break;
				default:
					value = GetEncodingRare(codepage);
					if (value == null)
					{
						return null;
					}
					break;
				}
				_cacheLock.EnterWriteLock();
				try
				{
					if (_encodings.TryGetValue(codepage, out var value2))
					{
						return value2;
					}
					_encodings.Add(codepage, value);
					return value;
				}
				finally
				{
					_cacheLock.ExitWriteLock();
				}
			}
			finally
			{
				_cacheLock.ExitUpgradeableReadLock();
			}
		}

		public override Encoding? GetEncoding(string name)
		{
			int codePageFromName = System.Text.EncodingTable.GetCodePageFromName(name);
			if (codePageFromName == 0)
			{
				return null;
			}
			return GetEncoding(codePageFromName);
		}

		private static Encoding GetEncodingRare(int codepage)
		{
			Encoding result = null;
			switch (codepage)
			{
			case 57002:
			case 57003:
			case 57004:
			case 57005:
			case 57006:
			case 57007:
			case 57008:
			case 57009:
			case 57010:
			case 57011:
				result = new ISCIIEncoding(codepage);
				break;
			case 10008:
				result = new DBCSCodePageEncoding(10008, 20936);
				break;
			case 10003:
				result = new DBCSCodePageEncoding(10003, 20949);
				break;
			case 54936:
				result = new GB18030Encoding();
				break;
			case 50220:
			case 50221:
			case 50222:
			case 50225:
			case 52936:
				result = new ISO2022Encoding(codepage);
				break;
			case 50227:
			case 51936:
				result = new DBCSCodePageEncoding(codepage, 936);
				break;
			case 51932:
				result = new EUCJPEncoding();
				break;
			case 51949:
				result = new DBCSCodePageEncoding(codepage, 20949);
				break;
			case 38598:
				result = new SBCSCodePageEncoding(codepage, 28598);
				break;
			}
			return result;
		}
	}
	internal class DBCSCodePageEncoding : BaseCodePageEncoding
	{
		internal sealed class DBCSDecoder : System.Text.DecoderNLS
		{
			internal byte bLeftOver;

			internal override bool HasState => bLeftOver != 0;

			public DBCSDecoder(DBCSCodePageEncoding encoding)
				: base(encoding)
			{
			}

			public override void Reset()
			{
				bLeftOver = 0;
				m_fallbackBuffer?.Reset();
			}
		}

		protected unsafe char* mapBytesToUnicode = null;

		protected unsafe ushort* mapUnicodeToBytes = null;

		protected const char UNKNOWN_CHAR_FLAG = '\0';

		protected const char UNICODE_REPLACEMENT_CHAR = '\ufffd';

		protected const char LEAD_BYTE_CHAR = '\ufffe';

		private ushort _bytesUnknown;

		private int _byteCountUnknown;

		protected char charUnknown;

		private static object s_InternalSyncObject;

		private static object InternalSyncObject
		{
			get
			{
				if (s_InternalSyncObject == null)
				{
					object value = new object();
					Interlocked.CompareExchange<object>(ref s_InternalSyncObject, value, (object)null);
				}
				return s_InternalSyncObject;
			}
		}

		public DBCSCodePageEncoding(int codePage)
			: this(codePage, codePage)
		{
		}

		internal unsafe DBCSCodePageEncoding(int codePage, int dataCodePage)
			: base(codePage, dataCodePage)
		{
		}

		internal unsafe DBCSCodePageEncoding(int codePage, int dataCodePage, EncoderFallback enc, DecoderFallback dec)
			: base(codePage, dataCodePage, enc, dec)
		{
		}

		internal unsafe static char ReadChar(char* pChar)
		{
			if (BitConverter.IsLittleEndian)
			{
				return *pChar;
			}
			return (char)BinaryPrimitives.ReverseEndianness(*pChar);
		}

		protected unsafe override void LoadManagedCodePage()
		{
			fixed (byte* ptr = &m_codePageHeader[0])
			{
				CodePageHeader* ptr2 = (CodePageHeader*)ptr;
				if (ptr2->ByteCount != 2)
				{
					throw new NotSupportedException(System.SR.Format(System.SR.NotSupported_NoCodepageData, CodePage));
				}
				_bytesUnknown = ptr2->ByteReplace;
				charUnknown = ptr2->UnicodeReplace;
				if (base.DecoderFallback is InternalDecoderBestFitFallback)
				{
					((InternalDecoderBestFitFallback)base.DecoderFallback).cReplacement = charUnknown;
				}
				_byteCountUnknown = 1;
				if (_bytesUnknown > 255)
				{
					_byteCountUnknown++;
				}
				int num = 262148 + iExtraBytes;
				byte* nativeMemory = GetNativeMemory(num);
				Unsafe.InitBlockUnaligned(nativeMemory, 0, (uint)num);
				mapBytesToUnicode = (char*)nativeMemory;
				mapUnicodeToBytes = (ushort*)(nativeMemory + 131072);
				byte[] array = new byte[m_dataSize];
				lock (BaseCodePageEncoding.s_streamLock)
				{
					BaseCodePageEncoding.s_codePagesEncodingDataStream.Seek(m_firstDataWordOffset, SeekOrigin.Begin);
					int num2 = BaseCodePageEncoding.s_codePagesEncodingDataStream.Read(array, 0, m_dataSize);
				}
				fixed (byte* ptr3 = array)
				{
					char* ptr4 = (char*)ptr3;
					int num3 = 0;
					int num4 = 0;
					while (num3 < 65536)
					{
						char c = ReadChar(ptr4);
						ptr4++;
						switch (c)
						{
						case '\u0001':
							num3 = ReadChar(ptr4);
							ptr4++;
							continue;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num3 += c;
							continue;
						}
						switch (c)
						{
						case '\uffff':
							num4 = num3;
							c = (char)num3;
							break;
						case '\ufffe':
							num4 = num3;
							break;
						case '\ufffd':
							num3++;
							continue;
						default:
							num4 = num3;
							break;
						}
						if (CleanUpBytes(ref num4))
						{
							if (c != '\ufffe')
							{
								mapUnicodeToBytes[(int)c] = (ushort)num4;
							}
							mapBytesToUnicode[num4] = c;
						}
						num3++;
					}
				}
				CleanUpEndBytes(mapBytesToUnicode);
			}
		}

		protected virtual bool CleanUpBytes(ref int bytes)
		{
			return true;
		}

		protected unsafe virtual void CleanUpEndBytes(char* chars)
		{
		}

		protected unsafe override void ReadBestFitTable()
		{
			lock (InternalSyncObject)
			{
				if (arrayUnicodeBestFit != null)
				{
					return;
				}
				byte[] array = new byte[m_dataSize];
				lock (BaseCodePageEncoding.s_streamLock)
				{
					BaseCodePageEncoding.s_codePagesEncodingDataStream.Seek(m_firstDataWordOffset, SeekOrigin.Begin);
					int num = BaseCodePageEncoding.s_codePagesEncodingDataStream.Read(array, 0, m_dataSize);
				}
				fixed (byte* ptr = array)
				{
					char* ptr2 = (char*)ptr;
					int num2 = 0;
					while (num2 < 65536)
					{
						char c = ReadChar(ptr2);
						ptr2++;
						switch (c)
						{
						case '\u0001':
							num2 = ReadChar(ptr2);
							ptr2++;
							break;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num2 += c;
							break;
						default:
							num2++;
							break;
						}
					}
					char* ptr3 = ptr2;
					int num3 = 0;
					num2 = ReadChar(ptr2);
					ptr2++;
					while (num2 < 65536)
					{
						char c2 = ReadChar(ptr2);
						ptr2++;
						switch (c2)
						{
						case '\u0001':
							num2 = ReadChar(ptr2);
							ptr2++;
							continue;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num2 += c2;
							continue;
						}
						if (c2 != '\ufffd')
						{
							int bytes = num2;
							if (CleanUpBytes(ref bytes) && mapBytesToUnicode[bytes] != c2)
							{
								num3++;
							}
						}
						num2++;
					}
					char[] array2 = new char[num3 * 2];
					num3 = 0;
					ptr2 = ptr3;
					num2 = ReadChar(ptr2);
					ptr2++;
					bool flag = false;
					while (num2 < 65536)
					{
						char c3 = ReadChar(ptr2);
						ptr2++;
						switch (c3)
						{
						case '\u0001':
							num2 = ReadChar(ptr2);
							ptr2++;
							continue;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num2 += c3;
							continue;
						}
						if (c3 != '\ufffd')
						{
							int bytes2 = num2;
							if (CleanUpBytes(ref bytes2) && mapBytesToUnicode[bytes2] != c3)
							{
								if (bytes2 != num2)
								{
									flag = true;
								}
								array2[num3++] = (char)bytes2;
								array2[num3++] = c3;
							}
						}
						num2++;
					}
					if (flag)
					{
						for (int i = 0; i < array2.Length - 2; i += 2)
						{
							int num4 = i;
							char c4 = array2[i];
							for (int j = i + 2; j < array2.Length; j += 2)
							{
								if (c4 > array2[j])
								{
									c4 = array2[j];
									num4 = j;
								}
							}
							if (num4 != i)
							{
								char c5 = array2[num4];
								array2[num4] = array2[i];
								array2[i] = c5;
								c5 = array2[num4 + 1];
								array2[num4 + 1] = array2[i + 1];
								array2[i + 1] = c5;
							}
						}
					}
					arrayBytesBestFit = array2;
					char* ptr4 = ptr2;
					int num5 = ReadChar(ptr2++);
					num3 = 0;
					while (num5 < 65536)
					{
						char c6 = ReadChar(ptr2);
						ptr2++;
						switch (c6)
						{
						case '\u0001':
							num5 = ReadChar(ptr2);
							ptr2++;
							continue;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num5 += c6;
							continue;
						}
						if (c6 > '\0')
						{
							num3++;
						}
						num5++;
					}
					array2 = new char[num3 * 2];
					ptr2 = ptr4;
					num5 = ReadChar(ptr2++);
					num3 = 0;
					while (num5 < 65536)
					{
						char c7 = ReadChar(ptr2);
						ptr2++;
						switch (c7)
						{
						case '\u0001':
							num5 = ReadChar(ptr2);
							ptr2++;
							continue;
						case '\u0002':
						case '\u0003':
						case '\u0004':
						case '\u0005':
						case '\u0006':
						case '\a':
						case '\b':
						case '\t':
						case '\n':
						case '\v':
						case '\f':
						case '\r':
						case '\u000e':
						case '\u000f':
						case '\u0010':
						case '\u0011':
						case '\u0012':
						case '\u0013':
						case '\u0014':
						case '\u0015':
						case '\u0016':
						case '\u0017':
						case '\u0018':
						case '\u0019':
						case '\u001a':
						case '\u001b':
						case '\u001c':
						case '\u001d':
						case '\u001e':
						case '\u001f':
							num5 += c7;
							continue;
						}
						if (c7 > '\0')
						{
							int bytes3 = c7;
							if (CleanUpBytes(ref bytes3))
							{
								array2[num3++] = (char)num5;
								array2[num3++] = mapBytesToUnicode[bytes3];
							}
						}
						num5++;
					}
					arrayUnicodeBestFit = array2;
				}
			}
		}

		public unsafe override int GetByteCount(char* chars, int count, System.Text.EncoderNLS encoder)
		{
			CheckMemorySection();
			char c = '\0';
			if (encoder != null)
			{
				c = encoder.charLeftOver;
				if (encoder.InternalHasFallbackBuffer && encoder.FallbackBuffer.Remaining > 0)
				{
					throw new ArgumentException(System.SR.Format(System.SR.Argument_EncoderFallbackNotEmpty, EncodingName, encoder.Fallback.GetType()));
				}
			}
			int num = 0;
			char* ptr = chars + count;
			EncoderFallbackBuffer encoderFallbackBuffer = null;
			EncoderFallbackBufferHelper encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
			if (c > '\0')
			{
				encoderFallbackBuffer = encoder.FallbackBuffer;
				encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
				encoderFallbackBufferHelper.InternalInitialize(chars, ptr, encoder, _setEncoder: false);
				encoderFallbackBufferHelper.InternalFallback(c, ref chars);
			}
			char c2;
			while ((c2 = ((encoderFallbackBuffer != null) ? encoderFallbackBufferHelper.InternalGetNextChar() : '\0')) != 0 || chars < ptr)
			{
				if (c2 == '\0')
				{
					c2 = *chars;
					chars++;
				}
				ushort num2 = mapUnicodeToBytes[(int)c2];
				if (num2 == 0 && c2 != 0)
				{
					if (encoderFallbackBuffer == null)
					{
						encoderFallbackBuffer = ((encoder != null) ? encoder.FallbackBuffer : base.EncoderFallback.CreateFallbackBuffer());
						encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
						encoderFallbackBufferHelper.InternalInitialize(ptr - count, ptr, encoder, _setEncoder: false);
					}
					encoderFallbackBufferHelper.InternalFallback(c2, ref chars);
				}
				else
				{
					num++;
					if (num2 >= 256)
					{
						num++;
					}
				}
			}
			return num;
		}

		public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, System.Text.EncoderNLS encoder)
		{
			CheckMemorySection();
			EncoderFallbackBuffer encoderFallbackBuffer = null;
			char* ptr = chars + charCount;
			char* ptr2 = chars;
			byte* ptr3 = bytes;
			byte* ptr4 = bytes + byteCount;
			EncoderFallbackBufferHelper encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
			char c = '\0';
			if (encoder != null)
			{
				c = encoder.charLeftOver;
				encoderFallbackBuffer = encoder.FallbackBuffer;
				encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
				encoderFallbackBufferHelper.InternalInitialize(chars, ptr, encoder, _setEncoder: true);
				if (encoder.m_throwOnOverflow && encoderFallbackBuffer.Remaining > 0)
				{
					throw new ArgumentException(System.SR.Format(System.SR.Argument_EncoderFallbackNotEmpty, EncodingName, encoder.Fallback.GetType()));
				}
				if (c > '\0')
				{
					encoderFallbackBufferHelper.InternalFallback(c, ref chars);
				}
			}
			char c2;
			while ((c2 = ((encoderFallbackBuffer != null) ? encoderFallbackBufferHelper.InternalGetNextChar() : '\0')) != 0 || chars < ptr)
			{
				if (c2 == '\0')
				{
					c2 = *chars;
					chars++;
				}
				ushort num = mapUnicodeToBytes[(int)c2];
				if (num == 0 && c2 != 0)
				{
					if (encoderFallbackBuffer == null)
					{
						encoderFallbackBuffer = base.EncoderFallback.CreateFallbackBuffer();
						encoderFallbackBufferHelper = new EncoderFallbackBufferHelper(encoderFallbackBuffer);
						encoderFallbackBufferHelper.InternalInitialize(ptr - charCount, ptr, encoder, _setEncoder: true);
					}
					encoderFallbackBufferHelper.InternalFallback(c2, ref chars);
					continue;
				}
				if (num >= 256)
				{
					if (bytes + 1 >= ptr4)
					{
						if (encoderFallbackBuffer == null || !encoderFallbackBufferHelper.bFallingBack)
						{
							chars--;
						}
						else
						{
							encoderFallbackBuffer.MovePrevious();
						}
						ThrowBytesOverflow(encoder, chars == ptr2);
						break;
					}
					*bytes = (byte)(num >> 8);
					bytes++;
				}
				else if (bytes >= ptr4)
				{
					if (encoderFallbackBuffer == null || !encoderFallbackBufferHelper.bFallingBack)
					{
						chars--;
					}
					else
					{
						encoderFallbackBuffer.MovePrevious();
					}
					ThrowBytesOverflow(encoder, chars == ptr2);
					break;
				}
				*bytes = (byte)(num & 0xFFu);
				bytes++;
			}
			if (encoder != null)
			{
				if (encoderFallbackBuffer != null && !encoderFallbackBufferHelper.bUsedEncoder)
				{
					encoder.charLeftOver = '\0';
				}
				encoder.m_charsUsed = (int)(chars - ptr2);
			}
			return (int)(bytes - ptr3);
		}

		public unsafe override int GetCharCount(byte* bytes, int count, System.Text.DecoderNLS baseDecoder)
		{
			CheckMemorySection();
			DBCSDecoder dBCSDecoder = (DBCSDecoder)baseDecoder;
			DecoderFallbackBuffer decoderFallbackBuffer = null;
			byte* ptr = bytes + count;
			int num = count;
			DecoderFallbackBufferHelper decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
			if (dBCSDecoder != null && dBCSDecoder.bLeftOver > 0)
			{
				if (count == 0)
				{
					if (!dBCSDecoder.MustFlush)
					{
						return 0;
					}
					decoderFallbackBuffer = dBCSDecoder.FallbackBuffer;
					decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
					decoderFallbackBufferHelper.InternalInitialize(bytes, null);
					byte[] bytes2 = new byte[1] { dBCSDecoder.bLeftOver };
					return decoderFallbackBufferHelper.InternalFallback(bytes2, bytes);
				}
				int num2 = dBCSDecoder.bLeftOver << 8;
				num2 |= *bytes;
				bytes++;
				if (mapBytesToUnicode[num2] == '\0' && num2 != 0)
				{
					num--;
					decoderFallbackBuffer = dBCSDecoder.FallbackBuffer;
					decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
					decoderFallbackBufferHelper.InternalInitialize(ptr - count, null);
					byte[] bytes3 = new byte[2]
					{
						(byte)(num2 >> 8),
						(byte)num2
					};
					num += decoderFallbackBufferHelper.InternalFallback(bytes3, bytes);
				}
			}
			while (bytes < ptr)
			{
				int num3 = *bytes;
				bytes++;
				char c = mapBytesToUnicode[num3];
				if (c == '\ufffe')
				{
					num--;
					if (bytes < ptr)
					{
						num3 <<= 8;
						num3 |= *bytes;
						bytes++;
						c = mapBytesToUnicode[num3];
					}
					else
					{
						if (dBCSDecoder != null && !dBCSDecoder.MustFlush)
						{
							break;
						}
						num++;
						c = '\0';
					}
				}
				if (c == '\0' && num3 != 0)
				{
					if (decoderFallbackBuffer == null)
					{
						decoderFallbackBuffer = ((dBCSDecoder != null) ? dBCSDecoder.FallbackBuffer : base.DecoderFallback.CreateFallbackBuffer());
						decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
						decoderFallbackBufferHelper.InternalInitialize(ptr - count, null);
					}
					num--;
					byte[] bytes4 = ((num3 >= 256) ? new byte[2]
					{
						(byte)(num3 >> 8),
						(byte)num3
					} : new byte[1] { (byte)num3 });
					num += decoderFallbackBufferHelper.InternalFallback(bytes4, bytes);
				}
			}
			return num;
		}

		public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount, System.Text.DecoderNLS baseDecoder)
		{
			CheckMemorySection();
			DBCSDecoder dBCSDecoder = (DBCSDecoder)baseDecoder;
			byte* ptr = bytes;
			byte* ptr2 = bytes + byteCount;
			char* ptr3 = chars;
			char* ptr4 = chars + charCount;
			bool flag = false;
			DecoderFallbackBuffer decoderFallbackBuffer = null;
			DecoderFallbackBufferHelper decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
			if (dBCSDecoder != null && dBCSDecoder.bLeftOver > 0)
			{
				if (byteCount == 0)
				{
					if (!dBCSDecoder.MustFlush)
					{
						return 0;
					}
					decoderFallbackBuffer = dBCSDecoder.FallbackBuffer;
					decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
					decoderFallbackBufferHelper.InternalInitialize(bytes, ptr4);
					byte[] bytes2 = new byte[1] { dBCSDecoder.bLeftOver };
					if (!decoderFallbackBufferHelper.InternalFallback(bytes2, bytes, ref chars))
					{
						ThrowCharsOverflow(dBCSDecoder, nothingDecoded: true);
					}
					dBCSDecoder.bLeftOver = 0;
					return (int)(chars - ptr3);
				}
				int num = dBCSDecoder.bLeftOver << 8;
				num |= *bytes;
				bytes++;
				char c = mapBytesToUnicode[num];
				if (c == '\0' && num != 0)
				{
					decoderFallbackBuffer = dBCSDecoder.FallbackBuffer;
					decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
					decoderFallbackBufferHelper.InternalInitialize(ptr2 - byteCount, ptr4);
					byte[] bytes3 = new byte[2]
					{
						(byte)(num >> 8),
						(byte)num
					};
					if (!decoderFallbackBufferHelper.InternalFallback(bytes3, bytes, ref chars))
					{
						ThrowCharsOverflow(dBCSDecoder, nothingDecoded: true);
					}
				}
				else
				{
					if (chars >= ptr4)
					{
						ThrowCharsOverflow(dBCSDecoder, nothingDecoded: true);
					}
					*(chars++) = c;
				}
			}
			while (bytes < ptr2)
			{
				int num2 = *bytes;
				bytes++;
				char c2 = mapBytesToUnicode[num2];
				if (c2 == '\ufffe')
				{
					if (bytes < ptr2)
					{
						num2 <<= 8;
						num2 |= *bytes;
						bytes++;
						c2 = mapBytesToUnicode[num2];
					}
					else
					{
						if (dBCSDecoder != null && !dBCSDecoder.MustFlush)
						{
							flag = true;
							dBCSDecoder.bLeftOver = (byte)num2;
							break;
						}
						c2 = '\0';
					}
				}
				if (c2 == '\0' && num2 != 0)
				{
					if (decoderFallbackBuffer == null)
					{
						decoderFallbackBuffer = ((dBCSDecoder != null) ? dBCSDecoder.FallbackBuffer : base.DecoderFallback.CreateFallbackBuffer());
						decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
						decoderFallbackBufferHelper.InternalInitialize(ptr2 - byteCount, ptr4);
					}
					byte[] array = ((num2 >= 256) ? new byte[2]
					{
						(byte)(num2 >> 8),
						(byte)num2
					} : new byte[1] { (byte)num2 });
					if (!decoderFallbackBufferHelper.InternalFallback(array, bytes, ref chars))
					{
						bytes -= array.Length;
						decoderFallbackBufferHelper.InternalReset();
						ThrowCharsOverflow(dBCSDecoder, bytes == ptr);
						break;
					}
					continue;
				}
				if (chars >= ptr4)
				{
					bytes--;
					if (num2 >= 256)
					{
						bytes--;
					}
					ThrowCharsOverflow(dBCSDecoder, bytes == ptr);
					break;
				}
				*(chars++) = c2;
			}
			if (dBCSDecoder != null)
			{
				if (!flag)
				{
					dBCSDecoder.bLeftOver = 0;
				}
				dBCSDecoder.m_bytesUsed = (int)(bytes - ptr);
			}
			return (int)(chars - ptr3);
		}

		public override int GetMaxByteCount(int charCount)
		{
			if (charCount < 0)
			{
				throw new ArgumentOutOfRangeException("charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			long num = (long)charCount + 1L;
			if (base.EncoderFallback.MaxCharCount > 1)
			{
				num *= base.EncoderFallback.MaxCharCount;
			}
			num *= 2;
			if (num > int.MaxValue)
			{
				throw new ArgumentOutOfRangeException("charCount", System.SR.ArgumentOutOfRange_GetByteCountOverflow);
			}
			return (int)num;
		}

		public override int GetMaxCharCount(int byteCount)
		{
			if (byteCount < 0)
			{
				throw new ArgumentOutOfRangeException("byteCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			long num = (long)byteCount + 1L;
			if (base.DecoderFallback.MaxCharCount > 1)
			{
				num *= base.DecoderFallback.MaxCharCount;
			}
			if (num > int.MaxValue)
			{
				throw new ArgumentOutOfRangeException("byteCount", System.SR.ArgumentOutOfRange_GetCharCountOverflow);
			}
			return (int)num;
		}

		public override Decoder GetDecoder()
		{
			return new DBCSDecoder(this);
		}
	}
	internal sealed class InternalDecoderBestFitFallback : DecoderFallback
	{
		internal BaseCodePageEncoding encoding;

		internal char[] arrayBestFit;

		internal char cReplacement = '?';

		public override int MaxCharCount => 1;

		internal InternalDecoderBestFitFallback(BaseCodePageEncoding _encoding)
		{
			encoding = _encoding;
		}

		public override DecoderFallbackBuffer CreateFallbackBuffer()
		{
			return new InternalDecoderBestFitFallbackBuffer(this);
		}

		public override bool Equals([NotNullWhen(true)] object value)
		{
			if (value is InternalDecoderBestFitFallback internalDecoderBestFitFallback)
			{
				return encoding.CodePage == internalDecoderBestFitFallback.encoding.CodePage;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return encoding.CodePage;
		}
	}
	internal sealed class InternalDecoderBestFitFallbackBuffer : DecoderFallbackBuffer
	{
		internal char cBestFit;

		internal int iCount = -1;

		internal int iSize;

		private readonly InternalDecoderBestFitFallback _oFallback;

		private static object s_InternalSyncObject;

		private static object InternalSyncObject
		{
			get
			{
				if (s_InternalSyncObject == null)
				{
					object value = new object();
					Interlocked.CompareExchange<object>(ref s_InternalSyncObject, value, (object)null);
				}
				return s_InternalSyncObject;
			}
		}

		public override int Remaining
		{
			get
			{
				if (iCount <= 0)
				{
					return 0;
				}
				return iCount;
			}
		}

		public InternalDecoderBestFitFallbackBuffer(InternalDecoderBestFitFallback fallback)
		{
			_oFallback = fallback;
			if (_oFallback.arrayBestFit != null)
			{
				return;
			}
			lock (InternalSyncObject)
			{
				InternalDecoderBestFitFallback oFallback = _oFallback;
				if (oFallback.arrayBestFit == null)
				{
					oFallback.arrayBestFit = fallback.encoding.GetBestFitBytesToUnicodeData();
				}
			}
		}

		public override bool Fallback(byte[] bytesUnknown, int index)
		{
			cBestFit = TryBestFit(bytesUnknown);
			if (cBestFit == '\0')
			{
				cBestFit = _oFallback.cReplacement;
			}
			iCount = (iSize = 1);
			return true;
		}

		public override char GetNextChar()
		{
			iCount--;
			if (iCount < 0)
			{
				return '\0';
			}
			if (iCount == int.MaxValue)
			{
				iCount = -1;
				return '\0';
			}
			return cBestFit;
		}

		public override bool MovePrevious()
		{
			if (iCount >= 0)
			{
				iCount++;
			}
			if (iCount >= 0)
			{
				return iCount <= iSize;
			}
			return false;
		}

		public override void Reset()
		{
			iCount = -1;
		}

		internal unsafe static int InternalFallback(byte[] bytes, byte* pBytes)
		{
			return 1;
		}

		private char TryBestFit(byte[] bytesCheck)
		{
			int num = 0;
			int num2 = _oFallback.arrayBestFit.Length;
			if (num2 == 0)
			{
				return '\0';
			}
			if (bytesCheck.Length == 0 || bytesCheck.Length > 2)
			{
				return '\0';
			}
			char c = ((bytesCheck.Length != 1) ? ((char)((bytesCheck[0] << 8) + bytesCheck[1])) : ((char)bytesCheck[0]));
			if (c < _oFallback.arrayBestFit[0] || c > _oFallback.arrayBestFit[num2 - 2])
			{
				return '\0';
			}
			int num3;
			while ((num3 = num2 - num) > 6)
			{
				int num4 = (num3 / 2 + num) & 0xFFFE;
				char c2 = _oFallback.arrayBestFit[num4];
				if (c2 == c)
				{
					return _oFallback.arrayBestFit[num4 + 1];
				}
				if (c2 < c)
				{
					num = num4;
				}
				else
				{
					num2 = num4;
				}
			}
			for (int num4 = num; num4 < num2; num4 += 2)
			{
				if (_oFallback.arrayBestFit[num4] == c)
				{
					return _oFallback.arrayBestFit[num4 + 1];
				}
			}
			return '\0';
		}
	}
	internal struct DecoderFallbackBufferHelper
	{
		internal unsafe byte* byteStart;

		internal unsafe char* charEnd;

		private readonly DecoderFallbackBuffer _fallbackBuffer;

		public unsafe DecoderFallbackBufferHelper(DecoderFallbackBuffer fallbackBuffer)
		{
			_fallbackBuffer = fallbackBuffer;
			byteStart = null;
			charEnd = null;
		}

		internal unsafe void InternalReset()
		{
			byteStart = null;
			_fallbackBuffer.Reset();
		}

		internal unsafe void InternalInitialize(byte* _byteStart, char* _charEnd)
		{
			byteStart = _byteStart;
			charEnd = _charEnd;
		}

		internal unsafe bool InternalFallback(byte[] bytes, byte* pBytes, ref char* chars)
		{
			if (_fallbackBuffer.Fallback(bytes, (int)(pBytes - byteStart - bytes.Length)))
			{
				char* ptr = chars;
				bool flag = false;
				char nextChar;
				while ((nextChar = _fallbackBuffer.GetNextChar()) != 0)
				{
					if (char.IsSurrogate(nextChar))
					{
						if (char.IsHighSurrogate(nextChar))
						{
							if (flag)
							{
								throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
							}
							flag = true;
						}
						else
						{
							if (!flag)
							{
								throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
							}
							flag = false;
						}
					}
					if (ptr >= charEnd)
					{
						return false;
					}
					*(ptr++) = nextChar;
				}
				if (flag)
				{
					throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
				}
				chars = ptr;
			}
			return true;
		}

		internal unsafe int InternalFallback(byte[] bytes, byte* pBytes)
		{
			if (_fallbackBuffer.Fallback(bytes, (int)(pBytes - byteStart - bytes.Length)))
			{
				int num = 0;
				bool flag = false;
				char nextChar;
				while ((nextChar = _fallbackBuffer.GetNextChar()) != 0)
				{
					if (char.IsSurrogate(nextChar))
					{
						if (char.IsHighSurrogate(nextChar))
						{
							if (flag)
							{
								throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
							}
							flag = true;
						}
						else
						{
							if (!flag)
							{
								throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
							}
							flag = false;
						}
					}
					num++;
				}
				if (flag)
				{
					throw new ArgumentException(System.SR.Argument_InvalidCharSequenceNoIndex);
				}
				return num;
			}
			return 0;
		}
	}
	internal class DecoderNLS : Decoder, ISerializable
	{
		protected EncodingNLS m_encoding;

		protected bool m_mustFlush;

		internal bool m_throwOnOverflow;

		internal int m_bytesUsed;

		internal DecoderFallback m_fallback;

		internal DecoderFallbackBuffer m_fallbackBuffer;

		internal new DecoderFallback Fallback => m_fallback;

		internal bool InternalHasFallbackBuffer => m_fallbackBuffer != null;

		public new DecoderFallbackBuffer FallbackBuffer
		{
			get
			{
				if (m_fallbackBuffer == null)
				{
					m_fallbackBuffer = ((m_fallback != null) ? m_fallback.CreateFallbackBuffer() : DecoderFallback.ReplacementFallback.CreateFallbackBuffer());
				}
				return m_fallbackBuffer;
			}
		}

		public bool MustFlush => m_mustFlush;

		internal virtual bool HasState => false;

		internal DecoderNLS(EncodingNLS encoding)
		{
			m_encoding = encoding;
			m_fallback = m_encoding.DecoderFallback;
			Reset();
		}

		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException();
		}

		public override void Reset()
		{
			m_fallbackBuffer?.Reset();
		}

		public override int GetCharCount(byte[] bytes, int index, int count)
		{
			return GetCharCount(bytes, index, count, flush: false);
		}

		public unsafe override int GetCharCount(byte[] bytes, int index, int count, bool flush)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (index < 0 || count < 0)
			{
				throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (bytes.Length - index < count)
			{
				throw new ArgumentOutOfRangeException("bytes", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			fixed (byte* ptr = &bytes[0])
			{
				return GetCharCount(ptr + index, count, flush);
			}
		}

		public unsafe override int GetCharCount(byte* bytes, int count, bool flush)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = true;
			return m_encoding.GetCharCount(bytes, count, this);
		}

		public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
		{
			return GetChars(bytes, byteIndex, byteCount, chars, charIndex, flush: false);
		}

		public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, bool flush)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (byteIndex < 0 || byteCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (bytes.Length - byteIndex < byteCount)
			{
				throw new ArgumentOutOfRangeException("bytes", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (charIndex < 0 || charIndex > chars.Length)
			{
				throw new ArgumentOutOfRangeException("charIndex", System.SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
			}
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			int charCount = chars.Length - charIndex;
			if (chars.Length == 0)
			{
				chars = new char[1];
			}
			fixed (byte* ptr = &bytes[0])
			{
				fixed (char* ptr2 = &chars[0])
				{
					return GetChars(ptr + byteIndex, byteCount, ptr2 + charIndex, charCount, flush);
				}
			}
		}

		public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount, bool flush)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (byteCount < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteCount < 0) ? "byteCount" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = true;
			return m_encoding.GetChars(bytes, byteCount, chars, charCount, this);
		}

		public unsafe override void Convert(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (byteIndex < 0 || byteCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (charIndex < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (bytes.Length - byteIndex < byteCount)
			{
				throw new ArgumentOutOfRangeException("bytes", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (chars.Length - charIndex < charCount)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			if (chars.Length == 0)
			{
				chars = new char[1];
			}
			fixed (byte* ptr = &bytes[0])
			{
				fixed (char* ptr2 = &chars[0])
				{
					Convert(ptr + byteIndex, byteCount, ptr2 + charIndex, charCount, flush, out bytesUsed, out charsUsed, out completed);
				}
			}
		}

		public unsafe override void Convert(byte* bytes, int byteCount, char* chars, int charCount, bool flush, out int bytesUsed, out int charsUsed, out bool completed)
		{
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (byteCount < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteCount < 0) ? "byteCount" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = false;
			m_bytesUsed = 0;
			charsUsed = m_encoding.GetChars(bytes, byteCount, chars, charCount, this);
			bytesUsed = m_bytesUsed;
			completed = bytesUsed == byteCount && (!flush || !HasState) && (m_fallbackBuffer == null || m_fallbackBuffer.Remaining == 0);
		}

		internal void ClearMustFlush()
		{
			m_mustFlush = false;
		}
	}
	internal sealed class InternalEncoderBestFitFallback : EncoderFallback
	{
		internal BaseCodePageEncoding encoding;

		internal char[] arrayBestFit;

		public override int MaxCharCount => 1;

		internal InternalEncoderBestFitFallback(BaseCodePageEncoding _encoding)
		{
			encoding = _encoding;
		}

		public override EncoderFallbackBuffer CreateFallbackBuffer()
		{
			return new InternalEncoderBestFitFallbackBuffer(this);
		}

		public override bool Equals([NotNullWhen(true)] object value)
		{
			if (value is InternalEncoderBestFitFallback internalEncoderBestFitFallback)
			{
				return encoding.CodePage == internalEncoderBestFitFallback.encoding.CodePage;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return encoding.CodePage;
		}
	}
	internal sealed class InternalEncoderBestFitFallbackBuffer : EncoderFallbackBuffer
	{
		private char _cBestFit;

		private readonly InternalEncoderBestFitFallback _oFallback;

		private int _iCount = -1;

		private int _iSize;

		private static object s_InternalSyncObject;

		private static object InternalSyncObject
		{
			get
			{
				if (s_InternalSyncObject == null)
				{
					object value = new object();
					Interlocked.CompareExchange<object>(ref s_InternalSyncObject, value, (object)null);
				}
				return s_InternalSyncObject;
			}
		}

		public override int Remaining
		{
			get
			{
				if (_iCount <= 0)
				{
					return 0;
				}
				return _iCount;
			}
		}

		public InternalEncoderBestFitFallbackBuffer(InternalEncoderBestFitFallback fallback)
		{
			_oFallback = fallback;
			if (_oFallback.arrayBestFit != null)
			{
				return;
			}
			lock (InternalSyncObject)
			{
				InternalEncoderBestFitFallback oFallback = _oFallback;
				if (oFallback.arrayBestFit == null)
				{
					oFallback.arrayBestFit = fallback.encoding.GetBestFitUnicodeToBytesData();
				}
			}
		}

		public override bool Fallback(char charUnknown, int index)
		{
			_iCount = (_iSize = 1);
			_cBestFit = TryBestFit(charUnknown);
			if (_cBestFit == '\0')
			{
				_cBestFit = '?';
			}
			return true;
		}

		public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index)
		{
			if (!char.IsHighSurrogate(charUnknownHigh))
			{
				throw new ArgumentOutOfRangeException("charUnknownHigh", System.SR.Format(System.SR.ArgumentOutOfRange_Range, 55296, 56319));
			}
			if (!char.IsLowSurrogate(charUnknownLow))
			{
				throw new ArgumentOutOfRangeException("charUnknownLow", System.SR.Format(System.SR.ArgumentOutOfRange_Range, 56320, 57343));
			}
			_cBestFit = '?';
			_iCount = (_iSize = 2);
			return true;
		}

		public override char GetNextChar()
		{
			_iCount--;
			if (_iCount < 0)
			{
				return '\0';
			}
			if (_iCount == int.MaxValue)
			{
				_iCount = -1;
				return '\0';
			}
			return _cBestFit;
		}

		public override bool MovePrevious()
		{
			if (_iCount >= 0)
			{
				_iCount++;
			}
			if (_iCount >= 0)
			{
				return _iCount <= _iSize;
			}
			return false;
		}

		public override void Reset()
		{
			_iCount = -1;
		}

		private char TryBestFit(char cUnknown)
		{
			int num = 0;
			int num2 = _oFallback.arrayBestFit.Length;
			int num3;
			while ((num3 = num2 - num) > 6)
			{
				int num4 = (num3 / 2 + num) & 0xFFFE;
				char c = _oFallback.arrayBestFit[num4];
				if (c == cUnknown)
				{
					return _oFallback.arrayBestFit[num4 + 1];
				}
				if (c < cUnknown)
				{
					num = num4;
				}
				else
				{
					num2 = num4;
				}
			}
			for (int num4 = num; num4 < num2; num4 += 2)
			{
				if (_oFallback.arrayBestFit[num4] == cUnknown)
				{
					return _oFallback.arrayBestFit[num4 + 1];
				}
			}
			return '\0';
		}
	}
	internal struct EncoderFallbackBufferHelper
	{
		internal unsafe char* charStart;

		internal unsafe char* charEnd;

		internal System.Text.EncoderNLS encoder;

		internal bool setEncoder;

		internal bool bUsedEncoder;

		internal bool bFallingBack;

		internal int iRecursionCount;

		private const int iMaxRecursion = 250;

		private readonly EncoderFallbackBuffer _fallbackBuffer;

		public unsafe EncoderFallbackBufferHelper(EncoderFallbackBuffer fallbackBuffer)
		{
			_fallbackBuffer = fallbackBuffer;
			bFallingBack = (bUsedEncoder = (setEncoder = false));
			iRecursionCount = 0;
			charEnd = (charStart = null);
			encoder = null;
		}

		internal unsafe void InternalReset()
		{
			charStart = null;
			bFallingBack = false;
			iRecursionCount = 0;
			_fallbackBuffer.Reset();
		}

		internal unsafe void InternalInitialize(char* _charStart, char* _charEnd, System.Text.EncoderNLS _encoder, bool _setEncoder)
		{
			charStart = _charStart;
			charEnd = _charEnd;
			encoder = _encoder;
			setEncoder = _setEncoder;
			bUsedEncoder = false;
			bFallingBack = false;
			iRecursionCount = 0;
		}

		internal char InternalGetNextChar()
		{
			char nextChar = _fallbackBuffer.GetNextChar();
			bFallingBack = nextChar != '\0';
			if (nextChar == '\0')
			{
				iRecursionCount = 0;
			}
			return nextChar;
		}

		internal unsafe bool InternalFallback(char ch, ref char* chars)
		{
			int index = (int)(chars - charStart) - 1;
			if (char.IsHighSurrogate(ch))
			{
				if (chars >= charEnd)
				{
					if (encoder != null && !encoder.MustFlush)
					{
						if (setEncoder)
						{
							bUsedEncoder = true;
							encoder.charLeftOver = ch;
						}
						bFallingBack = false;
						return false;
					}
				}
				else
				{
					char c = *chars;
					if (char.IsLowSurrogate(c))
					{
						if (bFallingBack && iRecursionCount++ > 250)
						{
							ThrowLastCharRecursive(char.ConvertToUtf32(ch, c));
						}
						chars++;
						bFallingBack = _fallbackBuffer.Fallback(ch, c, index);
						return bFallingBack;
					}
				}
			}
			if (bFallingBack && iRecursionCount++ > 250)
			{
				ThrowLastCharRecursive(ch);
			}
			bFallingBack = _fallbackBuffer.Fallback(ch, index);
			return bFallingBack;
		}

		internal static void ThrowLastCharRecursive(int charRecursive)
		{
			throw new ArgumentException(System.SR.Format(System.SR.Argument_RecursiveFallback, charRecursive), "chars");
		}
	}
	internal class EncoderNLS : Encoder, ISerializable
	{
		internal char charLeftOver;

		protected EncodingNLS m_encoding;

		protected bool m_mustFlush;

		internal bool m_throwOnOverflow;

		internal int m_charsUsed;

		internal EncoderFallback m_fallback;

		internal EncoderFallbackBuffer m_fallbackBuffer;

		internal new EncoderFallback Fallback => m_fallback;

		internal bool InternalHasFallbackBuffer => m_fallbackBuffer != null;

		public new EncoderFallbackBuffer FallbackBuffer
		{
			get
			{
				if (m_fallbackBuffer == null)
				{
					m_fallbackBuffer = ((m_fallback != null) ? m_fallback.CreateFallbackBuffer() : EncoderFallback.ReplacementFallback.CreateFallbackBuffer());
				}
				return m_fallbackBuffer;
			}
		}

		public Encoding Encoding => m_encoding;

		public bool MustFlush => m_mustFlush;

		internal virtual bool HasState => charLeftOver != '\0';

		internal EncoderNLS(EncodingNLS encoding)
		{
			m_encoding = encoding;
			m_fallback = m_encoding.EncoderFallback;
			Reset();
		}

		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			throw new PlatformNotSupportedException();
		}

		public override void Reset()
		{
			charLeftOver = '\0';
			m_fallbackBuffer?.Reset();
		}

		public unsafe override int GetByteCount(char[] chars, int index, int count, bool flush)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (index < 0 || count < 0)
			{
				throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (chars.Length - index < count)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (chars.Length == 0)
			{
				chars = new char[1];
			}
			int num = -1;
			fixed (char* ptr = &chars[0])
			{
				num = GetByteCount(ptr + index, count, flush);
			}
			return num;
		}

		public unsafe override int GetByteCount(char* chars, int count, bool flush)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = true;
			return m_encoding.GetByteCount(chars, count, this);
		}

		public unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (charIndex < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (chars.Length - charIndex < charCount)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (byteIndex < 0 || byteIndex > bytes.Length)
			{
				throw new ArgumentOutOfRangeException("byteIndex", System.SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
			}
			if (chars.Length == 0)
			{
				chars = new char[1];
			}
			int byteCount = bytes.Length - byteIndex;
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			fixed (char* ptr = &chars[0])
			{
				fixed (byte* ptr2 = &bytes[0])
				{
					return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, flush);
				}
			}
		}

		public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, bool flush)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (byteCount < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteCount < 0) ? "byteCount" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = true;
			return m_encoding.GetBytes(chars, charCount, bytes, byteCount, this);
		}

		public unsafe override void Convert(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (charIndex < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (byteIndex < 0 || byteCount < 0)
			{
				throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (chars.Length - charIndex < charCount)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (bytes.Length - byteIndex < byteCount)
			{
				throw new ArgumentOutOfRangeException("bytes", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (chars.Length == 0)
			{
				chars = new char[1];
			}
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			fixed (char* ptr = &chars[0])
			{
				fixed (byte* ptr2 = &bytes[0])
				{
					Convert(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, flush, out charsUsed, out bytesUsed, out completed);
				}
			}
		}

		public unsafe override void Convert(char* chars, int charCount, byte* bytes, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (charCount < 0 || byteCount < 0)
			{
				throw new ArgumentOutOfRangeException((charCount < 0) ? "charCount" : "byteCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			m_mustFlush = flush;
			m_throwOnOverflow = false;
			m_charsUsed = 0;
			bytesUsed = m_encoding.GetBytes(chars, charCount, bytes, byteCount, this);
			charsUsed = m_charsUsed;
			completed = charsUsed == charCount && (!flush || !HasState) && (m_fallbackBuffer == null || m_fallbackBuffer.Remaining == 0);
		}

		internal void ClearMustFlush()
		{
			m_mustFlush = false;
		}
	}
	internal sealed class EncodingByteBuffer
	{
		private unsafe byte* _bytes;

		private unsafe readonly byte* _byteStart;

		private unsafe readonly byte* _byteEnd;

		private unsafe char* _chars;

		private unsafe readonly char* _charStart;

		private unsafe readonly char* _charEnd;

		private int _byteCountResult;

		private readonly EncodingNLS _enc;

		private readonly System.Text.EncoderNLS _encoder;

		internal EncoderFallbackBuffer fallbackBuffer;

		internal EncoderFallbackBufferHelper fallbackBufferHelper;

		internal unsafe bool MoreData
		{
			get
			{
				if (fallbackBuffer.Remaining <= 0)
				{
					return _chars < _charEnd;
				}
				return true;
			}
		}

		internal unsafe int CharsUsed => (int)(_chars - _charStart);

		internal int Count => _byteCountResult;

		internal unsafe EncodingByteBuffer(EncodingNLS inEncoding, System.Text.EncoderNLS inEncoder, byte* inByteStart, int inByteCount, char* inCharStart, int inCharCount)
		{
			_enc = inEncoding;
			_encoder = inEncoder;
			_charStart = inCharStart;
			_chars = inCharStart;
			_charEnd = inCharStart + inCharCount;
			_bytes = inByteStart;
			_byteStart = inByteStart;
			_byteEnd = inByteStart + inByteCount;
			if (_encoder == null)
			{
				fallbackBuffer = _enc.EncoderFallback.CreateFallbackBuffer();
			}
			else
			{
				fallbackBuffer = _encoder.FallbackBuffer;
				if (_encoder.m_throwOnOverflow && _encoder.InternalHasFallbackBuffer && fallbackBuffer.Remaining > 0)
				{
					throw new ArgumentException(System.SR.Format(System.SR.Argument_EncoderFallbackNotEmpty, _encoder.Encoding.EncodingName, _encoder.Fallback.GetType()));
				}
			}
			fallbackBufferHelper = new EncoderFallbackBufferHelper(fallbackBuffer);
			fallbackBufferHelper.InternalInitialize(_chars, _charEnd, _encoder, _bytes != null);
		}

		internal unsafe bool AddByte(byte b, int moreBytesExpected)
		{
			if (_bytes != null)
			{
				if (_bytes >= _byteEnd - moreBytesExpected)
				{
					MovePrevious(bThrow: true);
					return false;
				}
				*(_bytes++) = b;
			}
			_byteCountResult++;
			return true;
		}

		internal bool AddByte(byte b1)
		{
			return AddByte(b1, 0);
		}

		internal bool AddByte(byte b1, byte b2)
		{
			return AddByte(b1, b2, 0);
		}

		internal bool AddByte(byte b1, byte b2, int moreBytesExpected)
		{
			if (AddByte(b1, 1 + moreBytesExpected))
			{
				return AddByte(b2, moreBytesExpected);
			}
			return false;
		}

		internal bool AddByte(byte b1, byte b2, byte b3)
		{
			return AddByte(b1, b2, b3, 0);
		}

		internal bool AddByte(byte b1, byte b2, byte b3, int moreBytesExpected)
		{
			if (AddByte(b1, 2 + moreBytesExpected) && AddByte(b2, 1 + moreBytesExpected))
			{
				return AddByte(b3, moreBytesExpected);
			}
			return false;
		}

		internal bool AddByte(byte b1, byte b2, byte b3, byte b4)
		{
			if (AddByte(b1, 3) && AddByte(b2, 2) && AddByte(b3, 1))
			{
				return AddByte(b4, 0);
			}
			return false;
		}

		internal unsafe void MovePrevious(bool bThrow)
		{
			if (fallbackBufferHelper.bFallingBack)
			{
				fallbackBuffer.MovePrevious();
			}
			else if (_chars > _charStart)
			{
				_chars--;
			}
			if (bThrow)
			{
				_enc.ThrowBytesOverflow(_encoder, _bytes == _byteStart);
			}
		}

		internal unsafe bool Fallback(char charFallback)
		{
			return fallbackBufferHelper.InternalFallback(charFallback, ref _chars);
		}

		internal unsafe char GetNextChar()
		{
			char c = fallbackBufferHelper.InternalGetNextChar();
			if (c == '\0' && _chars < _charEnd)
			{
				c = *(_chars++);
			}
			return c;
		}
	}
	internal sealed class EncodingCharBuffer
	{
		private unsafe char* _chars;

		private unsafe readonly char* _charStart;

		private unsafe readonly char* _charEnd;

		private int _charCountResult;

		private readonly EncodingNLS _enc;

		private readonly System.Text.DecoderNLS _decoder;

		private unsafe readonly byte* _byteStart;

		private unsafe readonly byte* _byteEnd;

		private unsafe byte* _bytes;

		private readonly DecoderFallbackBuffer _fallbackBuffer;

		private DecoderFallbackBufferHelper _fallbackBufferHelper;

		internal unsafe bool MoreData => _bytes < _byteEnd;

		internal unsafe int BytesUsed => (int)(_bytes - _byteStart);

		internal int Count => _charCountResult;

		internal unsafe EncodingCharBuffer(EncodingNLS enc, System.Text.DecoderNLS decoder, char* charStart, int charCount, byte* byteStart, int byteCount)
		{
			_enc = enc;
			_decoder = decoder;
			_chars = charStart;
			_charStart = charStart;
			_charEnd = charStart + charCount;
			_byteStart = byteStart;
			_bytes = byteStart;
			_byteEnd = byteStart + byteCount;
			if (_decoder == null)
			{
				_fallbackBuffer = enc.DecoderFallback.CreateFallbackBuffer();
			}
			else
			{
				_fallbackBuffer = _decoder.FallbackBuffer;
			}
			_fallbackBufferHelper = new DecoderFallbackBufferHelper(_fallbackBuffer);
			_fallbackBufferHelper.InternalInitialize(_bytes, _charEnd);
		}

		internal unsafe bool AddChar(char ch, int numBytes)
		{
			if (_chars != null)
			{
				if (_chars >= _charEnd)
				{
					_bytes -= numBytes;
					_enc.ThrowCharsOverflow(_decoder, _bytes <= _byteStart);
					return false;
				}
				*(_chars++) = ch;
			}
			_charCountResult++;
			return true;
		}

		internal bool AddChar(char ch)
		{
			return AddChar(ch, 1);
		}

		internal unsafe bool AddChar(char ch1, char ch2, int numBytes)
		{
			if (_chars >= _charEnd - 1)
			{
				_bytes -= numBytes;
				_enc.ThrowCharsOverflow(_decoder, _bytes <= _byteStart);
				return false;
			}
			if (AddChar(ch1, numBytes))
			{
				return AddChar(ch2, numBytes);
			}
			return false;
		}

		internal unsafe void AdjustBytes(int count)
		{
			_bytes += count;
		}

		internal unsafe bool EvenMoreData(int count)
		{
			return _bytes <= _byteEnd - count;
		}

		internal unsafe byte GetNextByte()
		{
			if (_bytes >= _byteEnd)
			{
				return 0;
			}
			return *(_bytes++);
		}

		internal bool Fallback(byte fallbackByte)
		{
			byte[] byteBuffer = new byte[1] { fallbackByte };
			return Fallback(byteBuffer);
		}

		internal bool Fallback(byte byte1, byte byte2)
		{
			byte[] byteBuffer = new byte[2] { byte1, byte2 };
			return Fallback(byteBuffer);
		}

		internal bool Fallback(byte byte1, byte byte2, byte byte3, byte byte4)
		{
			byte[] byteBuffer = new byte[4] { byte1, byte2, byte3, byte4 };
			return Fallback(byteBuffer);
		}

		internal unsafe bool Fallback(byte[] byteBuffer)
		{
			if (_chars != null)
			{
				char* chars = _chars;
				if (!_fallbackBufferHelper.InternalFallback(byteBuffer, _bytes, ref _chars))
				{
					_bytes -= byteBuffer.Length;
					_fallbackBufferHelper.InternalReset();
					_enc.ThrowCharsOverflow(_decoder, _chars == _charStart);
					return false;
				}
				_charCountResult += (int)(_chars - chars);
			}
			else
			{
				_charCountResult += _fallbackBufferHelper.InternalFallback(byteBuffer, _bytes);
			}
			return true;
		}
	}
	internal abstract class EncodingNLS : Encoding
	{
		private string _encodingName;

		private string _webName;

		public override string EncodingName
		{
			get
			{
				if (_encodingName == null)
				{
					_encodingName = GetLocalizedEncodingNameResource(CodePage);
					if (_encodingName == null)
					{
						throw new NotSupportedException(System.SR.Format(System.SR.MissingEncodingNameResource, WebName, CodePage));
					}
					if (_encodingName.StartsWith("Globalization_cp_", StringComparison.OrdinalIgnoreCase))
					{
						_encodingName = System.Text.EncodingTable.GetEnglishNameFromCodePage(CodePage);
						if (_encodingName == null)
						{
							throw new NotSupportedException(System.SR.Format(System.SR.MissingEncodingNameResource, WebName, CodePage));
						}
					}
				}
				return _encodingName;
			}
		}

		public override string WebName
		{
			get
			{
				if (_webName == null)
				{
					_webName = System.Text.EncodingTable.GetWebNameFromCodePage(CodePage);
					if (_webName == null)
					{
						throw new NotSupportedException(System.SR.Format(System.SR.NotSupported_NoCodepageData, CodePage));
					}
				}
				return _webName;
			}
		}

		public override string HeaderName => CodePage switch
		{
			932 => "iso-2022-jp", 
			50221 => "iso-2022-jp", 
			50225 => "euc-kr", 
			_ => WebName, 
		};

		public override string BodyName => CodePage switch
		{
			932 => "iso-2022-jp", 
			1250 => "iso-8859-2", 
			1251 => "koi8-r", 
			1252 => "iso-8859-1", 
			1253 => "iso-8859-7", 
			1254 => "iso-8859-9", 
			50221 => "iso-2022-jp", 
			50225 => "iso-2022-kr", 
			_ => WebName, 
		};

		protected EncodingNLS(int codePage)
			: base(codePage)
		{
		}

		protected EncodingNLS(int codePage, EncoderFallback enc, DecoderFallback dec)
			: base(codePage, enc, dec)
		{
		}

		public unsafe abstract int GetByteCount(char* chars, int count, System.Text.EncoderNLS encoder);

		public unsafe abstract int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, System.Text.EncoderNLS encoder);

		public unsafe abstract int GetCharCount(byte* bytes, int count, System.Text.DecoderNLS decoder);

		public unsafe abstract int GetChars(byte* bytes, int byteCount, char* chars, int charCount, System.Text.DecoderNLS decoder);

		public unsafe override int GetByteCount(char[] chars, int index, int count)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (index < 0 || count < 0)
			{
				throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (chars.Length - index < count)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (chars.Length == 0)
			{
				return 0;
			}
			fixed (char* ptr = &chars[0])
			{
				return GetByteCount(ptr + index, count, null);
			}
		}

		public unsafe override int GetByteCount(string s)
		{
			if (s == null)
			{
				throw new ArgumentNullException("s");
			}
			fixed (char* chars = s)
			{
				return GetByteCount(chars, s.Length, null);
			}
		}

		public unsafe override int GetByteCount(char* chars, int count)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			return GetByteCount(chars, count, null);
		}

		public unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
		{
			if (s == null)
			{
				throw new ArgumentNullException("s");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (charIndex < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (s.Length - charIndex < charCount)
			{
				throw new ArgumentOutOfRangeException("s", System.SR.ArgumentOutOfRange_IndexCount);
			}
			if (byteIndex < 0 || byteIndex > bytes.Length)
			{
				throw new ArgumentOutOfRangeException("byteIndex", System.SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
			}
			int byteCount = bytes.Length - byteIndex;
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			fixed (char* ptr = s)
			{
				fixed (byte* ptr2 = &bytes[0])
				{
					return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, null);
				}
			}
		}

		public unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
		{
			if (chars == null)
			{
				throw new ArgumentNullException("chars");
			}
			if (bytes == null)
			{
				throw new ArgumentNullException("bytes");
			}
			if (charIndex < 0 || charCount < 0)
			{
				throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", System.SR.ArgumentOutOfRange_NeedNonNegNum);
			}
			if (chars.Length - charIndex < charCount)
			{
				throw new ArgumentOutOfRangeException("chars", System.SR.ArgumentOutOfRange_IndexCountBuffer);
			}
			if (byteIndex < 0 || byteIndex > bytes.Length)
			{
				throw new ArgumentOutOfRangeException("byteIndex", System.SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
			}
			if (chars.Length == 0)
			{
				return 0;
			}
			int byteCount = bytes.Length - byteIndex;
			if (bytes.Length == 0)
			{
				bytes = new byte[1];
			}
			fixed (char* ptr = &chars[0])
			{
				fixed (byte* ptr2 

plugins/System.Text.Encodings.Web.dll

Decompiled 7 months ago
using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.Threading;
using FxResources.System.Text.Encodings.Web;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyDefaultAlias("System.Text.Encodings.Web")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides types for encoding and escaping strings for use in JavaScript, HyperText Markup Language (HTML), and uniform resource locators (URL).\r\n\r\nCommonly Used Types:\r\nSystem.Text.Encodings.Web.HtmlEncoder\r\nSystem.Text.Encodings.Web.UrlEncoder\r\nSystem.Text.Encodings.Web.JavaScriptEncoder")]
[assembly: AssemblyFileVersion("8.0.23.53103")]
[assembly: AssemblyInformationalVersion("8.0.0+5535e31a712343a63f5d7d796cd874e563e5ac14")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Encodings.Web")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("8.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FxResources.System.Text.Encodings.Web
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class HexConverter
	{
		public enum Casing : uint
		{
			Upper = 0u,
			Lower = 8224u
		}

		public static ReadOnlySpan<byte> CharToHexLookup => new byte[256]
		{
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 0, 1,
			2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
			255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
			15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 10, 11, 12,
			13, 14, 15, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void ToBytesBuffer(byte value, Span<byte> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (byte)num2;
			buffer[startingIndex] = (byte)(num2 >> 8);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void ToCharsBuffer(byte value, Span<char> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (char)(num2 & 0xFFu);
			buffer[startingIndex] = (char)(num2 >> 8);
		}

		public static void EncodeToUtf16(ReadOnlySpan<byte> bytes, Span<char> chars, Casing casing = Casing.Upper)
		{
			for (int i = 0; i < bytes.Length; i++)
			{
				ToCharsBuffer(bytes[i], chars, i * 2, casing);
			}
		}

		public static string ToString(ReadOnlySpan<byte> bytes, Casing casing = Casing.Upper)
		{
			Span<char> span = ((bytes.Length <= 16) ? stackalloc char[bytes.Length * 2] : new char[bytes.Length * 2].AsSpan());
			Span<char> buffer = span;
			int num = 0;
			ReadOnlySpan<byte> readOnlySpan = bytes;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				byte value = readOnlySpan[i];
				ToCharsBuffer(value, buffer, num, casing);
				num += 2;
			}
			return buffer.ToString();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharUpper(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 7;
			}
			return (char)value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharLower(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 39;
			}
			return (char)value;
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes)
		{
			int charsProcessed;
			return TryDecodeFromUtf16(chars, bytes, out charsProcessed);
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes, out int charsProcessed)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			while (num2 < bytes.Length)
			{
				num3 = FromChar(chars[num + 1]);
				num4 = FromChar(chars[num]);
				if ((num3 | num4) == 255)
				{
					break;
				}
				bytes[num2++] = (byte)((num4 << 4) | num3);
				num += 2;
			}
			if (num3 == 255)
			{
				num++;
			}
			charsProcessed = num;
			return (num3 | num4) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromChar(int c)
		{
			if (c < CharToHexLookup.Length)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromUpperChar(int c)
		{
			if (c <= 71)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromLowerChar(int c)
		{
			switch (c)
			{
			case 48:
			case 49:
			case 50:
			case 51:
			case 52:
			case 53:
			case 54:
			case 55:
			case 56:
			case 57:
				return c - 48;
			case 97:
			case 98:
			case 99:
			case 100:
			case 101:
			case 102:
				return c - 97 + 10;
			default:
				return 255;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexChar(int c)
		{
			if (IntPtr.Size == 8)
			{
				ulong num = (uint)(c - 48);
				ulong num2 = (ulong)(-17875860044349952L << (int)num);
				ulong num3 = num - 64;
				return (long)(num2 & num3) < 0L;
			}
			return FromChar(c) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexUpperChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 65) <= 5u;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexLowerChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 97) <= 5u;
			}
			return true;
		}
	}
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string TextEncoderDoesNotImplementMaxOutputCharsPerInputChar => GetResourceString("TextEncoderDoesNotImplementMaxOutputCharsPerInputChar");

		internal static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		private static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		private static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		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);
		}

		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(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string EntryPoint { get; set; }

		public StringMarshalling StringMarshalling { get; set; }

		public Type StringMarshallingCustomType { get; set; }

		public bool SetLastError { get; set; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Numerics
{
	internal static class BitOperations
	{
		private static ReadOnlySpan<byte> Log2DeBruijn => new byte[32]
		{
			0, 9, 1, 10, 13, 21, 2, 29, 11, 14,
			16, 18, 22, 25, 3, 30, 8, 12, 20, 28,
			15, 17, 24, 7, 19, 27, 23, 6, 26, 5,
			4, 31
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int Log2(uint value)
		{
			return Log2SoftwareFallback(value | 1u);
		}

		private static int Log2SoftwareFallback(uint value)
		{
			value |= value >> 1;
			value |= value >> 2;
			value |= value >> 4;
			value |= value >> 8;
			value |= value >> 16;
			return Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(Log2DeBruijn), (nint)(value * 130329821 >> 27));
		}
	}
}
namespace System.Text
{
	internal static class UnicodeDebug
	{
		[Conditional("DEBUG")]
		internal static void AssertIsBmpCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsBmpCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsHighSurrogateCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsHighSurrogateCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsLowSurrogateCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsLowSurrogateCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidCodePoint(uint codePoint)
		{
			System.Text.UnicodeUtility.IsValidCodePoint(codePoint);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidScalar(uint scalarValue)
		{
			System.Text.UnicodeUtility.IsValidUnicodeScalar(scalarValue);
		}

		[Conditional("DEBUG")]
		internal static void AssertIsValidSupplementaryPlaneScalar(uint scalarValue)
		{
			if (System.Text.UnicodeUtility.IsValidUnicodeScalar(scalarValue))
			{
				System.Text.UnicodeUtility.IsBmpCodePoint(scalarValue);
			}
		}

		private static string ToHexString(uint codePoint)
		{
			return FormattableString.Invariant($"U+{codePoint:X4}");
		}
	}
	internal static class UnicodeUtility
	{
		public const uint ReplacementChar = 65533u;

		public static int GetPlane(uint codePoint)
		{
			return (int)(codePoint >> 16);
		}

		public static uint GetScalarFromUtf16SurrogatePair(uint highSurrogateCodePoint, uint lowSurrogateCodePoint)
		{
			return (highSurrogateCodePoint << 10) + lowSurrogateCodePoint - 56613888;
		}

		public static int GetUtf16SequenceLength(uint value)
		{
			value -= 65536;
			value += 33554432;
			value >>= 24;
			return (int)value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void GetUtf16SurrogatesFromSupplementaryPlaneScalar(uint value, out char highSurrogateCodePoint, out char lowSurrogateCodePoint)
		{
			highSurrogateCodePoint = (char)(value + 56557568 >> 10);
			lowSurrogateCodePoint = (char)((value & 0x3FF) + 56320);
		}

		public static int GetUtf8SequenceLength(uint value)
		{
			int num = (int)(value - 2048) >> 31;
			value ^= 0xF800u;
			value -= 63616;
			value += 67108864;
			value >>= 24;
			return (int)value + num * 2;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsAsciiCodePoint(uint value)
		{
			return value <= 127;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsBmpCodePoint(uint value)
		{
			return value <= 65535;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHighSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 55296u, 56319u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsInRangeInclusive(uint value, uint lowerBound, uint upperBound)
		{
			return value - lowerBound <= upperBound - lowerBound;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsLowSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 56320u, 57343u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsSurrogateCodePoint(uint value)
		{
			return IsInRangeInclusive(value, 55296u, 57343u);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsValidCodePoint(uint codePoint)
		{
			return codePoint <= 1114111;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsValidUnicodeScalar(uint value)
		{
			return ((value - 1114112) ^ 0xD800) >= 4293855232u;
		}
	}
	internal ref struct ValueStringBuilder
	{
		private char[] _arrayToReturnToPool;

		private Span<char> _chars;

		private int _pos;

		public int Length
		{
			get
			{
				return _pos;
			}
			set
			{
				_pos = value;
			}
		}

		public int Capacity => _chars.Length;

		public ref char this[int index] => ref _chars[index];

		public Span<char> RawChars => _chars;

		public ValueStringBuilder(Span<char> initialBuffer)
		{
			_arrayToReturnToPool = null;
			_chars = initialBuffer;
			_pos = 0;
		}

		public ValueStringBuilder(int initialCapacity)
		{
			_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(initialCapacity);
			_chars = _arrayToReturnToPool;
			_pos = 0;
		}

		public void EnsureCapacity(int capacity)
		{
			if ((uint)capacity > (uint)_chars.Length)
			{
				Grow(capacity - _pos);
			}
		}

		public ref char GetPinnableReference()
		{
			return ref MemoryMarshal.GetReference(_chars);
		}

		public ref char GetPinnableReference(bool terminate)
		{
			if (terminate)
			{
				EnsureCapacity(Length + 1);
				_chars[Length] = '\0';
			}
			return ref MemoryMarshal.GetReference(_chars);
		}

		public override string ToString()
		{
			string result = _chars.Slice(0, _pos).ToString();
			Dispose();
			return result;
		}

		public ReadOnlySpan<char> AsSpan(bool terminate)
		{
			if (terminate)
			{
				EnsureCapacity(Length + 1);
				_chars[Length] = '\0';
			}
			return _chars.Slice(0, _pos);
		}

		public ReadOnlySpan<char> AsSpan()
		{
			return _chars.Slice(0, _pos);
		}

		public ReadOnlySpan<char> AsSpan(int start)
		{
			return _chars.Slice(start, _pos - start);
		}

		public ReadOnlySpan<char> AsSpan(int start, int length)
		{
			return _chars.Slice(start, length);
		}

		public bool TryCopyTo(Span<char> destination, out int charsWritten)
		{
			if (_chars.Slice(0, _pos).TryCopyTo(destination))
			{
				charsWritten = _pos;
				Dispose();
				return true;
			}
			charsWritten = 0;
			Dispose();
			return false;
		}

		public void Insert(int index, char value, int count)
		{
			if (_pos > _chars.Length - count)
			{
				Grow(count);
			}
			int length = _pos - index;
			_chars.Slice(index, length).CopyTo(_chars.Slice(index + count));
			_chars.Slice(index, count).Fill(value);
			_pos += count;
		}

		public void Insert(int index, string s)
		{
			if (s != null)
			{
				int length = s.Length;
				if (_pos > _chars.Length - length)
				{
					Grow(length);
				}
				int length2 = _pos - index;
				_chars.Slice(index, length2).CopyTo(_chars.Slice(index + length));
				s.AsSpan().CopyTo(_chars.Slice(index));
				_pos += length;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Append(char c)
		{
			int pos = _pos;
			Span<char> chars = _chars;
			if ((uint)pos < (uint)chars.Length)
			{
				chars[pos] = c;
				_pos = pos + 1;
			}
			else
			{
				GrowAndAppend(c);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Append(string s)
		{
			if (s != null)
			{
				int pos = _pos;
				if (s.Length == 1 && (uint)pos < (uint)_chars.Length)
				{
					_chars[pos] = s[0];
					_pos = pos + 1;
				}
				else
				{
					AppendSlow(s);
				}
			}
		}

		private void AppendSlow(string s)
		{
			int pos = _pos;
			if (pos > _chars.Length - s.Length)
			{
				Grow(s.Length);
			}
			s.AsSpan().CopyTo(_chars.Slice(pos));
			_pos += s.Length;
		}

		public void Append(char c, int count)
		{
			if (_pos > _chars.Length - count)
			{
				Grow(count);
			}
			Span<char> span = _chars.Slice(_pos, count);
			for (int i = 0; i < span.Length; i++)
			{
				span[i] = c;
			}
			_pos += count;
		}

		public unsafe void Append(char* value, int length)
		{
			int pos = _pos;
			if (pos > _chars.Length - length)
			{
				Grow(length);
			}
			Span<char> span = _chars.Slice(_pos, length);
			for (int i = 0; i < span.Length; i++)
			{
				span[i] = *(value++);
			}
			_pos += length;
		}

		public void Append(ReadOnlySpan<char> value)
		{
			int pos = _pos;
			if (pos > _chars.Length - value.Length)
			{
				Grow(value.Length);
			}
			value.CopyTo(_chars.Slice(_pos));
			_pos += value.Length;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public Span<char> AppendSpan(int length)
		{
			int pos = _pos;
			if (pos > _chars.Length - length)
			{
				Grow(length);
			}
			_pos = pos + length;
			return _chars.Slice(pos, length);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void GrowAndAppend(char c)
		{
			Grow(1);
			Append(c);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void Grow(int additionalCapacityBeyondPos)
		{
			int minimumLength = (int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), Math.Min((uint)(_chars.Length * 2), 2147483591u));
			char[] array = ArrayPool<char>.Shared.Rent(minimumLength);
			_chars.Slice(0, _pos).CopyTo(array);
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			_chars = (_arrayToReturnToPool = array);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Dispose()
		{
			char[] arrayToReturnToPool = _arrayToReturnToPool;
			this = default(System.Text.ValueStringBuilder);
			if (arrayToReturnToPool != null)
			{
				ArrayPool<char>.Shared.Return(arrayToReturnToPool);
			}
		}
	}
	internal readonly struct Rune : IEquatable<Rune>
	{
		private const int MaxUtf16CharsPerRune = 2;

		private const char HighSurrogateStart = '\ud800';

		private const char LowSurrogateStart = '\udc00';

		private const int HighSurrogateRange = 1023;

		private readonly uint _value;

		public bool IsAscii => System.Text.UnicodeUtility.IsAsciiCodePoint(_value);

		public bool IsBmp => System.Text.UnicodeUtility.IsBmpCodePoint(_value);

		public static Rune ReplacementChar => UnsafeCreate(65533u);

		public int Utf16SequenceLength => System.Text.UnicodeUtility.GetUtf16SequenceLength(_value);

		public int Value => (int)_value;

		public Rune(uint value)
		{
			if (!System.Text.UnicodeUtility.IsValidUnicodeScalar(value))
			{
				ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value);
			}
			_value = value;
		}

		public Rune(int value)
			: this((uint)value)
		{
		}

		private Rune(uint scalarValue, bool _)
		{
			_value = scalarValue;
		}

		public static bool operator ==(Rune left, Rune right)
		{
			return left._value == right._value;
		}

		public static bool operator !=(Rune left, Rune right)
		{
			return left._value != right._value;
		}

		public static bool IsControl(Rune value)
		{
			return ((value._value + 1) & 0xFFFFFF7Fu) <= 32;
		}

		public static OperationStatus DecodeFromUtf16(ReadOnlySpan<char> source, out Rune result, out int charsConsumed)
		{
			if (!source.IsEmpty)
			{
				char c = source[0];
				if (TryCreate(c, out result))
				{
					charsConsumed = 1;
					return OperationStatus.Done;
				}
				if (1u < (uint)source.Length)
				{
					char lowSurrogate = source[1];
					if (TryCreate(c, lowSurrogate, out result))
					{
						charsConsumed = 2;
						return OperationStatus.Done;
					}
				}
				else if (char.IsHighSurrogate(c))
				{
					goto IL_004c;
				}
				charsConsumed = 1;
				result = ReplacementChar;
				return OperationStatus.InvalidData;
			}
			goto IL_004c;
			IL_004c:
			charsConsumed = source.Length;
			result = ReplacementChar;
			return OperationStatus.NeedMoreData;
		}

		public static OperationStatus DecodeFromUtf8(ReadOnlySpan<byte> source, out Rune result, out int bytesConsumed)
		{
			int num = 0;
			uint num2;
			if ((uint)num < (uint)source.Length)
			{
				num2 = source[num];
				if (System.Text.UnicodeUtility.IsAsciiCodePoint(num2))
				{
					goto IL_0021;
				}
				if (System.Text.UnicodeUtility.IsInRangeInclusive(num2, 194u, 244u))
				{
					num2 = num2 - 194 << 6;
					num++;
					if ((uint)num >= (uint)source.Length)
					{
						goto IL_0163;
					}
					int num3 = (sbyte)source[num];
					if (num3 < -64)
					{
						num2 += (uint)num3;
						num2 += 128;
						num2 += 128;
						if (num2 < 2048)
						{
							goto IL_0021;
						}
						if (System.Text.UnicodeUtility.IsInRangeInclusive(num2, 2080u, 3343u) && !System.Text.UnicodeUtility.IsInRangeInclusive(num2, 2912u, 2943u) && !System.Text.UnicodeUtility.IsInRangeInclusive(num2, 3072u, 3087u))
						{
							num++;
							if ((uint)num >= (uint)source.Length)
							{
								goto IL_0163;
							}
							num3 = (sbyte)source[num];
							if (num3 < -64)
							{
								num2 <<= 6;
								num2 += (uint)num3;
								num2 += 128;
								num2 -= 131072;
								if (num2 > 65535)
								{
									num++;
									if ((uint)num >= (uint)source.Length)
									{
										goto IL_0163;
									}
									num3 = (sbyte)source[num];
									if (num3 >= -64)
									{
										goto IL_0153;
									}
									num2 <<= 6;
									num2 += (uint)num3;
									num2 += 128;
									num2 -= 4194304;
								}
								goto IL_0021;
							}
						}
					}
				}
				else
				{
					num = 1;
				}
				goto IL_0153;
			}
			goto IL_0163;
			IL_0021:
			bytesConsumed = num + 1;
			result = UnsafeCreate(num2);
			return OperationStatus.Done;
			IL_0153:
			bytesConsumed = num;
			result = ReplacementChar;
			return OperationStatus.InvalidData;
			IL_0163:
			bytesConsumed = num;
			result = ReplacementChar;
			return OperationStatus.NeedMoreData;
		}

		public override bool Equals([NotNullWhen(true)] object obj)
		{
			if (obj is Rune other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Rune other)
		{
			return this == other;
		}

		public override int GetHashCode()
		{
			return Value;
		}

		public static bool TryCreate(char ch, out Rune result)
		{
			if (!System.Text.UnicodeUtility.IsSurrogateCodePoint(ch))
			{
				result = UnsafeCreate(ch);
				return true;
			}
			result = default(Rune);
			return false;
		}

		public static bool TryCreate(char highSurrogate, char lowSurrogate, out Rune result)
		{
			uint num = (uint)(highSurrogate - 55296);
			uint num2 = (uint)(lowSurrogate - 56320);
			if ((num | num2) <= 1023)
			{
				result = UnsafeCreate((uint)((int)(num << 10) + (lowSurrogate - 56320) + 65536));
				return true;
			}
			result = default(Rune);
			return false;
		}

		public bool TryEncodeToUtf16(Span<char> destination, out int charsWritten)
		{
			if (destination.Length >= 1)
			{
				if (IsBmp)
				{
					destination[0] = (char)_value;
					charsWritten = 1;
					return true;
				}
				if (destination.Length >= 2)
				{
					System.Text.UnicodeUtility.GetUtf16SurrogatesFromSupplementaryPlaneScalar(_value, out destination[0], out destination[1]);
					charsWritten = 2;
					return true;
				}
			}
			charsWritten = 0;
			return false;
		}

		public bool TryEncodeToUtf8(Span<byte> destination, out int bytesWritten)
		{
			if (destination.Length >= 1)
			{
				if (IsAscii)
				{
					destination[0] = (byte)_value;
					bytesWritten = 1;
					return true;
				}
				if (destination.Length >= 2)
				{
					if (_value <= 2047)
					{
						destination[0] = (byte)(_value + 12288 >> 6);
						destination[1] = (byte)((_value & 0x3F) + 128);
						bytesWritten = 2;
						return true;
					}
					if (destination.Length >= 3)
					{
						if (_value <= 65535)
						{
							destination[0] = (byte)(_value + 917504 >> 12);
							destination[1] = (byte)(((_value & 0xFC0) >> 6) + 128);
							destination[2] = (byte)((_value & 0x3F) + 128);
							bytesWritten = 3;
							return true;
						}
						if (destination.Length >= 4)
						{
							destination[0] = (byte)(_value + 62914560 >> 18);
							destination[1] = (byte)(((_value & 0x3F000) >> 12) + 128);
							destination[2] = (byte)(((_value & 0xFC0) >> 6) + 128);
							destination[3] = (byte)((_value & 0x3F) + 128);
							bytesWritten = 4;
							return true;
						}
					}
				}
			}
			bytesWritten = 0;
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static Rune UnsafeCreate(uint scalarValue)
		{
			return new Rune(scalarValue, _: false);
		}
	}
}
namespace System.Text.Unicode
{
	internal static class UnicodeHelpers
	{
		internal const int UNICODE_LAST_CODEPOINT = 1114111;

		private static ReadOnlySpan<byte> DefinedCharsBitmapSpan => new byte[8192]
		{
			0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 127, 0, 0, 0, 0,
			254, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 252, 240, 215, 255, 255, 251, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 254, 255, 255, 255,
			127, 254, 255, 255, 255, 255, 255, 231, 254, 255,
			255, 255, 255, 255, 255, 0, 255, 255, 255, 135,
			31, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 191, 255, 255, 255, 255,
			255, 255, 255, 231, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 3, 0, 255, 255,
			255, 255, 255, 255, 255, 231, 255, 255, 255, 255,
			255, 63, 255, 127, 255, 255, 255, 79, 255, 7,
			255, 255, 255, 127, 3, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 239, 159, 249, 255, 255, 253,
			197, 243, 159, 121, 128, 176, 207, 255, 255, 127,
			238, 135, 249, 255, 255, 253, 109, 211, 135, 57,
			2, 94, 192, 255, 127, 0, 238, 191, 251, 255,
			255, 253, 237, 243, 191, 59, 1, 0, 207, 255,
			3, 254, 238, 159, 249, 255, 255, 253, 237, 243,
			159, 57, 224, 176, 207, 255, 255, 0, 236, 199,
			61, 214, 24, 199, 255, 195, 199, 61, 129, 0,
			192, 255, 255, 7, 255, 223, 253, 255, 255, 253,
			255, 243, 223, 61, 96, 39, 207, 255, 128, 255,
			255, 223, 253, 255, 255, 253, 239, 243, 223, 61,
			96, 96, 207, 255, 14, 0, 255, 223, 253, 255,
			255, 255, 255, 255, 223, 253, 240, 255, 207, 255,
			255, 255, 238, 255, 127, 252, 255, 255, 251, 47,
			127, 132, 95, 255, 192, 255, 28, 0, 254, 255,
			255, 255, 255, 255, 255, 135, 255, 255, 255, 15,
			0, 0, 0, 0, 214, 247, 255, 255, 175, 255,
			255, 63, 95, 127, 255, 243, 0, 0, 0, 0,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 254,
			255, 255, 255, 31, 254, 255, 255, 255, 255, 254,
			255, 255, 255, 223, 255, 223, 255, 7, 0, 0,
			0, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 191, 32, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 61, 127, 61, 255, 255,
			255, 255, 255, 61, 255, 255, 255, 255, 61, 127,
			61, 255, 127, 255, 255, 255, 255, 255, 255, 255,
			61, 255, 255, 255, 255, 255, 255, 255, 255, 231,
			255, 255, 255, 31, 255, 255, 255, 3, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 63, 63,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			254, 255, 255, 31, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 1, 255, 255, 63, 128,
			255, 255, 127, 0, 255, 255, 15, 0, 255, 223,
			13, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 63, 255, 3, 255, 3, 255, 255,
			255, 3, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 1, 255, 255, 255, 255, 255, 7,
			255, 255, 255, 255, 255, 255, 255, 255, 63, 0,
			255, 255, 255, 127, 255, 15, 255, 15, 241, 255,
			255, 255, 255, 63, 31, 0, 255, 255, 255, 255,
			255, 15, 255, 255, 255, 3, 255, 199, 255, 255,
			255, 255, 255, 255, 255, 207, 255, 255, 255, 255,
			255, 255, 255, 127, 255, 255, 255, 159, 255, 3,
			255, 3, 255, 63, 255, 255, 255, 127, 0, 0,
			0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 31, 255, 255, 255, 255, 255, 127,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 15, 240, 255, 255, 255, 255,
			255, 255, 255, 248, 255, 227, 255, 255, 255, 255,
			255, 255, 255, 1, 255, 255, 255, 255, 255, 231,
			255, 0, 255, 255, 255, 255, 255, 7, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 63, 63, 255, 255, 255, 255,
			63, 63, 255, 170, 255, 255, 255, 63, 255, 255,
			255, 255, 255, 255, 223, 255, 223, 255, 207, 239,
			255, 255, 220, 127, 0, 248, 255, 255, 255, 124,
			255, 255, 255, 255, 255, 127, 223, 255, 243, 255,
			255, 127, 255, 31, 255, 255, 255, 255, 1, 0,
			255, 255, 255, 255, 1, 0, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 15, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 127, 0, 0, 0,
			255, 7, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			207, 255, 255, 255, 191, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 15, 254,
			255, 255, 255, 255, 191, 32, 255, 255, 255, 255,
			255, 255, 255, 128, 1, 128, 255, 255, 127, 0,
			127, 127, 127, 127, 127, 127, 127, 127, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 63, 0, 0, 0, 0, 255, 255,
			255, 251, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 15, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			63, 0, 0, 0, 255, 15, 254, 255, 255, 255,
			255, 255, 255, 255, 254, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 127, 254, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 224, 255,
			255, 255, 255, 255, 254, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 127, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 15, 0, 255, 255,
			255, 255, 255, 127, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 31, 255, 255, 255, 255,
			255, 255, 127, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 15, 0, 0,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 7,
			235, 3, 0, 0, 252, 255, 255, 255, 255, 255,
			255, 31, 255, 3, 255, 255, 255, 255, 255, 255,
			255, 0, 255, 255, 255, 255, 255, 255, 255, 255,
			63, 192, 255, 3, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 15, 128,
			255, 255, 255, 31, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 191, 255, 195, 255, 255, 255, 127,
			255, 255, 255, 255, 255, 255, 127, 0, 255, 63,
			255, 243, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 7, 0, 0, 248, 255, 255,
			127, 0, 126, 126, 126, 0, 127, 127, 255, 255,
			255, 255, 255, 255, 255, 15, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 63, 255, 3, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			15, 0, 255, 255, 127, 248, 255, 255, 255, 255,
			255, 15, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 63, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 3, 0, 0,
			0, 0, 127, 0, 248, 224, 255, 255, 127, 95,
			219, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 7, 0, 248, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 252, 255, 255, 255, 255, 255,
			255, 128, 0, 0, 0, 0, 255, 255, 255, 255,
			255, 3, 255, 255, 255, 255, 255, 255, 247, 255,
			127, 15, 223, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 31,
			254, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 127, 252, 252, 252, 28, 127, 127,
			0, 62
		};

		internal static ReadOnlySpan<byte> GetDefinedBmpCodePointsBitmapLittleEndian()
		{
			return DefinedCharsBitmapSpan;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void GetUtf16SurrogatePairFromAstralScalarValue(uint scalar, out char highSurrogate, out char lowSurrogate)
		{
			highSurrogate = (char)(scalar + 56557568 >> 10);
			lowSurrogate = (char)((scalar & 0x3FF) + 56320);
		}

		internal static int GetUtf8RepresentationForScalarValue(uint scalar)
		{
			if (scalar <= 127)
			{
				return (byte)scalar;
			}
			if (scalar <= 2047)
			{
				byte b = (byte)(0xC0u | (scalar >> 6));
				byte b2 = (byte)(0x80u | (scalar & 0x3Fu));
				return (b2 << 8) | b;
			}
			if (scalar <= 65535)
			{
				byte b3 = (byte)(0xE0u | (scalar >> 12));
				byte b4 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
				byte b5 = (byte)(0x80u | (scalar & 0x3Fu));
				return (((b5 << 8) | b4) << 8) | b3;
			}
			byte b6 = (byte)(0xF0u | (scalar >> 18));
			byte b7 = (byte)(0x80u | ((scalar >> 12) & 0x3Fu));
			byte b8 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
			byte b9 = (byte)(0x80u | (scalar & 0x3Fu));
			return (((((b9 << 8) | b8) << 8) | b7) << 8) | b6;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static bool IsSupplementaryCodePoint(int scalar)
		{
			return (scalar & -65536) != 0;
		}
	}
	public sealed class UnicodeRange
	{
		public int FirstCodePoint { get; private set; }

		public int Length { get; private set; }

		public UnicodeRange(int firstCodePoint, int length)
		{
			if (firstCodePoint < 0 || firstCodePoint > 65535)
			{
				throw new ArgumentOutOfRangeException("firstCodePoint");
			}
			if (length < 0 || (long)firstCodePoint + (long)length > 65536)
			{
				throw new ArgumentOutOfRangeException("length");
			}
			FirstCodePoint = firstCodePoint;
			Length = length;
		}

		public static UnicodeRange Create(char firstCharacter, char lastCharacter)
		{
			if (lastCharacter < firstCharacter)
			{
				throw new ArgumentOutOfRangeException("lastCharacter");
			}
			return new UnicodeRange(firstCharacter, 1 + (lastCharacter - firstCharacter));
		}
	}
	public static class UnicodeRanges
	{
		private static UnicodeRange _none;

		private static UnicodeRange _all;

		private static UnicodeRange _u0000;

		private static UnicodeRange _u0080;

		private static UnicodeRange _u0100;

		private static UnicodeRange _u0180;

		private static UnicodeRange _u0250;

		private static UnicodeRange _u02B0;

		private static UnicodeRange _u0300;

		private static UnicodeRange _u0370;

		private static UnicodeRange _u0400;

		private static UnicodeRange _u0500;

		private static UnicodeRange _u0530;

		private static UnicodeRange _u0590;

		private static UnicodeRange _u0600;

		private static UnicodeRange _u0700;

		private static UnicodeRange _u0750;

		private static UnicodeRange _u0780;

		private static UnicodeRange _u07C0;

		private static UnicodeRange _u0800;

		private static UnicodeRange _u0840;

		private static UnicodeRange _u0860;

		private static UnicodeRange _u0870;

		private static UnicodeRange _u08A0;

		private static UnicodeRange _u0900;

		private static UnicodeRange _u0980;

		private static UnicodeRange _u0A00;

		private static UnicodeRange _u0A80;

		private static UnicodeRange _u0B00;

		private static UnicodeRange _u0B80;

		private static UnicodeRange _u0C00;

		private static UnicodeRange _u0C80;

		private static UnicodeRange _u0D00;

		private static UnicodeRange _u0D80;

		private static UnicodeRange _u0E00;

		private static UnicodeRange _u0E80;

		private static UnicodeRange _u0F00;

		private static UnicodeRange _u1000;

		private static UnicodeRange _u10A0;

		private static UnicodeRange _u1100;

		private static UnicodeRange _u1200;

		private static UnicodeRange _u1380;

		private static UnicodeRange _u13A0;

		private static UnicodeRange _u1400;

		private static UnicodeRange _u1680;

		private static UnicodeRange _u16A0;

		private static UnicodeRange _u1700;

		private static UnicodeRange _u1720;

		private static UnicodeRange _u1740;

		private static UnicodeRange _u1760;

		private static UnicodeRange _u1780;

		private static UnicodeRange _u1800;

		private static UnicodeRange _u18B0;

		private static UnicodeRange _u1900;

		private static UnicodeRange _u1950;

		private static UnicodeRange _u1980;

		private static UnicodeRange _u19E0;

		private static UnicodeRange _u1A00;

		private static UnicodeRange _u1A20;

		private static UnicodeRange _u1AB0;

		private static UnicodeRange _u1B00;

		private static UnicodeRange _u1B80;

		private static UnicodeRange _u1BC0;

		private static UnicodeRange _u1C00;

		private static UnicodeRange _u1C50;

		private static UnicodeRange _u1C80;

		private static UnicodeRange _u1C90;

		private static UnicodeRange _u1CC0;

		private static UnicodeRange _u1CD0;

		private static UnicodeRange _u1D00;

		private static UnicodeRange _u1D80;

		private static UnicodeRange _u1DC0;

		private static UnicodeRange _u1E00;

		private static UnicodeRange _u1F00;

		private static UnicodeRange _u2000;

		private static UnicodeRange _u2070;

		private static UnicodeRange _u20A0;

		private static UnicodeRange _u20D0;

		private static UnicodeRange _u2100;

		private static UnicodeRange _u2150;

		private static UnicodeRange _u2190;

		private static UnicodeRange _u2200;

		private static UnicodeRange _u2300;

		private static UnicodeRange _u2400;

		private static UnicodeRange _u2440;

		private static UnicodeRange _u2460;

		private static UnicodeRange _u2500;

		private static UnicodeRange _u2580;

		private static UnicodeRange _u25A0;

		private static UnicodeRange _u2600;

		private static UnicodeRange _u2700;

		private static UnicodeRange _u27C0;

		private static UnicodeRange _u27F0;

		private static UnicodeRange _u2800;

		private static UnicodeRange _u2900;

		private static UnicodeRange _u2980;

		private static UnicodeRange _u2A00;

		private static UnicodeRange _u2B00;

		private static UnicodeRange _u2C00;

		private static UnicodeRange _u2C60;

		private static UnicodeRange _u2C80;

		private static UnicodeRange _u2D00;

		private static UnicodeRange _u2D30;

		private static UnicodeRange _u2D80;

		private static UnicodeRange _u2DE0;

		private static UnicodeRange _u2E00;

		private static UnicodeRange _u2E80;

		private static UnicodeRange _u2F00;

		private static UnicodeRange _u2FF0;

		private static UnicodeRange _u3000;

		private static UnicodeRange _u3040;

		private static UnicodeRange _u30A0;

		private static UnicodeRange _u3100;

		private static UnicodeRange _u3130;

		private static UnicodeRange _u3190;

		private static UnicodeRange _u31A0;

		private static UnicodeRange _u31C0;

		private static UnicodeRange _u31F0;

		private static UnicodeRange _u3200;

		private static UnicodeRange _u3300;

		private static UnicodeRange _u3400;

		private static UnicodeRange _u4DC0;

		private static UnicodeRange _u4E00;

		private static UnicodeRange _uA000;

		private static UnicodeRange _uA490;

		private static UnicodeRange _uA4D0;

		private static UnicodeRange _uA500;

		private static UnicodeRange _uA640;

		private static UnicodeRange _uA6A0;

		private static UnicodeRange _uA700;

		private static UnicodeRange _uA720;

		private static UnicodeRange _uA800;

		private static UnicodeRange _uA830;

		private static UnicodeRange _uA840;

		private static UnicodeRange _uA880;

		private static UnicodeRange _uA8E0;

		private static UnicodeRange _uA900;

		private static UnicodeRange _uA930;

		private static UnicodeRange _uA960;

		private static UnicodeRange _uA980;

		private static UnicodeRange _uA9E0;

		private static UnicodeRange _uAA00;

		private static UnicodeRange _uAA60;

		private static UnicodeRange _uAA80;

		private static UnicodeRange _uAAE0;

		private static UnicodeRange _uAB00;

		private static UnicodeRange _uAB30;

		private static UnicodeRange _uAB70;

		private static UnicodeRange _uABC0;

		private static UnicodeRange _uAC00;

		private static UnicodeRange _uD7B0;

		private static UnicodeRange _uF900;

		private static UnicodeRange _uFB00;

		private static UnicodeRange _uFB50;

		private static UnicodeRange _uFE00;

		private static UnicodeRange _uFE10;

		private static UnicodeRange _uFE20;

		private static UnicodeRange _uFE30;

		private static UnicodeRange _uFE50;

		private static UnicodeRange _uFE70;

		private static UnicodeRange _uFF00;

		private static UnicodeRange _uFFF0;

		public static UnicodeRange None => _none ?? CreateEmptyRange(ref _none);

		public static UnicodeRange All => _all ?? CreateRange(ref _all, '\0', '\uffff');

		public static UnicodeRange BasicLatin => _u0000 ?? CreateRange(ref _u0000, '\0', '\u007f');

		public static UnicodeRange Latin1Supplement => _u0080 ?? CreateRange(ref _u0080, '\u0080', 'ÿ');

		public static UnicodeRange LatinExtendedA => _u0100 ?? CreateRange(ref _u0100, 'Ā', 'ſ');

		public static UnicodeRange LatinExtendedB => _u0180 ?? CreateRange(ref _u0180, 'ƀ', 'ɏ');

		public static UnicodeRange IpaExtensions => _u0250 ?? CreateRange(ref _u0250, 'ɐ', 'ʯ');

		public static UnicodeRange SpacingModifierLetters => _u02B0 ?? CreateRange(ref _u02B0, 'ʰ', '\u02ff');

		public static UnicodeRange CombiningDiacriticalMarks => _u0300 ?? CreateRange(ref _u0300, '\u0300', '\u036f');

		public static UnicodeRange GreekandCoptic => _u0370 ?? CreateRange(ref _u0370, 'Ͱ', 'Ͽ');

		public static UnicodeRange Cyrillic => _u0400 ?? CreateRange(ref _u0400, 'Ѐ', 'ӿ');

		public static UnicodeRange CyrillicSupplement => _u0500 ?? CreateRange(ref _u0500, 'Ԁ', 'ԯ');

		public static UnicodeRange Armenian => _u0530 ?? CreateRange(ref _u0530, '\u0530', '֏');

		public static UnicodeRange Hebrew => _u0590 ?? CreateRange(ref _u0590, '\u0590', '\u05ff');

		public static UnicodeRange Arabic => _u0600 ?? CreateRange(ref _u0600, '\u0600', 'ۿ');

		public static UnicodeRange Syriac => _u0700 ?? CreateRange(ref _u0700, '܀', 'ݏ');

		public static UnicodeRange ArabicSupplement => _u0750 ?? CreateRange(ref _u0750, 'ݐ', 'ݿ');

		public static UnicodeRange Thaana => _u0780 ?? CreateRange(ref _u0780, 'ހ', '\u07bf');

		public static UnicodeRange NKo => _u07C0 ?? CreateRange(ref _u07C0, '߀', '߿');

		public static UnicodeRange Samaritan => _u0800 ?? CreateRange(ref _u0800, 'ࠀ', '\u083f');

		public static UnicodeRange Mandaic => _u0840 ?? CreateRange(ref _u0840, 'ࡀ', '\u085f');

		public static UnicodeRange SyriacSupplement => _u0860 ?? CreateRange(ref _u0860, 'ࡠ', '\u086f');

		public static UnicodeRange ArabicExtendedB => _u0870 ?? CreateRange(ref _u0870, '\u0870', '\u089f');

		public static UnicodeRange ArabicExtendedA => _u08A0 ?? CreateRange(ref _u08A0, 'ࢠ', '\u08ff');

		public static UnicodeRange Devanagari => _u0900 ?? CreateRange(ref _u0900, '\u0900', 'ॿ');

		public static UnicodeRange Bengali => _u0980 ?? CreateRange(ref _u0980, 'ঀ', '\u09ff');

		public static UnicodeRange Gurmukhi => _u0A00 ?? CreateRange(ref _u0A00, '\u0a00', '\u0a7f');

		public static UnicodeRange Gujarati => _u0A80 ?? CreateRange(ref _u0A80, '\u0a80', '\u0aff');

		public static UnicodeRange Oriya => _u0B00 ?? CreateRange(ref _u0B00, '\u0b00', '\u0b7f');

		public static UnicodeRange Tamil => _u0B80 ?? CreateRange(ref _u0B80, '\u0b80', '\u0bff');

		public static UnicodeRange Telugu => _u0C00 ?? CreateRange(ref _u0C00, '\u0c00', '౿');

		public static UnicodeRange Kannada => _u0C80 ?? CreateRange(ref _u0C80, 'ಀ', '\u0cff');

		public static UnicodeRange Malayalam => _u0D00 ?? CreateRange(ref _u0D00, '\u0d00', 'ൿ');

		public static UnicodeRange Sinhala => _u0D80 ?? CreateRange(ref _u0D80, '\u0d80', '\u0dff');

		public static UnicodeRange Thai => _u0E00 ?? CreateRange(ref _u0E00, '\u0e00', '\u0e7f');

		public static UnicodeRange Lao => _u0E80 ?? CreateRange(ref _u0E80, '\u0e80', '\u0eff');

		public static UnicodeRange Tibetan => _u0F00 ?? CreateRange(ref _u0F00, 'ༀ', '\u0fff');

		public static UnicodeRange Myanmar => _u1000 ?? CreateRange(ref _u1000, 'က', '႟');

		public static UnicodeRange Georgian => _u10A0 ?? CreateRange(ref _u10A0, 'Ⴀ', 'ჿ');

		public static UnicodeRange HangulJamo => _u1100 ?? CreateRange(ref _u1100, 'ᄀ', 'ᇿ');

		public static UnicodeRange Ethiopic => _u1200 ?? CreateRange(ref _u1200, 'ሀ', '\u137f');

		public static UnicodeRange EthiopicSupplement => _u1380 ?? CreateRange(ref _u1380, 'ᎀ', '\u139f');

		public static UnicodeRange Cherokee => _u13A0 ?? CreateRange(ref _u13A0, 'Ꭰ', '\u13ff');

		public static UnicodeRange UnifiedCanadianAboriginalSyllabics => _u1400 ?? CreateRange(ref _u1400, '᐀', 'ᙿ');

		public static UnicodeRange Ogham => _u1680 ?? CreateRange(ref _u1680, '\u1680', '\u169f');

		public static UnicodeRange Runic => _u16A0 ?? CreateRange(ref _u16A0, 'ᚠ', '\u16ff');

		public static UnicodeRange Tagalog => _u1700 ?? CreateRange(ref _u1700, 'ᜀ', '\u171f');

		public static UnicodeRange Hanunoo => _u1720 ?? CreateRange(ref _u1720, 'ᜠ', '\u173f');

		public static UnicodeRange Buhid => _u1740 ?? CreateRange(ref _u1740, 'ᝀ', '\u175f');

		public static UnicodeRange Tagbanwa => _u1760 ?? CreateRange(ref _u1760, 'ᝠ', '\u177f');

		public static UnicodeRange Khmer => _u1780 ?? CreateRange(ref _u1780, 'ក', '\u17ff');

		public static UnicodeRange Mongolian => _u1800 ?? CreateRange(ref _u1800, '᠀', '\u18af');

		public static UnicodeRange UnifiedCanadianAboriginalSyllabicsExtended => _u18B0 ?? CreateRange(ref _u18B0, 'ᢰ', '\u18ff');

		public static UnicodeRange Limbu => _u1900 ?? CreateRange(ref _u1900, 'ᤀ', '᥏');

		public static UnicodeRange TaiLe => _u1950 ?? CreateRange(ref _u1950, 'ᥐ', '\u197f');

		public static UnicodeRange NewTaiLue => _u1980 ?? CreateRange(ref _u1980, 'ᦀ', '᧟');

		public static UnicodeRange KhmerSymbols => _u19E0 ?? CreateRange(ref _u19E0, '᧠', '᧿');

		public static UnicodeRange Buginese => _u1A00 ?? CreateRange(ref _u1A00, 'ᨀ', '᨟');

		public static UnicodeRange TaiTham => _u1A20 ?? CreateRange(ref _u1A20, 'ᨠ', '\u1aaf');

		public static UnicodeRange CombiningDiacriticalMarksExtended => _u1AB0 ?? CreateRange(ref _u1AB0, '\u1ab0', '\u1aff');

		public static UnicodeRange Balinese => _u1B00 ?? CreateRange(ref _u1B00, '\u1b00', '\u1b7f');

		public static UnicodeRange Sundanese => _u1B80 ?? CreateRange(ref _u1B80, '\u1b80', 'ᮿ');

		public static UnicodeRange Batak => _u1BC0 ?? CreateRange(ref _u1BC0, 'ᯀ', '᯿');

		public static UnicodeRange Lepcha => _u1C00 ?? CreateRange(ref _u1C00, 'ᰀ', 'ᱏ');

		public static UnicodeRange OlChiki => _u1C50 ?? CreateRange(ref _u1C50, '᱐', '᱿');

		public static UnicodeRange CyrillicExtendedC => _u1C80 ?? CreateRange(ref _u1C80, 'ᲀ', '\u1c8f');

		public static UnicodeRange GeorgianExtended => _u1C90 ?? CreateRange(ref _u1C90, 'Ა', 'Ჿ');

		public static UnicodeRange SundaneseSupplement => _u1CC0 ?? CreateRange(ref _u1CC0, '᳀', '\u1ccf');

		public static UnicodeRange VedicExtensions => _u1CD0 ?? CreateRange(ref _u1CD0, '\u1cd0', '\u1cff');

		public static UnicodeRange PhoneticExtensions => _u1D00 ?? CreateRange(ref _u1D00, 'ᴀ', 'ᵿ');

		public static UnicodeRange PhoneticExtensionsSupplement => _u1D80 ?? CreateRange(ref _u1D80, 'ᶀ', 'ᶿ');

		public static UnicodeRange CombiningDiacriticalMarksSupplement => _u1DC0 ?? CreateRange(ref _u1DC0, '\u1dc0', '\u1dff');

		public static UnicodeRange LatinExtendedAdditional => _u1E00 ?? CreateRange(ref _u1E00, 'Ḁ', 'ỿ');

		public static UnicodeRange GreekExtended => _u1F00 ?? CreateRange(ref _u1F00, 'ἀ', '\u1fff');

		public static UnicodeRange GeneralPunctuation => _u2000 ?? CreateRange(ref _u2000, '\u2000', '\u206f');

		public static UnicodeRange SuperscriptsandSubscripts => _u2070 ?? CreateRange(ref _u2070, '⁰', '\u209f');

		public static UnicodeRange CurrencySymbols => _u20A0 ?? CreateRange(ref _u20A0, '₠', '\u20cf');

		public static UnicodeRange CombiningDiacriticalMarksforSymbols => _u20D0 ?? CreateRange(ref _u20D0, '\u20d0', '\u20ff');

		public static UnicodeRange LetterlikeSymbols => _u2100 ?? CreateRange(ref _u2100, '℀', '⅏');

		public static UnicodeRange NumberForms => _u2150 ?? CreateRange(ref _u2150, '⅐', '\u218f');

		public static UnicodeRange Arrows => _u2190 ?? CreateRange(ref _u2190, '←', '⇿');

		public static UnicodeRange MathematicalOperators => _u2200 ?? CreateRange(ref _u2200, '∀', '⋿');

		public static UnicodeRange MiscellaneousTechnical => _u2300 ?? CreateRange(ref _u2300, '⌀', '⏿');

		public static UnicodeRange ControlPictures => _u2400 ?? CreateRange(ref _u2400, '␀', '\u243f');

		public static UnicodeRange OpticalCharacterRecognition => _u2440 ?? CreateRange(ref _u2440, '⑀', '\u245f');

		public static UnicodeRange EnclosedAlphanumerics => _u2460 ?? CreateRange(ref _u2460, '①', '⓿');

		public static UnicodeRange BoxDrawing => _u2500 ?? CreateRange(ref _u2500, '─', '╿');

		public static UnicodeRange BlockElements => _u2580 ?? CreateRange(ref _u2580, '▀', '▟');

		public static UnicodeRange GeometricShapes => _u25A0 ?? CreateRange(ref _u25A0, '■', '◿');

		public static UnicodeRange MiscellaneousSymbols => _u2600 ?? CreateRange(ref _u2600, '☀', '⛿');

		public static UnicodeRange Dingbats => _u2700 ?? CreateRange(ref _u2700, '✀', '➿');

		public static UnicodeRange MiscellaneousMathematicalSymbolsA => _u27C0 ?? CreateRange(ref _u27C0, '⟀', '⟯');

		public static UnicodeRange SupplementalArrowsA => _u27F0 ?? CreateRange(ref _u27F0, '⟰', '⟿');

		public static UnicodeRange BraillePatterns => _u2800 ?? CreateRange(ref _u2800, '⠀', '⣿');

		public static UnicodeRange SupplementalArrowsB => _u2900 ?? CreateRange(ref _u2900, '⤀', '⥿');

		public static UnicodeRange MiscellaneousMathematicalSymbolsB => _u2980 ?? CreateRange(ref _u2980, '⦀', '⧿');

		public static UnicodeRange SupplementalMathematicalOperators => _u2A00 ?? CreateRange(ref _u2A00, '⨀', '⫿');

		public static UnicodeRange MiscellaneousSymbolsandArrows => _u2B00 ?? CreateRange(ref _u2B00, '⬀', '⯿');

		public static UnicodeRange Glagolitic => _u2C00 ?? CreateRange(ref _u2C00, 'Ⰰ', '\u2c5f');

		public static UnicodeRange LatinExtendedC => _u2C60 ?? CreateRange(ref _u2C60, 'Ⱡ', 'Ɀ');

		public static UnicodeRange Coptic => _u2C80 ?? CreateRange(ref _u2C80, 'Ⲁ', '⳿');

		public static UnicodeRange GeorgianSupplement => _u2D00 ?? CreateRange(ref _u2D00, 'ⴀ', '\u2d2f');

		public static UnicodeRange Tifinagh => _u2D30 ?? CreateRange(ref _u2D30, 'ⴰ', '\u2d7f');

		public static UnicodeRange EthiopicExtended => _u2D80 ?? CreateRange(ref _u2D80, 'ⶀ', '\u2ddf');

		public static UnicodeRange CyrillicExtendedA => _u2DE0 ?? CreateRange(ref _u2DE0, '\u2de0', '\u2dff');

		public static UnicodeRange SupplementalPunctuation => _u2E00 ?? CreateRange(ref _u2E00, '⸀', '\u2e7f');

		public static UnicodeRange CjkRadicalsSupplement => _u2E80 ?? CreateRange(ref _u2E80, '⺀', '\u2eff');

		public static UnicodeRange KangxiRadicals => _u2F00 ?? CreateRange(ref _u2F00, '⼀', '\u2fdf');

		public static UnicodeRange IdeographicDescriptionCharacters => _u2FF0 ?? CreateRange(ref _u2FF0, '⿰', '\u2fff');

		public static UnicodeRange CjkSymbolsandPunctuation => _u3000 ?? CreateRange(ref _u3000, '\u3000', '〿');

		public static UnicodeRange Hiragana => _u3040 ?? CreateRange(ref _u3040, '\u3040', 'ゟ');

		public static UnicodeRange Katakana => _u30A0 ?? CreateRange(ref _u30A0, '゠', 'ヿ');

		public static UnicodeRange Bopomofo => _u3100 ?? CreateRange(ref _u3100, '\u3100', 'ㄯ');

		public static UnicodeRange HangulCompatibilityJamo => _u3130 ?? CreateRange(ref _u3130, '\u3130', '\u318f');

		public static UnicodeRange Kanbun => _u3190 ?? CreateRange(ref _u3190, '㆐', '㆟');

		public static UnicodeRange BopomofoExtended => _u31A0 ?? CreateRange(ref _u31A0, 'ㆠ', 'ㆿ');

		public static UnicodeRange CjkStrokes => _u31C0 ?? CreateRange(ref _u31C0, '㇀', '\u31ef');

		public static UnicodeRange KatakanaPhoneticExtensions => _u31F0 ?? CreateRange(ref _u31F0, 'ㇰ', 'ㇿ');

		public static UnicodeRange EnclosedCjkLettersandMonths => _u3200 ?? CreateRange(ref _u3200, '㈀', '㋿');

		public static UnicodeRange CjkCompatibility => _u3300 ?? CreateRange(ref _u3300, '㌀', '㏿');

		public static UnicodeRange CjkUnifiedIdeographsExtensionA => _u3400 ?? CreateRange(ref _u3400, '㐀', '䶿');

		public static UnicodeRange YijingHexagramSymbols => _u4DC0 ?? CreateRange(ref _u4DC0, '䷀', '䷿');

		public static UnicodeRange CjkUnifiedIdeographs => _u4E00 ?? CreateRange(ref _u4E00, '一', '\u9fff');

		public static UnicodeRange YiSyllables => _uA000 ?? CreateRange(ref _uA000, 'ꀀ', '\ua48f');

		public static UnicodeRange YiRadicals => _uA490 ?? CreateRange(ref _uA490, '꒐', '\ua4cf');

		public static UnicodeRange Lisu => _uA4D0 ?? CreateRange(ref _uA4D0, 'ꓐ', '꓿');

		public static UnicodeRange Vai => _uA500 ?? CreateRange(ref _uA500, 'ꔀ', '\ua63f');

		public static UnicodeRange CyrillicExtendedB => _uA640 ?? CreateRange(ref _uA640, 'Ꙁ', '\ua69f');

		public static UnicodeRange Bamum => _uA6A0 ?? CreateRange(ref _uA6A0, 'ꚠ', '\ua6ff');

		public static UnicodeRange ModifierToneLetters => _uA700 ?? CreateRange(ref _uA700, '\ua700', 'ꜟ');

		public static UnicodeRange LatinExtendedD => _uA720 ?? CreateRange(ref _uA720, '\ua720', 'ꟿ');

		public static UnicodeRange SylotiNagri => _uA800 ?? CreateRange(ref _uA800, 'ꠀ', '\ua82f');

		public static UnicodeRange CommonIndicNumberForms => _uA830 ?? CreateRange(ref _uA830, '꠰', '\ua83f');

		public static UnicodeRange Phagspa => _uA840 ?? CreateRange(ref _uA840, 'ꡀ', '\ua87f');

		public static UnicodeRange Saurashtra => _uA880 ?? CreateRange(ref _uA880, '\ua880', '\ua8df');

		public static UnicodeRange DevanagariExtended => _uA8E0 ?? CreateRange(ref _uA8E0, '\ua8e0', '\ua8ff');

		public static UnicodeRange KayahLi => _uA900 ?? CreateRange(ref _uA900, '꤀', '꤯');

		public static UnicodeRange Rejang => _uA930 ?? CreateRange(ref _uA930, 'ꤰ', '꥟');

		public static UnicodeRange HangulJamoExtendedA => _uA960 ?? CreateRange(ref _uA960, 'ꥠ', '\ua97f');

		public static UnicodeRange Javanese => _uA980 ?? CreateRange(ref _uA980, '\ua980', '꧟');

		public static UnicodeRange MyanmarExtendedB => _uA9E0 ?? CreateRange(ref _uA9E0, 'ꧠ', '\ua9ff');

		public static UnicodeRange Cham => _uAA00 ?? CreateRange(ref _uAA00, 'ꨀ', '꩟');

		public static UnicodeRange MyanmarExtendedA => _uAA60 ?? CreateRange(ref _uAA60, 'ꩠ', 'ꩿ');

		public static UnicodeRange TaiViet => _uAA80 ?? CreateRange(ref _uAA80, 'ꪀ', '꫟');

		public static UnicodeRange MeeteiMayekExtensions => _uAAE0 ?? CreateRange(ref _uAAE0, 'ꫠ', '\uaaff');

		public static UnicodeRange EthiopicExtendedA => _uAB00 ?? CreateRange(ref _uAB00, '\uab00', '\uab2f');

		public static UnicodeRange LatinExtendedE => _uAB30 ?? CreateRange(ref _uAB30, 'ꬰ', '\uab6f');

		public static UnicodeRange CherokeeSupplement => _uAB70 ?? CreateRange(ref _uAB70, 'ꭰ', 'ꮿ');

		public static UnicodeRange MeeteiMayek => _uABC0 ?? CreateRange(ref _uABC0, 'ꯀ', '\uabff');

		public static UnicodeRange HangulSyllables => _uAC00 ?? CreateRange(ref _uAC00, '가', '\ud7af');

		public static UnicodeRange HangulJamoExtendedB => _uD7B0 ?? CreateRange(ref _uD7B0, 'ힰ', '\ud7ff');

		public static UnicodeRange CjkCompatibilityIdeographs => _uF900 ?? CreateRange(ref _uF900, '豈', '\ufaff');

		public static UnicodeRange AlphabeticPresentationForms => _uFB00 ?? CreateRange(ref _uFB00, 'ff', 'ﭏ');

		public static UnicodeRange ArabicPresentationFormsA => _uFB50 ?? CreateRange(ref _uFB50, 'ﭐ', '\ufdff');

		public static UnicodeRange VariationSelectors => _uFE00 ?? CreateRange(ref _uFE00, '\ufe00', '\ufe0f');

		public static UnicodeRange VerticalForms => _uFE10 ?? CreateRange(ref _uFE10, '︐', '\ufe1f');

		public static UnicodeRange CombiningHalfMarks => _uFE20 ?? CreateRange(ref _uFE20, '\ufe20', '\ufe2f');

		public static UnicodeRange CjkCompatibilityForms => _uFE30 ?? CreateRange(ref _uFE30, '︰', '\ufe4f');

		public static UnicodeRange SmallFormVariants => _uFE50 ?? CreateRange(ref _uFE50, '﹐', '\ufe6f');

		public static UnicodeRange ArabicPresentationFormsB => _uFE70 ?? CreateRange(ref _uFE70, 'ﹰ', '\ufeff');

		public static UnicodeRange HalfwidthandFullwidthForms => _uFF00 ?? CreateRange(ref _uFF00, '\uff00', '\uffef');

		public static UnicodeRange Specials => _uFFF0 ?? CreateRange(ref _uFFF0, '\ufff0', '\uffff');

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static UnicodeRange CreateEmptyRange([NotNull] ref UnicodeRange range)
		{
			Volatile.Write(ref range, new UnicodeRange(0, 0));
			return range;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static UnicodeRange CreateRange([NotNull] ref UnicodeRange range, char first, char last)
		{
			Volatile.Write(ref range, UnicodeRange.Create(first, last));
			return range;
		}
	}
}
namespace System.Text.Encodings.Web
{
	internal struct AsciiByteMap
	{
		private const int BufferSize = 128;

		private unsafe fixed byte Buffer[128];

		internal unsafe void InsertAsciiChar(char key, byte value)
		{
			if (key < '\u0080')
			{
				Buffer[(uint)key] = value;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal unsafe readonly bool TryLookup(Rune key, out byte value)
		{
			if (key.IsAscii)
			{
				byte b = Buffer[(uint)key.Value];
				if (b != 0)
				{
					value = b;
					return true;
				}
			}
			value = 0;
			return false;
		}
	}
	internal struct AllowedBmpCodePointsBitmap
	{
		private const int BitmapLengthInDWords = 2048;

		private unsafe fixed uint Bitmap[2048];

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe void AllowChar(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			ref uint reference = ref Bitmap[(ulong)index];
			reference |= (uint)(1 << offset);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe void ForbidChar(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			ref uint reference = ref Bitmap[(ulong)index];
			reference &= (uint)(~(1 << offset));
		}

		public void ForbidHtmlCharacters()
		{
			ForbidChar('<');
			ForbidChar('>');
			ForbidChar('&');
			ForbidChar('\'');
			ForbidChar('"');
			ForbidChar('+');
		}

		public unsafe void ForbidUndefinedCharacters()
		{
			fixed (uint* pointer = Bitmap)
			{
				ReadOnlySpan<byte> definedBmpCodePointsBitmapLittleEndian = UnicodeHelpers.GetDefinedBmpCodePointsBitmapLittleEndian();
				Span<uint> span = new Span<uint>(pointer, 2048);
				for (int i = 0; i < span.Length; i++)
				{
					span[i] &= BinaryPrimitives.ReadUInt32LittleEndian(definedBmpCodePointsBitmapLittleEndian.Slice(i * 4));
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe readonly bool IsCharAllowed(char value)
		{
			_GetIndexAndOffset(value, out UIntPtr index, out int offset);
			if ((Bitmap[(ulong)index] & (uint)(1 << offset)) != 0)
			{
				return true;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe read

plugins/System.Text.Json.dll

Decompiled 7 months ago
using System;
using System.Buffers;
using System.Buffers.Text;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Numerics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Encodings.Web;
using System.Text.Json.Nodes;
using System.Text.Json.Reflection;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Converters;
using System.Text.Json.Serialization.Metadata;
using System.Threading;
using System.Threading.Tasks;
using FxResources.System.Text.Json;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyDefaultAlias("System.Text.Json")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
[assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Provides high-performance and low-allocating types that serialize objects to JavaScript Object Notation (JSON) text and deserialize JSON text to objects, with UTF-8 support built-in. Also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM), that is read-only, for random access of the JSON elements within a structured view of the data.\r\n\r\nThe System.Text.Json library is built-in as part of the shared framework in .NET Runtime. The package can be installed when you need to use it in other target frameworks.")]
[assembly: AssemblyFileVersion("8.0.23.53103")]
[assembly: AssemblyInformationalVersion("8.0.0+5535e31a712343a63f5d7d796cd874e563e5ac14")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Json")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("8.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: System.Runtime.CompilerServices.NullablePublicOnly(false)]
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 IsUnmanagedAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsByRefLikeAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public NullablePublicOnlyAttribute(bool P_0)
		{
			IncludesInternals = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	internal sealed class ScopedRefAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FxResources.System.Text.Json
{
	internal static class SR
	{
	}
}
namespace System
{
	internal static class HexConverter
	{
		public enum Casing : uint
		{
			Upper = 0u,
			Lower = 8224u
		}

		public static ReadOnlySpan<byte> CharToHexLookup => new byte[256]
		{
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 0, 1,
			2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
			255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
			15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 10, 11, 12,
			13, 14, 15, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255
		};

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void ToBytesBuffer(byte value, Span<byte> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (byte)num2;
			buffer[startingIndex] = (byte)(num2 >> 8);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static void ToCharsBuffer(byte value, Span<char> buffer, int startingIndex = 0, Casing casing = Casing.Upper)
		{
			uint num = (uint)(((value & 0xF0) << 4) + (value & 0xF) - 35209);
			uint num2 = ((((0 - num) & 0x7070) >> 4) + num + 47545) | (uint)casing;
			buffer[startingIndex + 1] = (char)(num2 & 0xFFu);
			buffer[startingIndex] = (char)(num2 >> 8);
		}

		public static void EncodeToUtf16(ReadOnlySpan<byte> bytes, Span<char> chars, Casing casing = Casing.Upper)
		{
			for (int i = 0; i < bytes.Length; i++)
			{
				ToCharsBuffer(bytes[i], chars, i * 2, casing);
			}
		}

		public static string ToString(ReadOnlySpan<byte> bytes, Casing casing = Casing.Upper)
		{
			Span<char> span = ((bytes.Length <= 16) ? stackalloc char[bytes.Length * 2] : new char[bytes.Length * 2].AsSpan());
			Span<char> buffer = span;
			int num = 0;
			ReadOnlySpan<byte> readOnlySpan = bytes;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				byte value = readOnlySpan[i];
				ToCharsBuffer(value, buffer, num, casing);
				num += 2;
			}
			return buffer.ToString();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharUpper(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 7;
			}
			return (char)value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static char ToCharLower(int value)
		{
			value &= 0xF;
			value += 48;
			if (value > 57)
			{
				value += 39;
			}
			return (char)value;
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes)
		{
			int charsProcessed;
			return TryDecodeFromUtf16(chars, bytes, out charsProcessed);
		}

		public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes, out int charsProcessed)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			while (num2 < bytes.Length)
			{
				num3 = FromChar(chars[num + 1]);
				num4 = FromChar(chars[num]);
				if ((num3 | num4) == 255)
				{
					break;
				}
				bytes[num2++] = (byte)((num4 << 4) | num3);
				num += 2;
			}
			if (num3 == 255)
			{
				num++;
			}
			charsProcessed = num;
			return (num3 | num4) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromChar(int c)
		{
			if (c < CharToHexLookup.Length)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromUpperChar(int c)
		{
			if (c <= 71)
			{
				return CharToHexLookup[c];
			}
			return 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int FromLowerChar(int c)
		{
			switch (c)
			{
			case 48:
			case 49:
			case 50:
			case 51:
			case 52:
			case 53:
			case 54:
			case 55:
			case 56:
			case 57:
				return c - 48;
			case 97:
			case 98:
			case 99:
			case 100:
			case 101:
			case 102:
				return c - 97 + 10;
			default:
				return 255;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexChar(int c)
		{
			if (IntPtr.Size == 8)
			{
				ulong num = (uint)(c - 48);
				ulong num2 = (ulong)(-17875860044349952L << (int)num);
				ulong num3 = num - 64;
				return (long)(num2 & num3) < 0L;
			}
			return FromChar(c) != 255;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexUpperChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 65) <= 5u;
			}
			return true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHexLowerChar(int c)
		{
			if ((uint)(c - 48) > 9u)
			{
				return (uint)(c - 97) <= 5u;
			}
			return true;
		}
	}
	internal static class Obsoletions
	{
		internal const string SharedUrlFormat = "https://aka.ms/dotnet-warnings/{0}";

		internal const string SystemTextEncodingUTF7Message = "The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.";

		internal const string SystemTextEncodingUTF7DiagId = "SYSLIB0001";

		internal const string PrincipalPermissionAttributeMessage = "PrincipalPermissionAttribute is not honored by the runtime and must not be used.";

		internal const string PrincipalPermissionAttributeDiagId = "SYSLIB0002";

		internal const string CodeAccessSecurityMessage = "Code Access Security is not supported or honored by the runtime.";

		internal const string CodeAccessSecurityDiagId = "SYSLIB0003";

		internal const string ConstrainedExecutionRegionMessage = "The Constrained Execution Region (CER) feature is not supported.";

		internal const string ConstrainedExecutionRegionDiagId = "SYSLIB0004";

		internal const string GlobalAssemblyCacheMessage = "The Global Assembly Cache is not supported.";

		internal const string GlobalAssemblyCacheDiagId = "SYSLIB0005";

		internal const string ThreadAbortMessage = "Thread.Abort is not supported and throws PlatformNotSupportedException.";

		internal const string ThreadResetAbortMessage = "Thread.ResetAbort is not supported and throws PlatformNotSupportedException.";

		internal const string ThreadAbortDiagId = "SYSLIB0006";

		internal const string DefaultCryptoAlgorithmsMessage = "The default implementation of this cryptography algorithm is not supported.";

		internal const string DefaultCryptoAlgorithmsDiagId = "SYSLIB0007";

		internal const string CreatePdbGeneratorMessage = "The CreatePdbGenerator API is not supported and throws PlatformNotSupportedException.";

		internal const string CreatePdbGeneratorDiagId = "SYSLIB0008";

		internal const string AuthenticationManagerMessage = "The AuthenticationManager Authenticate and PreAuthenticate methods are not supported and throw PlatformNotSupportedException.";

		internal const string AuthenticationManagerDiagId = "SYSLIB0009";

		internal const string RemotingApisMessage = "This Remoting API is not supported and throws PlatformNotSupportedException.";

		internal const string RemotingApisDiagId = "SYSLIB0010";

		internal const string BinaryFormatterMessage = "BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.";

		internal const string BinaryFormatterDiagId = "SYSLIB0011";

		internal const string CodeBaseMessage = "Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.";

		internal const string CodeBaseDiagId = "SYSLIB0012";

		internal const string EscapeUriStringMessage = "Uri.EscapeUriString can corrupt the Uri string in some cases. Consider using Uri.EscapeDataString for query string components instead.";

		internal const string EscapeUriStringDiagId = "SYSLIB0013";

		internal const string WebRequestMessage = "WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.";

		internal const string WebRequestDiagId = "SYSLIB0014";

		internal const string DisablePrivateReflectionAttributeMessage = "DisablePrivateReflectionAttribute has no effect in .NET 6.0+.";

		internal const string DisablePrivateReflectionAttributeDiagId = "SYSLIB0015";

		internal const string GetContextInfoMessage = "Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.";

		internal const string GetContextInfoDiagId = "SYSLIB0016";

		internal const string StrongNameKeyPairMessage = "Strong name signing is not supported and throws PlatformNotSupportedException.";

		internal const string StrongNameKeyPairDiagId = "SYSLIB0017";

		internal const string ReflectionOnlyLoadingMessage = "ReflectionOnly loading is not supported and throws PlatformNotSupportedException.";

		internal const string ReflectionOnlyLoadingDiagId = "SYSLIB0018";

		internal const string RuntimeEnvironmentMessage = "RuntimeEnvironment members SystemConfigurationFile, GetRuntimeInterfaceAsIntPtr, and GetRuntimeInterfaceAsObject are not supported and throw PlatformNotSupportedException.";

		internal const string RuntimeEnvironmentDiagId = "SYSLIB0019";

		internal const string JsonSerializerOptionsIgnoreNullValuesMessage = "JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.";

		internal const string JsonSerializerOptionsIgnoreNullValuesDiagId = "SYSLIB0020";

		internal const string DerivedCryptographicTypesMessage = "Derived cryptographic types are obsolete. Use the Create method on the base type instead.";

		internal const string DerivedCryptographicTypesDiagId = "SYSLIB0021";

		internal const string RijndaelMessage = "The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.";

		internal const string RijndaelDiagId = "SYSLIB0022";

		internal const string RNGCryptoServiceProviderMessage = "RNGCryptoServiceProvider is obsolete. To generate a random number, use one of the RandomNumberGenerator static methods instead.";

		internal const string RNGCryptoServiceProviderDiagId = "SYSLIB0023";

		internal const string AppDomainCreateUnloadMessage = "Creating and unloading AppDomains is not supported and throws an exception.";

		internal const string AppDomainCreateUnloadDiagId = "SYSLIB0024";

		internal const string SuppressIldasmAttributeMessage = "SuppressIldasmAttribute has no effect in .NET 6.0+.";

		internal const string SuppressIldasmAttributeDiagId = "SYSLIB0025";

		internal const string X509CertificateImmutableMessage = "X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.";

		internal const string X509CertificateImmutableDiagId = "SYSLIB0026";

		internal const string PublicKeyPropertyMessage = "PublicKey.Key is obsolete. Use the appropriate method to get the public key, such as GetRSAPublicKey.";

		internal const string PublicKeyPropertyDiagId = "SYSLIB0027";

		internal const string X509CertificatePrivateKeyMessage = "X509Certificate2.PrivateKey is obsolete. Use the appropriate method to get the private key, such as GetRSAPrivateKey, or use the CopyWithPrivateKey method to create a new instance with a private key.";

		internal const string X509CertificatePrivateKeyDiagId = "SYSLIB0028";

		internal const string ProduceLegacyHmacValuesMessage = "ProduceLegacyHmacValues is obsolete. Producing legacy HMAC values is not supported.";

		internal const string ProduceLegacyHmacValuesDiagId = "SYSLIB0029";

		internal const string UseManagedSha1Message = "HMACSHA1 always uses the algorithm implementation provided by the platform. Use a constructor without the useManagedSha1 parameter.";

		internal const string UseManagedSha1DiagId = "SYSLIB0030";

		internal const string CryptoConfigEncodeOIDMessage = "EncodeOID is obsolete. Use the ASN.1 functionality provided in System.Formats.Asn1.";

		internal const string CryptoConfigEncodeOIDDiagId = "SYSLIB0031";

		internal const string CorruptedStateRecoveryMessage = "Recovery from corrupted process state exceptions is not supported; HandleProcessCorruptedStateExceptionsAttribute is ignored.";

		internal const string CorruptedStateRecoveryDiagId = "SYSLIB0032";

		internal const string Rfc2898CryptDeriveKeyMessage = "Rfc2898DeriveBytes.CryptDeriveKey is obsolete and is not supported. Use PasswordDeriveBytes.CryptDeriveKey instead.";

		internal const string Rfc2898CryptDeriveKeyDiagId = "SYSLIB0033";

		internal const string CmsSignerCspParamsCtorMessage = "CmsSigner(CspParameters) is obsolete and is not supported. Use an alternative constructor instead.";

		internal const string CmsSignerCspParamsCtorDiagId = "SYSLIB0034";

		internal const string SignerInfoCounterSigMessage = "ComputeCounterSignature without specifying a CmsSigner is obsolete and is not supported. Use the overload that accepts a CmsSigner.";

		internal const string SignerInfoCounterSigDiagId = "SYSLIB0035";

		internal const string RegexCompileToAssemblyMessage = "Regex.CompileToAssembly is obsolete and not supported. Use the GeneratedRegexAttribute with the regular expression source generator instead.";

		internal const string RegexCompileToAssemblyDiagId = "SYSLIB0036";

		internal const string AssemblyNameMembersMessage = "AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.";

		internal const string AssemblyNameMembersDiagId = "SYSLIB0037";

		internal const string SystemDataSerializationFormatBinaryMessage = "SerializationFormat.Binary is obsolete and should not be used. See https://aka.ms/serializationformat-binary-obsolete for more information.";

		internal const string SystemDataSerializationFormatBinaryDiagId = "SYSLIB0038";

		internal const string TlsVersion10and11Message = "TLS versions 1.0 and 1.1 have known vulnerabilities and are not recommended. Use a newer TLS version instead, or use SslProtocols.None to defer to OS defaults.";

		internal const string TlsVersion10and11DiagId = "SYSLIB0039";

		internal const string EncryptionPolicyMessage = "EncryptionPolicy.NoEncryption and AllowEncryption significantly reduce security and should not be used in production code.";

		internal const string EncryptionPolicyDiagId = "SYSLIB0040";

		internal const string Rfc2898OutdatedCtorMessage = "The default hash algorithm and iteration counts in Rfc2898DeriveBytes constructors are outdated and insecure. Use a constructor that accepts the hash algorithm and the number of iterations.";

		internal const string Rfc2898OutdatedCtorDiagId = "SYSLIB0041";

		internal const string EccXmlExportImportMessage = "ToXmlString and FromXmlString have no implementation for ECC types, and are obsolete. Use a standard import and export format such as ExportSubjectPublicKeyInfo or ImportSubjectPublicKeyInfo for public keys and ExportPkcs8PrivateKey or ImportPkcs8PrivateKey for private keys.";

		internal const string EccXmlExportImportDiagId = "SYSLIB0042";

		internal const string EcDhPublicKeyBlobMessage = "ECDiffieHellmanPublicKey.ToByteArray() and the associated constructor do not have a consistent and interoperable implementation on all platforms. Use ECDiffieHellmanPublicKey.ExportSubjectPublicKeyInfo() instead.";

		internal const string EcDhPublicKeyBlobDiagId = "SYSLIB0043";

		internal const string AssemblyNameCodeBaseMessage = "AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete. Using them for loading an assembly is not supported.";

		internal const string AssemblyNameCodeBaseDiagId = "SYSLIB0044";

		internal const string CryptoStringFactoryMessage = "Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.";

		internal const string CryptoStringFactoryDiagId = "SYSLIB0045";

		internal const string ControlledExecutionRunMessage = "ControlledExecution.Run method may corrupt the process and should not be used in production code.";

		internal const string ControlledExecutionRunDiagId = "SYSLIB0046";

		internal const string XmlSecureResolverMessage = "XmlSecureResolver is obsolete. Use XmlResolver.ThrowingResolver instead when attempting to forbid XML external entity resolution.";

		internal const string XmlSecureResolverDiagId = "SYSLIB0047";

		internal const string RsaEncryptDecryptValueMessage = "RSA.EncryptValue and DecryptValue are not supported and throw NotSupportedException. Use RSA.Encrypt and RSA.Decrypt instead.";

		internal const string RsaEncryptDecryptDiagId = "SYSLIB0048";

		internal const string JsonSerializerOptionsAddContextMessage = "JsonSerializerOptions.AddContext is obsolete. To register a JsonSerializerContext, use either the TypeInfoResolver or TypeInfoResolverChain properties.";

		internal const string JsonSerializerOptionsAddContextDiagId = "SYSLIB0049";

		internal const string LegacyFormatterMessage = "Formatter-based serialization is obsolete and should not be used.";

		internal const string LegacyFormatterDiagId = "SYSLIB0050";

		internal const string LegacyFormatterImplMessage = "This API supports obsolete formatter-based serialization. It should not be called or extended by application code.";

		internal const string LegacyFormatterImplDiagId = "SYSLIB0051";

		internal const string RegexExtensibilityImplMessage = "This API supports obsolete mechanisms for Regex extensibility. It is not supported.";

		internal const string RegexExtensibilityDiagId = "SYSLIB0052";

		internal const string AesGcmTagConstructorMessage = "AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size.";

		internal const string AesGcmTagConstructorDiagId = "SYSLIB0053";
	}
	internal static class SR
	{
		private static readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled;

		private static ResourceManager s_resourceManager;

		internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR)));

		internal static string ArrayDepthTooLarge => GetResourceString("ArrayDepthTooLarge");

		internal static string CallFlushToAvoidDataLoss => GetResourceString("CallFlushToAvoidDataLoss");

		internal static string CannotReadIncompleteUTF16 => GetResourceString("CannotReadIncompleteUTF16");

		internal static string CannotReadInvalidUTF16 => GetResourceString("CannotReadInvalidUTF16");

		internal static string CannotStartObjectArrayAfterPrimitiveOrClose => GetResourceString("CannotStartObjectArrayAfterPrimitiveOrClose");

		internal static string CannotStartObjectArrayWithoutProperty => GetResourceString("CannotStartObjectArrayWithoutProperty");

		internal static string CannotTranscodeInvalidUtf8 => GetResourceString("CannotTranscodeInvalidUtf8");

		internal static string CannotDecodeInvalidBase64 => GetResourceString("CannotDecodeInvalidBase64");

		internal static string CannotTranscodeInvalidUtf16 => GetResourceString("CannotTranscodeInvalidUtf16");

		internal static string CannotEncodeInvalidUTF16 => GetResourceString("CannotEncodeInvalidUTF16");

		internal static string CannotEncodeInvalidUTF8 => GetResourceString("CannotEncodeInvalidUTF8");

		internal static string CannotWritePropertyWithinArray => GetResourceString("CannotWritePropertyWithinArray");

		internal static string CannotWritePropertyAfterProperty => GetResourceString("CannotWritePropertyAfterProperty");

		internal static string CannotWriteValueAfterPrimitiveOrClose => GetResourceString("CannotWriteValueAfterPrimitiveOrClose");

		internal static string CannotWriteValueWithinObject => GetResourceString("CannotWriteValueWithinObject");

		internal static string DepthTooLarge => GetResourceString("DepthTooLarge");

		internal static string DestinationTooShort => GetResourceString("DestinationTooShort");

		internal static string EmptyJsonIsInvalid => GetResourceString("EmptyJsonIsInvalid");

		internal static string EndOfCommentNotFound => GetResourceString("EndOfCommentNotFound");

		internal static string EndOfStringNotFound => GetResourceString("EndOfStringNotFound");

		internal static string ExpectedEndAfterSingleJson => GetResourceString("ExpectedEndAfterSingleJson");

		internal static string ExpectedEndOfDigitNotFound => GetResourceString("ExpectedEndOfDigitNotFound");

		internal static string ExpectedFalse => GetResourceString("ExpectedFalse");

		internal static string ExpectedJsonTokens => GetResourceString("ExpectedJsonTokens");

		internal static string ExpectedOneCompleteToken => GetResourceString("ExpectedOneCompleteToken");

		internal static string ExpectedNextDigitEValueNotFound => GetResourceString("ExpectedNextDigitEValueNotFound");

		internal static string ExpectedNull => GetResourceString("ExpectedNull");

		internal static string ExpectedSeparatorAfterPropertyNameNotFound => GetResourceString("ExpectedSeparatorAfterPropertyNameNotFound");

		internal static string ExpectedStartOfPropertyNotFound => GetResourceString("ExpectedStartOfPropertyNotFound");

		internal static string ExpectedStartOfPropertyOrValueNotFound => GetResourceString("ExpectedStartOfPropertyOrValueNotFound");

		internal static string ExpectedStartOfValueNotFound => GetResourceString("ExpectedStartOfValueNotFound");

		internal static string ExpectedTrue => GetResourceString("ExpectedTrue");

		internal static string ExpectedValueAfterPropertyNameNotFound => GetResourceString("ExpectedValueAfterPropertyNameNotFound");

		internal static string FailedToGetLargerSpan => GetResourceString("FailedToGetLargerSpan");

		internal static string FoundInvalidCharacter => GetResourceString("FoundInvalidCharacter");

		internal static string InvalidCast => GetResourceString("InvalidCast");

		internal static string InvalidCharacterAfterEscapeWithinString => GetResourceString("InvalidCharacterAfterEscapeWithinString");

		internal static string InvalidCharacterWithinString => GetResourceString("InvalidCharacterWithinString");

		internal static string InvalidEnumTypeWithSpecialChar => GetResourceString("InvalidEnumTypeWithSpecialChar");

		internal static string InvalidEndOfJsonNonPrimitive => GetResourceString("InvalidEndOfJsonNonPrimitive");

		internal static string InvalidHexCharacterWithinString => GetResourceString("InvalidHexCharacterWithinString");

		internal static string JsonDocumentDoesNotSupportComments => GetResourceString("JsonDocumentDoesNotSupportComments");

		internal static string JsonElementHasWrongType => GetResourceString("JsonElementHasWrongType");

		internal static string DefaultTypeInfoResolverImmutable => GetResourceString("DefaultTypeInfoResolverImmutable");

		internal static string TypeInfoResolverChainImmutable => GetResourceString("TypeInfoResolverChainImmutable");

		internal static string TypeInfoImmutable => GetResourceString("TypeInfoImmutable");

		internal static string MaxDepthMustBePositive => GetResourceString("MaxDepthMustBePositive");

		internal static string CommentHandlingMustBeValid => GetResourceString("CommentHandlingMustBeValid");

		internal static string MismatchedObjectArray => GetResourceString("MismatchedObjectArray");

		internal static string CannotWriteEndAfterProperty => GetResourceString("CannotWriteEndAfterProperty");

		internal static string ObjectDepthTooLarge => GetResourceString("ObjectDepthTooLarge");

		internal static string PropertyNameTooLarge => GetResourceString("PropertyNameTooLarge");

		internal static string FormatDecimal => GetResourceString("FormatDecimal");

		internal static string FormatDouble => GetResourceString("FormatDouble");

		internal static string FormatInt32 => GetResourceString("FormatInt32");

		internal static string FormatInt64 => GetResourceString("FormatInt64");

		internal static string FormatSingle => GetResourceString("FormatSingle");

		internal static string FormatUInt32 => GetResourceString("FormatUInt32");

		internal static string FormatUInt64 => GetResourceString("FormatUInt64");

		internal static string RequiredDigitNotFoundAfterDecimal => GetResourceString("RequiredDigitNotFoundAfterDecimal");

		internal static string RequiredDigitNotFoundAfterSign => GetResourceString("RequiredDigitNotFoundAfterSign");

		internal static string RequiredDigitNotFoundEndOfData => GetResourceString("RequiredDigitNotFoundEndOfData");

		internal static string SpecialNumberValuesNotSupported => GetResourceString("SpecialNumberValuesNotSupported");

		internal static string ValueTooLarge => GetResourceString("ValueTooLarge");

		internal static string ZeroDepthAtEnd => GetResourceString("ZeroDepthAtEnd");

		internal static string DeserializeUnableToConvertValue => GetResourceString("DeserializeUnableToConvertValue");

		internal static string DeserializeWrongType => GetResourceString("DeserializeWrongType");

		internal static string SerializationInvalidBufferSize => GetResourceString("SerializationInvalidBufferSize");

		internal static string BufferWriterAdvancedTooFar => GetResourceString("BufferWriterAdvancedTooFar");

		internal static string InvalidComparison => GetResourceString("InvalidComparison");

		internal static string UnsupportedFormat => GetResourceString("UnsupportedFormat");

		internal static string ExpectedStartOfPropertyOrValueAfterComment => GetResourceString("ExpectedStartOfPropertyOrValueAfterComment");

		internal static string TrailingCommaNotAllowedBeforeArrayEnd => GetResourceString("TrailingCommaNotAllowedBeforeArrayEnd");

		internal static string TrailingCommaNotAllowedBeforeObjectEnd => GetResourceString("TrailingCommaNotAllowedBeforeObjectEnd");

		internal static string SerializerOptionsReadOnly => GetResourceString("SerializerOptionsReadOnly");

		internal static string SerializerOptions_InvalidChainedResolver => GetResourceString("SerializerOptions_InvalidChainedResolver");

		internal static string StreamNotWritable => GetResourceString("StreamNotWritable");

		internal static string CannotWriteCommentWithEmbeddedDelimiter => GetResourceString("CannotWriteCommentWithEmbeddedDelimiter");

		internal static string SerializerPropertyNameConflict => GetResourceString("SerializerPropertyNameConflict");

		internal static string SerializerPropertyNameNull => GetResourceString("SerializerPropertyNameNull");

		internal static string SerializationDataExtensionPropertyInvalid => GetResourceString("SerializationDataExtensionPropertyInvalid");

		internal static string SerializationDuplicateTypeAttribute => GetResourceString("SerializationDuplicateTypeAttribute");

		internal static string ExtensionDataConflictsWithUnmappedMemberHandling => GetResourceString("ExtensionDataConflictsWithUnmappedMemberHandling");

		internal static string SerializationNotSupportedType => GetResourceString("SerializationNotSupportedType");

		internal static string TypeRequiresAsyncSerialization => GetResourceString("TypeRequiresAsyncSerialization");

		internal static string InvalidCharacterAtStartOfComment => GetResourceString("InvalidCharacterAtStartOfComment");

		internal static string UnexpectedEndOfDataWhileReadingComment => GetResourceString("UnexpectedEndOfDataWhileReadingComment");

		internal static string CannotSkip => GetResourceString("CannotSkip");

		internal static string NotEnoughData => GetResourceString("NotEnoughData");

		internal static string UnexpectedEndOfLineSeparator => GetResourceString("UnexpectedEndOfLineSeparator");

		internal static string JsonSerializerDoesNotSupportComments => GetResourceString("JsonSerializerDoesNotSupportComments");

		internal static string DeserializeNoConstructor => GetResourceString("DeserializeNoConstructor");

		internal static string DeserializePolymorphicInterface => GetResourceString("DeserializePolymorphicInterface");

		internal static string SerializationConverterOnAttributeNotCompatible => GetResourceString("SerializationConverterOnAttributeNotCompatible");

		internal static string SerializationConverterOnAttributeInvalid => GetResourceString("SerializationConverterOnAttributeInvalid");

		internal static string SerializationConverterRead => GetResourceString("SerializationConverterRead");

		internal static string SerializationConverterNotCompatible => GetResourceString("SerializationConverterNotCompatible");

		internal static string ResolverTypeNotCompatible => GetResourceString("ResolverTypeNotCompatible");

		internal static string ResolverTypeInfoOptionsNotCompatible => GetResourceString("ResolverTypeInfoOptionsNotCompatible");

		internal static string SerializationConverterWrite => GetResourceString("SerializationConverterWrite");

		internal static string NamingPolicyReturnNull => GetResourceString("NamingPolicyReturnNull");

		internal static string SerializationDuplicateAttribute => GetResourceString("SerializationDuplicateAttribute");

		internal static string SerializeUnableToSerialize => GetResourceString("SerializeUnableToSerialize");

		internal static string FormatByte => GetResourceString("FormatByte");

		internal static string FormatInt16 => GetResourceString("FormatInt16");

		internal static string FormatSByte => GetResourceString("FormatSByte");

		internal static string FormatUInt16 => GetResourceString("FormatUInt16");

		internal static string SerializerCycleDetected => GetResourceString("SerializerCycleDetected");

		internal static string InvalidLeadingZeroInNumber => GetResourceString("InvalidLeadingZeroInNumber");

		internal static string MetadataCannotParsePreservedObjectToImmutable => GetResourceString("MetadataCannotParsePreservedObjectToImmutable");

		internal static string MetadataDuplicateIdFound => GetResourceString("MetadataDuplicateIdFound");

		internal static string MetadataIdIsNotFirstProperty => GetResourceString("MetadataIdIsNotFirstProperty");

		internal static string MetadataInvalidReferenceToValueType => GetResourceString("MetadataInvalidReferenceToValueType");

		internal static string MetadataInvalidTokenAfterValues => GetResourceString("MetadataInvalidTokenAfterValues");

		internal static string MetadataPreservedArrayFailed => GetResourceString("MetadataPreservedArrayFailed");

		internal static string MetadataInvalidPropertyInArrayMetadata => GetResourceString("MetadataInvalidPropertyInArrayMetadata");

		internal static string MetadataStandaloneValuesProperty => GetResourceString("MetadataStandaloneValuesProperty");

		internal static string MetadataReferenceCannotContainOtherProperties => GetResourceString("MetadataReferenceCannotContainOtherProperties");

		internal static string MetadataReferenceNotFound => GetResourceString("MetadataReferenceNotFound");

		internal static string MetadataValueWasNotString => GetResourceString("MetadataValueWasNotString");

		internal static string MetadataInvalidPropertyWithLeadingDollarSign => GetResourceString("MetadataInvalidPropertyWithLeadingDollarSign");

		internal static string MetadataUnexpectedProperty => GetResourceString("MetadataUnexpectedProperty");

		internal static string UnmappedJsonProperty => GetResourceString("UnmappedJsonProperty");

		internal static string MetadataDuplicateTypeProperty => GetResourceString("MetadataDuplicateTypeProperty");

		internal static string MultipleMembersBindWithConstructorParameter => GetResourceString("MultipleMembersBindWithConstructorParameter");

		internal static string ConstructorParamIncompleteBinding => GetResourceString("ConstructorParamIncompleteBinding");

		internal static string ObjectWithParameterizedCtorRefMetadataNotSupported => GetResourceString("ObjectWithParameterizedCtorRefMetadataNotSupported");

		internal static string SerializerConverterFactoryReturnsNull => GetResourceString("SerializerConverterFactoryReturnsNull");

		internal static string SerializationNotSupportedParentType => GetResourceString("SerializationNotSupportedParentType");

		internal static string ExtensionDataCannotBindToCtorParam => GetResourceString("ExtensionDataCannotBindToCtorParam");

		internal static string BufferMaximumSizeExceeded => GetResourceString("BufferMaximumSizeExceeded");

		internal static string CannotSerializeInvalidType => GetResourceString("CannotSerializeInvalidType");

		internal static string SerializeTypeInstanceNotSupported => GetResourceString("SerializeTypeInstanceNotSupported");

		internal static string JsonIncludeOnInaccessibleProperty => GetResourceString("JsonIncludeOnInaccessibleProperty");

		internal static string CannotSerializeInvalidMember => GetResourceString("CannotSerializeInvalidMember");

		internal static string CannotPopulateCollection => GetResourceString("CannotPopulateCollection");

		internal static string ConstructorContainsNullParameterNames => GetResourceString("ConstructorContainsNullParameterNames");

		internal static string DefaultIgnoreConditionAlreadySpecified => GetResourceString("DefaultIgnoreConditionAlreadySpecified");

		internal static string DefaultIgnoreConditionInvalid => GetResourceString("DefaultIgnoreConditionInvalid");

		internal static string DictionaryKeyTypeNotSupported => GetResourceString("DictionaryKeyTypeNotSupported");

		internal static string IgnoreConditionOnValueTypeInvalid => GetResourceString("IgnoreConditionOnValueTypeInvalid");

		internal static string NumberHandlingOnPropertyInvalid => GetResourceString("NumberHandlingOnPropertyInvalid");

		internal static string ConverterCanConvertMultipleTypes => GetResourceString("ConverterCanConvertMultipleTypes");

		internal static string MetadataReferenceOfTypeCannotBeAssignedToType => GetResourceString("MetadataReferenceOfTypeCannotBeAssignedToType");

		internal static string DeserializeUnableToAssignValue => GetResourceString("DeserializeUnableToAssignValue");

		internal static string DeserializeUnableToAssignNull => GetResourceString("DeserializeUnableToAssignNull");

		internal static string SerializerConverterFactoryReturnsJsonConverterFactory => GetResourceString("SerializerConverterFactoryReturnsJsonConverterFactory");

		internal static string SerializerConverterFactoryInvalidArgument => GetResourceString("SerializerConverterFactoryInvalidArgument");

		internal static string NodeElementWrongType => GetResourceString("NodeElementWrongType");

		internal static string NodeElementCannotBeObjectOrArray => GetResourceString("NodeElementCannotBeObjectOrArray");

		internal static string NodeAlreadyHasParent => GetResourceString("NodeAlreadyHasParent");

		internal static string NodeCycleDetected => GetResourceString("NodeCycleDetected");

		internal static string NodeUnableToConvert => GetResourceString("NodeUnableToConvert");

		internal static string NodeUnableToConvertElement => GetResourceString("NodeUnableToConvertElement");

		internal static string NodeValueNotAllowed => GetResourceString("NodeValueNotAllowed");

		internal static string NodeWrongType => GetResourceString("NodeWrongType");

		internal static string NodeParentWrongType => GetResourceString("NodeParentWrongType");

		internal static string NodeDuplicateKey => GetResourceString("NodeDuplicateKey");

		internal static string SerializerContextOptionsReadOnly => GetResourceString("SerializerContextOptionsReadOnly");

		internal static string ConverterForPropertyMustBeValid => GetResourceString("ConverterForPropertyMustBeValid");

		internal static string NoMetadataForType => GetResourceString("NoMetadataForType");

		internal static string AmbiguousMetadataForType => GetResourceString("AmbiguousMetadataForType");

		internal static string CollectionIsReadOnly => GetResourceString("CollectionIsReadOnly");

		internal static string ArrayIndexNegative => GetResourceString("ArrayIndexNegative");

		internal static string ArrayTooSmall => GetResourceString("ArrayTooSmall");

		internal static string NodeJsonObjectCustomConverterNotAllowedOnExtensionProperty => GetResourceString("NodeJsonObjectCustomConverterNotAllowedOnExtensionProperty");

		internal static string NoMetadataForTypeProperties => GetResourceString("NoMetadataForTypeProperties");

		internal static string FieldCannotBeVirtual => GetResourceString("FieldCannotBeVirtual");

		internal static string MissingFSharpCoreMember => GetResourceString("MissingFSharpCoreMember");

		internal static string FSharpDiscriminatedUnionsNotSupported => GetResourceString("FSharpDiscriminatedUnionsNotSupported");

		internal static string Polymorphism_BaseConverterDoesNotSupportMetadata => GetResourceString("Polymorphism_BaseConverterDoesNotSupportMetadata");

		internal static string Polymorphism_DerivedConverterDoesNotSupportMetadata => GetResourceString("Polymorphism_DerivedConverterDoesNotSupportMetadata");

		internal static string Polymorphism_TypeDoesNotSupportPolymorphism => GetResourceString("Polymorphism_TypeDoesNotSupportPolymorphism");

		internal static string Polymorphism_DerivedTypeIsNotSupported => GetResourceString("Polymorphism_DerivedTypeIsNotSupported");

		internal static string Polymorphism_DerivedTypeIsAlreadySpecified => GetResourceString("Polymorphism_DerivedTypeIsAlreadySpecified");

		internal static string Polymorphism_TypeDicriminatorIdIsAlreadySpecified => GetResourceString("Polymorphism_TypeDicriminatorIdIsAlreadySpecified");

		internal static string Polymorphism_InvalidCustomTypeDiscriminatorPropertyName => GetResourceString("Polymorphism_InvalidCustomTypeDiscriminatorPropertyName");

		internal static string Polymorphism_ConfigurationDoesNotSpecifyDerivedTypes => GetResourceString("Polymorphism_ConfigurationDoesNotSpecifyDerivedTypes");

		internal static string Polymorphism_UnrecognizedTypeDiscriminator => GetResourceString("Polymorphism_UnrecognizedTypeDiscriminator");

		internal static string Polymorphism_RuntimeTypeNotSupported => GetResourceString("Polymorphism_RuntimeTypeNotSupported");

		internal static string Polymorphism_RuntimeTypeDiamondAmbiguity => GetResourceString("Polymorphism_RuntimeTypeDiamondAmbiguity");

		internal static string InvalidJsonTypeInfoOperationForKind => GetResourceString("InvalidJsonTypeInfoOperationForKind");

		internal static string CreateObjectConverterNotCompatible => GetResourceString("CreateObjectConverterNotCompatible");

		internal static string JsonPropertyInfoBoundToDifferentParent => GetResourceString("JsonPropertyInfoBoundToDifferentParent");

		internal static string JsonSerializerOptionsNoTypeInfoResolverSpecified => GetResourceString("JsonSerializerOptionsNoTypeInfoResolverSpecified");

		internal static string JsonSerializerIsReflectionDisabled => GetResourceString("JsonSerializerIsReflectionDisabled");

		internal static string JsonPolymorphismOptionsAssociatedWithDifferentJsonTypeInfo => GetResourceString("JsonPolymorphismOptionsAssociatedWithDifferentJsonTypeInfo");

		internal static string JsonPropertyRequiredAndNotDeserializable => GetResourceString("JsonPropertyRequiredAndNotDeserializable");

		internal static string JsonPropertyRequiredAndExtensionData => GetResourceString("JsonPropertyRequiredAndExtensionData");

		internal static string JsonRequiredPropertiesMissing => GetResourceString("JsonRequiredPropertiesMissing");

		internal static string ObjectCreationHandlingPopulateNotSupportedByConverter => GetResourceString("ObjectCreationHandlingPopulateNotSupportedByConverter");

		internal static string ObjectCreationHandlingPropertyMustHaveAGetter => GetResourceString("ObjectCreationHandlingPropertyMustHaveAGetter");

		internal static string ObjectCreationHandlingPropertyValueTypeMustHaveASetter => GetResourceString("ObjectCreationHandlingPropertyValueTypeMustHaveASetter");

		internal static string ObjectCreationHandlingPropertyCannotAllowPolymorphicDeserialization => GetResourceString("ObjectCreationHandlingPropertyCannotAllowPolymorphicDeserialization");

		internal static string ObjectCreationHandlingPropertyCannotAllowReadOnlyMember => GetResourceString("ObjectCreationHandlingPropertyCannotAllowReadOnlyMember");

		internal static string ObjectCreationHandlingPropertyCannotAllowReferenceHandling => GetResourceString("ObjectCreationHandlingPropertyCannotAllowReferenceHandling");

		internal static string ObjectCreationHandlingPropertyDoesNotSupportParameterizedConstructors => GetResourceString("ObjectCreationHandlingPropertyDoesNotSupportParameterizedConstructors");

		internal static string FormatInt128 => GetResourceString("FormatInt128");

		internal static string FormatUInt128 => GetResourceString("FormatUInt128");

		internal static string FormatHalf => GetResourceString("FormatHalf");

		internal static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

		private static string GetResourceString(string resourceKey)
		{
			if (UsingResourceKeys())
			{
				return resourceKey;
			}
			string result = null;
			try
			{
				result = ResourceManager.GetString(resourceKey);
			}
			catch (MissingManifestResourceException)
			{
			}
			return result;
		}

		private static string GetResourceString(string resourceKey, string defaultString)
		{
			string resourceString = GetResourceString(resourceKey);
			if (!(resourceKey == resourceString) && resourceString != null)
			{
				return resourceString;
			}
			return defaultString;
		}

		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);
		}

		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(IFormatProvider provider, string resourceFormat, object p1)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1);
			}
			return string.Format(provider, resourceFormat, p1);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2);
			}
			return string.Format(provider, resourceFormat, p1, p2);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
		{
			if (UsingResourceKeys())
			{
				return string.Join(", ", resourceFormat, p1, p2, p3);
			}
			return string.Format(provider, resourceFormat, p1, p2, p3);
		}

		internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
		{
			if (args != null)
			{
				if (UsingResourceKeys())
				{
					return resourceFormat + ", " + string.Join(", ", args);
				}
				return string.Format(provider, resourceFormat, args);
			}
			return resourceFormat;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	internal sealed class ObsoleteAttribute : Attribute
	{
		public string Message { get; }

		public bool IsError { get; }

		public string DiagnosticId { get; set; }

		public string UrlFormat { get; set; }

		public ObsoleteAttribute()
		{
		}

		public ObsoleteAttribute(string message)
		{
			Message = message;
		}

		public ObsoleteAttribute(string message, bool error)
		{
			Message = message;
			IsError = error;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field, AllowMultiple = true, Inherited = false)]
	internal sealed class DynamicDependencyAttribute : Attribute
	{
		public string MemberSignature { get; }

		public DynamicallyAccessedMemberTypes MemberTypes { get; }

		public Type Type { get; }

		public string TypeName { get; }

		public string AssemblyName { get; }

		public string Condition { get; set; }

		public DynamicDependencyAttribute(string memberSignature)
		{
			MemberSignature = memberSignature;
		}

		public DynamicDependencyAttribute(string memberSignature, Type type)
		{
			MemberSignature = memberSignature;
			Type = type;
		}

		public DynamicDependencyAttribute(string memberSignature, string typeName, string assemblyName)
		{
			MemberSignature = memberSignature;
			TypeName = typeName;
			AssemblyName = assemblyName;
		}

		public DynamicDependencyAttribute(DynamicallyAccessedMemberTypes memberTypes, Type type)
		{
			MemberTypes = memberTypes;
			Type = type;
		}

		public DynamicDependencyAttribute(DynamicallyAccessedMemberTypes memberTypes, string typeName, string assemblyName)
		{
			MemberTypes = memberTypes;
			TypeName = typeName;
			AssemblyName = assemblyName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
	internal sealed class DynamicallyAccessedMembersAttribute : Attribute
	{
		public DynamicallyAccessedMemberTypes MemberTypes { get; }

		public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
		{
			MemberTypes = memberTypes;
		}
	}
	[Flags]
	internal enum DynamicallyAccessedMemberTypes
	{
		None = 0,
		PublicParameterlessConstructor = 1,
		PublicConstructors = 3,
		NonPublicConstructors = 4,
		PublicMethods = 8,
		NonPublicMethods = 0x10,
		PublicFields = 0x20,
		NonPublicFields = 0x40,
		PublicNestedTypes = 0x80,
		NonPublicNestedTypes = 0x100,
		PublicProperties = 0x200,
		NonPublicProperties = 0x400,
		PublicEvents = 0x800,
		NonPublicEvents = 0x1000,
		Interfaces = 0x2000,
		All = -1
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	internal sealed class RequiresUnreferencedCodeAttribute : Attribute
	{
		public string Message { get; }

		public string Url { get; set; }

		public RequiresUnreferencedCodeAttribute(string message)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
	internal sealed class UnconditionalSuppressMessageAttribute : Attribute
	{
		public string Category { get; }

		public string CheckId { get; }

		public string Scope { get; set; }

		public string Target { get; set; }

		public string MessageId { get; set; }

		public string Justification { get; set; }

		public UnconditionalSuppressMessageAttribute(string category, string checkId)
		{
			Category = category;
			CheckId = checkId;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = Array.Empty<object>();
		}

		public StringSyntaxAttribute(string syntax, params object[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	internal sealed class RequiresDynamicCodeAttribute : Attribute
	{
		public string Message { get; }

		public string Url { get; set; }

		public RequiresDynamicCodeAttribute(string message)
		{
			Message = message;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string EntryPoint { get; set; }

		public StringMarshalling StringMarshalling { get; set; }

		public Type StringMarshallingCustomType { get; set; }

		public bool SetLastError { get; set; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string Message { get; }

		public string Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[EditorBrowsable(EditorBrowsableState.Never)]
	internal static class IsExternalInit
	{
	}
}
namespace System.Collections.Generic
{
	internal sealed class ReferenceEqualityComparer : IEqualityComparer<object>, IEqualityComparer
	{
		public static ReferenceEqualityComparer Instance { get; } = new ReferenceEqualityComparer();


		private ReferenceEqualityComparer()
		{
		}

		public new bool Equals(object x, object y)
		{
			return x == y;
		}

		public int GetHashCode(object obj)
		{
			return RuntimeHelpers.GetHashCode(obj);
		}
	}
	internal static class StackExtensions
	{
		public static bool TryPeek<T>(this Stack<T> stack, [MaybeNullWhen(false)] out T result)
		{
			if (stack.Count > 0)
			{
				result = stack.Peek();
				return true;
			}
			result = default(T);
			return false;
		}

		public static bool TryPop<T>(this Stack<T> stack, [MaybeNullWhen(false)] out T result)
		{
			if (stack.Count > 0)
			{
				result = stack.Pop();
				return true;
			}
			result = default(T);
			return false;
		}
	}
}
namespace System.Buffers
{
	internal sealed class ArrayBufferWriter<T> : IBufferWriter<T>
	{
		private const int ArrayMaxLength = 2147483591;

		private const int DefaultInitialBufferSize = 256;

		private T[] _buffer;

		private int _index;

		public ReadOnlyMemory<T> WrittenMemory => _buffer.AsMemory(0, _index);

		public ReadOnlySpan<T> WrittenSpan => _buffer.AsSpan(0, _index);

		public int WrittenCount => _index;

		public int Capacity => _buffer.Length;

		public int FreeCapacity => _buffer.Length - _index;

		public ArrayBufferWriter()
		{
			_buffer = Array.Empty<T>();
			_index = 0;
		}

		public ArrayBufferWriter(int initialCapacity)
		{
			if (initialCapacity <= 0)
			{
				throw new ArgumentException(null, "initialCapacity");
			}
			_buffer = new T[initialCapacity];
			_index = 0;
		}

		public void Clear()
		{
			_buffer.AsSpan(0, _index).Clear();
			_index = 0;
		}

		public void ResetWrittenCount()
		{
			_index = 0;
		}

		public void Advance(int count)
		{
			if (count < 0)
			{
				throw new ArgumentException(null, "count");
			}
			if (_index > _buffer.Length - count)
			{
				ThrowInvalidOperationException_AdvancedTooFar(_buffer.Length);
			}
			_index += count;
		}

		public Memory<T> GetMemory(int sizeHint = 0)
		{
			CheckAndResizeBuffer(sizeHint);
			return _buffer.AsMemory(_index);
		}

		public Span<T> GetSpan(int sizeHint = 0)
		{
			CheckAndResizeBuffer(sizeHint);
			return _buffer.AsSpan(_index);
		}

		private void CheckAndResizeBuffer(int sizeHint)
		{
			if (sizeHint < 0)
			{
				throw new ArgumentException("sizeHint");
			}
			if (sizeHint == 0)
			{
				sizeHint = 1;
			}
			if (sizeHint <= FreeCapacity)
			{
				return;
			}
			int num = _buffer.Length;
			int num2 = Math.Max(sizeHint, num);
			if (num == 0)
			{
				num2 = Math.Max(num2, 256);
			}
			int num3 = num + num2;
			if ((uint)num3 > 2147483647u)
			{
				uint num4 = (uint)(num - FreeCapacity + sizeHint);
				if (num4 > 2147483591)
				{
					ThrowOutOfMemoryException(num4);
				}
				num3 = 2147483591;
			}
			Array.Resize(ref _buffer, num3);
		}

		private static void ThrowInvalidOperationException_AdvancedTooFar(int capacity)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.BufferWriterAdvancedTooFar, capacity));
		}

		private static void ThrowOutOfMemoryException(uint capacity)
		{
			throw new OutOfMemoryException(System.SR.Format(System.SR.BufferMaximumSizeExceeded, capacity));
		}
	}
}
namespace System.Buffers.Text
{
	internal enum SequenceValidity
	{
		Empty,
		WellFormed,
		Incomplete,
		Invalid
	}
}
namespace System.Text.Json
{
	internal sealed class PooledByteBufferWriter : IBufferWriter<byte>, IDisposable
	{
		private byte[] _rentedBuffer;

		private int _index;

		private const int MinimumBufferSize = 256;

		public const int MaximumBufferSize = 2147483591;

		public ReadOnlyMemory<byte> WrittenMemory => _rentedBuffer.AsMemory(0, _index);

		public int WrittenCount => _index;

		public int Capacity => _rentedBuffer.Length;

		public int FreeCapacity => _rentedBuffer.Length - _index;

		private PooledByteBufferWriter()
		{
		}

		public PooledByteBufferWriter(int initialCapacity)
			: this()
		{
			_rentedBuffer = ArrayPool<byte>.Shared.Rent(initialCapacity);
			_index = 0;
		}

		public void Clear()
		{
			ClearHelper();
		}

		public void ClearAndReturnBuffers()
		{
			ClearHelper();
			byte[] rentedBuffer = _rentedBuffer;
			_rentedBuffer = null;
			ArrayPool<byte>.Shared.Return(rentedBuffer);
		}

		private void ClearHelper()
		{
			_rentedBuffer.AsSpan(0, _index).Clear();
			_index = 0;
		}

		public void Dispose()
		{
			if (_rentedBuffer != null)
			{
				ClearHelper();
				byte[] rentedBuffer = _rentedBuffer;
				_rentedBuffer = null;
				ArrayPool<byte>.Shared.Return(rentedBuffer);
			}
		}

		public void InitializeEmptyInstance(int initialCapacity)
		{
			_rentedBuffer = ArrayPool<byte>.Shared.Rent(initialCapacity);
			_index = 0;
		}

		public static PooledByteBufferWriter CreateEmptyInstanceForCaching()
		{
			return new PooledByteBufferWriter();
		}

		public void Advance(int count)
		{
			_index += count;
		}

		public Memory<byte> GetMemory(int sizeHint = 256)
		{
			CheckAndResizeBuffer(sizeHint);
			return _rentedBuffer.AsMemory(_index);
		}

		public Span<byte> GetSpan(int sizeHint = 256)
		{
			CheckAndResizeBuffer(sizeHint);
			return _rentedBuffer.AsSpan(_index);
		}

		internal Task WriteToStreamAsync(Stream destination, CancellationToken cancellationToken)
		{
			return destination.WriteAsync(_rentedBuffer, 0, _index, cancellationToken);
		}

		internal void WriteToStream(Stream destination)
		{
			destination.Write(_rentedBuffer, 0, _index);
		}

		private void CheckAndResizeBuffer(int sizeHint)
		{
			int num = _rentedBuffer.Length;
			int num2 = num - _index;
			if (_index >= 1073741795)
			{
				sizeHint = Math.Max(sizeHint, 2147483591 - num);
			}
			if (sizeHint <= num2)
			{
				return;
			}
			int num3 = Math.Max(sizeHint, num);
			int num4 = num + num3;
			if ((uint)num4 > 2147483591u)
			{
				num4 = num + sizeHint;
				if ((uint)num4 > 2147483591u)
				{
					ThrowHelper.ThrowOutOfMemoryException_BufferMaximumSizeExceeded((uint)num4);
				}
			}
			byte[] rentedBuffer = _rentedBuffer;
			_rentedBuffer = ArrayPool<byte>.Shared.Rent(num4);
			Span<byte> span = rentedBuffer.AsSpan(0, _index);
			span.CopyTo(_rentedBuffer);
			span.Clear();
			ArrayPool<byte>.Shared.Return(rentedBuffer);
		}
	}
	internal static class ThrowHelper
	{
		public const string ExceptionSourceValueToRethrowAsJsonException = "System.Text.Json.Rethrowable";

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowOutOfMemoryException_BufferMaximumSizeExceeded(uint capacity)
		{
			throw new OutOfMemoryException(System.SR.Format(System.SR.BufferMaximumSizeExceeded, capacity));
		}

		[DoesNotReturn]
		public static void ThrowArgumentNullException(string parameterName)
		{
			throw new ArgumentNullException(parameterName);
		}

		[DoesNotReturn]
		public static void ThrowArgumentOutOfRangeException_MaxDepthMustBePositive(string parameterName)
		{
			throw GetArgumentOutOfRangeException(parameterName, System.SR.MaxDepthMustBePositive);
		}

		private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(string parameterName, string message)
		{
			return new ArgumentOutOfRangeException(parameterName, message);
		}

		[DoesNotReturn]
		public static void ThrowArgumentOutOfRangeException_CommentEnumMustBeInRange(string parameterName)
		{
			throw GetArgumentOutOfRangeException(parameterName, System.SR.CommentHandlingMustBeValid);
		}

		[DoesNotReturn]
		public static void ThrowArgumentOutOfRangeException_ArrayIndexNegative(string paramName)
		{
			throw new ArgumentOutOfRangeException(paramName, System.SR.ArrayIndexNegative);
		}

		[DoesNotReturn]
		public static void ThrowArgumentOutOfRangeException_JsonConverterFactory_TypeNotSupported(Type typeToConvert)
		{
			throw new ArgumentOutOfRangeException("typeToConvert", System.SR.Format(System.SR.SerializerConverterFactoryInvalidArgument, typeToConvert.FullName));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_ArrayTooSmall(string paramName)
		{
			throw new ArgumentException(System.SR.ArrayTooSmall, paramName);
		}

		private static ArgumentException GetArgumentException(string message)
		{
			return new ArgumentException(message);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException(string message)
		{
			throw GetArgumentException(message);
		}

		public static InvalidOperationException GetInvalidOperationException_CallFlushFirst(int _buffered)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.CallFlushToAvoidDataLoss, _buffered));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_DestinationTooShort()
		{
			throw GetArgumentException(System.SR.DestinationTooShort);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_PropertyNameTooLarge(int tokenLength)
		{
			throw GetArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, tokenLength));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_ValueTooLarge(long tokenLength)
		{
			throw GetArgumentException(System.SR.Format(System.SR.ValueTooLarge, tokenLength));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_ValueNotSupported()
		{
			throw GetArgumentException(System.SR.SpecialNumberValuesNotSupported);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NeedLargerSpan()
		{
			throw GetInvalidOperationException(System.SR.FailedToGetLargerSpan);
		}

		[DoesNotReturn]
		public static void ThrowPropertyNameTooLargeArgumentException(int length)
		{
			throw GetArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, length));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException(ReadOnlySpan<byte> propertyName, ReadOnlySpan<byte> value)
		{
			if (propertyName.Length > 166666666)
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.ValueTooLarge, value.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowArgumentException(ReadOnlySpan<byte> propertyName, ReadOnlySpan<char> value)
		{
			if (propertyName.Length > 166666666)
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.ValueTooLarge, value.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowArgumentException(ReadOnlySpan<char> propertyName, ReadOnlySpan<byte> value)
		{
			if (propertyName.Length > 166666666)
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.ValueTooLarge, value.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowArgumentException(ReadOnlySpan<char> propertyName, ReadOnlySpan<char> value)
		{
			if (propertyName.Length > 166666666)
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.ValueTooLarge, value.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationOrArgumentException(ReadOnlySpan<byte> propertyName, int currentDepth, int maxDepth)
		{
			currentDepth &= 0x7FFFFFFF;
			if (currentDepth >= maxDepth)
			{
				ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, maxDepth));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException(int currentDepth, int maxDepth)
		{
			currentDepth &= 0x7FFFFFFF;
			ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, maxDepth));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException(string message)
		{
			throw GetInvalidOperationException(message);
		}

		private static InvalidOperationException GetInvalidOperationException(string message)
		{
			return new InvalidOperationException(message)
			{
				Source = "System.Text.Json.Rethrowable"
			};
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_DepthNonZeroOrEmptyJson(int currentDepth)
		{
			throw GetInvalidOperationException(currentDepth);
		}

		private static InvalidOperationException GetInvalidOperationException(int currentDepth)
		{
			currentDepth &= 0x7FFFFFFF;
			if (currentDepth != 0)
			{
				return GetInvalidOperationException(System.SR.Format(System.SR.ZeroDepthAtEnd, currentDepth));
			}
			return GetInvalidOperationException(System.SR.EmptyJsonIsInvalid);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationOrArgumentException(ReadOnlySpan<char> propertyName, int currentDepth, int maxDepth)
		{
			currentDepth &= 0x7FFFFFFF;
			if (currentDepth >= maxDepth)
			{
				ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, maxDepth));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedArray(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("array", tokenType);
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedObject(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("object", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("number", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedBoolean(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("boolean", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("string", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedPropertyName(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("propertyName", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedStringComparison(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException(tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedComment(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("comment", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_CannotSkipOnPartial()
		{
			throw GetInvalidOperationException(System.SR.CannotSkip);
		}

		private static InvalidOperationException GetInvalidOperationException(string message, JsonTokenType tokenType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.InvalidCast, tokenType, message));
		}

		private static InvalidOperationException GetInvalidOperationException(JsonTokenType tokenType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.InvalidComparison, tokenType));
		}

		[DoesNotReturn]
		internal static void ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
		{
			throw GetJsonElementWrongTypeException(expectedType.ToValueKind(), actualType.ToValueKind());
		}

		internal static InvalidOperationException GetJsonElementWrongTypeException(JsonValueKind expectedType, JsonValueKind actualType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.JsonElementHasWrongType, expectedType, actualType));
		}

		internal static InvalidOperationException GetJsonElementWrongTypeException(string expectedTypeName, JsonValueKind actualType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.JsonElementHasWrongType, expectedTypeName, actualType));
		}

		[DoesNotReturn]
		public static void ThrowJsonReaderException(ref Utf8JsonReader json, ExceptionResource resource, byte nextByte = 0, ReadOnlySpan<byte> bytes = default(ReadOnlySpan<byte>))
		{
			throw GetJsonReaderException(ref json, resource, nextByte, bytes);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static JsonException GetJsonReaderException(ref Utf8JsonReader json, ExceptionResource resource, byte nextByte, ReadOnlySpan<byte> bytes)
		{
			string resourceString = GetResourceString(ref json, resource, nextByte, JsonHelpers.Utf8GetString(bytes));
			long lineNumber = json.CurrentState._lineNumber;
			long bytePositionInLine = json.CurrentState._bytePositionInLine;
			resourceString += $" LineNumber: {lineNumber} | BytePositionInLine: {bytePositionInLine}.";
			return new JsonReaderException(resourceString, lineNumber, bytePositionInLine);
		}

		private static bool IsPrintable(byte value)
		{
			if (value >= 32)
			{
				return value < 127;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static string GetPrintableString(byte value)
		{
			if (!IsPrintable(value))
			{
				return $"0x{value:X2}";
			}
			char c = (char)value;
			return c.ToString();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static string GetResourceString(ref Utf8JsonReader json, ExceptionResource resource, byte nextByte, string characters)
		{
			string printableString = GetPrintableString(nextByte);
			string result = "";
			switch (resource)
			{
			case ExceptionResource.ArrayDepthTooLarge:
				result = System.SR.Format(System.SR.ArrayDepthTooLarge, json.CurrentState.Options.MaxDepth);
				break;
			case ExceptionResource.MismatchedObjectArray:
				result = System.SR.Format(System.SR.MismatchedObjectArray, printableString);
				break;
			case ExceptionResource.TrailingCommaNotAllowedBeforeArrayEnd:
				result = System.SR.TrailingCommaNotAllowedBeforeArrayEnd;
				break;
			case ExceptionResource.TrailingCommaNotAllowedBeforeObjectEnd:
				result = System.SR.TrailingCommaNotAllowedBeforeObjectEnd;
				break;
			case ExceptionResource.EndOfStringNotFound:
				result = System.SR.EndOfStringNotFound;
				break;
			case ExceptionResource.RequiredDigitNotFoundAfterSign:
				result = System.SR.Format(System.SR.RequiredDigitNotFoundAfterSign, printableString);
				break;
			case ExceptionResource.RequiredDigitNotFoundAfterDecimal:
				result = System.SR.Format(System.SR.RequiredDigitNotFoundAfterDecimal, printableString);
				break;
			case ExceptionResource.RequiredDigitNotFoundEndOfData:
				result = System.SR.RequiredDigitNotFoundEndOfData;
				break;
			case ExceptionResource.ExpectedEndAfterSingleJson:
				result = System.SR.Format(System.SR.ExpectedEndAfterSingleJson, printableString);
				break;
			case ExceptionResource.ExpectedEndOfDigitNotFound:
				result = System.SR.Format(System.SR.ExpectedEndOfDigitNotFound, printableString);
				break;
			case ExceptionResource.ExpectedNextDigitEValueNotFound:
				result = System.SR.Format(System.SR.ExpectedNextDigitEValueNotFound, printableString);
				break;
			case ExceptionResource.ExpectedSeparatorAfterPropertyNameNotFound:
				result = System.SR.Format(System.SR.ExpectedSeparatorAfterPropertyNameNotFound, printableString);
				break;
			case ExceptionResource.ExpectedStartOfPropertyNotFound:
				result = System.SR.Format(System.SR.ExpectedStartOfPropertyNotFound, printableString);
				break;
			case ExceptionResource.ExpectedStartOfPropertyOrValueNotFound:
				result = System.SR.ExpectedStartOfPropertyOrValueNotFound;
				break;
			case ExceptionResource.ExpectedStartOfPropertyOrValueAfterComment:
				result = System.SR.Format(System.SR.ExpectedStartOfPropertyOrValueAfterComment, printableString);
				break;
			case ExceptionResource.ExpectedStartOfValueNotFound:
				result = System.SR.Format(System.SR.ExpectedStartOfValueNotFound, printableString);
				break;
			case ExceptionResource.ExpectedValueAfterPropertyNameNotFound:
				result = System.SR.ExpectedValueAfterPropertyNameNotFound;
				break;
			case ExceptionResource.FoundInvalidCharacter:
				result = System.SR.Format(System.SR.FoundInvalidCharacter, printableString);
				break;
			case ExceptionResource.InvalidEndOfJsonNonPrimitive:
				result = System.SR.Format(System.SR.InvalidEndOfJsonNonPrimitive, json.TokenType);
				break;
			case ExceptionResource.ObjectDepthTooLarge:
				result = System.SR.Format(System.SR.ObjectDepthTooLarge, json.CurrentState.Options.MaxDepth);
				break;
			case ExceptionResource.ExpectedFalse:
				result = System.SR.Format(System.SR.ExpectedFalse, characters);
				break;
			case ExceptionResource.ExpectedNull:
				result = System.SR.Format(System.SR.ExpectedNull, characters);
				break;
			case ExceptionResource.ExpectedTrue:
				result = System.SR.Format(System.SR.ExpectedTrue, characters);
				break;
			case ExceptionResource.InvalidCharacterWithinString:
				result = System.SR.Format(System.SR.InvalidCharacterWithinString, printableString);
				break;
			case ExceptionResource.InvalidCharacterAfterEscapeWithinString:
				result = System.SR.Format(System.SR.InvalidCharacterAfterEscapeWithinString, printableString);
				break;
			case ExceptionResource.InvalidHexCharacterWithinString:
				result = System.SR.Format(System.SR.InvalidHexCharacterWithinString, printableString);
				break;
			case ExceptionResource.EndOfCommentNotFound:
				result = System.SR.EndOfCommentNotFound;
				break;
			case ExceptionResource.ZeroDepthAtEnd:
				result = System.SR.Format(System.SR.ZeroDepthAtEnd);
				break;
			case ExceptionResource.ExpectedJsonTokens:
				result = System.SR.ExpectedJsonTokens;
				break;
			case ExceptionResource.NotEnoughData:
				result = System.SR.NotEnoughData;
				break;
			case ExceptionResource.ExpectedOneCompleteToken:
				result = System.SR.ExpectedOneCompleteToken;
				break;
			case ExceptionResource.InvalidCharacterAtStartOfComment:
				result = System.SR.Format(System.SR.InvalidCharacterAtStartOfComment, printableString);
				break;
			case ExceptionResource.UnexpectedEndOfDataWhileReadingComment:
				result = System.SR.Format(System.SR.UnexpectedEndOfDataWhileReadingComment);
				break;
			case ExceptionResource.UnexpectedEndOfLineSeparator:
				result = System.SR.Format(System.SR.UnexpectedEndOfLineSeparator);
				break;
			case ExceptionResource.InvalidLeadingZeroInNumber:
				result = System.SR.Format(System.SR.InvalidLeadingZeroInNumber, printableString);
				break;
			}
			return result;
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException(ExceptionResource resource, int currentDepth, int maxDepth, byte token, JsonTokenType tokenType)
		{
			throw GetInvalidOperationException(resource, currentDepth, maxDepth, token, tokenType);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_InvalidCommentValue()
		{
			throw new ArgumentException(System.SR.CannotWriteCommentWithEmbeddedDelimiter);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_InvalidUTF8(ReadOnlySpan<byte> value)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = Math.Min(value.Length, 10);
			for (int i = 0; i < num; i++)
			{
				byte b = value[i];
				if (IsPrintable(b))
				{
					stringBuilder.Append((char)b);
				}
				else
				{
					stringBuilder.Append($"0x{b:X2}");
				}
			}
			if (num < value.Length)
			{
				stringBuilder.Append("...");
			}
			throw new ArgumentException(System.SR.Format(System.SR.CannotEncodeInvalidUTF8, stringBuilder));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_InvalidUTF16(int charAsInt)
		{
			throw new ArgumentException(System.SR.Format(System.SR.CannotEncodeInvalidUTF16, $"0x{charAsInt:X2}"));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ReadInvalidUTF16(int charAsInt)
		{
			throw GetInvalidOperationException(System.SR.Format(System.SR.CannotReadInvalidUTF16, $"0x{charAsInt:X2}"));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ReadIncompleteUTF16()
		{
			throw GetInvalidOperationException(System.SR.CannotReadIncompleteUTF16);
		}

		public static InvalidOperationException GetInvalidOperationException_ReadInvalidUTF8(DecoderFallbackException innerException = null)
		{
			return GetInvalidOperationException(System.SR.CannotTranscodeInvalidUtf8, innerException);
		}

		public static ArgumentException GetArgumentException_ReadInvalidUTF16(EncoderFallbackException innerException)
		{
			return new ArgumentException(System.SR.CannotTranscodeInvalidUtf16, innerException);
		}

		public static InvalidOperationException GetInvalidOperationException(string message, Exception innerException)
		{
			InvalidOperationException ex = new InvalidOperationException(message, innerException);
			ex.Source = "System.Text.Json.Rethrowable";
			return ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static InvalidOperationException GetInvalidOperationException(ExceptionResource resource, int currentDepth, int maxDepth, byte token, JsonTokenType tokenType)
		{
			string resourceString = GetResourceString(resource, currentDepth, maxDepth, token, tokenType);
			InvalidOperationException invalidOperationException = GetInvalidOperationException(resourceString);
			invalidOperationException.Source = "System.Text.Json.Rethrowable";
			return invalidOperationException;
		}

		[DoesNotReturn]
		public static void ThrowOutOfMemoryException(uint capacity)
		{
			throw new OutOfMemoryException(System.SR.Format(System.SR.BufferMaximumSizeExceeded, capacity));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static string GetResourceString(ExceptionResource resource, int currentDepth, int maxDepth, byte token, JsonTokenType tokenType)
		{
			string result = "";
			switch (resource)
			{
			case ExceptionResource.MismatchedObjectArray:
				result = ((tokenType == JsonTokenType.PropertyName) ? System.SR.Format(System.SR.CannotWriteEndAfterProperty, (char)token) : System.SR.Format(System.SR.MismatchedObjectArray, (char)token));
				break;
			case ExceptionResource.DepthTooLarge:
				result = System.SR.Format(System.SR.DepthTooLarge, currentDepth & 0x7FFFFFFF, maxDepth);
				break;
			case ExceptionResource.CannotStartObjectArrayWithoutProperty:
				result = System.SR.Format(System.SR.CannotStartObjectArrayWithoutProperty, tokenType);
				break;
			case ExceptionResource.CannotStartObjectArrayAfterPrimitiveOrClose:
				result = System.SR.Format(System.SR.CannotStartObjectArrayAfterPrimitiveOrClose, tokenType);
				break;
			case ExceptionResource.CannotWriteValueWithinObject:
				result = System.SR.Format(System.SR.CannotWriteValueWithinObject, tokenType);
				break;
			case ExceptionResource.CannotWritePropertyWithinArray:
				result = ((tokenType == JsonTokenType.PropertyName) ? System.SR.Format(System.SR.CannotWritePropertyAfterProperty) : System.SR.Format(System.SR.CannotWritePropertyWithinArray, tokenType));
				break;
			case ExceptionResource.CannotWriteValueAfterPrimitiveOrClose:
				result = System.SR.Format(System.SR.CannotWriteValueAfterPrimitiveOrClose, tokenType);
				break;
			}
			return result;
		}

		[DoesNotReturn]
		public static void ThrowFormatException()
		{
			throw new FormatException
			{
				Source = "System.Text.Json.Rethrowable"
			};
		}

		public static void ThrowFormatException(NumericType numericType)
		{
			string message = "";
			switch (numericType)
			{
			case NumericType.Byte:
				message = System.SR.FormatByte;
				break;
			case NumericType.SByte:
				message = System.SR.FormatSByte;
				break;
			case NumericType.Int16:
				message = System.SR.FormatInt16;
				break;
			case NumericType.Int32:
				message = System.SR.FormatInt32;
				break;
			case NumericType.Int64:
				message = System.SR.FormatInt64;
				break;
			case NumericType.Int128:
				message = System.SR.FormatInt128;
				break;
			case NumericType.UInt16:
				message = System.SR.FormatUInt16;
				break;
			case NumericType.UInt32:
				message = System.SR.FormatUInt32;
				break;
			case NumericType.UInt64:
				message = System.SR.FormatUInt64;
				break;
			case NumericType.UInt128:
				message = System.SR.FormatUInt128;
				break;
			case NumericType.Half:
				message = System.SR.FormatHalf;
				break;
			case NumericType.Single:
				message = System.SR.FormatSingle;
				break;
			case NumericType.Double:
				message = System.SR.FormatDouble;
				break;
			case NumericType.Decimal:
				message = System.SR.FormatDecimal;
				break;
			}
			throw new FormatException(message)
			{
				Source = "System.Text.Json.Rethrowable"
			};
		}

		[DoesNotReturn]
		public static void ThrowFormatException(DataType dataType)
		{
			string message = "";
			switch (dataType)
			{
			case DataType.Boolean:
			case DataType.DateOnly:
			case DataType.DateTime:
			case DataType.DateTimeOffset:
			case DataType.TimeOnly:
			case DataType.TimeSpan:
			case DataType.Guid:
			case DataType.Version:
				message = System.SR.Format(System.SR.UnsupportedFormat, dataType);
				break;
			case DataType.Base64String:
				message = System.SR.CannotDecodeInvalidBase64;
				break;
			}
			throw new FormatException(message)
			{
				Source = "System.Text.Json.Rethrowable"
			};
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExpectedChar(JsonTokenType tokenType)
		{
			throw GetInvalidOperationException("char", tokenType);
		}

		[DoesNotReturn]
		public static void ThrowObjectDisposedException_Utf8JsonWriter()
		{
			throw new ObjectDisposedException("Utf8JsonWriter");
		}

		[DoesNotReturn]
		public static void ThrowObjectDisposedException_JsonDocument()
		{
			throw new ObjectDisposedException("JsonDocument");
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_NodeValueNotAllowed(string paramName)
		{
			throw new ArgumentException(System.SR.NodeValueNotAllowed, paramName);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_DuplicateKey(string paramName, string propertyName)
		{
			throw new ArgumentException(System.SR.Format(System.SR.NodeDuplicateKey, propertyName), paramName);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NodeAlreadyHasParent()
		{
			throw new InvalidOperationException(System.SR.NodeAlreadyHasParent);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NodeCycleDetected()
		{
			throw new InvalidOperationException(System.SR.NodeCycleDetected);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NodeElementCannotBeObjectOrArray()
		{
			throw new InvalidOperationException(System.SR.NodeElementCannotBeObjectOrArray);
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException_CollectionIsReadOnly()
		{
			throw GetNotSupportedException_CollectionIsReadOnly();
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NodeWrongType(string typeName)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.NodeWrongType, typeName));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NodeParentWrongType(string typeName)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.NodeParentWrongType, typeName));
		}

		public static NotSupportedException GetNotSupportedException_CollectionIsReadOnly()
		{
			return new NotSupportedException(System.SR.CollectionIsReadOnly);
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_DeserializeWrongType(Type type, object value)
		{
			throw new ArgumentException(System.SR.Format(System.SR.DeserializeWrongType, type, value.GetType()));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_SerializerDoesNotSupportComments(string paramName)
		{
			throw new ArgumentException(System.SR.JsonSerializerDoesNotSupportComments, paramName);
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException_SerializationNotSupported(Type propertyType)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.SerializationNotSupportedType, propertyType));
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException_TypeRequiresAsyncSerialization(Type propertyType)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.TypeRequiresAsyncSerialization, propertyType));
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException_DictionaryKeyTypeNotSupported(Type keyType, JsonConverter converter)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.DictionaryKeyTypeNotSupported, keyType, converter.GetType()));
		}

		[DoesNotReturn]
		public static void ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
		{
			throw new JsonException(System.SR.Format(System.SR.DeserializeUnableToConvertValue, propertyType))
			{
				AppendPathInformation = true
			};
		}

		[DoesNotReturn]
		public static void ThrowInvalidCastException_DeserializeUnableToAssignValue(Type typeOfValue, Type declaredType)
		{
			throw new InvalidCastException(System.SR.Format(System.SR.DeserializeUnableToAssignValue, typeOfValue, declaredType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_DeserializeUnableToAssignNull(Type declaredType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.DeserializeUnableToAssignNull, declaredType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPopulateNotSupportedByConverter(JsonPropertyInfo propertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ObjectCreationHandlingPopulateNotSupportedByConverter, propertyInfo.Name, propertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPropertyMustHaveAGetter(JsonPropertyInfo propertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ObjectCreationHandlingPropertyMustHaveAGetter, propertyInfo.Name, propertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPropertyValueTypeMustHaveASetter(JsonPropertyInfo propertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ObjectCreationHandlingPropertyValueTypeMustHaveASetter, propertyInfo.Name, propertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPropertyCannotAllowPolymorphicDeserialization(JsonPropertyInfo propertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ObjectCreationHandlingPropertyCannotAllowPolymorphicDeserialization, propertyInfo.Name, propertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPropertyCannotAllowReadOnlyMember(JsonPropertyInfo propertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ObjectCreationHandlingPropertyCannotAllowReadOnlyMember, propertyInfo.Name, propertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ObjectCreationHandlingPropertyCannotAllowReferenceHandling()
		{
			throw new InvalidOperationException(System.SR.ObjectCreationHandlingPropertyCannotAllowReferenceHandling);
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException_ObjectCreationHandlingPropertyDoesNotSupportParameterizedConstructors()
		{
			throw new NotSupportedException(System.SR.ObjectCreationHandlingPropertyDoesNotSupportParameterizedConstructors);
		}

		[DoesNotReturn]
		public static void ThrowJsonException_SerializationConverterRead(JsonConverter converter)
		{
			throw new JsonException(System.SR.Format(System.SR.SerializationConverterRead, converter))
			{
				AppendPathInformation = true
			};
		}

		[DoesNotReturn]
		public static void ThrowJsonException_SerializationConverterWrite(JsonConverter converter)
		{
			throw new JsonException(System.SR.Format(System.SR.SerializationConverterWrite, converter))
			{
				AppendPathInformation = true
			};
		}

		[DoesNotReturn]
		public static void ThrowJsonException_SerializerCycleDetected(int maxDepth)
		{
			throw new JsonException(System.SR.Format(System.SR.SerializerCycleDetected, maxDepth))
			{
				AppendPathInformation = true
			};
		}

		[DoesNotReturn]
		public static void ThrowJsonException(string message = null)
		{
			throw new JsonException(message)
			{
				AppendPathInformation = true
			};
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_CannotSerializeInvalidType(string paramName, Type typeToConvert, Type declaringType, string propertyName)
		{
			if (declaringType == null)
			{
				throw new ArgumentException(System.SR.Format(System.SR.CannotSerializeInvalidType, typeToConvert), paramName);
			}
			throw new ArgumentException(System.SR.Format(System.SR.CannotSerializeInvalidMember, typeToConvert, propertyName, declaringType), paramName);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_CannotSerializeInvalidType(Type typeToConvert, Type declaringType, MemberInfo memberInfo)
		{
			if (declaringType == null)
			{
				throw new InvalidOperationException(System.SR.Format(System.SR.CannotSerializeInvalidType, typeToConvert));
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.CannotSerializeInvalidMember, typeToConvert, memberInfo.Name, declaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationConverterNotCompatible(Type converterType, Type type)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationConverterNotCompatible, converterType, type));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ResolverTypeNotCompatible(Type requestedType, Type actualType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ResolverTypeNotCompatible, actualType, requestedType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ResolverTypeInfoOptionsNotCompatible()
		{
			throw new InvalidOperationException(System.SR.ResolverTypeInfoOptionsNotCompatible);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_JsonSerializerOptionsNoTypeInfoResolverSpecified()
		{
			throw new InvalidOperationException(System.SR.JsonSerializerOptionsNoTypeInfoResolverSpecified);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled()
		{
			throw new InvalidOperationException(System.SR.JsonSerializerIsReflectionDisabled);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationConverterOnAttributeInvalid(Type classType, MemberInfo memberInfo)
		{
			string text = classType.ToString();
			if (memberInfo != null)
			{
				text = text + "." + memberInfo.Name;
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationConverterOnAttributeInvalid, text));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationConverterOnAttributeNotCompatible(Type classTypeAttributeIsOn, MemberInfo memberInfo, Type typeToConvert)
		{
			string text = classTypeAttributeIsOn.ToString();
			if (memberInfo != null)
			{
				text = text + "." + memberInfo.Name;
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationConverterOnAttributeNotCompatible, text, typeToConvert));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerOptionsReadOnly(JsonSerializerContext context)
		{
			string message = ((context == null) ? System.SR.SerializerOptionsReadOnly : System.SR.SerializerContextOptionsReadOnly);
			throw new InvalidOperationException(message);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_DefaultTypeInfoResolverImmutable()
		{
			throw new InvalidOperationException(System.SR.DefaultTypeInfoResolverImmutable);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_TypeInfoResolverChainImmutable()
		{
			throw new InvalidOperationException(System.SR.TypeInfoResolverChainImmutable);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_TypeInfoImmutable()
		{
			throw new InvalidOperationException(System.SR.TypeInfoImmutable);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_InvalidChainedResolver()
		{
			throw new InvalidOperationException(System.SR.SerializerOptions_InvalidChainedResolver);
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerPropertyNameConflict(Type type, string propertyName)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializerPropertyNameConflict, type, propertyName));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerPropertyNameNull(JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializerPropertyNameNull, jsonPropertyInfo.DeclaringType, jsonPropertyInfo.MemberName));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_JsonPropertyRequiredAndNotDeserializable(JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.JsonPropertyRequiredAndNotDeserializable, jsonPropertyInfo.Name, jsonPropertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_JsonPropertyRequiredAndExtensionData(JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.JsonPropertyRequiredAndExtensionData, jsonPropertyInfo.Name, jsonPropertyInfo.DeclaringType));
		}

		[DoesNotReturn]
		public static void ThrowJsonException_JsonRequiredPropertyMissing(JsonTypeInfo parent, BitArray requiredPropertiesSet)
		{
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = true;
			foreach (KeyValuePair<string, JsonPropertyInfo> item in parent.PropertyCache.List)
			{
				JsonPropertyInfo value = item.Value;
				if (value.IsRequired && !requiredPropertiesSet[value.RequiredPropertyIndex])
				{
					if (!flag)
					{
						stringBuilder.Append(CultureInfo.CurrentUICulture.TextInfo.ListSeparator);
						stringBuilder.Append(' ');
					}
					stringBuilder.Append(value.Name);
					flag = false;
					if (stringBuilder.Length >= 50)
					{
						break;
					}
				}
			}
			throw new JsonException(System.SR.Format(System.SR.JsonRequiredPropertiesMissing, parent.Type, stringBuilder.ToString()));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NamingPolicyReturnNull(JsonNamingPolicy namingPolicy)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.NamingPolicyReturnNull, namingPolicy));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerConverterFactoryReturnsNull(Type converterType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR

plugins/System.Threading.Tasks.Extensions.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading.Tasks;
using System.Threading.Tasks.Sources;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("System.Threading.Tasks.Extensions")]
[assembly: AssemblyDescription("System.Threading.Tasks.Extensions")]
[assembly: AssemblyDefaultAlias("System.Threading.Tasks.Extensions")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyFileVersion("4.6.28619.01")]
[assembly: AssemblyInformationalVersion("4.6.28619.01 @BuiltBy: dlab14-DDVSOWINAGE069 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/7601f4f6225089ffb291dc7d58293c7bbf5c5d4f")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyVersion("4.2.0.1")]
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 System
{
	internal static class ThrowHelper
	{
		internal static void ThrowArgumentNullException(System.ExceptionArgument argument)
		{
			throw GetArgumentNullException(argument);
		}

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

		private static ArgumentNullException GetArgumentNullException(System.ExceptionArgument argument)
		{
			return new ArgumentNullException(GetArgumentName(argument));
		}

		private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(System.ExceptionArgument argument)
		{
			return new ArgumentOutOfRangeException(GetArgumentName(argument));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static string GetArgumentName(System.ExceptionArgument argument)
		{
			return argument.ToString();
		}
	}
	internal enum ExceptionArgument
	{
		task,
		source,
		state
	}
}
namespace System.Threading.Tasks
{
	[StructLayout(LayoutKind.Auto)]
	[AsyncMethodBuilder(typeof(AsyncValueTaskMethodBuilder))]
	public readonly struct ValueTask : IEquatable<ValueTask>
	{
		private sealed class ValueTaskSourceAsTask : TaskCompletionSource<bool>
		{
			private static readonly Action<object> s_completionAction = delegate(object state)
			{
				IValueTaskSource source;
				if (!(state is ValueTaskSourceAsTask valueTaskSourceAsTask) || (source = valueTaskSourceAsTask._source) == null)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.state);
					return;
				}
				valueTaskSourceAsTask._source = null;
				ValueTaskSourceStatus status = source.GetStatus(valueTaskSourceAsTask._token);
				try
				{
					source.GetResult(valueTaskSourceAsTask._token);
					valueTaskSourceAsTask.TrySetResult(result: false);
				}
				catch (Exception exception)
				{
					if (status == ValueTaskSourceStatus.Canceled)
					{
						valueTaskSourceAsTask.TrySetCanceled();
					}
					else
					{
						valueTaskSourceAsTask.TrySetException(exception);
					}
				}
			};

			private IValueTaskSource _source;

			private readonly short _token;

			public ValueTaskSourceAsTask(IValueTaskSource source, short token)
			{
				_token = token;
				_source = source;
				source.OnCompleted(s_completionAction, this, token, ValueTaskSourceOnCompletedFlags.None);
			}
		}

		private static readonly Task s_canceledTask = Task.Delay(-1, new CancellationToken(canceled: true));

		internal readonly object _obj;

		internal readonly short _token;

		internal readonly bool _continueOnCapturedContext;

		internal static Task CompletedTask { get; } = Task.Delay(0);


		public bool IsCompleted
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return true;
				}
				if (obj is Task task)
				{
					return task.IsCompleted;
				}
				return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) != ValueTaskSourceStatus.Pending;
			}
		}

		public bool IsCompletedSuccessfully
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return true;
				}
				if (obj is Task task)
				{
					return task.Status == TaskStatus.RanToCompletion;
				}
				return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Succeeded;
			}
		}

		public bool IsFaulted
		{
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return false;
				}
				if (obj is Task task)
				{
					return task.IsFaulted;
				}
				return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Faulted;
			}
		}

		public bool IsCanceled
		{
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return false;
				}
				if (obj is Task task)
				{
					return task.IsCanceled;
				}
				return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Canceled;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTask(Task task)
		{
			if (task == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.task);
			}
			_obj = task;
			_continueOnCapturedContext = true;
			_token = 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTask(IValueTaskSource source, short token)
		{
			if (source == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.source);
			}
			_obj = source;
			_token = token;
			_continueOnCapturedContext = true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private ValueTask(object obj, short token, bool continueOnCapturedContext)
		{
			_obj = obj;
			_token = token;
			_continueOnCapturedContext = continueOnCapturedContext;
		}

		public override int GetHashCode()
		{
			return _obj?.GetHashCode() ?? 0;
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTask)
			{
				return Equals((ValueTask)obj);
			}
			return false;
		}

		public bool Equals(ValueTask other)
		{
			if (_obj == other._obj)
			{
				return _token == other._token;
			}
			return false;
		}

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

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

		public Task AsTask()
		{
			object obj = _obj;
			object obj2;
			if (obj != null)
			{
				obj2 = obj as Task;
				if (obj2 == null)
				{
					return GetTaskForValueTaskSource(Unsafe.As<IValueTaskSource>(obj));
				}
			}
			else
			{
				obj2 = CompletedTask;
			}
			return (Task)obj2;
		}

		public ValueTask Preserve()
		{
			if (_obj != null)
			{
				return new ValueTask(AsTask());
			}
			return this;
		}

		private Task GetTaskForValueTaskSource(IValueTaskSource t)
		{
			ValueTaskSourceStatus status = t.GetStatus(_token);
			if (status != 0)
			{
				try
				{
					t.GetResult(_token);
					return CompletedTask;
				}
				catch (Exception exception)
				{
					if (status == ValueTaskSourceStatus.Canceled)
					{
						return s_canceledTask;
					}
					TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
					taskCompletionSource.TrySetException(exception);
					return taskCompletionSource.Task;
				}
			}
			ValueTaskSourceAsTask valueTaskSourceAsTask = new ValueTaskSourceAsTask(t, _token);
			return valueTaskSourceAsTask.Task;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[StackTraceHidden]
		internal void ThrowIfCompletedUnsuccessfully()
		{
			object obj = _obj;
			if (obj != null)
			{
				if (obj is Task task)
				{
					task.GetAwaiter().GetResult();
				}
				else
				{
					Unsafe.As<IValueTaskSource>(obj).GetResult(_token);
				}
			}
		}

		public ValueTaskAwaiter GetAwaiter()
		{
			return new ValueTaskAwaiter(this);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
		{
			return new ConfiguredValueTaskAwaitable(new ValueTask(_obj, _token, continueOnCapturedContext));
		}
	}
	[StructLayout(LayoutKind.Auto)]
	[AsyncMethodBuilder(typeof(AsyncValueTaskMethodBuilder<>))]
	public readonly struct ValueTask<TResult> : IEquatable<ValueTask<TResult>>
	{
		private sealed class ValueTaskSourceAsTask : TaskCompletionSource<TResult>
		{
			private static readonly Action<object> s_completionAction = delegate(object state)
			{
				IValueTaskSource<TResult> source;
				if (!(state is ValueTaskSourceAsTask valueTaskSourceAsTask) || (source = valueTaskSourceAsTask._source) == null)
				{
					System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.state);
					return;
				}
				valueTaskSourceAsTask._source = null;
				ValueTaskSourceStatus status = source.GetStatus(valueTaskSourceAsTask._token);
				try
				{
					valueTaskSourceAsTask.TrySetResult(source.GetResult(valueTaskSourceAsTask._token));
				}
				catch (Exception exception)
				{
					if (status == ValueTaskSourceStatus.Canceled)
					{
						valueTaskSourceAsTask.TrySetCanceled();
					}
					else
					{
						valueTaskSourceAsTask.TrySetException(exception);
					}
				}
			};

			private IValueTaskSource<TResult> _source;

			private readonly short _token;

			public ValueTaskSourceAsTask(IValueTaskSource<TResult> source, short token)
			{
				_source = source;
				_token = token;
				source.OnCompleted(s_completionAction, this, token, ValueTaskSourceOnCompletedFlags.None);
			}
		}

		private static Task<TResult> s_canceledTask;

		internal readonly object _obj;

		internal readonly TResult _result;

		internal readonly short _token;

		internal readonly bool _continueOnCapturedContext;

		public bool IsCompleted
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return true;
				}
				if (obj is Task<TResult> task)
				{
					return task.IsCompleted;
				}
				return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) != ValueTaskSourceStatus.Pending;
			}
		}

		public bool IsCompletedSuccessfully
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return true;
				}
				if (obj is Task<TResult> task)
				{
					return task.Status == TaskStatus.RanToCompletion;
				}
				return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Succeeded;
			}
		}

		public bool IsFaulted
		{
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return false;
				}
				if (obj is Task<TResult> task)
				{
					return task.IsFaulted;
				}
				return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Faulted;
			}
		}

		public bool IsCanceled
		{
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return false;
				}
				if (obj is Task<TResult> task)
				{
					return task.IsCanceled;
				}
				return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Canceled;
			}
		}

		public TResult Result
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				object obj = _obj;
				if (obj == null)
				{
					return _result;
				}
				if (obj is Task<TResult> task)
				{
					return task.GetAwaiter().GetResult();
				}
				return Unsafe.As<IValueTaskSource<TResult>>(obj).GetResult(_token);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTask(TResult result)
		{
			_result = result;
			_obj = null;
			_continueOnCapturedContext = true;
			_token = 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTask(Task<TResult> task)
		{
			if (task == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.task);
			}
			_obj = task;
			_result = default(TResult);
			_continueOnCapturedContext = true;
			_token = 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTask(IValueTaskSource<TResult> source, short token)
		{
			if (source == null)
			{
				System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.source);
			}
			_obj = source;
			_token = token;
			_result = default(TResult);
			_continueOnCapturedContext = true;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private ValueTask(object obj, TResult result, short token, bool continueOnCapturedContext)
		{
			_obj = obj;
			_result = result;
			_token = token;
			_continueOnCapturedContext = continueOnCapturedContext;
		}

		public override int GetHashCode()
		{
			if (_obj == null)
			{
				if (_result == null)
				{
					return 0;
				}
				return _result.GetHashCode();
			}
			return _obj.GetHashCode();
		}

		public override bool Equals(object obj)
		{
			if (obj is ValueTask<TResult>)
			{
				return Equals((ValueTask<TResult>)obj);
			}
			return false;
		}

		public bool Equals(ValueTask<TResult> other)
		{
			if (_obj == null && other._obj == null)
			{
				return EqualityComparer<TResult>.Default.Equals(_result, other._result);
			}
			if (_obj == other._obj)
			{
				return _token == other._token;
			}
			return false;
		}

		public static bool operator ==(ValueTask<TResult> left, ValueTask<TResult> right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(ValueTask<TResult> left, ValueTask<TResult> right)
		{
			return !left.Equals(right);
		}

		public Task<TResult> AsTask()
		{
			object obj = _obj;
			if (obj == null)
			{
				return Task.FromResult(_result);
			}
			if (obj is Task<TResult> result)
			{
				return result;
			}
			return GetTaskForValueTaskSource(Unsafe.As<IValueTaskSource<TResult>>(obj));
		}

		public ValueTask<TResult> Preserve()
		{
			if (_obj != null)
			{
				return new ValueTask<TResult>(AsTask());
			}
			return this;
		}

		private Task<TResult> GetTaskForValueTaskSource(IValueTaskSource<TResult> t)
		{
			ValueTaskSourceStatus status = t.GetStatus(_token);
			if (status != 0)
			{
				try
				{
					return Task.FromResult(t.GetResult(_token));
				}
				catch (Exception exception)
				{
					if (status == ValueTaskSourceStatus.Canceled)
					{
						Task<TResult> task = s_canceledTask;
						if (task == null)
						{
							TaskCompletionSource<TResult> taskCompletionSource = new TaskCompletionSource<TResult>();
							taskCompletionSource.TrySetCanceled();
							task = (s_canceledTask = taskCompletionSource.Task);
						}
						return task;
					}
					TaskCompletionSource<TResult> taskCompletionSource2 = new TaskCompletionSource<TResult>();
					taskCompletionSource2.TrySetException(exception);
					return taskCompletionSource2.Task;
				}
			}
			ValueTaskSourceAsTask valueTaskSourceAsTask = new ValueTaskSourceAsTask(t, _token);
			return valueTaskSourceAsTask.Task;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ValueTaskAwaiter<TResult> GetAwaiter()
		{
			return new ValueTaskAwaiter<TResult>(this);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext)
		{
			return new ConfiguredValueTaskAwaitable<TResult>(new ValueTask<TResult>(_obj, _result, _token, continueOnCapturedContext));
		}

		public override string ToString()
		{
			if (IsCompletedSuccessfully)
			{
				TResult result = Result;
				if (result != null)
				{
					return result.ToString();
				}
			}
			return string.Empty;
		}
	}
}
namespace System.Threading.Tasks.Sources
{
	[Flags]
	public enum ValueTaskSourceOnCompletedFlags
	{
		None = 0,
		UseSchedulingContext = 1,
		FlowExecutionContext = 2
	}
	public enum ValueTaskSourceStatus
	{
		Pending,
		Succeeded,
		Faulted,
		Canceled
	}
	public interface IValueTaskSource
	{
		ValueTaskSourceStatus GetStatus(short token);

		void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags);

		void GetResult(short token);
	}
	public interface IValueTaskSource<out TResult>
	{
		ValueTaskSourceStatus GetStatus(short token);

		void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags);

		TResult GetResult(short token);
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false, AllowMultiple = false)]
	public sealed class AsyncMethodBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public AsyncMethodBuilderAttribute(Type builderType)
		{
			BuilderType = builderType;
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct AsyncValueTaskMethodBuilder
	{
		private AsyncTaskMethodBuilder _methodBuilder;

		private bool _haveResult;

		private bool _useBuilder;

		public ValueTask Task
		{
			get
			{
				if (_haveResult)
				{
					return default(ValueTask);
				}
				_useBuilder = true;
				return new ValueTask(_methodBuilder.Task);
			}
		}

		public static AsyncValueTaskMethodBuilder Create()
		{
			return default(AsyncValueTaskMethodBuilder);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
		{
			_methodBuilder.Start(ref stateMachine);
		}

		public void SetStateMachine(IAsyncStateMachine stateMachine)
		{
			_methodBuilder.SetStateMachine(stateMachine);
		}

		public void SetResult()
		{
			if (_useBuilder)
			{
				_methodBuilder.SetResult();
			}
			else
			{
				_haveResult = true;
			}
		}

		public void SetException(Exception exception)
		{
			_methodBuilder.SetException(exception);
		}

		public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_useBuilder = true;
			_methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine);
		}

		[SecuritySafeCritical]
		public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_useBuilder = true;
			_methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public struct AsyncValueTaskMethodBuilder<TResult>
	{
		private AsyncTaskMethodBuilder<TResult> _methodBuilder;

		private TResult _result;

		private bool _haveResult;

		private bool _useBuilder;

		public ValueTask<TResult> Task
		{
			get
			{
				if (_haveResult)
				{
					return new ValueTask<TResult>(_result);
				}
				_useBuilder = true;
				return new ValueTask<TResult>(_methodBuilder.Task);
			}
		}

		public static AsyncValueTaskMethodBuilder<TResult> Create()
		{
			return default(AsyncValueTaskMethodBuilder<TResult>);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
		{
			_methodBuilder.Start(ref stateMachine);
		}

		public void SetStateMachine(IAsyncStateMachine stateMachine)
		{
			_methodBuilder.SetStateMachine(stateMachine);
		}

		public void SetResult(TResult result)
		{
			if (_useBuilder)
			{
				_methodBuilder.SetResult(result);
				return;
			}
			_result = result;
			_haveResult = true;
		}

		public void SetException(Exception exception)
		{
			_methodBuilder.SetException(exception);
		}

		public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_useBuilder = true;
			_methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine);
		}

		[SecuritySafeCritical]
		public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_useBuilder = true;
			_methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public readonly struct ConfiguredValueTaskAwaitable
	{
		[StructLayout(LayoutKind.Auto)]
		public readonly struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
		{
			private readonly ValueTask _value;

			public bool IsCompleted
			{
				[MethodImpl(MethodImplOptions.AggressiveInlining)]
				get
				{
					return _value.IsCompleted;
				}
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			internal ConfiguredValueTaskAwaiter(ValueTask value)
			{
				_value = value;
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			[StackTraceHidden]
			public void GetResult()
			{
				_value.ThrowIfCompletedUnsuccessfully();
			}

			public void OnCompleted(Action continuation)
			{
				object obj = _value._obj;
				if (obj is Task task)
				{
					task.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
				}
				else if (obj != null)
				{
					Unsafe.As<IValueTaskSource>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.FlowExecutionContext | (_value._continueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None));
				}
				else
				{
					ValueTask.CompletedTask.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
				}
			}

			public void UnsafeOnCompleted(Action continuation)
			{
				object obj = _value._obj;
				if (obj is Task task)
				{
					task.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
				}
				else if (obj != null)
				{
					Unsafe.As<IValueTaskSource>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, _value._continueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
				}
				else
				{
					ValueTask.CompletedTask.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
				}
			}
		}

		private readonly ValueTask _value;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ConfiguredValueTaskAwaitable(ValueTask value)
		{
			_value = value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ConfiguredValueTaskAwaiter GetAwaiter()
		{
			return new ConfiguredValueTaskAwaiter(_value);
		}
	}
	[StructLayout(LayoutKind.Auto)]
	public readonly struct ConfiguredValueTaskAwaitable<TResult>
	{
		[StructLayout(LayoutKind.Auto)]
		public readonly struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
		{
			private readonly ValueTask<TResult> _value;

			public bool IsCompleted
			{
				[MethodImpl(MethodImplOptions.AggressiveInlining)]
				get
				{
					return _value.IsCompleted;
				}
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			internal ConfiguredValueTaskAwaiter(ValueTask<TResult> value)
			{
				_value = value;
			}

			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			[StackTraceHidden]
			public TResult GetResult()
			{
				return _value.Result;
			}

			public void OnCompleted(Action continuation)
			{
				object obj = _value._obj;
				if (obj is Task<TResult> task)
				{
					task.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
				}
				else if (obj != null)
				{
					Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.FlowExecutionContext | (_value._continueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None));
				}
				else
				{
					ValueTask.CompletedTask.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
				}
			}

			public void UnsafeOnCompleted(Action continuation)
			{
				object obj = _value._obj;
				if (obj is Task<TResult> task)
				{
					task.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
				}
				else if (obj != null)
				{
					Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, _value._continueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
				}
				else
				{
					ValueTask.CompletedTask.ConfigureAwait(_value._continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
				}
			}
		}

		private readonly ValueTask<TResult> _value;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ConfiguredValueTaskAwaitable(ValueTask<TResult> value)
		{
			_value = value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public ConfiguredValueTaskAwaiter GetAwaiter()
		{
			return new ConfiguredValueTaskAwaiter(_value);
		}
	}
	public readonly struct ValueTaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
	{
		internal static readonly Action<object> s_invokeActionDelegate = delegate(object state)
		{
			if (!(state is Action action))
			{
				System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.state);
			}
			else
			{
				action();
			}
		};

		private readonly ValueTask _value;

		public bool IsCompleted
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return _value.IsCompleted;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ValueTaskAwaiter(ValueTask value)
		{
			_value = value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[StackTraceHidden]
		public void GetResult()
		{
			_value.ThrowIfCompletedUnsuccessfully();
		}

		public void OnCompleted(Action continuation)
		{
			object obj = _value._obj;
			if (obj is Task task)
			{
				task.GetAwaiter().OnCompleted(continuation);
			}
			else if (obj != null)
			{
				Unsafe.As<IValueTaskSource>(obj).OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext);
			}
			else
			{
				ValueTask.CompletedTask.GetAwaiter().OnCompleted(continuation);
			}
		}

		public void UnsafeOnCompleted(Action continuation)
		{
			object obj = _value._obj;
			if (obj is Task task)
			{
				task.GetAwaiter().UnsafeOnCompleted(continuation);
			}
			else if (obj != null)
			{
				Unsafe.As<IValueTaskSource>(obj).OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
			}
			else
			{
				ValueTask.CompletedTask.GetAwaiter().UnsafeOnCompleted(continuation);
			}
		}
	}
	public readonly struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion, INotifyCompletion
	{
		private readonly ValueTask<TResult> _value;

		public bool IsCompleted
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return _value.IsCompleted;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal ValueTaskAwaiter(ValueTask<TResult> value)
		{
			_value = value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[StackTraceHidden]
		public TResult GetResult()
		{
			return _value.Result;
		}

		public void OnCompleted(Action continuation)
		{
			object obj = _value._obj;
			if (obj is Task<TResult> task)
			{
				task.GetAwaiter().OnCompleted(continuation);
			}
			else if (obj != null)
			{
				Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext);
			}
			else
			{
				ValueTask.CompletedTask.GetAwaiter().OnCompleted(continuation);
			}
		}

		public void UnsafeOnCompleted(Action continuation)
		{
			object obj = _value._obj;
			if (obj is Task<TResult> task)
			{
				task.GetAwaiter().UnsafeOnCompleted(continuation);
			}
			else if (obj != null)
			{
				Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
			}
			else
			{
				ValueTask.CompletedTask.GetAwaiter().UnsafeOnCompleted(continuation);
			}
		}
	}
	[AttributeUsage(AttributeTargets.All)]
	internal class __BlockReflectionAttribute : Attribute
	{
	}
}
namespace System.Diagnostics
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)]
	internal sealed class StackTraceHiddenAttribute : Attribute
	{
	}
}

plugins/YoutubeExplode.Converter.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using CliWrap;
using CliWrap.Builders;
using CliWrap.Exceptions;
using Microsoft.CodeAnalysis;
using YoutubeExplode.Converter.Utils;
using YoutubeExplode.Converter.Utils.Extensions;
using YoutubeExplode.Videos;
using YoutubeExplode.Videos.ClosedCaptions;
using YoutubeExplode.Videos.Streams;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tyrrrz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (C) Oleksii Holub")]
[assembly: AssemblyDescription("Extension for YoutubeExplode that provides an interface to download and convert videos using FFmpeg")]
[assembly: AssemblyFileVersion("6.3.10.0")]
[assembly: AssemblyInformationalVersion("6.3.10+33e10ddb84c87d67a07d993a3554ec0e08f2b681")]
[assembly: AssemblyProduct("YoutubeExplode.Converter")]
[assembly: AssemblyTitle("YoutubeExplode.Converter")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Tyrrrz/YoutubeExplode")]
[assembly: AssemblyVersion("6.3.10.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class PolyfillExtensions
{
	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			HttpResponseMessage obj = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			obj.EnsureSuccessStatusCode();
			return await ReadAsStreamAsync(obj.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStreamAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsByteArrayAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetByteArrayAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsStringAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStringAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<Stream> ReadAsStreamAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStreamAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> ReadAsByteArrayAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> ReadAsStringAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default(CancellationToken))
	{
		TaskCompletionSource<object?> tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
		try
		{
			process.EnableRaisingEvents = true;
		}
		catch when (process.HasExited)
		{
			return;
		}
		process.Exited += HandleExited;
		try
		{
			using (cancellationToken.Register(delegate
			{
				tcs.TrySetCanceled(cancellationToken);
			}))
			{
				await tcs.Task;
			}
		}
		finally
		{
			process.Exited -= HandleExited;
		}
		void HandleExited(object? sender, EventArgs args)
		{
			tcs.TrySetResult(null);
		}
	}

	public static bool IsAssignableTo(this Type type, Type? otherType)
	{
		return otherType?.IsAssignableFrom(type) ?? false;
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
	}

	public static async Task WaitAsync(this Task task, CancellationToken cancellationToken)
	{
		await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout)
	{
		await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
		return task.Result;
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, CancellationToken cancellationToken)
	{
		return await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout)
	{
		return await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer, i, Math.Min(minimumBytes, buffer.Length - i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, byte[] buffer, int offset, int count)
	{
		int num;
		for (int i = 0; i < count; i += num)
		{
			num = stream.Read(buffer, offset + i, count - i);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static void ReadExactly(this Stream stream, byte[] buffer)
	{
		stream.ReadExactly(buffer, 0, buffer.Length);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, totalBytesRead, Math.Min(minimumBytes, buffer.Length - totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
	{
		int num;
		for (int totalBytesRead = 0; totalBytesRead < count; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, offset + totalBytesRead, count - totalBytesRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		await stream.ReadExactlyAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer.Slice(i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, Span<byte> buffer)
	{
		byte[] array = buffer.ToArray();
		stream.ReadExactly(array, 0, array.Length);
		array.CopyTo(buffer);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer.Slice(totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		byte[] bufferArray = buffer.ToArray();
		await stream.ReadExactlyAsync(bufferArray, 0, bufferArray.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		bufferArray.CopyTo(buffer);
	}

	private static void KillProcessTree(int processId)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		ManagementObjectSearcher val = new ManagementObjectSearcher($"SELECT * FROM Win32_Process WHERE ParentProcessID={processId}");
		try
		{
			ManagementObjectCollection val2 = val.Get();
			try
			{
				try
				{
					using Process process = Process.GetProcessById(processId);
					if (!process.HasExited)
					{
						process.Kill();
					}
				}
				catch
				{
				}
				foreach (ManagementObject item in ((IEnumerable)val2).Cast<ManagementObject>())
				{
					KillProcessTree(Convert.ToInt32(((ManagementBaseObject)item)["ProcessID"]));
				}
			}
			finally
			{
				((IDisposable)val2)?.Dispose();
			}
		}
		finally
		{
			((IDisposable)val)?.Dispose();
		}
	}

	public static void Kill(this Process process, bool entireProcessTree)
	{
		if (!entireProcessTree)
		{
			process.Kill();
		}
		else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
		{
			process.Kill();
		}
		else
		{
			KillProcessTree(process.Id);
		}
	}
}
namespace YoutubeExplode.Converter
{
	public static class ConversionExtensions
	{
		[Obsolete("Use the Container.IsAudioOnly property instead.")]
		[ExcludeFromCodeCoverage]
		public static bool IsAudioOnly(this Container container)
		{
			return ((Container)(ref container)).IsAudioOnly;
		}

		private static async IAsyncEnumerable<IStreamInfo> GetOptimalStreamInfosAsync(this VideoClient videoClient, VideoId videoId, Container container, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_000f: 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_0016: 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)
			StreamManifest streamManifest = await videoClient.Streams.GetManifestAsync(videoId, cancellationToken);
			if (!streamManifest.GetAudioOnlyStreams().Any() || !streamManifest.GetVideoOnlyStreams().Any())
			{
				yield return (from s in streamManifest.GetMuxedStreams()
					orderby s.VideoQuality descending, s.Container == container descending
					select s).First();
				yield break;
			}
			yield return (from s in streamManifest.GetAudioOnlyStreams()
				orderby s.Container == container descending, s.Bitrate descending
				select s).First();
			if (!((Container)(ref container)).IsAudioOnly)
			{
				yield return (from s in streamManifest.GetVideoOnlyStreams()
					orderby s.VideoQuality descending, s.Container == container descending
					select s).First();
			}
		}

		public static async ValueTask DownloadAsync(this VideoClient videoClient, IReadOnlyList<IStreamInfo> streamInfos, IReadOnlyList<ClosedCaptionTrackInfo> closedCaptionTrackInfos, ConversionRequest request, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			FFmpeg ffmpeg = new FFmpeg(request.FFmpegCliFilePath);
			await new Converter(videoClient, ffmpeg, request.Preset).ProcessAsync(request.OutputFilePath, request.Container, streamInfos, closedCaptionTrackInfos, progress, cancellationToken);
		}

		public static async ValueTask DownloadAsync(this VideoClient videoClient, IReadOnlyList<IStreamInfo> streamInfos, ConversionRequest request, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			await videoClient.DownloadAsync(streamInfos, Array.Empty<ClosedCaptionTrackInfo>(), request, progress, cancellationToken);
		}

		public static async ValueTask DownloadAsync(this VideoClient videoClient, VideoId videoId, ConversionRequest request, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_0016: 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)
			await videoClient.DownloadAsync((IReadOnlyList<IStreamInfo>)(await videoClient.GetOptimalStreamInfosAsync(videoId, request.Container, cancellationToken)), request, progress, cancellationToken);
		}

		public static async ValueTask DownloadAsync(this VideoClient videoClient, VideoId videoId, string outputFilePath, Action<ConversionRequestBuilder> configure, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_0016: 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)
			ConversionRequestBuilder conversionRequestBuilder = new ConversionRequestBuilder(outputFilePath);
			configure(conversionRequestBuilder);
			ConversionRequest request = conversionRequestBuilder.Build();
			await videoClient.DownloadAsync(videoId, request, progress, cancellationToken);
		}

		public static async ValueTask DownloadAsync(this VideoClient videoClient, VideoId videoId, string outputFilePath, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_0016: 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)
			await videoClient.DownloadAsync(videoId, outputFilePath, delegate
			{
			}, progress, cancellationToken);
		}
	}
	[Obsolete("Use YoutubeExplode.Videos.Streams.Container instead")]
	[ExcludeFromCodeCoverage]
	public readonly struct ConversionFormat
	{
		public string Name { get; }

		public bool IsAudioOnly => ConversionExtensions.IsAudioOnly(new Container(Name));

		public ConversionFormat(string name)
		{
			Name = name;
		}

		public override string ToString()
		{
			return Name;
		}
	}
	public enum ConversionPreset
	{
		VerySlow = -2,
		Slow,
		Medium,
		Fast,
		VeryFast,
		UltraFast
	}
	public class ConversionRequest
	{
		public string FFmpegCliFilePath { get; }

		public string OutputFilePath { get; }

		public Container Container { get; }

		[Obsolete("Use the Container property instead.")]
		[ExcludeFromCodeCoverage]
		public ConversionFormat Format
		{
			get
			{
				//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)
				Container container = Container;
				return new ConversionFormat(((Container)(ref container)).Name);
			}
		}

		public ConversionPreset Preset { get; }

		public ConversionRequest(string ffmpegCliFilePath, string outputFilePath, Container container, ConversionPreset preset)
		{
			//IL_0015: 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)
			FFmpegCliFilePath = ffmpegCliFilePath;
			OutputFilePath = outputFilePath;
			Container = container;
			Preset = preset;
		}

		[Obsolete("Use the other constructor overload")]
		[ExcludeFromCodeCoverage]
		public ConversionRequest(string ffmpegCliFilePath, string outputFilePath, ConversionFormat format, ConversionPreset preset)
			: this(ffmpegCliFilePath, outputFilePath, new Container(format.Name), preset)
		{
		}//IL_000a: Unknown result type (might be due to invalid IL or missing references)

	}
	public class ConversionRequestBuilder
	{
		private readonly string _outputFilePath;

		private string? _ffmpegCliFilePath;

		private Container? _container;

		private ConversionPreset _preset;

		public ConversionRequestBuilder(string outputFilePath)
		{
			_outputFilePath = outputFilePath;
		}

		private Container GetDefaultContainer()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Container(Path.GetExtension(_outputFilePath).TrimStart('.').NullIfWhiteSpace() ?? "mp4");
		}

		public ConversionRequestBuilder SetFFmpegPath(string path)
		{
			_ffmpegCliFilePath = path;
			return this;
		}

		public ConversionRequestBuilder SetContainer(Container container)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			_container = container;
			return this;
		}

		public ConversionRequestBuilder SetContainer(string container)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return SetContainer(new Container(container));
		}

		[Obsolete("Use SetContainer instead.")]
		[ExcludeFromCodeCoverage]
		public ConversionRequestBuilder SetFormat(ConversionFormat format)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return SetContainer(new Container(format.Name));
		}

		[Obsolete("Use SetContainer instead.")]
		[ExcludeFromCodeCoverage]
		public ConversionRequestBuilder SetFormat(string format)
		{
			return SetContainer(format);
		}

		public ConversionRequestBuilder SetPreset(ConversionPreset preset)
		{
			_preset = preset;
			return this;
		}

		public ConversionRequest Build()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			return new ConversionRequest(_ffmpegCliFilePath ?? FFmpeg.GetFilePath(), _outputFilePath, (Container)(((??)_container) ?? GetDefaultContainer()), _preset);
		}
	}
	internal class Converter
	{
		private class StreamInput : IDisposable
		{
			public IStreamInfo Info { get; }

			public string FilePath { get; }

			public StreamInput(IStreamInfo info, string filePath)
			{
				Info = info;
				FilePath = filePath;
				base..ctor();
			}

			public void Dispose()
			{
				try
				{
					File.Delete(FilePath);
				}
				catch
				{
				}
			}
		}

		private class SubtitleInput : IDisposable
		{
			public ClosedCaptionTrackInfo Info { get; }

			public string FilePath { get; }

			public SubtitleInput(ClosedCaptionTrackInfo info, string filePath)
			{
				Info = info;
				FilePath = filePath;
				base..ctor();
			}

			public void Dispose()
			{
				try
				{
					File.Delete(FilePath);
				}
				catch
				{
				}
			}
		}

		[CompilerGenerated]
		private VideoClient <videoClient>P;

		[CompilerGenerated]
		private FFmpeg <ffmpeg>P;

		[CompilerGenerated]
		private ConversionPreset <preset>P;

		public Converter(VideoClient videoClient, FFmpeg ffmpeg, ConversionPreset preset)
		{
			<videoClient>P = videoClient;
			<ffmpeg>P = ffmpeg;
			<preset>P = preset;
			base..ctor();
		}

		private async ValueTask ProcessAsync(string filePath, Container container, IReadOnlyList<StreamInput> streamInputs, IReadOnlyList<SubtitleInput> subtitleInputs, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_001e: 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)
			ArgumentsBuilder val = new ArgumentsBuilder();
			foreach (StreamInput streamInput in streamInputs)
			{
				val.Add("-i").Add(streamInput.FilePath);
			}
			foreach (SubtitleInput subtitleInput in subtitleInputs)
			{
				val.Add("-fix_sub_duration").Add("-i").Add(subtitleInput.FilePath);
			}
			for (int i = 0; i < streamInputs.Count + subtitleInputs.Count; i++)
			{
				val.Add("-map").Add((IFormattable)i);
			}
			val.Add("-f").Add(((Container)(ref container)).Name).Add("-preset")
				.Add((IFormattable)<preset>P);
			int num = 0;
			int num2 = 0;
			foreach (StreamInput streamInput2 in streamInputs)
			{
				IStreamInfo info = streamInput2.Info;
				IAudioStreamInfo val2 = (IAudioStreamInfo)(object)((info is IAudioStreamInfo) ? info : null);
				if (val2 != null)
				{
					if (((IStreamInfo)val2).Container == container)
					{
						val.Add($"-c:a:{num}").Add("copy");
					}
					num++;
				}
				IStreamInfo info2 = streamInput2.Info;
				IVideoStreamInfo val3 = (IVideoStreamInfo)(object)((info2 is IVideoStreamInfo) ? info2 : null);
				if (val3 != null)
				{
					if (((IStreamInfo)val3).Container == container)
					{
						val.Add($"-c:v:{num2}").Add("copy");
					}
					num2++;
				}
			}
			if (container == Container.Mp4 && subtitleInputs.Any())
			{
				val.Add("-c:s").Add("mov_text");
			}
			if (container == Container.Mp3)
			{
				int num3 = 0;
				foreach (StreamInput streamInput3 in streamInputs)
				{
					IStreamInfo info3 = streamInput3.Info;
					IAudioStreamInfo val4 = (IAudioStreamInfo)(object)((info3 is IAudioStreamInfo) ? info3 : null);
					if (val4 != null)
					{
						ArgumentsBuilder obj = val.Add($"-b:a:{num3++}");
						Bitrate bitrate = ((IStreamInfo)val4).Bitrate;
						obj.Add(Math.Round(((Bitrate)(ref bitrate)).KiloBitsPerSecond) + "K");
					}
				}
			}
			int num4 = 0;
			int num5 = 0;
			foreach (StreamInput streamInput4 in streamInputs)
			{
				IStreamInfo info4 = streamInput4.Info;
				IAudioStreamInfo val5 = (IAudioStreamInfo)(object)((info4 is IAudioStreamInfo) ? info4 : null);
				if (val5 != null)
				{
					val.Add($"-metadata:s:a:{num4++}").Add($"title={((IStreamInfo)val5).Bitrate}");
				}
				IStreamInfo info5 = streamInput4.Info;
				IVideoStreamInfo val6 = (IVideoStreamInfo)(object)((info5 is IVideoStreamInfo) ? info5 : null);
				if (val6 != null)
				{
					ArgumentsBuilder obj2 = val.Add($"-metadata:s:v:{num5++}");
					VideoQuality videoQuality = val6.VideoQuality;
					obj2.Add($"title={((VideoQuality)(ref videoQuality)).Label} | {((IStreamInfo)val6).Bitrate}");
				}
			}
			foreach (var item3 in subtitleInputs.WithIndex())
			{
				SubtitleInput item = item3.value;
				int item2 = item3.index;
				string text = item.Info.Language.TryGetThreeLetterCode();
				Language language;
				if (text == null)
				{
					language = item.Info.Language;
					text = ((Language)(ref language)).Code;
				}
				string text2 = text;
				ArgumentsBuilder obj3 = val.Add($"-metadata:s:s:{item2}").Add("language=" + text2).Add($"-metadata:s:s:{item2}");
				language = item.Info.Language;
				obj3.Add("title=" + ((Language)(ref language)).Name);
			}
			val.Add("-loglevel").Add("info").Add("-stats");
			val.Add("-hide_banner").Add("-threads").Add((IFormattable)Environment.ProcessorCount)
				.Add("-nostdin")
				.Add("-y");
			val.Add(filePath);
			await <ffmpeg>P.ExecuteAsync(val.Build(), progress, cancellationToken);
		}

		private async ValueTask PopulateStreamInputsAsync(string baseFilePath, IReadOnlyList<IStreamInfo> streamInfos, ICollection<StreamInput> streamInputs, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			ProgressMuxer progressMuxer = progress?.Pipe((IProgress<double> p) => new ProgressMuxer(p));
			IProgress<double>[] second = streamInfos.Select(delegate(IStreamInfo s)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				ProgressMuxer progressMuxer2 = progressMuxer;
				if (progressMuxer2 == null)
				{
					return null;
				}
				FileSize size = s.Size;
				return progressMuxer2.CreateInput(((FileSize)(ref size)).MegaBytes);
			}).ToArray();
			int lastIndex = 0;
			foreach (var item3 in System.Linq.PolyfillExtensions.Zip(streamInfos, second))
			{
				IStreamInfo item = item3.left;
				IProgress<double> item2 = item3.right;
				StreamInput streamInput = new StreamInput(item, $"{baseFilePath}.stream-{lastIndex++}.tmp");
				streamInputs.Add(streamInput);
				await <videoClient>P.Streams.DownloadAsync(item, streamInput.FilePath, item2, cancellationToken);
			}
			progress?.Report(1.0);
		}

		private async ValueTask PopulateSubtitleInputsAsync(string baseFilePath, IReadOnlyList<ClosedCaptionTrackInfo> closedCaptionTrackInfos, ICollection<SubtitleInput> subtitleInputs, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			ProgressMuxer progressMuxer = progress?.Pipe((IProgress<double> p) => new ProgressMuxer(p));
			IProgress<double>[] second = closedCaptionTrackInfos.Select((ClosedCaptionTrackInfo _) => progressMuxer?.CreateInput()).ToArray();
			int lastIndex = 0;
			foreach (var item3 in System.Linq.PolyfillExtensions.Zip(closedCaptionTrackInfos, second))
			{
				ClosedCaptionTrackInfo item = item3.left;
				IProgress<double> item2 = item3.right;
				SubtitleInput subtitleInput = new SubtitleInput(item, $"{baseFilePath}.subtitles-{lastIndex++}.tmp");
				subtitleInputs.Add(subtitleInput);
				await <videoClient>P.ClosedCaptions.DownloadAsync(item, subtitleInput.FilePath, item2, cancellationToken);
			}
			progress?.Report(1.0);
		}

		public async ValueTask ProcessAsync(string filePath, Container container, IReadOnlyList<IStreamInfo> streamInfos, IReadOnlyList<ClosedCaptionTrackInfo> closedCaptionTrackInfos, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!streamInfos.Any())
			{
				throw new InvalidOperationException("No streams provided.");
			}
			ProgressMuxer progressMuxer = progress?.Pipe((IProgress<double> p) => new ProgressMuxer(p));
			IProgress<double> progress2 = progressMuxer?.CreateInput();
			IProgress<double> subtitleDownloadProgress = progressMuxer?.CreateInput(0.01);
			IProgress<double> conversionProgress = progressMuxer?.CreateInput(0.05 + (double)(5 * streamInfos.Count((IStreamInfo s) => s.Container != container)));
			List<StreamInput> streamInputs = new List<StreamInput>(streamInfos.Count);
			List<SubtitleInput> subtitleInputs = new List<SubtitleInput>(closedCaptionTrackInfos.Count);
			try
			{
				await PopulateStreamInputsAsync(filePath, streamInfos, streamInputs, progress2, cancellationToken);
				await PopulateSubtitleInputsAsync(filePath, closedCaptionTrackInfos, subtitleInputs, subtitleDownloadProgress, cancellationToken);
				await ProcessAsync(filePath, container, streamInputs, subtitleInputs, conversionProgress, cancellationToken);
			}
			finally
			{
				foreach (StreamInput item in streamInputs)
				{
					item.Dispose();
				}
				foreach (SubtitleInput item2 in subtitleInputs)
				{
					item2.Dispose();
				}
			}
		}
	}
	internal class FFmpeg
	{
		[CompilerGenerated]
		private string <filePath>P;

		public FFmpeg(string filePath)
		{
			<filePath>P = filePath;
			base..ctor();
		}

		public async ValueTask ExecuteAsync(string arguments, IProgress<double>? progress, CancellationToken cancellationToken = default(CancellationToken))
		{
			StringBuilder stdErrBuffer = new StringBuilder();
			PipeTarget val = PipeTarget.Merge((PipeTarget[])(object)new PipeTarget[2]
			{
				PipeTarget.ToStringBuilder(stdErrBuffer),
				progress?.Pipe(CreateProgressRouter) ?? PipeTarget.Null
			});
			try
			{
				await Cli.Wrap(<filePath>P).WithArguments(arguments).WithStandardErrorPipe(val)
					.ExecuteAsync(cancellationToken);
			}
			catch (CommandExecutionException val2)
			{
				CommandExecutionException innerException = val2;
				throw new InvalidOperationException($"FFmpeg command-line tool failed with an error.\r\n\r\nStandard error:\r\n{stdErrBuffer}", (Exception?)(object)innerException);
			}
		}

		public static string GetFilePath()
		{
			return Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory ?? Directory.GetCurrentDirectory()).FirstOrDefault((string f) => string.Equals(Path.GetFileNameWithoutExtension(f), "ffmpeg", StringComparison.OrdinalIgnoreCase)) ?? "ffmpeg";
		}

		private static PipeTarget CreateProgressRouter(IProgress<double> progress)
		{
			IProgress<double> progress2 = progress;
			TimeSpan? totalDuration = null;
			return PipeTarget.ToDelegate((Action<string>)delegate(string line)
			{
				if (!totalDuration.HasValue)
				{
					Match match = Regex.Match(line, "Duration:\\s(\\d+):(\\d+):(\\d+\\.\\d+)");
					if (match.Success)
					{
						int num = int.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture);
						int num2 = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
						double value = double.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);
						totalDuration = TimeSpan.FromHours(num) + TimeSpan.FromMinutes(num2) + TimeSpan.FromSeconds(value);
					}
				}
				if (totalDuration.HasValue && !(totalDuration == TimeSpan.Zero))
				{
					Match match2 = Regex.Match(line, "time=(\\d+):(\\d+):(\\d+\\.\\d+)");
					if (match2.Success)
					{
						int num3 = int.Parse(match2.Groups[1].Value, CultureInfo.InvariantCulture);
						int num4 = int.Parse(match2.Groups[2].Value, CultureInfo.InvariantCulture);
						double value2 = double.Parse(match2.Groups[3].Value, CultureInfo.InvariantCulture);
						TimeSpan timeSpan = TimeSpan.FromHours(num3) + TimeSpan.FromMinutes(num4) + TimeSpan.FromSeconds(value2);
						progress2.Report((timeSpan.TotalMilliseconds / totalDuration.Value.TotalMilliseconds).Clamp(0.0, 1.0));
					}
				}
			});
		}
	}
}
namespace YoutubeExplode.Converter.Utils
{
	internal class ProgressMuxer
	{
		[CompilerGenerated]
		private IProgress<double> <target>P;

		private readonly object _lock;

		private readonly Dictionary<int, double> _splitWeights;

		private readonly Dictionary<int, double> _splitValues;

		public ProgressMuxer(IProgress<double> target)
		{
			<target>P = target;
			_lock = new object();
			_splitWeights = new Dictionary<int, double>();
			_splitValues = new Dictionary<int, double>();
			base..ctor();
		}

		public IProgress<double> CreateInput(double weight = 1.0)
		{
			lock (_lock)
			{
				int index = _splitWeights.Count;
				_splitWeights[index] = weight;
				_splitValues[index] = 0.0;
				return new Progress<double>(delegate(double p)
				{
					lock (_lock)
					{
						_splitValues[index] = p;
						double num = 0.0;
						double num2 = 0.0;
						for (int i = 0; i < _splitWeights.Count; i++)
						{
							num += _splitWeights[i] * _splitValues[i];
							num2 += _splitWeights[i];
						}
						<target>P.Report(num / num2);
					}
				});
			}
		}
	}
}
namespace YoutubeExplode.Converter.Utils.Extensions
{
	internal static class AsyncCollectionExtensions
	{
		public static async ValueTask<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source)
		{
			List<T> list = new List<T>();
			await foreach (T item in source)
			{
				list.Add(item);
			}
			return list;
		}

		public static ValueTaskAwaiter<List<T>> GetAwaiter<T>(this IAsyncEnumerable<T> source)
		{
			return source.ToListAsync().GetAwaiter();
		}
	}
	internal static class CollectionExtensions
	{
		public static IEnumerable<(T value, int index)> WithIndex<T>(this IEnumerable<T> source)
		{
			int i = 0;
			foreach (T item in source)
			{
				yield return (item, i++);
			}
		}
	}
	internal static class GenericExtensions
	{
		public static TOut Pipe<TIn, TOut>(this TIn input, Func<TIn, TOut> transform)
		{
			return transform(input);
		}

		public static T Clamp<T>(this T value, T min, T max) where T : IComparable<T>
		{
			if (value.CompareTo(min) > 0)
			{
				if (value.CompareTo(max) < 0)
				{
					return value;
				}
				return max;
			}
			return min;
		}
	}
	internal static class LanguageExtensions
	{
		public static string? TryGetThreeLetterCode(this Language language)
		{
			string text = ((Language)(ref language)).Code.SubstringUntil("-", StringComparison.OrdinalIgnoreCase);
			if (text.Length == 3)
			{
				return text;
			}
			return text.ToLowerInvariant() switch
			{
				"aa" => "aar", 
				"ab" => "abk", 
				"ae" => "ave", 
				"af" => "afr", 
				"ak" => "aka", 
				"am" => "amh", 
				"an" => "arg", 
				"ar" => "ara", 
				"as" => "asm", 
				"av" => "ava", 
				"ay" => "aym", 
				"az" => "aze", 
				"ba" => "bak", 
				"be" => "bel", 
				"bg" => "bul", 
				"bh" => "bih", 
				"bi" => "bis", 
				"bm" => "bam", 
				"bn" => "ben", 
				"bo" => "bod", 
				"br" => "bre", 
				"bs" => "bos", 
				"ca" => "cat", 
				"ce" => "che", 
				"ch" => "cha", 
				"co" => "cos", 
				"cr" => "cre", 
				"cs" => "cze", 
				"cu" => "chu", 
				"cv" => "chv", 
				"cy" => "cym", 
				"da" => "dan", 
				"de" => "deu", 
				"dv" => "div", 
				"dz" => "dzo", 
				"ee" => "ewe", 
				"el" => "ell", 
				"en" => "eng", 
				"eo" => "epo", 
				"es" => "spa", 
				"et" => "est", 
				"eu" => "eus", 
				"fa" => "fas", 
				"ff" => "ful", 
				"fi" => "fin", 
				"fj" => "fij", 
				"fo" => "fao", 
				"fr" => "fra", 
				"fy" => "fry", 
				"ga" => "gle", 
				"gd" => "gla", 
				"gl" => "glg", 
				"gn" => "grn", 
				"gu" => "guj", 
				"gv" => "glv", 
				"ha" => "hau", 
				"he" => "heb", 
				"hi" => "hin", 
				"ho" => "hmo", 
				"hr" => "hrv", 
				"ht" => "hat", 
				"hu" => "hun", 
				"hy" => "hye", 
				"hz" => "her", 
				"ia" => "ina", 
				"id" => "ind", 
				"ie" => "ile", 
				"ig" => "ibo", 
				"ii" => "iii", 
				"ik" => "ipk", 
				"in" => "ind", 
				"io" => "ido", 
				"is" => "isl", 
				"it" => "ita", 
				"iu" => "iku", 
				"iw" => "heb", 
				"ja" => "jpn", 
				"ji" => "yid", 
				"jv" => "jav", 
				"jw" => "jav", 
				"ka" => "kat", 
				"kg" => "kon", 
				"ki" => "kik", 
				"kj" => "kua", 
				"kk" => "kaz", 
				"kl" => "kal", 
				"km" => "khm", 
				"kn" => "kan", 
				"ko" => "kor", 
				"kr" => "kau", 
				"ks" => "kas", 
				"ku" => "kur", 
				"kv" => "kom", 
				"kw" => "cor", 
				"ky" => "kir", 
				"la" => "lat", 
				"lb" => "ltz", 
				"lg" => "lug", 
				"li" => "lim", 
				"ln" => "lin", 
				"lo" => "lao", 
				"lt" => "lit", 
				"lu" => "lub", 
				"lv" => "lav", 
				"mg" => "mlg", 
				"mh" => "mah", 
				"mi" => "mri", 
				"mk" => "mkd", 
				"ml" => "mal", 
				"mn" => "mon", 
				"mo" => "ron", 
				"mr" => "mar", 
				"ms" => "msa", 
				"mt" => "mlt", 
				"my" => "mya", 
				"na" => "nau", 
				"nb" => "nob", 
				"nd" => "nde", 
				"ne" => "nep", 
				"ng" => "ndo", 
				"nl" => "nld", 
				"nn" => "nno", 
				"no" => "nor", 
				"nr" => "nbl", 
				"nv" => "nav", 
				"ny" => "nya", 
				"oc" => "oci", 
				"oj" => "oji", 
				"om" => "orm", 
				"or" => "ori", 
				"os" => "oss", 
				"pa" => "pan", 
				"pi" => "pli", 
				"pl" => "pol", 
				"ps" => "pus", 
				"pt" => "por", 
				"qu" => "que", 
				"rm" => "roh", 
				"rn" => "run", 
				"ro" => "ron", 
				"ru" => "rus", 
				"rw" => "kin", 
				"sa" => "san", 
				"sc" => "srd", 
				"sd" => "snd", 
				"se" => "sme", 
				"sg" => "sag", 
				"sh" => "hbs", 
				"si" => "sin", 
				"sk" => "slo", 
				"sl" => "slv", 
				"sm" => "smo", 
				"sn" => "sna", 
				"so" => "som", 
				"sq" => "sqi", 
				"sr" => "srp", 
				"ss" => "ssw", 
				"st" => "sot", 
				"su" => "sun", 
				"sv" => "swe", 
				"sw" => "swa", 
				"ta" => "tam", 
				"te" => "tel", 
				"tg" => "tgk", 
				"th" => "tha", 
				"ti" => "tir", 
				"tk" => "tuk", 
				"tl" => "tgl", 
				"tn" => "tsn", 
				"to" => "ton", 
				"tr" => "tur", 
				"ts" => "tso", 
				"tt" => "tat", 
				"tw" => "twi", 
				"ty" => "tah", 
				"ug" => "uig", 
				"uk" => "ukr", 
				"ur" => "urd", 
				"uz" => "uzb", 
				"ve" => "ven", 
				"vi" => "vie", 
				"vo" => "vol", 
				"wa" => "wln", 
				"wo" => "wol", 
				"xh" => "xho", 
				"yi" => "yid", 
				"yo" => "yor", 
				"za" => "zha", 
				"zh" => "zho", 
				"zu" => "zul", 
				_ => null, 
			};
		}
	}
	internal static class StringExtensions
	{
		public static string? NullIfWhiteSpace(this string s)
		{
			if (string.IsNullOrWhiteSpace(s))
			{
				return null;
			}
			return s;
		}

		public static string SubstringUntil(this string str, string sub, StringComparison comparison = StringComparison.Ordinal)
		{
			int num = str.IndexOf(sub, comparison);
			if (num >= 0)
			{
				return str.Substring(0, num);
			}
			return str;
		}
	}
}
namespace System.Linq
{
	internal static class PolyfillExtensions
	{
		public static T ElementAt<T>(this IEnumerable<T> source, Index index)
		{
			if (index.IsFromEnd)
			{
				ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
				return collection.ElementAt(collection.Count - index.Value);
			}
			return source.ElementAt(index.Value);
		}

		public static T? ElementAtOrDefault<T>(this IEnumerable<T> source, Index index)
		{
			if (index.IsFromEnd)
			{
				ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
				return collection.ElementAtOrDefault(collection.Count - index.Value);
			}
			return source.ElementAtOrDefault(index.Value);
		}

		public static T FirstOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			using IEnumerator<T> enumerator = source.GetEnumerator();
			if (enumerator.MoveNext())
			{
				return enumerator.Current;
			}
			return defaultValue;
		}

		public static T FirstOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			foreach (T item in source)
			{
				if (predicate(item))
				{
					return item;
				}
			}
			return defaultValue;
		}

		public static T LastOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			T result = defaultValue;
			foreach (T item in source)
			{
				result = item;
			}
			return result;
		}

		public static T LastOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			T result = defaultValue;
			foreach (T item in source)
			{
				if (predicate(item))
				{
					result = item;
				}
			}
			return result;
		}

		public static T SingleOrDefault<T>(this IEnumerable<T> source, T defaultValue)
		{
			T result = defaultValue;
			bool flag = false;
			foreach (T item in source)
			{
				if (flag)
				{
					throw new InvalidOperationException("Sequence contains more than one element.");
				}
				result = item;
				flag = true;
			}
			return result;
		}

		public static T SingleOrDefault<T>(this IEnumerable<T> source, Func<T, bool> predicate, T defaultValue)
		{
			T result = defaultValue;
			bool flag = false;
			foreach (T item in source)
			{
				if (predicate(item))
				{
					if (flag)
					{
						throw new InvalidOperationException("Sequence contains more than one element.");
					}
					result = item;
					flag = true;
				}
			}
			return result;
		}

		public static IEnumerable<T> Take<T>(this IEnumerable<T> source, Range range)
		{
			ICollection<T> collection = (source as ICollection<T>) ?? source.ToArray();
			var (count, count2) = range.GetOffsetAndLength(collection.Count);
			return collection.Skip(count).Take(count2);
		}

		public static T? Min<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderBy((T x) => x, comparer).FirstOrDefault();
		}

		public static T? MinBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer)
		{
			return source.OrderBy(keySelector, comparer).FirstOrDefault();
		}

		public static T? MinBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return MinBy(source, keySelector, Comparer<TKey>.Default);
		}

		public static T? Max<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderByDescending((T x) => x, comparer).FirstOrDefault();
		}

		public static T? MaxBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey>? comparer)
		{
			return source.OrderByDescending(keySelector, comparer).FirstOrDefault();
		}

		public static T? MaxBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return MaxBy(source, keySelector, Comparer<TKey>.Default);
		}

		public static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			return from x in source.GroupBy(keySelector, comparer)
				select x.First();
		}

		public static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector)
		{
			return DistinctBy(source, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> ExceptBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(other, comparer);
			foreach (T item in source)
			{
				if (!set.Contains(keySelector(item)))
				{
					yield return item;
				}
			}
		}

		public static IEnumerable<T> ExceptBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector)
		{
			return ExceptBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> IntersectBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(other, comparer);
			foreach (T item in source)
			{
				if (set.Contains(keySelector(item)))
				{
					yield return item;
				}
			}
		}

		public static IEnumerable<T> IntersectBy<T, TKey>(this IEnumerable<T> source, IEnumerable<TKey> other, Func<T, TKey> keySelector)
		{
			return IntersectBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T> UnionBy<T, TKey>(this IEnumerable<T> source, IEnumerable<T> other, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer)
		{
			HashSet<TKey> set = new HashSet<TKey>(comparer);
			foreach (T item in source)
			{
				if (set.Add(keySelector(item)))
				{
					yield return item;
				}
			}
			foreach (T item2 in other)
			{
				if (set.Add(keySelector(item2)))
				{
					yield return item2;
				}
			}
		}

		public static IEnumerable<T> UnionBy<T, TKey>(this IEnumerable<T> source, IEnumerable<T> other, Func<T, TKey> keySelector)
		{
			return UnionBy(source, other, keySelector, EqualityComparer<TKey>.Default);
		}

		public static IEnumerable<T[]> Chunk<T>(this IEnumerable<T> source, int size)
		{
			List<T> chunk = new List<T>(size);
			foreach (T item in source)
			{
				chunk.Add(item);
				if (chunk.Count == size)
				{
					yield return chunk.ToArray();
					chunk.Clear();
				}
			}
			if (chunk.Count > 0)
			{
				yield return chunk.ToArray();
			}
		}

		public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderBy((T x) => x, comparer);
		}

		public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source)
		{
			return source.Order(Comparer<T>.Default);
		}

		public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source, IComparer<T>? comparer)
		{
			return source.OrderByDescending((T x) => x, comparer);
		}

		public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source)
		{
			return source.OrderDescending(Comparer<T>.Default);
		}

		public static IEnumerable<(TFirst left, TSecond right)> Zip<TFirst, TSecond>(this IEnumerable<TFirst> first, IEnumerable<TSecond> second)
		{
			return first.Zip(second, (TFirst x, TSecond y) => (x, y));
		}
	}
}
namespace System.Runtime.InteropServices
{
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class LibraryImportAttribute : Attribute
	{
		public string LibraryName { get; }

		public string? EntryPoint { get; init; }

		public bool SetLastError { get; init; }

		public StringMarshalling StringMarshalling { get; init; }

		public Type? StringMarshallingCustomType { get; init; }

		public LibraryImportAttribute(string libraryName)
		{
			LibraryName = libraryName;
		}
	}
	internal enum StringMarshalling
	{
		Custom,
		Utf8,
		Utf16
	}
}
namespace System.Runtime.CompilerServices
{
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class SkipLocalsInitAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; init; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	[ExcludeFromCodeCoverage]
	internal class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[Flags]
	internal enum DynamicallyAccessedMemberTypes
	{
		All = -1,
		None = 0,
		PublicParameterlessConstructor = 1,
		PublicConstructors = 3,
		NonPublicConstructors = 4,
		PublicMethods = 8,
		NonPublicMethods = 0x10,
		PublicFields = 0x20,
		NonPublicFields = 0x40,
		PublicNestedTypes = 0x80,
		NonPublicNestedTypes = 0x100,
		PublicProperties = 0x200,
		NonPublicProperties = 0x400,
		PublicEvents = 0x800,
		NonPublicEvents = 0x1000,
		Interfaces = 0x2000
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal class DynamicallyAccessedMembersAttribute : Attribute
	{
		public DynamicallyAccessedMemberTypes MemberTypes { get; }

		public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
		{
			MemberTypes = memberTypes;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor)]
	[ExcludeFromCodeCoverage]
	internal class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	[ExcludeFromCodeCoverage]
	internal class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}

		public StringSyntaxAttribute(string syntax)
			: this(syntax, new object[0])
		{
		}
	}
}
namespace System.Threading.Tasks
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.Net.Http
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.Management
{
	internal static class PolyfillExtensions
	{
	}
}
namespace System.IO
{
	internal static class PolyfillExtensions
	{
	}
}

plugins/YoutubeExplode.dll

Decompiled 7 months ago
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using AngleSharp.Dom;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Parser;
using Deorcify;
using Microsoft.CodeAnalysis;
using YoutubeExplode.Bridge;
using YoutubeExplode.Bridge.Cipher;
using YoutubeExplode.Channels;
using YoutubeExplode.Common;
using YoutubeExplode.Exceptions;
using YoutubeExplode.Playlists;
using YoutubeExplode.Search;
using YoutubeExplode.Utils;
using YoutubeExplode.Utils.Extensions;
using YoutubeExplode.Videos;
using YoutubeExplode.Videos.ClosedCaptions;
using YoutubeExplode.Videos.Streams;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tyrrrz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (C) Oleksii Holub")]
[assembly: AssemblyDescription("Abstraction layer over YouTube's internal API. Note: this package has limited availability in Russia and Belarus.")]
[assembly: AssemblyFileVersion("6.3.10.0")]
[assembly: AssemblyInformationalVersion("6.3.10+33e10ddb84c87d67a07d993a3554ec0e08f2b681")]
[assembly: AssemblyProduct("YoutubeExplode")]
[assembly: AssemblyTitle("YoutubeExplode")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Tyrrrz/YoutubeExplode")]
[assembly: AssemblyVersion("6.3.10.0")]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		Initializer.Execute();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class PolyfillExtensions
{
	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			HttpResponseMessage obj = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			obj.EnsureSuccessStatusCode();
			return await ReadAsStreamAsync(obj.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<Stream> GetStreamAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStreamAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsByteArrayAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<byte[]> GetByteArrayAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetByteArrayAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		_ = 1;
		try
		{
			using HttpResponseMessage response = await httpClient.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			response.EnsureSuccessStatusCode();
			return await ReadAsStringAsync(response.Content, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		}
		catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken && cancellationToken.IsCancellationRequested)
		{
			throw new OperationCanceledException(ex.Message, ex.InnerException, cancellationToken);
		}
	}

	public static async Task<string> GetStringAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken = default(CancellationToken))
	{
		return await GetStringAsync(httpClient, requestUri.ToString(), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<Stream> ReadAsStreamAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStreamAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<byte[]> ReadAsByteArrayAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<string> ReadAsStringAsync(this HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
	{
		cancellationToken.ThrowIfCancellationRequested();
		return await httpContent.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default(CancellationToken))
	{
		TaskCompletionSource<object?> tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
		try
		{
			process.EnableRaisingEvents = true;
		}
		catch when (process.HasExited)
		{
			return;
		}
		process.Exited += HandleExited;
		try
		{
			using (cancellationToken.Register(delegate
			{
				tcs.TrySetCanceled(cancellationToken);
			}))
			{
				await tcs.Task;
			}
		}
		finally
		{
			process.Exited -= HandleExited;
		}
		void HandleExited(object? sender, EventArgs args)
		{
			tcs.TrySetResult(null);
		}
	}

	public static bool IsAssignableTo(this Type type, Type? otherType)
	{
		return otherType?.IsAssignableFrom(type) ?? false;
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
	}

	public static async Task WaitAsync(this Task task, CancellationToken cancellationToken)
	{
		await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task WaitAsync(this Task task, TimeSpan timeout)
	{
		await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout, CancellationToken cancellationToken)
	{
		Task cancellationTask = Task.Delay(timeout, cancellationToken);
		Task finishedTask = await Task.WhenAny(new Task[2] { task, cancellationTask }).ConfigureAwait(continueOnCapturedContext: false);
		await finishedTask.ConfigureAwait(continueOnCapturedContext: false);
		if (finishedTask == cancellationTask)
		{
			throw new TimeoutException("The operation has timed out.");
		}
		return task.Result;
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, CancellationToken cancellationToken)
	{
		return await WaitAsync(task, Timeout.InfiniteTimeSpan, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout)
	{
		return await WaitAsync(task, timeout, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer, i, Math.Min(minimumBytes, buffer.Length - i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, byte[] buffer, int offset, int count)
	{
		int num;
		for (int i = 0; i < count; i += num)
		{
			num = stream.Read(buffer, offset + i, count - i);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static void ReadExactly(this Stream stream, byte[] buffer)
	{
		stream.ReadExactly(buffer, 0, buffer.Length);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, byte[] buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, totalBytesRead, Math.Min(minimumBytes, buffer.Length - totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
	{
		int num;
		for (int totalBytesRead = 0; totalBytesRead < count; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer, offset + totalBytesRead, count - totalBytesRead, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				throw new EndOfStreamException();
			}
		}
	}

	public static async Task ReadExactlyAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		await stream.ReadExactlyAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
	}

	public static int ReadAtLeast(this Stream stream, Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true)
	{
		int i;
		int num;
		for (i = 0; i < buffer.Length; i += num)
		{
			num = stream.Read(buffer.Slice(i));
			if (num <= 0)
			{
				break;
			}
		}
		if (i < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return i;
	}

	public static void ReadExactly(this Stream stream, Span<byte> buffer)
	{
		byte[] array = buffer.ToArray();
		stream.ReadExactly(array, 0, array.Length);
		array.CopyTo(buffer);
	}

	public static async Task<int> ReadAtLeastAsync(this Stream stream, Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true, CancellationToken cancellationToken = default(CancellationToken))
	{
		int totalBytesRead;
		int num;
		for (totalBytesRead = 0; totalBytesRead < buffer.Length; totalBytesRead += num)
		{
			num = await stream.ReadAsync(buffer.Slice(totalBytesRead), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (num <= 0)
			{
				break;
			}
		}
		if (totalBytesRead < minimumBytes && throwOnEndOfStream)
		{
			throw new EndOfStreamException();
		}
		return totalBytesRead;
	}

	public static async Task ReadExactlyAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
	{
		byte[] bufferArray = buffer.ToArray();
		await stream.ReadExactlyAsync(bufferArray, 0, bufferArray.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
		bufferArray.CopyTo(buffer);
	}
}
namespace YoutubeExplode
{
	public class YoutubeClient
	{
		public VideoClient Videos { get; }

		public PlaylistClient Playlists { get; }

		public ChannelClient Channels { get; }

		public SearchClient Search { get; }

		public YoutubeClient(HttpClient http, IReadOnlyList<Cookie> initialCookies)
		{
			HttpClient http2 = new HttpClient(new YoutubeHttpHandler(http, initialCookies), disposeHandler: true);
			Videos = new VideoClient(http2);
			Playlists = new PlaylistClient(http2);
			Channels = new ChannelClient(http2);
			Search = new SearchClient(http2);
		}

		public YoutubeClient(HttpClient http)
			: this(http, Array.Empty<Cookie>())
		{
		}

		public YoutubeClient(IReadOnlyList<Cookie> initialCookies)
			: this(Http.Client, initialCookies)
		{
		}

		public YoutubeClient()
			: this(Http.Client)
		{
		}
	}
	internal class YoutubeHttpHandler : ClientDelegatingHandler
	{
		private readonly CookieContainer _cookieContainer = new CookieContainer();

		public YoutubeHttpHandler(HttpClient http, IReadOnlyList<Cookie> initialCookies, bool disposeClient = false)
			: base(http, disposeClient)
		{
			foreach (Cookie initialCookie in initialCookies)
			{
				_cookieContainer.Add(initialCookie);
			}
			_cookieContainer.Add(new Cookie("SOCS", "CAISNQgDEitib3FfaWRlbnRpdHlmcm9udGVuZHVpc2VydmVyXzIwMjMwODI5LjA3X3AxGgJlbiACGgYIgLC_pwY")
			{
				Domain = "youtube.com"
			});
		}

		private string? TryGenerateAuthHeaderValue(Uri uri)
		{
			Cookie[] source = _cookieContainer.GetCookies(uri).Cast<Cookie>().ToArray();
			string text = source.FirstOrDefault((Cookie c) => string.Equals(c.Name, "__Secure-3PAPISID", StringComparison.Ordinal))?.Value ?? source.FirstOrDefault((Cookie c) => string.Equals(c.Name, "SAPISID", StringComparison.Ordinal))?.Value;
			if (string.IsNullOrWhiteSpace(text))
			{
				return null;
			}
			long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
			string domain = uri.GetDomain();
			string s = $"{num} {text} {domain}";
			string arg = Hash.Compute(SHA1.Create(), Encoding.UTF8.GetBytes(s)).ToHex();
			return $"SAPISIDHASH {num}_{arg}";
		}

		private HttpRequestMessage HandleRequest(HttpRequestMessage request)
		{
			if ((object)request.RequestUri == null)
			{
				return request;
			}
			if (request.RequestUri.AbsolutePath.StartsWith("/youtubei/", StringComparison.Ordinal) && !UrlEx.ContainsQueryParameter(request.RequestUri.Query, "key"))
			{
				request.RequestUri = new Uri(UrlEx.SetQueryParameter(request.RequestUri.OriginalString, "key", "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w"));
			}
			if (!UrlEx.ContainsQueryParameter(request.RequestUri.Query, "hl"))
			{
				request.RequestUri = new Uri(UrlEx.SetQueryParameter(request.RequestUri.OriginalString, "hl", "en"));
			}
			if (!request.Headers.Contains("Origin"))
			{
				request.Headers.Add("Origin", request.RequestUri.GetDomain());
			}
			if (!request.Headers.Contains("User-Agent"))
			{
				request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36");
			}
			if (!request.Headers.Contains("Cookie") && _cookieContainer.Count > 0)
			{
				string cookieHeader = _cookieContainer.GetCookieHeader(request.RequestUri);
				if (!string.IsNullOrWhiteSpace(cookieHeader))
				{
					request.Headers.Add("Cookie", cookieHeader);
				}
			}
			if (!request.Headers.Contains("Authorization"))
			{
				string text = TryGenerateAuthHeaderValue(request.RequestUri);
				if (text != null)
				{
					request.Headers.Add("Authorization", text);
				}
			}
			return request;
		}

		private HttpResponseMessage HandleResponse(HttpResponseMessage response)
		{
			if ((object)response.RequestMessage?.RequestUri == null)
			{
				return response;
			}
			if (response.StatusCode == HttpStatusCode.TooManyRequests)
			{
				throw new RequestLimitExceededException("Exceeded request rate limit. Please try again in a few hours. Alternatively, inject cookies corresponding to a pre-authenticated user when initializing an instance of `YoutubeClient`.");
			}
			if (response.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> values))
			{
				foreach (string item in values)
				{
					_cookieContainer.SetCookies(response.RequestMessage.RequestUri, item);
				}
			}
			return response;
		}

		protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
		{
			int retriesRemaining = 5;
			while (true)
			{
				try
				{
					HttpResponseMessage httpResponseMessage = HandleResponse(await base.SendAsync(HandleRequest(request), cancellationToken));
					if (httpResponseMessage.StatusCode < HttpStatusCode.InternalServerError || retriesRemaining <= 0)
					{
						return httpResponseMessage;
					}
					httpResponseMessage.Dispose();
				}
				catch (HttpRequestException) when (retriesRemaining > 0)
				{
				}
				retriesRemaining--;
			}
		}
	}
}
namespace YoutubeExplode.Videos
{
	public class Engagement
	{
		public long ViewCount { get; }

		public long LikeCount { get; }

		public long DislikeCount { get; }

		public double AverageRating
		{
			get
			{
				if (LikeCount + DislikeCount == 0L)
				{
					return 0.0;
				}
				return 1.0 + 4.0 * (double)LikeCount / (double)(LikeCount + DislikeCount);
			}
		}

		public Engagement(long viewCount, long likeCount, long dislikeCount)
		{
			ViewCount = viewCount;
			LikeCount = likeCount;
			DislikeCount = dislikeCount;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Rating: {AverageRating:N1}";
		}
	}
	public interface IVideo
	{
		VideoId Id { get; }

		string Url { get; }

		string Title { get; }

		Author Author { get; }

		TimeSpan? Duration { get; }

		IReadOnlyList<Thumbnail> Thumbnails { get; }
	}
	public class Video : IVideo
	{
		public VideoId Id { get; }

		public string Url => $"https://www.youtube.com/watch?v={Id}";

		public string Title { get; }

		public Author Author { get; }

		public DateTimeOffset UploadDate { get; }

		public string Description { get; }

		public TimeSpan? Duration { get; }

		public IReadOnlyList<Thumbnail> Thumbnails { get; }

		public IReadOnlyList<string> Keywords { get; }

		public Engagement Engagement { get; }

		public Video(VideoId id, string title, Author author, DateTimeOffset uploadDate, string description, TimeSpan? duration, IReadOnlyList<Thumbnail> thumbnails, IReadOnlyList<string> keywords, Engagement engagement)
		{
			Id = id;
			Title = title;
			Author = author;
			UploadDate = uploadDate;
			Description = description;
			Duration = duration;
			Thumbnails = thumbnails;
			Keywords = keywords;
			Engagement = engagement;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return "Video (" + Title + ")";
		}
	}
	public class VideoClient
	{
		private readonly VideoController _controller;

		public StreamClient Streams { get; }

		public ClosedCaptionClient ClosedCaptions { get; }

		public VideoClient(HttpClient http)
		{
			_controller = new VideoController(http);
			Streams = new StreamClient(http);
			ClosedCaptions = new ClosedCaptionClient(http);
		}

		public async ValueTask<Video> GetAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			VideoWatchPage watchPage = await _controller.GetVideoWatchPageAsync(videoId, cancellationToken);
			PlayerResponse playerResponse = watchPage.PlayerResponse;
			if (playerResponse == null)
			{
				playerResponse = await _controller.GetPlayerResponseAsync(videoId, cancellationToken);
			}
			PlayerResponse playerResponse2 = playerResponse;
			string title = playerResponse2.Title ?? "";
			string channelTitle = playerResponse2.Author ?? throw new YoutubeExplodeException("Failed to extract the video author.");
			string text = playerResponse2.ChannelId ?? throw new YoutubeExplodeException("Failed to extract the video channel ID.");
			DateTimeOffset uploadDate = playerResponse2.UploadDate ?? watchPage.UploadDate ?? throw new YoutubeExplodeException("Failed to extract the video upload date.");
			Thumbnail[] thumbnails = playerResponse2.Thumbnails.Select(delegate(ThumbnailData t)
			{
				string? url = t.Url ?? throw new YoutubeExplodeException("Failed to extract the thumbnail URL.");
				int width = t.Width ?? throw new YoutubeExplodeException("Failed to extract the thumbnail width.");
				int height = t.Height ?? throw new YoutubeExplodeException("Failed to extract the thumbnail height.");
				Resolution resolution = new Resolution(width, height);
				return new Thumbnail(url, resolution);
			}).Concat(Thumbnail.GetDefaultSet(videoId)).ToArray();
			return new Video(videoId, title, new Author(text, channelTitle), uploadDate, playerResponse2.Description ?? "", playerResponse2.Duration, thumbnails, playerResponse2.Keywords, new Engagement(playerResponse2.ViewCount.GetValueOrDefault(), watchPage.LikeCount.GetValueOrDefault(), watchPage.DislikeCount.GetValueOrDefault()));
		}
	}
	internal class VideoController
	{
		protected HttpClient Http { get; }

		public VideoController(HttpClient http)
		{
			Http = http;
			base..ctor();
		}

		public async ValueTask<VideoWatchPage> GetVideoWatchPageAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			int retriesRemaining = 5;
			VideoWatchPage videoWatchPage;
			while (true)
			{
				videoWatchPage = VideoWatchPage.TryParse(await PolyfillExtensions.GetStringAsync(Http, $"https://www.youtube.com/watch?v={videoId}&bpctr=9999999999", cancellationToken));
				if (videoWatchPage != null)
				{
					break;
				}
				if (retriesRemaining <= 0)
				{
					throw new YoutubeExplodeException("Video watch page is broken. Please try again in a few minutes.");
				}
				retriesRemaining--;
			}
			if (!videoWatchPage.IsAvailable)
			{
				throw new VideoUnavailableException($"Video '{videoId}' is not available.");
			}
			return videoWatchPage;
		}

		public async ValueTask<PlayerResponse> GetPlayerResponseAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://www.youtube.com/youtubei/v1/player")
			{
				Content = new StringContent($"{{\r\n    \"videoId\": \"{videoId}\",\r\n    \"context\": {{\r\n        \"client\": {{\r\n            \"clientName\": \"ANDROID_TESTSUITE\",\r\n            \"clientVersion\": \"1.9\",\r\n            \"androidSdkVersion\": 30,\r\n            \"hl\": \"en\",\r\n            \"gl\": \"US\",\r\n            \"utcOffsetMinutes\": 0\r\n        }}\r\n    }}\r\n}}")
			};
			request.Headers.Add("User-Agent", "com.google.android.youtube/17.36.4 (Linux; U; Android 12; GB) gzip");
			using HttpResponseMessage response = await Http.SendAsync(request, cancellationToken);
			response.EnsureSuccessStatusCode();
			PlayerResponse playerResponse = PlayerResponse.Parse(await PolyfillExtensions.ReadAsStringAsync(response.Content, cancellationToken));
			if (!playerResponse.IsAvailable)
			{
				throw new VideoUnavailableException($"Video '{videoId}' is not available.");
			}
			return playerResponse;
		}

		public async ValueTask<PlayerResponse> GetPlayerResponseAsync(VideoId videoId, string? signatureTimestamp, CancellationToken cancellationToken = default(CancellationToken))
		{
			using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://www.youtube.com/youtubei/v1/player")
			{
				Content = new StringContent(string.Format("{{\r\n    \"videoId\": \"{0}\",\r\n    \"context\": {{\r\n        \"client\": {{\r\n            \"clientName\": \"TVHTML5_SIMPLY_EMBEDDED_PLAYER\",\r\n            \"clientVersion\": \"2.0\",\r\n            \"hl\": \"en\",\r\n            \"gl\": \"US\",\r\n            \"utcOffsetMinutes\": 0\r\n        }},\r\n        \"thirdParty\": {{\r\n            \"embedUrl\": \"https://www.youtube.com\"\r\n        }}\r\n    }},\r\n    \"playbackContext\": {{\r\n        \"contentPlaybackContext\": {{\r\n            \"signatureTimestamp\": \"{1}\"\r\n        }}\r\n    }}\r\n}}", videoId, signatureTimestamp ?? "19369"))
			};
			using HttpResponseMessage response = await Http.SendAsync(request, cancellationToken);
			response.EnsureSuccessStatusCode();
			PlayerResponse playerResponse = PlayerResponse.Parse(await PolyfillExtensions.ReadAsStringAsync(response.Content, cancellationToken));
			if (!playerResponse.IsAvailable)
			{
				throw new VideoUnavailableException($"Video '{videoId}' is not available.");
			}
			return playerResponse;
		}
	}
	public readonly struct VideoId : IEquatable<VideoId>
	{
		public string Value { get; }

		private VideoId(string value)
		{
			Value = value;
		}

		public override string ToString()
		{
			return Value;
		}

		private static bool IsValid(string videoId)
		{
			if (videoId.Length == 11)
			{
				return videoId.All(delegate(char c)
				{
					bool flag = char.IsLetterOrDigit(c);
					if (!flag)
					{
						bool flag2 = ((c == '-' || c == '_') ? true : false);
						flag = flag2;
					}
					return flag;
				});
			}
			return false;
		}

		private static string? TryNormalize(string? videoIdOrUrl)
		{
			if (string.IsNullOrWhiteSpace(videoIdOrUrl))
			{
				return null;
			}
			if (IsValid(videoIdOrUrl))
			{
				return videoIdOrUrl;
			}
			string text = Regex.Match(videoIdOrUrl, "youtube\\..+?/watch.*?v=(.*?)(?:&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text) && IsValid(text))
			{
				return text;
			}
			string text2 = Regex.Match(videoIdOrUrl, "youtu\\.be/(.*?)(?:\\?|&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text2) && IsValid(text2))
			{
				return text2;
			}
			string text3 = Regex.Match(videoIdOrUrl, "youtube\\..+?/embed/(.*?)(?:\\?|&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text3) && IsValid(text3))
			{
				return text3;
			}
			string text4 = Regex.Match(videoIdOrUrl, "youtube\\..+?/shorts/(.*?)(?:\\?|&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text4) && IsValid(text4))
			{
				return text4;
			}
			string text5 = Regex.Match(videoIdOrUrl, "youtube\\..+?/live/(.*?)(?:\\?|&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text5) && IsValid(text5))
			{
				return text5;
			}
			return null;
		}

		public static VideoId? TryParse(string? videoIdOrUrl)
		{
			return TryNormalize(videoIdOrUrl)?.Pipe((string id) => new VideoId(id));
		}

		public static VideoId Parse(string videoIdOrUrl)
		{
			return TryParse(videoIdOrUrl) ?? throw new ArgumentException("Invalid YouTube video ID or URL '" + videoIdOrUrl + "'.");
		}

		public static implicit operator VideoId(string videoIdOrUrl)
		{
			return Parse(videoIdOrUrl);
		}

		public static implicit operator string(VideoId videoId)
		{
			return videoId.ToString();
		}

		public bool Equals(VideoId other)
		{
			return StringComparer.Ordinal.Equals(Value, other.Value);
		}

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

		public override int GetHashCode()
		{
			return StringComparer.Ordinal.GetHashCode(Value);
		}

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

		public static bool operator !=(VideoId left, VideoId right)
		{
			return !(left == right);
		}
	}
}
namespace YoutubeExplode.Videos.Streams
{
	public class AudioOnlyStreamInfo : IAudioStreamInfo, IStreamInfo
	{
		public string Url { get; }

		public Container Container { get; }

		public FileSize Size { get; }

		public Bitrate Bitrate { get; }

		public string AudioCodec { get; }

		public AudioOnlyStreamInfo(string url, Container container, FileSize size, Bitrate bitrate, string audioCodec)
		{
			Url = url;
			Container = container;
			Size = size;
			Bitrate = bitrate;
			AudioCodec = audioCodec;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Audio-only ({Container})";
		}
	}
	public readonly struct Bitrate : IComparable<Bitrate>, IEquatable<Bitrate>
	{
		public long BitsPerSecond { get; }

		public double KiloBitsPerSecond => (double)BitsPerSecond / 1024.0;

		public double MegaBitsPerSecond => KiloBitsPerSecond / 1024.0;

		public double GigaBitsPerSecond => MegaBitsPerSecond / 1024.0;

		public Bitrate(long bitsPerSecond)
		{
			BitsPerSecond = bitsPerSecond;
		}

		private string GetLargestWholeNumberSymbol()
		{
			if (Math.Abs(GigaBitsPerSecond) >= 1.0)
			{
				return "Gbit/s";
			}
			if (Math.Abs(MegaBitsPerSecond) >= 1.0)
			{
				return "Mbit/s";
			}
			if (Math.Abs(KiloBitsPerSecond) >= 1.0)
			{
				return "Kbit/s";
			}
			return "Bit/s";
		}

		private double GetLargestWholeNumberValue()
		{
			if (Math.Abs(GigaBitsPerSecond) >= 1.0)
			{
				return GigaBitsPerSecond;
			}
			if (Math.Abs(MegaBitsPerSecond) >= 1.0)
			{
				return MegaBitsPerSecond;
			}
			if (Math.Abs(KiloBitsPerSecond) >= 1.0)
			{
				return KiloBitsPerSecond;
			}
			return BitsPerSecond;
		}

		public override string ToString()
		{
			return $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}";
		}

		public int CompareTo(Bitrate other)
		{
			return BitsPerSecond.CompareTo(other.BitsPerSecond);
		}

		public bool Equals(Bitrate other)
		{
			return CompareTo(other) == 0;
		}

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

		public override int GetHashCode()
		{
			return HashCode.Combine(BitsPerSecond);
		}

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

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

		public static bool operator >(Bitrate left, Bitrate right)
		{
			return left.CompareTo(right) > 0;
		}

		public static bool operator <(Bitrate left, Bitrate right)
		{
			return left.CompareTo(right) < 0;
		}
	}
	public readonly struct Container : IEquatable<Container>
	{
		public string Name { get; }

		public bool IsAudioOnly
		{
			get
			{
				if (!string.Equals(Name, "mp3", StringComparison.OrdinalIgnoreCase) && !string.Equals(Name, "m4a", StringComparison.OrdinalIgnoreCase) && !string.Equals(Name, "wav", StringComparison.OrdinalIgnoreCase) && !string.Equals(Name, "wma", StringComparison.OrdinalIgnoreCase) && !string.Equals(Name, "ogg", StringComparison.OrdinalIgnoreCase) && !string.Equals(Name, "aac", StringComparison.OrdinalIgnoreCase))
				{
					return string.Equals(Name, "opus", StringComparison.OrdinalIgnoreCase);
				}
				return true;
			}
		}

		public static Container Mp3 { get; } = new Container("mp3");


		public static Container Mp4 { get; } = new Container("mp4");


		public static Container WebM { get; } = new Container("webm");


		public static Container Tgpp { get; } = new Container("3gpp");


		public Container(string name)
		{
			Name = name;
		}

		public override string ToString()
		{
			return Name;
		}

		public bool Equals(Container other)
		{
			return StringComparer.OrdinalIgnoreCase.Equals(Name, other.Name);
		}

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

		public override int GetHashCode()
		{
			return StringComparer.OrdinalIgnoreCase.GetHashCode(Name);
		}

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

		public static bool operator !=(Container left, Container right)
		{
			return !(left == right);
		}
	}
	public readonly struct FileSize : IComparable<FileSize>, IEquatable<FileSize>
	{
		public long Bytes { get; }

		public double KiloBytes => (double)Bytes / 1024.0;

		public double MegaBytes => KiloBytes / 1024.0;

		public double GigaBytes => MegaBytes / 1024.0;

		public FileSize(long bytes)
		{
			Bytes = bytes;
		}

		private string GetLargestWholeNumberSymbol()
		{
			if (Math.Abs(GigaBytes) >= 1.0)
			{
				return "GB";
			}
			if (Math.Abs(MegaBytes) >= 1.0)
			{
				return "MB";
			}
			if (Math.Abs(KiloBytes) >= 1.0)
			{
				return "KB";
			}
			return "B";
		}

		private double GetLargestWholeNumberValue()
		{
			if (Math.Abs(GigaBytes) >= 1.0)
			{
				return GigaBytes;
			}
			if (Math.Abs(MegaBytes) >= 1.0)
			{
				return MegaBytes;
			}
			if (Math.Abs(KiloBytes) >= 1.0)
			{
				return KiloBytes;
			}
			return Bytes;
		}

		public override string ToString()
		{
			return $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}";
		}

		public int CompareTo(FileSize other)
		{
			return Bytes.CompareTo(other.Bytes);
		}

		public bool Equals(FileSize other)
		{
			return CompareTo(other) == 0;
		}

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

		public override int GetHashCode()
		{
			return HashCode.Combine(Bytes);
		}

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

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

		public static bool operator >(FileSize left, FileSize right)
		{
			return left.CompareTo(right) > 0;
		}

		public static bool operator <(FileSize left, FileSize right)
		{
			return left.CompareTo(right) < 0;
		}
	}
	public interface IAudioStreamInfo : IStreamInfo
	{
		string AudioCodec { get; }
	}
	public interface IStreamInfo
	{
		string Url { get; }

		Container Container { get; }

		FileSize Size { get; }

		Bitrate Bitrate { get; }
	}
	public static class StreamInfoExtensions
	{
		internal static bool IsThrottled(this IStreamInfo streamInfo)
		{
			return !string.Equals(UrlEx.TryGetQueryParameterValue(streamInfo.Url, "ratebypass"), "yes", StringComparison.OrdinalIgnoreCase);
		}

		public static IStreamInfo? TryGetWithHighestBitrate(this IEnumerable<IStreamInfo> streamInfos)
		{
			return System.Linq.PolyfillExtensions.MaxBy(streamInfos, (IStreamInfo s) => s.Bitrate);
		}

		public static IStreamInfo GetWithHighestBitrate(this IEnumerable<IStreamInfo> streamInfos)
		{
			return streamInfos.TryGetWithHighestBitrate() ?? throw new InvalidOperationException("Input stream collection is empty.");
		}
	}
	public interface IVideoStreamInfo : IStreamInfo
	{
		string VideoCodec { get; }

		VideoQuality VideoQuality { get; }

		Resolution VideoResolution { get; }
	}
	public static class VideoStreamInfoExtensions
	{
		public static IVideoStreamInfo? TryGetWithHighestVideoQuality(this IEnumerable<IVideoStreamInfo> streamInfos)
		{
			return System.Linq.PolyfillExtensions.MaxBy(streamInfos, (IVideoStreamInfo s) => s.VideoQuality);
		}

		public static IVideoStreamInfo GetWithHighestVideoQuality(this IEnumerable<IVideoStreamInfo> streamInfos)
		{
			return streamInfos.TryGetWithHighestVideoQuality() ?? throw new InvalidOperationException("Input stream collection is empty.");
		}
	}
	internal class MediaStream : Stream
	{
		[CompilerGenerated]
		private HttpClient <http>P;

		[CompilerGenerated]
		private IStreamInfo <streamInfo>P;

		private readonly long _segmentLength;

		private Stream? _segmentStream;

		private long _actualPosition;

		[ExcludeFromCodeCoverage]
		public override bool CanRead => true;

		[ExcludeFromCodeCoverage]
		public override bool CanSeek => true;

		[ExcludeFromCodeCoverage]
		public override bool CanWrite => false;

		public override long Length => <streamInfo>P.Size.Bytes;

		public override long Position { get; set; }

		public MediaStream(HttpClient http, IStreamInfo streamInfo)
		{
			<http>P = http;
			<streamInfo>P = streamInfo;
			_segmentLength = (<streamInfo>P.IsThrottled() ? 9898989 : <streamInfo>P.Size.Bytes);
			base..ctor();
		}

		private void ResetSegment()
		{
			_segmentStream?.Dispose();
			_segmentStream = null;
		}

		private async ValueTask<Stream> ResolveSegmentAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			if (_segmentStream != null)
			{
				return _segmentStream;
			}
			long position = Position;
			long num = Position + _segmentLength - 1;
			string requestUri = UrlEx.SetQueryParameter(<streamInfo>P.Url, "range", $"{position}-{num}");
			return _segmentStream = await PolyfillExtensions.GetStreamAsync(<http>P, requestUri, cancellationToken);
		}

		public async ValueTask InitializeAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			await ResolveSegmentAsync(cancellationToken);
		}

		private async ValueTask<int> ReadSegmentAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default(CancellationToken))
		{
			int retriesRemaining = 5;
			while (true)
			{
				try
				{
					return await (await ResolveSegmentAsync(cancellationToken)).ReadAsync(buffer, offset, count, cancellationToken);
				}
				catch (IOException) when (retriesRemaining > 0)
				{
					ResetSegment();
				}
				retriesRemaining--;
			}
		}

		public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
		{
			int num;
			while (true)
			{
				long requestedPosition = Position;
				if (_actualPosition != requestedPosition)
				{
					ResetSegment();
				}
				if (requestedPosition >= Length)
				{
					return 0;
				}
				num = await ReadSegmentAsync(buffer, offset, count, cancellationToken);
				Position = (_actualPosition = requestedPosition + num);
				if (num > 0)
				{
					break;
				}
				ResetSegment();
			}
			return num;
		}

		[ExcludeFromCodeCoverage]
		public override int Read(byte[] buffer, int offset, int count)
		{
			return ReadAsync(buffer, offset, count).GetAwaiter().GetResult();
		}

		[ExcludeFromCodeCoverage]
		public override void Write(byte[] buffer, int offset, int count)
		{
			throw new NotSupportedException();
		}

		[ExcludeFromCodeCoverage]
		public override void SetLength(long value)
		{
			throw new NotSupportedException();
		}

		[ExcludeFromCodeCoverage]
		public override long Seek(long offset, SeekOrigin origin)
		{
			return Position = origin switch
			{
				SeekOrigin.Begin => offset, 
				SeekOrigin.Current => Position + offset, 
				SeekOrigin.End => Length + offset, 
				_ => throw new ArgumentOutOfRangeException("origin"), 
			};
		}

		[ExcludeFromCodeCoverage]
		public override void Flush()
		{
			throw new NotSupportedException();
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				ResetSegment();
			}
			base.Dispose(disposing);
		}
	}
	public class MuxedStreamInfo : IAudioStreamInfo, IStreamInfo, IVideoStreamInfo
	{
		public string Url { get; }

		public Container Container { get; }

		public FileSize Size { get; }

		public Bitrate Bitrate { get; }

		public string AudioCodec { get; }

		public string VideoCodec { get; }

		public VideoQuality VideoQuality { get; }

		public Resolution VideoResolution { get; }

		public MuxedStreamInfo(string url, Container container, FileSize size, Bitrate bitrate, string audioCodec, string videoCodec, VideoQuality videoQuality, Resolution resolution)
		{
			Url = url;
			Container = container;
			Size = size;
			Bitrate = bitrate;
			AudioCodec = audioCodec;
			VideoCodec = videoCodec;
			VideoQuality = videoQuality;
			VideoResolution = resolution;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Muxed ({VideoQuality} | {Container})";
		}
	}
	public class StreamClient
	{
		private readonly HttpClient _http;

		private readonly StreamController _controller;

		private CipherManifest? _cipherManifest;

		public StreamClient(HttpClient http)
		{
			_http = http;
			_controller = new StreamController(http);
		}

		private async ValueTask<CipherManifest> ResolveCipherManifestAsync(CancellationToken cancellationToken)
		{
			if (_cipherManifest != null)
			{
				return _cipherManifest;
			}
			return _cipherManifest = (await _controller.GetPlayerSourceAsync(cancellationToken)).CipherManifest ?? throw new YoutubeExplodeException("Failed to extract the cipher manifest.");
		}

		private async IAsyncEnumerable<IStreamInfo> GetStreamInfosAsync(IEnumerable<IStreamData> streamDatas, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			foreach (IStreamData streamData in streamDatas)
			{
				int itag = streamData.Itag ?? throw new YoutubeExplodeException("Failed to extract the stream itag.");
				string url = streamData.Url ?? throw new YoutubeExplodeException("Failed to extract the stream URL.");
				if (!string.IsNullOrWhiteSpace(streamData.Signature))
				{
					CipherManifest cipherManifest = await ResolveCipherManifestAsync(cancellationToken);
					url = UrlEx.SetQueryParameter(url, streamData.SignatureParameter ?? "sig", cipherManifest.Decipher(streamData.Signature));
				}
				long num = streamData.ContentLength ?? (await _http.TryGetContentLengthAsync(url, ensureSuccess: false, cancellationToken)).GetValueOrDefault();
				long num2 = num;
				if (num2 <= 0)
				{
					continue;
				}
				Container container = (streamData.Container ?? throw new YoutubeExplodeException("Failed to extract the stream container.")).Pipe((string s) => new Container(s));
				Bitrate bitrate = (streamData.Bitrate ?? throw new YoutubeExplodeException("Failed to extract the stream bitrate.")).Pipe((long s) => new Bitrate(s));
				if (!string.IsNullOrWhiteSpace(streamData.VideoCodec))
				{
					int num3 = streamData.VideoFramerate ?? 24;
					VideoQuality videoQuality = ((!string.IsNullOrWhiteSpace(streamData.VideoQualityLabel)) ? VideoQuality.FromLabel(streamData.VideoQualityLabel, num3) : VideoQuality.FromItag(itag, num3));
					Resolution resolution = ((streamData.VideoWidth.HasValue && streamData.VideoHeight.HasValue) ? new Resolution(streamData.VideoWidth.Value, streamData.VideoHeight.Value) : videoQuality.GetDefaultVideoResolution());
					if (!string.IsNullOrWhiteSpace(streamData.AudioCodec))
					{
						yield return new MuxedStreamInfo(url, container, new FileSize(num2), bitrate, streamData.AudioCodec, streamData.VideoCodec, videoQuality, resolution);
					}
					else
					{
						yield return new VideoOnlyStreamInfo(url, container, new FileSize(num2), bitrate, streamData.VideoCodec, videoQuality, resolution);
					}
				}
				else
				{
					if (string.IsNullOrWhiteSpace(streamData.AudioCodec))
					{
						throw new YoutubeExplodeException("Failed to extract the stream codec.");
					}
					yield return new AudioOnlyStreamInfo(url, container, new FileSize(num2), bitrate, streamData.AudioCodec);
				}
			}
		}

		private async IAsyncEnumerable<IStreamInfo> GetStreamInfosAsync(VideoId videoId, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			PlayerResponse playerResponse = await _controller.GetPlayerResponseAsync(videoId, cancellationToken);
			if (!string.IsNullOrWhiteSpace(playerResponse.PreviewVideoId))
			{
				throw new VideoRequiresPurchaseException($"Video '{videoId}' requires purchase and cannot be played.", playerResponse.PreviewVideoId);
			}
			if (!playerResponse.IsPlayable)
			{
				CipherManifest cipherManifest = await ResolveCipherManifestAsync(cancellationToken);
				playerResponse = await _controller.GetPlayerResponseAsync(videoId, cipherManifest.SignatureTimestamp, cancellationToken);
			}
			if (!playerResponse.IsPlayable)
			{
				throw new VideoUnplayableException($"Video '{videoId}' is unplayable. " + "Reason: '" + playerResponse.PlayabilityError + "'.");
			}
			await foreach (IStreamInfo item in GetStreamInfosAsync(playerResponse.Streams, cancellationToken))
			{
				yield return item;
			}
			if (string.IsNullOrWhiteSpace(playerResponse.DashManifestUrl))
			{
				yield break;
			}
			DashManifest dashManifest = null;
			try
			{
				dashManifest = await _controller.GetDashManifestAsync(playerResponse.DashManifestUrl, cancellationToken);
			}
			catch (HttpRequestException)
			{
			}
			if (dashManifest == null)
			{
				yield break;
			}
			await foreach (IStreamInfo item2 in GetStreamInfosAsync(dashManifest.Streams, cancellationToken))
			{
				yield return item2;
			}
		}

		public async ValueTask<StreamManifest> GetManifestAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			int retriesRemaining = 5;
			while (true)
			{
				List<IStreamInfo> streamInfos = await GetStreamInfosAsync(videoId, cancellationToken);
				if (!streamInfos.Any())
				{
					break;
				}
				using (HttpResponseMessage httpResponseMessage = await _http.HeadAsync(streamInfos.First().Url, cancellationToken))
				{
					if (httpResponseMessage.StatusCode != HttpStatusCode.Forbidden || retriesRemaining <= 0)
					{
						httpResponseMessage.EnsureSuccessStatusCode();
						return new StreamManifest(streamInfos);
					}
				}
				retriesRemaining--;
			}
			throw new VideoUnplayableException($"Video '{videoId}' does not contain any playable streams.");
		}

		public async ValueTask<string> GetHttpLiveStreamUrlAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			PlayerResponse playerResponse = await _controller.GetPlayerResponseAsync(videoId, cancellationToken);
			if (!playerResponse.IsPlayable)
			{
				throw new VideoUnplayableException($"Video '{videoId}' is unplayable. " + "Reason: '" + playerResponse.PlayabilityError + "'.");
			}
			if (string.IsNullOrWhiteSpace(playerResponse.HlsManifestUrl))
			{
				throw new YoutubeExplodeException("Failed to extract the HTTP Live Stream manifest URL. " + $"Video '{videoId}' is likely not a live stream.");
			}
			return playerResponse.HlsManifestUrl;
		}

		public async ValueTask<Stream> GetAsync(IStreamInfo streamInfo, CancellationToken cancellationToken = default(CancellationToken))
		{
			MediaStream stream = new MediaStream(_http, streamInfo);
			await stream.InitializeAsync(cancellationToken);
			return stream;
		}

		public async ValueTask CopyToAsync(IStreamInfo streamInfo, Stream destination, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			using Stream input = await GetAsync(streamInfo, cancellationToken);
			await input.CopyToAsync(destination, progress, cancellationToken);
		}

		public async ValueTask DownloadAsync(IStreamInfo streamInfo, string filePath, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			using FileStream destination = File.Create(filePath);
			await CopyToAsync(streamInfo, destination, progress, cancellationToken);
		}
	}
	internal class StreamController : VideoController
	{
		public StreamController(HttpClient http)
			: base(http)
		{
		}

		public async ValueTask<PlayerSource> GetPlayerSourceAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			string value = Regex.Match(await PolyfillExtensions.GetStringAsync(base.Http, "https://www.youtube.com/iframe_api", cancellationToken), "player\\\\?/([0-9a-fA-F]{8})\\\\?/").Groups[1].Value;
			if (string.IsNullOrWhiteSpace(value))
			{
				throw new YoutubeExplodeException("Failed to extract the player version.");
			}
			return PlayerSource.Parse(await PolyfillExtensions.GetStringAsync(base.Http, "https://www.youtube.com/s/player/" + value + "/player_ias.vflset/en_US/base.js", cancellationToken));
		}

		public async ValueTask<DashManifest> GetDashManifestAsync(string url, CancellationToken cancellationToken = default(CancellationToken))
		{
			return DashManifest.Parse(await PolyfillExtensions.GetStringAsync(base.Http, url, cancellationToken));
		}
	}
	public class StreamManifest
	{
		public IReadOnlyList<IStreamInfo> Streams { get; }

		public StreamManifest(IReadOnlyList<IStreamInfo> streams)
		{
			Streams = streams;
		}

		public IEnumerable<IAudioStreamInfo> GetAudioStreams()
		{
			return Streams.OfType<IAudioStreamInfo>();
		}

		public IEnumerable<IVideoStreamInfo> GetVideoStreams()
		{
			return Streams.OfType<IVideoStreamInfo>();
		}

		public IEnumerable<MuxedStreamInfo> GetMuxedStreams()
		{
			return Streams.OfType<MuxedStreamInfo>();
		}

		public IEnumerable<AudioOnlyStreamInfo> GetAudioOnlyStreams()
		{
			return GetAudioStreams().OfType<AudioOnlyStreamInfo>();
		}

		public IEnumerable<VideoOnlyStreamInfo> GetVideoOnlyStreams()
		{
			return GetVideoStreams().OfType<VideoOnlyStreamInfo>();
		}
	}
	public class VideoOnlyStreamInfo : IVideoStreamInfo, IStreamInfo
	{
		public string Url { get; }

		public Container Container { get; }

		public FileSize Size { get; }

		public Bitrate Bitrate { get; }

		public string VideoCodec { get; }

		public VideoQuality VideoQuality { get; }

		public Resolution VideoResolution { get; }

		public VideoOnlyStreamInfo(string url, Container container, FileSize size, Bitrate bitrate, string videoCodec, VideoQuality videoQuality, Resolution videoResolution)
		{
			Url = url;
			Container = container;
			Size = size;
			Bitrate = bitrate;
			VideoCodec = videoCodec;
			VideoQuality = videoQuality;
			VideoResolution = videoResolution;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"Video-only ({VideoQuality} | {Container})";
		}
	}
	public readonly struct VideoQuality : IComparable<VideoQuality>, IEquatable<VideoQuality>
	{
		public string Label { get; }

		public int MaxHeight { get; }

		public int Framerate { get; }

		public bool IsHighDefinition => MaxHeight >= 1080;

		public VideoQuality(string label, int maxHeight, int framerate)
		{
			Label = label;
			MaxHeight = maxHeight;
			Framerate = framerate;
		}

		public VideoQuality(int maxHeight, int framerate)
			: this(FormatLabel(maxHeight, framerate), maxHeight, framerate)
		{
		}

		internal Resolution GetDefaultVideoResolution()
		{
			return MaxHeight switch
			{
				144 => new Resolution(256, 144), 
				240 => new Resolution(426, 240), 
				360 => new Resolution(640, 360), 
				480 => new Resolution(854, 480), 
				720 => new Resolution(1280, 720), 
				1080 => new Resolution(1920, 1080), 
				1440 => new Resolution(2560, 1440), 
				2160 => new Resolution(3840, 2160), 
				2880 => new Resolution(5120, 2880), 
				3072 => new Resolution(4096, 3072), 
				4320 => new Resolution(7680, 4320), 
				_ => new Resolution(16 * MaxHeight / 9, MaxHeight), 
			};
		}

		public override string ToString()
		{
			return Label;
		}

		private static string FormatLabel(int maxHeight, int framerate)
		{
			if (framerate <= 30)
			{
				return $"{maxHeight}p";
			}
			int num = (int)Math.Ceiling((double)framerate / 10.0) * 10;
			return $"{maxHeight}p{num}";
		}

		internal static VideoQuality FromLabel(string label, int framerateFallback)
		{
			Match match = Regex.Match(label, "^(\\d+)\\D(\\d+)?");
			int maxHeight = match.Groups[1].Value.ParseInt();
			return new VideoQuality(label, maxHeight, match.Groups[2].Value.NullIfWhiteSpace()?.ParseIntOrNull() ?? framerateFallback);
		}

		internal static VideoQuality FromItag(int itag, int framerate)
		{
			return new VideoQuality(itag switch
			{
				5 => 144, 
				6 => 240, 
				13 => 144, 
				17 => 144, 
				18 => 360, 
				22 => 720, 
				34 => 360, 
				35 => 480, 
				36 => 240, 
				37 => 1080, 
				38 => 3072, 
				43 => 360, 
				44 => 480, 
				45 => 720, 
				46 => 1080, 
				59 => 480, 
				78 => 480, 
				82 => 360, 
				83 => 480, 
				84 => 720, 
				85 => 1080, 
				91 => 144, 
				92 => 240, 
				93 => 360, 
				94 => 480, 
				95 => 720, 
				96 => 1080, 
				100 => 360, 
				101 => 480, 
				102 => 720, 
				132 => 240, 
				151 => 144, 
				133 => 240, 
				134 => 360, 
				135 => 480, 
				136 => 720, 
				137 => 1080, 
				138 => 4320, 
				142 => 240, 
				143 => 360, 
				144 => 480, 
				145 => 720, 
				146 => 1080, 
				160 => 144, 
				161 => 144, 
				167 => 360, 
				168 => 480, 
				169 => 720, 
				170 => 1080, 
				212 => 480, 
				213 => 480, 
				214 => 720, 
				215 => 720, 
				216 => 1080, 
				217 => 1080, 
				218 => 480, 
				219 => 480, 
				222 => 480, 
				223 => 480, 
				224 => 720, 
				225 => 720, 
				226 => 1080, 
				227 => 1080, 
				242 => 240, 
				243 => 360, 
				244 => 480, 
				245 => 480, 
				246 => 480, 
				247 => 720, 
				248 => 1080, 
				264 => 1440, 
				266 => 2160, 
				271 => 1440, 
				272 => 2160, 
				278 => 144, 
				298 => 720, 
				299 => 1080, 
				302 => 720, 
				303 => 1080, 
				308 => 1440, 
				313 => 2160, 
				315 => 2160, 
				330 => 144, 
				331 => 240, 
				332 => 360, 
				333 => 480, 
				334 => 720, 
				335 => 1080, 
				336 => 1440, 
				337 => 2160, 
				399 => 1080, 
				398 => 720, 
				397 => 480, 
				396 => 360, 
				395 => 240, 
				394 => 144, 
				_ => throw new ArgumentException($"Unrecognized itag '{itag}'.", "itag"), 
			}, framerate);
		}

		public int CompareTo(VideoQuality other)
		{
			int num = MaxHeight.CompareTo(other.MaxHeight);
			if (num != 0)
			{
				return num;
			}
			int num2 = Framerate.CompareTo(other.Framerate);
			if (num2 != 0)
			{
				return num2;
			}
			return StringComparer.OrdinalIgnoreCase.Compare(Label, other.Label);
		}

		public bool Equals(VideoQuality other)
		{
			if (StringComparer.OrdinalIgnoreCase.Equals(Label, other.Label) && MaxHeight == other.MaxHeight)
			{
				return Framerate == other.Framerate;
			}
			return false;
		}

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

		public override int GetHashCode()
		{
			return HashCode.Combine(StringComparer.OrdinalIgnoreCase.GetHashCode(Label), MaxHeight, Framerate);
		}

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

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

		public static bool operator >(VideoQuality left, VideoQuality right)
		{
			return left.CompareTo(right) > 0;
		}

		public static bool operator <(VideoQuality left, VideoQuality right)
		{
			return left.CompareTo(right) < 0;
		}
	}
}
namespace YoutubeExplode.Videos.ClosedCaptions
{
	public class ClosedCaption
	{
		public string Text { get; }

		public TimeSpan Offset { get; }

		public TimeSpan Duration { get; }

		public IReadOnlyList<ClosedCaptionPart> Parts { get; }

		public ClosedCaption(string text, TimeSpan offset, TimeSpan duration, IReadOnlyList<ClosedCaptionPart> parts)
		{
			Text = text;
			Offset = offset;
			Duration = duration;
			Parts = parts;
		}

		public ClosedCaptionPart? TryGetPartByTime(TimeSpan time)
		{
			return Parts.FirstOrDefault((ClosedCaptionPart p) => p.Offset >= time);
		}

		public ClosedCaptionPart GetPartByTime(TimeSpan time)
		{
			return TryGetPartByTime(time) ?? throw new InvalidOperationException($"No closed caption part found at {time}.");
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return Text;
		}
	}
	public class ClosedCaptionClient
	{
		private readonly ClosedCaptionController _controller;

		public ClosedCaptionClient(HttpClient http)
		{
			_controller = new ClosedCaptionController(http);
		}

		private async IAsyncEnumerable<ClosedCaptionTrackInfo> GetClosedCaptionTrackInfosAsync(VideoId videoId, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			foreach (PlayerResponse.ClosedCaptionTrackData closedCaptionTrack in (await _controller.GetPlayerResponseAsync(videoId, null, cancellationToken)).ClosedCaptionTracks)
			{
				string url = closedCaptionTrack.Url ?? throw new YoutubeExplodeException("Failed to extract the track URL.");
				string code = closedCaptionTrack.LanguageCode ?? throw new YoutubeExplodeException("Failed to extract the track language code.");
				string name = closedCaptionTrack.LanguageName ?? throw new YoutubeExplodeException("Failed to extract the track language name.");
				yield return new ClosedCaptionTrackInfo(url, new Language(code, name), closedCaptionTrack.IsAutoGenerated);
			}
		}

		public async ValueTask<ClosedCaptionManifest> GetManifestAsync(VideoId videoId, CancellationToken cancellationToken = default(CancellationToken))
		{
			return new ClosedCaptionManifest(await GetClosedCaptionTrackInfosAsync(videoId, cancellationToken));
		}

		private async IAsyncEnumerable<ClosedCaption> GetClosedCaptionsAsync(ClosedCaptionTrackInfo trackInfo, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			foreach (ClosedCaptionTrackResponse.CaptionData caption in (await _controller.GetClosedCaptionTrackResponseAsync(trackInfo.Url, cancellationToken)).Captions)
			{
				string text = caption.Text;
				if (string.IsNullOrEmpty(text))
				{
					continue;
				}
				TimeSpan? offset = caption.Offset;
				if (!offset.HasValue)
				{
					continue;
				}
				TimeSpan valueOrDefault = offset.GetValueOrDefault();
				offset = caption.Duration;
				if (!offset.HasValue)
				{
					continue;
				}
				TimeSpan valueOrDefault2 = offset.GetValueOrDefault();
				List<ClosedCaptionPart> list = new List<ClosedCaptionPart>();
				foreach (ClosedCaptionTrackResponse.PartData part in caption.Parts)
				{
					string text2 = part.Text;
					if (!string.IsNullOrEmpty(text2))
					{
						TimeSpan offset2 = part.Offset ?? throw new YoutubeExplodeException("Failed to extract the caption part offset.");
						ClosedCaptionPart item = new ClosedCaptionPart(text2, offset2);
						list.Add(item);
					}
				}
				yield return new ClosedCaption(text, valueOrDefault, valueOrDefault2, list);
			}
		}

		public async ValueTask<ClosedCaptionTrack> GetAsync(ClosedCaptionTrackInfo trackInfo, CancellationToken cancellationToken = default(CancellationToken))
		{
			return new ClosedCaptionTrack(await GetClosedCaptionsAsync(trackInfo, cancellationToken));
		}

		public async ValueTask WriteToAsync(ClosedCaptionTrackInfo trackInfo, TextWriter writer, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			ClosedCaptionTrack track = await GetAsync(trackInfo, cancellationToken);
			StringBuilder buffer = new StringBuilder();
			foreach (var (closedCaption, i) in track.Captions.WithIndex())
			{
				cancellationToken.ThrowIfCancellationRequested();
				buffer.AppendLine((i + 1).ToString(CultureInfo.InvariantCulture)).Append(FormatTimestamp(closedCaption.Offset)).Append(" --> ")
					.Append(FormatTimestamp(closedCaption.Offset + closedCaption.Duration))
					.AppendLine()
					.AppendLine(closedCaption.Text.Replace("-->", "––>"));
				await writer.WriteLineAsync(buffer.ToString());
				buffer.Clear();
				progress?.Report(((double)i + 1.0) / (double)track.Captions.Count);
			}
			static string FormatTimestamp(TimeSpan value)
			{
				return Math.Floor(value.TotalHours).ToString("00", CultureInfo.InvariantCulture) + ":" + value.Minutes.ToString("00", CultureInfo.InvariantCulture) + ":" + value.Seconds.ToString("00", CultureInfo.InvariantCulture) + "," + value.Milliseconds.ToString("000", CultureInfo.InvariantCulture);
			}
		}

		public async ValueTask DownloadAsync(ClosedCaptionTrackInfo trackInfo, string filePath, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			using StreamWriter writer = File.CreateText(filePath);
			await WriteToAsync(trackInfo, writer, progress, cancellationToken);
		}
	}
	internal class ClosedCaptionController : VideoController
	{
		public ClosedCaptionController(HttpClient http)
			: base(http)
		{
		}

		public async ValueTask<ClosedCaptionTrackResponse> GetClosedCaptionTrackResponseAsync(string url, CancellationToken cancellationToken = default(CancellationToken))
		{
			string requestUri = url.Pipe((string s) => UrlEx.SetQueryParameter(s, "format", "3")).Pipe((string s) => UrlEx.SetQueryParameter(s, "fmt", "3"));
			return ClosedCaptionTrackResponse.Parse(await PolyfillExtensions.GetStringAsync(base.Http, requestUri, cancellationToken));
		}
	}
	public class ClosedCaptionManifest
	{
		public IReadOnlyList<ClosedCaptionTrackInfo> Tracks { get; }

		public ClosedCaptionManifest(IReadOnlyList<ClosedCaptionTrackInfo> tracks)
		{
			Tracks = tracks;
		}

		public ClosedCaptionTrackInfo? TryGetByLanguage(string language)
		{
			string language2 = language;
			return Tracks.FirstOrDefault((ClosedCaptionTrackInfo t) => string.Equals(t.Language.Code, language2, StringComparison.OrdinalIgnoreCase) || string.Equals(t.Language.Name, language2, StringComparison.OrdinalIgnoreCase));
		}

		public ClosedCaptionTrackInfo GetByLanguage(string language)
		{
			return TryGetByLanguage(language) ?? throw new InvalidOperationException("No closed caption track available for language '" + language + "'.");
		}
	}
	public class ClosedCaptionPart
	{
		public string Text { get; }

		public TimeSpan Offset { get; }

		public ClosedCaptionPart(string text, TimeSpan offset)
		{
			Text = text;
			Offset = offset;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return Text;
		}
	}
	public class ClosedCaptionTrack
	{
		public IReadOnlyList<ClosedCaption> Captions { get; }

		public ClosedCaptionTrack(IReadOnlyList<ClosedCaption> captions)
		{
			Captions = captions;
		}

		public ClosedCaption? TryGetByTime(TimeSpan time)
		{
			return Captions.FirstOrDefault((ClosedCaption c) => time >= c.Offset && time <= c.Offset + c.Duration);
		}

		public ClosedCaption GetByTime(TimeSpan time)
		{
			return TryGetByTime(time) ?? throw new InvalidOperationException($"No closed caption found at {time}.");
		}
	}
	public class ClosedCaptionTrackInfo
	{
		public string Url { get; }

		public Language Language { get; }

		public bool IsAutoGenerated { get; }

		public ClosedCaptionTrackInfo(string url, Language language, bool isAutoGenerated)
		{
			Url = url;
			Language = language;
			IsAutoGenerated = isAutoGenerated;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return $"CC Track ({Language})";
		}
	}
	public readonly struct Language : IEquatable<Language>
	{
		public string Code { get; }

		public string Name { get; }

		public Language(string code, string name)
		{
			Code = code;
			Name = name;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return Code + " (" + Name + ")";
		}

		public bool Equals(Language other)
		{
			return StringComparer.OrdinalIgnoreCase.Equals(Code, other.Code);
		}

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

		public override int GetHashCode()
		{
			return StringComparer.OrdinalIgnoreCase.GetHashCode(Code);
		}

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

		public static bool operator !=(Language left, Language right)
		{
			return !(left == right);
		}
	}
}
namespace YoutubeExplode.Utils
{
	internal abstract class ClientDelegatingHandler : HttpMessageHandler
	{
		[CompilerGenerated]
		private HttpClient <http>P;

		[CompilerGenerated]
		private bool <disposeClient>P;

		protected ClientDelegatingHandler(HttpClient http, bool disposeClient = false)
		{
			<http>P = http;
			<disposeClient>P = disposeClient;
			base..ctor();
		}

		protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
		{
			using HttpRequestMessage clonedRequest = request.Clone();
			return await <http>P.SendAsync(clonedRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && <disposeClient>P)
			{
				<http>P.Dispose();
			}
			base.Dispose(disposing);
		}
	}
	internal static class Hash
	{
		public static byte[] Compute(HashAlgorithm algorithm, byte[] data)
		{
			using (algorithm)
			{
				return algorithm.ComputeHash(data);
			}
		}
	}
	internal static class Html
	{
		private static readonly HtmlParser HtmlParser = new HtmlParser();

		public static IHtmlDocument Parse(string source)
		{
			return HtmlParser.ParseDocument(source);
		}
	}
	internal static class Http
	{
		private static readonly Lazy<HttpClient> HttpClientLazy = new Lazy<HttpClient>(() => new HttpClient());

		public static HttpClient Client => HttpClientLazy.Value;
	}
	internal static class Json
	{
		public static string Extract(string source)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			bool flag = false;
			foreach (var item3 in source.WithIndex())
			{
				char item = item3.value;
				int item2 = item3.index;
				char c = ((item2 > 0) ? source[item2 - 1] : '\0');
				stringBuilder.Append(item);
				if (item == '"' && c != '\\')
				{
					flag = !flag;
				}
				else if (item == '{' && !flag)
				{
					num++;
				}
				else if (item == '}' && !flag)
				{
					num--;
				}
				if (num == 0)
				{
					break;
				}
			}
			return stringBuilder.ToString();
		}

		public static JsonElement Parse(string source)
		{
			using JsonDocument jsonDocument = JsonDocument.Parse(source);
			return jsonDocument.RootElement.Clone();
		}

		public static JsonElement? TryParse(string source)
		{
			try
			{
				return Parse(source);
			}
			catch (JsonException)
			{
				return null;
			}
		}
	}
	internal static class UrlEx
	{
		private static IEnumerable<KeyValuePair<string, string>> EnumerateQueryParameters(string url)
		{
			string text = (url.Contains('?') ? url.SubstringAfter("?") : url);
			string[] array = text.Split('&');
			foreach (string str in array)
			{
				string text2 = WebUtility.UrlDecode(str.SubstringUntil("="));
				string value = WebUtility.UrlDecode(str.SubstringAfter("="));
				if (!string.IsNullOrWhiteSpace(text2))
				{
					yield return new KeyValuePair<string, string>(text2, value);
				}
			}
		}

		public static IReadOnlyDictionary<string, string> GetQueryParameters(string url)
		{
			return EnumerateQueryParameters(url).ToDictionary<KeyValuePair<string, string>, string, string>((KeyValuePair<string, string> kvp) => kvp.Key, (KeyValuePair<string, string> kvp) => kvp.Value);
		}

		private static KeyValuePair<string, string>? TryGetQueryParameter(string url, string key)
		{
			foreach (KeyValuePair<string, string> item in EnumerateQueryParameters(url))
			{
				if (string.Equals(item.Key, key, StringComparison.Ordinal))
				{
					return item;
				}
			}
			return null;
		}

		public static string? TryGetQueryParameterValue(string url, string key)
		{
			return TryGetQueryParameter(url, key)?.Value;
		}

		public static bool ContainsQueryParameter(string url, string key)
		{
			return TryGetQueryParameterValue(url, key) != null;
		}

		public static string RemoveQueryParameter(string url, string key)
		{
			if (!ContainsQueryParameter(url, key))
			{
				return url;
			}
			UriBuilder uriBuilder = new UriBuilder(url);
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, string> item in EnumerateQueryParameters(url))
			{
				if (!string.Equals(item.Key, key, StringComparison.Ordinal))
				{
					stringBuilder.Append((stringBuilder.Length > 0) ? '&' : '?');
					stringBuilder.Append(WebUtility.UrlEncode(item.Key));
					stringBuilder.Append('=');
					stringBuilder.Append(WebUtility.UrlEncode(item.Value));
				}
			}
			uriBuilder.Query = stringBuilder.ToString();
			return uriBuilder.ToString();
		}

		public static string SetQueryParameter(string url, string key, string value)
		{
			string text = RemoveQueryParameter(url, key);
			bool flag = text.Contains('?');
			return text + (flag ? '&' : '?') + WebUtility.UrlEncode(key) + "=" + WebUtility.UrlEncode(value);
		}
	}
	internal static class Xml
	{
		public static XElement Parse(string source)
		{
			return XElement.Parse(source, LoadOptions.PreserveWhitespace).StripNamespaces();
		}
	}
}
namespace YoutubeExplode.Utils.Extensions
{
	internal static class AsyncCollectionExtensions
	{
		public static async IAsyncEnumerable<T> TakeAsync<T>(this IAsyncEnumerable<T> source, int count)
		{
			int currentCount = 0;
			await foreach (T item in source)
			{
				if (currentCount >= count)
				{
					break;
				}
				yield return item;
				currentCount++;
			}
		}

		public static async IAsyncEnumerable<T> SelectManyAsync<TSource, T>(this IAsyncEnumerable<TSource> source, Func<TSource, IEnumerable<T>> transform)
		{
			await foreach (TSource item in source)
			{
				foreach (T item2 in transform(item))
				{
					yield return item2;
				}
			}
		}

		public static async IAsyncEnumerable<T> OfTypeAsync<T>(this IAsyncEnumerable<object> source)
		{
			await foreach (object item in source)
			{
				if (item is T)
				{
					yield return (T)item;
				}
			}
		}

		public static async ValueTask<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source)
		{
			List<T> list = new List<T>();
			await foreach (T item in source)
			{
				list.Add(item);
			}
			return list;
		}

		public static ValueTaskAwaiter<List<T>> GetAwaiter<T>(this IAsyncEnumerable<T> source)
		{
			return source.ToListAsync().GetAwaiter();
		}
	}
	internal static class BinaryExtensions
	{
		public static string ToHex(this byte[] data, bool isUpperCase = true)
		{
			StringBuilder stringBuilder = new StringBuilder(2 * data.Length);
			foreach (byte b in data)
			{
				stringBuilder.Append(b.ToString(isUpperCase ? "X2" : "x2", CultureInfo.InvariantCulture));
			}
			return stringBuilder.ToString();
		}
	}
	internal static class CollectionExtensions
	{
		public static IEnumerable<(T value, int index)> WithIndex<T>(this IEnumerable<T> source)
		{
			int i = 0;
			foreach (T item in source)
			{
				yield return (item, i++);
			}
		}

		public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source) where T : class
		{
			foreach (T item in source)
			{
				if (item != null)
				{
					yield return item;
				}
			}
		}

		public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source) where T : struct
		{
			foreach (T? item in source)
			{
				if (item.HasValue)
				{
					yield return item.Value;
				}
			}
		}

		public static T? ElementAtOrNull<T>(this IEnumerable<T> source, int index) where T : struct
		{
			IReadOnlyList<T> readOnlyList = (source as IReadOnlyList<T>) ?? source.ToArray();
			if (index >= readOnlyList.Count)
			{
				return null;
			}
			return readOnlyList[index];
		}

		public static T? FirstOrNull<T>(this IEnumerable<T> source) where T : struct
		{
			using (IEnumerator<T> enumerator = source.GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					return enumerator.Current;
				}
			}
			return null;
		}
	}
	internal static class GenericExtensions
	{
		public static TOut Pipe<TIn, TOut>(this TIn input, Func<TIn, TOut> transform)
		{
			return transform(input);
		}
	}
	internal static class HttpExtensions
	{
		private class NonDisposableHttpContent : HttpContent
		{
			[CompilerGenerated]
			private HttpContent <content>P;

			public NonDisposableHttpContent(HttpContent content)
			{
				<content>P = content;
				base..ctor();
			}

			protected override async Task SerializeToStreamAsync(Stream stream, TransportContext? context)
			{
				await <content>P.CopyToAsync(stream);
			}

			protected override bool TryComputeLength(out long length)
			{
				length = 0L;
				return false;
			}
		}

		public static HttpRequestMessage Clone(this HttpRequestMessage request)
		{
			HttpRequestMessage httpRequestMessage = new HttpRequestMessage(request.Method, request.RequestUri)
			{
				Version = request.Version,
				Content = ((request.Content != null) ? new NonDisposableHttpContent(request.Content) : null)
			};
			string key;
			IEnumerable<string> value;
			foreach (KeyValuePair<string, IEnumerable<string>> header in request.Headers)
			{
				header.Deconstruct(out key, out value);
				string name = key;
				IEnumerable<string> values = value;
				httpRequestMessage.Headers.TryAddWithoutValidation(name, values);
			}
			if (request.Content != null && httpRequestMessage.Content != null)
			{
				foreach (KeyValuePair<string, IEnumerable<string>> header2 in request.Content.Headers)
				{
					header2.Deconstruct(out key, out value);
					string name2 = key;
					IEnumerable<string> values2 = value;
					httpRequestMessage.Content.Headers.TryAddWithoutValidation(name2, values2);
				}
			}
			return httpRequestMessage;
		}

		public static async ValueTask<HttpResponseMessage> HeadAsync(this HttpClient http, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
		{
			using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Head, requestUri);
			return await http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
		}

		public static async ValueTask<long?> TryGetContentLengthAsync(this HttpClient http, string requestUri, bool ensureSuccess = true, CancellationToken cancellationToken = default(CancellationToken))
		{
			using HttpResponseMessage httpResponseMessage = await http.HeadAsync(requestUri, cancellationToken);
			if (ensureSuccess)
			{
				httpResponseMessage.EnsureSuccessStatusCode();
			}
			return httpResponseMessage.Content.Headers.ContentLength;
		}
	}
	internal static class JsonExtensions
	{
		public static JsonElement? GetPropertyOrNull(this JsonElement element, string propertyName)
		{
			if (element.ValueKind != JsonValueKind.Object)
			{
				return null;
			}
			if (element.TryGetProperty(propertyName, out var value) && value.ValueKind != JsonValueKind.Null && value.ValueKind != 0)
			{
				return value;
			}
			return null;
		}

		public static string? GetStringOrNull(this JsonElement element)
		{
			if (element.ValueKind != JsonValueKind.String)
			{
				return null;
			}
			return element.GetString();
		}

		public static int? GetInt32OrNull(this JsonElement element)
		{
			if (element.ValueKind != JsonValueKind.Number || !element.TryGetInt32(out var value))
			{
				return null;
			}
			return value;
		}

		public static long? GetInt64OrNull(this JsonElement element)
		{
			if (element.ValueKind != JsonValueKind.Number || !element.TryGetInt64(out var value))
			{
				return null;
			}
			return value;
		}

		public static JsonElement.ArrayEnumerator? EnumerateArrayOrNull(this JsonElement element)
		{
			if (element.ValueKind != JsonValueKind.Array)
			{
				return null;
			}
			return element.EnumerateArray();
		}

		public static JsonElement.ArrayEnumerator EnumerateArrayOrEmpty(this JsonElement element)
		{
			return element.EnumerateArrayOrNull().GetValueOrDefault();
		}

		public static JsonElement.ObjectEnumerator? EnumerateObjectOrNull(this JsonElement element)
		{
			if (element.ValueKind != JsonValueKind.Object)
			{
				return null;
			}
			return element.EnumerateObject();
		}

		public static JsonElement.ObjectEnumerator EnumerateObjectOrEmpty(this JsonElement element)
		{
			return element.EnumerateObjectOrNull().GetValueOrDefault();
		}

		public static IEnumerable<JsonElement> EnumerateDescendantProperties(this JsonElement element, string propertyName)
		{
			string propertyName2 = propertyName;
			JsonElement? propertyOrNull = element.GetPropertyOrNull(propertyName2);
			if (propertyOrNull.HasValue)
			{
				yield return propertyOrNull.Value;
			}
			IEnumerable<JsonElement> enumerable = element.EnumerateArrayOrEmpty().SelectMany((JsonElement j) => j.EnumerateDescendantProperties(propertyName2));
			foreach (JsonElement item in enumerable)
			{
				yield return item;
			}
			IEnumerable<JsonElement> enumerable2 = element.EnumerateObjectOrEmpty().SelectMany((JsonProperty j) => j.Value.EnumerateDescendantProperties(propertyName2));
			foreach (JsonElement item2 in enumerable2)
			{
				yield return item2;
			}
		}
	}
	internal static class StreamExtensions
	{
		public static async ValueTask CopyToAsync(this Stream source, Stream destination, IProgress<double>? progress = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			using IMemoryOwner<byte> buffer = MemoryPool<byte>.Shared.Rent(81920);
			long totalBytesRead = 0L;
			while (true)
			{
				int bytesRead = await source.ReadAsync(buffer.Memory, cancellationToken);
				if (bytesRead <= 0)
				{
					break;
				}
				await destination.WriteAsync(buffer.Memory.Slice(0, bytesRead), cancellationToken);
				totalBytesRead += bytesRead;
				progress?.Report(1.0 * (double)totalBytesRead / (double)source.Length);
			}
		}
	}
	internal static class StringExtensions
	{
		public static string? NullIfWhiteSpace(this string str)
		{
			if (string.IsNullOrWhiteSpace(str))
			{
				return null;
			}
			return str;
		}

		public static string SubstringUntil(this string str, string sub, StringComparison comparison = StringComparison.Ordinal)
		{
			int num = str.IndexOf(sub, comparison);
			if (num >= 0)
			{
				return str.Substring(0, num);
			}
			return str;
		}

		public static string SubstringAfter(this string str, string sub, StringComparison comparison = StringComparison.Ordinal)
		{
			int num = str.IndexOf(sub, comparison);
			if (num >= 0)
			{
				return str.Substring(num + sub.Length, str.Length - num - sub.Length);
			}
			return string.Empty;
		}

		public static string StripNonDigit(this string str)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char item in str.Where(char.IsDigit))
			{
				stringBuilder.Append(item);
			}
			return stringBuilder.ToString();
		}

		public static string Reverse(this string str)
		{
			StringBuilder stringBuilder = new StringBuilder(str.Length);
			for (int num = str.Length - 1; num >= 0; num--)
			{
				stringBuilder.Append(str[num]);
			}
			return stringBuilder.ToString();
		}

		public static string SwapChars(this string str, int firstCharIndex, int secondCharIndex)
		{
			return new StringBuilder(str)
			{
				[firstCharIndex] = str[secondCharIndex],
				[secondCharIndex] = str[firstCharIndex]
			}.ToString();
		}

		public static int? ParseIntOrNull(this string str)
		{
			if (!int.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out var result))
			{
				return null;
			}
			return result;
		}

		public static int ParseInt(this string str)
		{
			return str.ParseIntOrNull() ?? throw new FormatException("Cannot parse integer number from string '" + str + "'.");
		}

		public static long? ParseLongOrNull(this string str)
		{
			if (!long.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out var result))
			{
				return null;
			}
			return result;
		}

		public static double? ParseDoubleOrNull(this string str)
		{
			if (!double.TryParse(str, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.InvariantInfo, out var result))
			{
				return null;
			}
			return result;
		}

		public static TimeSpan? ParseTimeSpanOrNull(this string str, string[] formats)
		{
			if (!TimeSpan.TryParseExact(str, formats, DateTimeFormatInfo.InvariantInfo, out var result))
			{
				return null;
			}
			return result;
		}

		public static DateTimeOffset? ParseDateTimeOffsetOrNull(this string str)
		{
			if (!DateTimeOffset.TryParse(str, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out var result))
			{
				return null;
			}
			return result;
		}

		public static string ConcatToString<T>(this IEnumerable<T> source)
		{
			return string.Concat(source);
		}
	}
	internal static class UriExtensions
	{
		public static string GetDomain(this Uri uri)
		{
			return uri.Scheme + Uri.SchemeDelimiter + uri.Host;
		}
	}
	internal static class XElementExtensions
	{
		public static XElement StripNamespaces(this XElement element)
		{
			XElement xElement = new XElement(element);
			foreach (XElement item in xElement.DescendantsAndSelf())
			{
				item.Name = XNamespace.None.GetName(item.Name.LocalName);
				item.ReplaceAttributes(from a in item.Attributes()
					where !a.IsNamespaceDeclaration
					where a.Name.Namespace != XNamespace.Xml && a.Name.Namespace != XNamespace.Xmlns
					select new XAttribute(XNamespace.None.GetName(a.Name.LocalName), a.Value));
			}
			return xElement;
		}
	}
}
namespace YoutubeExplode.Search
{
	public class ChannelSearchResult : ISearchResult, IBatchItem, IChannel
	{
		public ChannelId Id { get; }

		public string Url => $"https://www.youtube.com/channel/{Id}";

		public string Title { get; }

		public IReadOnlyList<Thumbnail> Thumbnails { get; }

		public ChannelSearchResult(ChannelId id, string title, IReadOnlyList<Thumbnail> thumbnails)
		{
			Id = id;
			Title = title;
			Thumbnails = thumbnails;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return "Channel (" + Title + ")";
		}
	}
	public interface ISearchResult : IBatchItem
	{
		string Url { get; }

		string Title { get; }
	}
	public class PlaylistSearchResult : ISearchResult, IBatchItem, IPlaylist
	{
		public PlaylistId Id { get; }

		public string Url => $"https://www.youtube.com/playlist?list={Id}";

		public string Title { get; }

		public Author? Author { get; }

		public IReadOnlyList<Thumbnail> Thumbnails { get; }

		public PlaylistSearchResult(PlaylistId id, string title, Author? author, IReadOnlyList<Thumbnail> thumbnails)
		{
			Id = id;
			Title = title;
			Author = author;
			Thumbnails = thumbnails;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return "Playlist (" + Title + ")";
		}
	}
	public class SearchClient
	{
		private readonly SearchController _controller;

		public SearchClient(HttpClient http)
		{
			_controller = new SearchController(http);
		}

		public async IAsyncEnumerable<Batch<ISearchResult>> GetResultBatchesAsync(string searchQuery, SearchFilter searchFilter, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			int num = -1;
			HashSet<string> encounteredIds = new HashSet<string>(StringComparer.Ordinal);
			string text = null;
			do
			{
				List<ISearchResult> results = new List<ISearchResult>();
				SearchResponse searchResults = await _controller.GetSearchResponseAsync(searchQuery, searchFilter, text, cancellationToken);
				IEnumerator<SearchResponse.VideoData> enumerator = searchResults.Videos.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						SearchResponse.VideoData current = enumerator.Current;
						if (searchFilter != 0 && searchFilter != SearchFilter.Video)
						{
							break;
						}
						string text2 = current.Id ?? throw new YoutubeExplodeException("Failed to extract the video ID.");
						if (encounteredIds.Add(text2))
						{
							string title = current.Title ?? throw new YoutubeExplodeException("Failed to extract the video title.");
							string channelTitle = current.Author ?? throw new YoutubeExplodeException("Failed to extract the video author.");
							string text3 = current.ChannelId ?? throw new YoutubeExplodeException("Failed to extract the video channel ID.");
							Thumbnail[] thumbnails = current.Thumbnails.Select(delegate(ThumbnailData t)
							{
								string? url3 = t.Url ?? throw new YoutubeExplodeException("Failed to extract the video thumbnail URL.");
								int width3 = t.Width ?? throw new YoutubeExplodeException("Failed to extract the video thumbnail width.");
								int height3 = t.Height ?? throw new YoutubeExplodeException("Failed to extract the video thumbnail height.");
								Resolution resolution3 = new Resolution(width3, height3);
								return new Thumbnail(url3, resolution3);
							}).Concat(Thumbnail.GetDefaultSet(text2)).ToArray();
							VideoSearchResult item = new VideoSearchResult(text2, title, new Author(text3, channelTitle), current.Duration, thumbnails);
							results.Add(item);
						}
					}
				}
				finally
				{
					if (num == -1)
					{
						enumerator?.Dispose();
					}
				}
				IEnumerator<SearchResponse.PlaylistData> enumerator2 = searchResults.Playlists.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						SearchResponse.PlaylistData current2 = enumerator2.Current;
						if (searchFilter != 0 && searchFilter != SearchFilter.Playlist)
						{
							break;
						}
						string text4 = current2.Id ?? throw new YoutubeExplodeException("Failed to extract the playlist ID.");
						if (encounteredIds.Add(text4))
						{
							string title2 = current2.Title ?? throw new YoutubeExplodeException("Failed to extract the playlist title.");
							Author author = ((!string.IsNullOrWhiteSpace(current2.ChannelId) && !string.IsNullOrWhiteSpace(current2.Author)) ? new Author(current2.ChannelId, current2.Author) : null);
							Thumbnail[] thumbnails2 = current2.Thumbnails.Select(delegate(ThumbnailData t)
							{
								string? url2 = t.Url ?? throw new YoutubeExplodeException("Failed to extract the playlist thumbnail URL.");
								int width2 = t.Width ?? throw new YoutubeExplodeException("Failed to extract the playlist thumbnail width.");
								int height2 = t.Height ?? throw new YoutubeExplodeException("Failed to extract the playlist thumbnail height.");
								Resolution resolution2 = new Resolution(width2, height2);
								return new Thumbnail(url2, resolution2);
							}).ToArray();
							PlaylistSearchResult item2 = new PlaylistSearchResult(text4, title2, author, thumbnails2);
							results.Add(item2);
						}
					}
				}
				finally
				{
					if (num == -1)
					{
						enumerator2?.Dispose();
					}
				}
				IEnumerator<SearchResponse.ChannelData> enumerator3 = searchResults.Channels.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						SearchResponse.ChannelData current3 = enumerator3.Current;
						if (searchFilter == SearchFilter.None || searchFilter == SearchFilter.Channel)
						{
							string text5 = current3.Id ?? throw new YoutubeExplodeException("Failed to extract the channel ID.");
							string title3 = current3.Title ?? throw new YoutubeExplodeException("Failed to extract the channel title.");
							Thumbnail[] thumbnails3 = current3.Thumbnails.Select(delegate(ThumbnailData t)
							{
								string? url = t.Url ?? throw new YoutubeExplodeException("Failed to extract the channel thumbnail URL.");
								int width = t.Width ?? throw new YoutubeExplodeException("Failed to extract the channel thumbnail width.");
								int height = t.Height ?? throw new YoutubeExplodeException("Failed to extract the channel thumbnail height.");
								Resolution resolution = new Resolution(width, height);
								return new Thumbnail(url, resolution);
							}).ToArray();
							ChannelSearchResult item3 = new ChannelSearchResult(text5, title3, thumbnails3);
							results.Add(item3);
							continue;
						}
						break;
					}
				}
				finally
				{
					if (num == -1)
					{
						enumerator3?.Dispose();
					}
				}
				yield return Batch.Create(results);
				num = -1;
				text = searchResults.ContinuationToken;
			}
			while (!string.IsNullOrWhiteSpace(text));
		}

		public IAsyncEnumerable<Batch<ISearchResult>> GetResultBatchesAsync(string searchQuery, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetResultBatchesAsync(searchQuery, SearchFilter.None, cancellationToken);
		}

		public IAsyncEnumerable<ISearchResult> GetResultsAsync(string searchQuery, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetResultBatchesAsync(searchQuery, cancellationToken).FlattenAsync();
		}

		public IAsyncEnumerable<VideoSearchResult> GetVideosAsync(string searchQuery, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetResultBatchesAsync(searchQuery, SearchFilter.Video, cancellationToken).FlattenAsync().OfTypeAsync<VideoSearchResult>();
		}

		public IAsyncEnumerable<PlaylistSearchResult> GetPlaylistsAsync(string searchQuery, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetResultBatchesAsync(searchQuery, SearchFilter.Playlist, cancellationToken).FlattenAsync().OfTypeAsync<PlaylistSearchResult>();
		}

		public IAsyncEnumerable<ChannelSearchResult> GetChannelsAsync(string searchQuery, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetResultBatchesAsync(searchQuery, SearchFilter.Channel, cancellationToken).FlattenAsync().OfTypeAsync<ChannelSearchResult>();
		}
	}
	internal class SearchController
	{
		[CompilerGenerated]
		private HttpClient <http>P;

		public SearchController(HttpClient http)
		{
			<http>P = http;
			base..ctor();
		}

		public async ValueTask<SearchResponse> GetSearchResponseAsync(string searchQuery, SearchFilter searchFilter, string? continuationToken, CancellationToken cancellationToken = default(CancellationToken))
		{
			HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "https://www.youtube.com/youtubei/v1/search");
			HttpRequestMessage httpRequestMessage2 = httpRequestMessage;
			string text = searchFilter switch
			{
				SearchFilter.Video => "EgIQAQ%3D%3D", 
				SearchFilter.Playlist => "EgIQAw%3D%3D", 
				SearchFilter.Channel => "EgIQAg%3D%3D", 
				_ => null, 
			};
			httpRequestMessage2.Content = new StringContent("{\r\n    \"query\": \"" + searchQuery + "\",\r\n    \"params\": \"" + text + "\",\r\n    \"continuation\": \"" + continuationToken + "\",\r\n    \"context\": {\r\n        \"client\": {\r\n            \"clientName\": \"WEB\",\r\n            \"clientVersion\": \"2.20210408.08.00\",\r\n            \"hl\": \"en\",\r\n            \"gl\": \"US\",\r\n            \"utcOffsetMinutes\": 0\r\n        }\r\n    }\r\n}");
			using HttpRequestMessage request = httpRequestMessage;
			using HttpResponseMessage response = await <http>P.SendAsync(request, cancellationToken);
			response.EnsureSuccessStatusCode();
			return SearchResponse.Parse(await PolyfillExtensions.ReadAsStringAsync(response.Content, cancellationToken));
		}
	}
	public enum SearchFilter
	{
		None,
		Video,
		Playlist,
		Channel
	}
	public class VideoSearchResult : ISearchResult, IBatchItem, IVideo
	{
		public VideoId Id { get; }

		public string Url => $"https://www.youtube.com/watch?v={Id}";

		public string Title { get; }

		public Author Author { get; }

		public TimeSpan? Duration { get; }

		public IReadOnlyList<Thumbnail> Thumbnails { get; }

		public VideoSearchResult(VideoId id, string title, Author author, TimeSpan? duration, IReadOnlyList<Thumbnail> thumbnails)
		{
			Id = id;
			Title = title;
			Author = author;
			Duration = duration;
			Thumbnails = thumbnails;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return "Video (" + Title + ")";
		}
	}
}
namespace YoutubeExplode.Playlists
{
	public interface IPlaylist
	{
		PlaylistId Id { get; }

		string Url { get; }

		string Title { get; }

		Author? Author { get; }

		IReadOnlyList<Thumbnail> Thumbnails { get; }
	}
	public class Playlist : IPlaylist
	{
		public PlaylistId Id { get; }

		public string Url => $"https://www.youtube.com/playlist?list={Id}";

		public string Title { get; }

		public Author? Author { get; }

		public string Description { get; }

		public IReadOnlyList<Thumbnail> Thumbnails { get; }

		public Playlist(PlaylistId id, string title, Author? author, string description, IReadOnlyList<Thumbnail> thumbnails)
		{
			Id = id;
			Title = title;
			Author = author;
			Description = description;
			Thumbnails = thumbnails;
		}

		[ExcludeFromCodeCoverage]
		public override string ToString()
		{
			return "Playlist (" + Title + ")";
		}
	}
	public class PlaylistClient
	{
		private readonly PlaylistController _controller;

		public PlaylistClient(HttpClient http)
		{
			_controller = new PlaylistController(http);
		}

		public async ValueTask<Playlist> GetAsync(PlaylistId playlistId, CancellationToken cancellationToken = default(CancellationToken))
		{
			IPlaylistData obj = await _controller.GetPlaylistResponseAsync(playlistId, cancellationToken);
			string title = obj.Title ?? throw new YoutubeExplodeException("Failed to extract the playlist title.");
			string channelId = obj.ChannelId;
			string author = obj.Author;
			Author author2 = ((channelId != null && author != null) ? new Author(channelId, author) : null);
			string description = obj.Description ?? "";
			Thumbnail[] thumbnails = obj.Thumbnails.Select(delegate(ThumbnailData t)
			{
				string? url = t.Url ?? throw new YoutubeExplodeException("Failed to extract the thumbnail URL.");
				int width = t.Width ?? throw new YoutubeExplodeException("Failed to extract the thumbnail width.");
				int height = t.Height ?? throw new YoutubeExplodeException("Failed to extract the thumbnail height.");
				Resolution resolution = new Resolution(width, height);
				return new Thumbnail(url, resolution);
			}).ToArray();
			return new Playlist(playlistId, title, author2, description, thumbnails);
		}

		public async IAsyncEnumerable<Batch<PlaylistVideo>> GetVideoBatchesAsync(PlaylistId playlistId, [EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
		{
			int num = -1;
			HashSet<VideoId> encounteredIds = new HashSet<VideoId>();
			VideoId? lastVideoId = null;
			int lastVideoIndex = 0;
			string visitorData = null;
			while (true)
			{
				PlaylistNextResponse response = await _controller.GetPlaylistNextResponseAsync(playlistId, lastVideoId, lastVideoIndex, visitorData, cancellationToken);
				List<PlaylistVideo> list = new List<PlaylistVideo>();
				IEnumerator<PlaylistVideoData> enumerator = response.Videos.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						PlaylistVideoData current = enumerator.Current;
						string text = current.Id ?? throw new YoutubeExplodeException("Failed to extract the video ID.");
						lastVideoId = text;
						lastVideoIndex = current.Index ?? throw new YoutubeExplodeException("Failed to extract the video index.");
						if (encounteredIds.Add(text))
						{
							string title = current.Title ?? "";
							string channelTitle = current.Author ?? throw new YoutubeExplodeException("Failed to extract the video author.");
							string text2 = current.ChannelId ?? throw new YoutubeExplodeException("Failed to extract the video channel ID.");
							Thumbnail[] thumbnails = current.Thumbnails.Select(delegate(ThumbnailData t)
							{
								string? url = t.Url ?? throw new YoutubeExplodeException("Failed to extract the thumbnail URL.");
								int width = t.Width ?? throw new YoutubeExplodeException("Failed to extract the thumbnail width.");
								int height = t.Height ?? throw new YoutubeExplodeException("Failed to extract the thumbnail height.");
								Resolution resolution = new Resolution(width, height);
								return new Thumbnail(url, resolution);
							}).Concat(Thumbnail.GetDefaultSet(text)).ToArray();
							PlaylistVideo item = new PlaylistVideo(playlistId, text, title, new Author(text2, channelTitle), current.Duration, thumbnails);
							list.Add(item);
						}
					}
				}
				finally
				{
					if (num == -1)
					{
						enumerator?.Dispose();
					}
				}
				if (!list.Any())
				{
					break;
				}
				yield return Batch.Create(list);
				num = -1;
				if (visitorData == null)
				{
					visitorData = response.VisitorData;
				}
			}
		}

		public IAsyncEnumerable<PlaylistVideo> GetVideosAsync(PlaylistId playlistId, CancellationToken cancellationToken = default(CancellationToken))
		{
			return GetVideoBatchesAsync(playlistId, cancellationToken).FlattenAsync();
		}
	}
	internal class PlaylistController
	{
		[CompilerGenerated]
		private HttpClient <http>P;

		public PlaylistController(HttpClient http)
		{
			<http>P = http;
			base..ctor();
		}

		public async ValueTask<PlaylistBrowseResponse> GetPlaylistBrowseResponseAsync(PlaylistId playlistId, CancellationToken cancellationToken = default(CancellationToken))
		{
			using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://www.youtube.com/youtubei/v1/browse")
			{
				Content = new StringContent($"{{\r\n    \"browseId\": \"VL{playlistId}\",\r\n    \"context\": {{\r\n        \"client\": {{\r\n            \"clientName\": \"WEB\",\r\n            \"clientVersion\": \"2.20210408.08.00\",\r\n            \"hl\": \"en\",\r\n            \"gl\": \"US\",\r\n            \"utcOffsetMinutes\": 0\r\n        }}\r\n    }}\r\n}}")
			};
			using HttpResponseMessage response = await <http>P.SendAsync(request, cancellationToken);
			response.EnsureSuccessStatusCode();
			PlaylistBrowseResponse playlistBrowseResponse = PlaylistBrowseResponse.Parse(await PolyfillExtensions.ReadAsStringAsync(response.Content, cancellationToken));
			if (!playlistBrowseResponse.IsAvailable)
			{
				throw new PlaylistUnavailableException($"Playlist '{playlistId}' is not available.");
			}
			return playlistBrowseResponse;
		}

		public async ValueTask<PlaylistNextResponse> GetPlaylistNextResponseAsync(PlaylistId playlistId, VideoId? videoId = null, int index = 0, string? visitorData = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			int retriesRemaining = 5;
			while (true)
			{
				using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://www.youtube.com/youtubei/v1/next")
				{
					Content = new StringContent($"{{\r\n    \"playlistId\": \"{playlistId}\",\r\n    \"videoId\": \"{videoId}\",\r\n    \"playlistIndex\": {index},\r\n    \"context\": {{\r\n        \"client\": {{\r\n            \"clientName\": \"WEB\",\r\n            \"clientVersion\": \"2.20210408.08.00\",\r\n            \"hl\": \"en\",\r\n            \"gl\": \"US\",\r\n            \"utcOffsetMinutes\": 0,\r\n            \"visitorData\": \"{visitorData}\"\r\n        }}\r\n    }}\r\n}}")
				})
				{
					using HttpResponseMessage response = await <http>P.SendAsync(request, cancellationToken);
					response.EnsureSuccessStatusCode();
					PlaylistNextResponse playlistNextResponse = PlaylistNextResponse.Parse(await PolyfillExtensions.ReadAsStringAsync(response.Content, cancellationToken));
					if (playlistNextResponse.IsAvailable)
					{
						return playlistNextResponse;
					}
					if (index <= 0 || string.IsNullOrWhiteSpace(visitorData) || retriesRemaining <= 0)
					{
						throw new PlaylistUnavailableException($"Playlist '{playlistId}' is not available.");
					}
				}
				retriesRemaining--;
			}
		}

		public async ValueTask<IPlaylistData> GetPlaylistResponseAsync(PlaylistId playlistId, CancellationToken cancellationToken = default(CancellationToken))
		{
			IPlaylistData result = default(IPlaylistData);
			int num;
			try
			{
				result = await GetPlaylistBrowseResponseAsync(playlistId, cancellationToken);
				return result;
			}
			catch (PlaylistUnavailableException)
			{
				num = 1;
			}
			if (num != 1)
			{
				return result;
			}
			return await GetPlaylistNextResponseAsync(playlistId, null, 0, null, cancellationToken);
		}
	}
	public readonly struct PlaylistId : IEquatable<PlaylistId>
	{
		public string Value { get; }

		private PlaylistId(string value)
		{
			Value = value;
		}

		public override string ToString()
		{
			return Value;
		}

		private static bool IsValid(string playlistId)
		{
			if (playlistId.Length >= 2)
			{
				return playlistId.All(delegate(char c)
				{
					bool flag = char.IsLetterOrDigit(c);
					if (!flag)
					{
						bool flag2 = ((c == '-' || c == '_') ? true : false);
						flag = flag2;
					}
					return flag;
				});
			}
			return false;
		}

		private static string? TryNormalize(string? playlistIdOrUrl)
		{
			if (string.IsNullOrWhiteSpace(playlistIdOrUrl))
			{
				return null;
			}
			if (IsValid(playlistIdOrUrl))
			{
				return playlistIdOrUrl;
			}
			string text = Regex.Match(playlistIdOrUrl, "youtube\\..+?/playlist.*?list=(.*?)(?:&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text) && IsValid(text))
			{
				return text;
			}
			string text2 = Regex.Match(playlistIdOrUrl, "youtube\\..+?/watch.*?list=(.*?)(?:&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
			if (!string.IsNullOrWhiteSpace(text2) && IsValid(text2))
			{
				return text2;
			}
			string text3 = Regex.Match(playlistIdOrUrl, "youtu\\.be/.*?/.*?list=(.*?)(?:&|/|$)").Groups[1].Value.Pipe(WebUtility.UrlDecode);
	

YoutubeBoomBox.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using YoutubeBoomBox.Commands;
using YoutubeBoomBox.Download;
using YoutubeBoomBox.Utils;
using YoutubeExplode;
using YoutubeExplode.Common;
using YoutubeExplode.Converter;
using YoutubeExplode.Search;
using YoutubeExplode.Videos;
using YoutubeExplode.Videos.Streams;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("YoutubeBoomBox")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Streams youtube playlists and videos to ingame boombox.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+418a3507db4a571b51ba8e95352b31496f5babef")]
[assembly: AssemblyProduct("YoutubeBoomBox")]
[assembly: AssemblyTitle("YoutubeBoomBox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace YoutubeBoomBox
{
	[HarmonyPatch(typeof(BoomboxItem))]
	public class BoomboxItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("ItemActivate")]
		public static void SettingAudioPatch(bool used, BoomboxItem __instance)
		{
			if (!__instance.isPlayingMusic)
			{
				if (AudioQueue.DefaultAudios == null)
				{
					AudioQueue.DefaultAudios = __instance.musicAudios;
				}
				if (AudioQueue.IsEmpty())
				{
					__instance.musicAudios = AudioQueue.DefaultAudios;
					return;
				}
				__instance.musicAudios = (AudioClip[])(object)new AudioClip[1] { AudioQueue.Get() };
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		public static void AddCommandsToInit(BoomboxItem __instance)
		{
			((Component)__instance).gameObject.AddComponent<AddCommand>();
			((Component)__instance).gameObject.AddComponent<ClearCommand>();
		}
	}
	[BepInPlugin("YoutubeBoomBox", "YoutubeBoomBox", "1.0.0")]
	public class YoutubeBoomBoxPlugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("YoutubeBoomBox");

		public static ManualLogSource Logger { get; } = Logger.CreateLogSource("YoutubeBoomBox");


		public static ConfigEntry<int> TimeoutLength { get; private set; }

		private void Awake()
		{
			TimeoutLength = ((BaseUnityPlugin)this).Config.Bind<int>("General", "TimeoutLength", 30, "Timeout length for downloads in seconds.");
			_harmony.PatchAll(typeof(YoutubeBoomBoxPlugin));
			_harmony.PatchAll(typeof(BoomboxItemPatch));
			Logger.LogInfo((object)$"Patch {typeof(BoomboxItemPatch)} is loaded!");
			_harmony.PatchAll(typeof(HUDManagerPatch));
			Logger.LogInfo((object)$"Patch {typeof(HUDManagerPatch)} is loaded!");
			Logger.LogInfo((object)"Plugin YoutubeBoomBox is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "YoutubeBoomBox";

		public const string PLUGIN_NAME = "YoutubeBoomBox";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace YoutubeBoomBox.Utils
{
	public static class AudioQueue
	{
		private static List<AudioClip> _clips = new List<AudioClip>();

		private static int _fp;

		public static AudioClip[] DefaultAudios { get; set; }

		public static void Clear()
		{
			_clips.Clear();
		}

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

		public static void Add(AudioClip clip)
		{
			_clips.Add(clip);
		}

		public static AudioClip Get()
		{
			if (_fp >= _clips.Count)
			{
				_fp = 0;
			}
			AudioClip result = _clips[_fp];
			_fp++;
			return result;
		}

		public static int Length()
		{
			return _clips.Count;
		}
	}
}
namespace YoutubeBoomBox.Download
{
	public static class YoutubeInfo
	{
		private static int _count = 1;

		public static string FilePath { get; } = Path.Combine(Paths.PluginPath, "Archie-YoutubeBoomBox");


		public static string MusicName
		{
			get
			{
				string result = $"{_count}.mp3";
				_count++;
				return result;
			}
		}
	}
	public class YoutubeService
	{
		private readonly YoutubeClient _youtubeClient = new YoutubeClient();

		public async Task<string> DownloadVideoAudioAsync(string searchQuery, int maxTime)
		{
			YoutubeBoomBoxPlugin.Logger.LogInfo((object)("Starting video audio download for query: " + searchQuery));
			string url = null;
			await using (IAsyncEnumerator<Batch<ISearchResult>> asyncEnumerator = _youtubeClient.Search.GetResultBatchesAsync(searchQuery, default(CancellationToken)).GetAsyncEnumerator())
			{
				if (await asyncEnumerator.MoveNextAsync())
				{
					Batch<ISearchResult> current = asyncEnumerator.Current;
					url = current.Items.First().Url;
				}
			}
			if (url == null)
			{
				throw new Exception("No video found");
			}
			VideoId videoId = VideoId.Parse(url);
			string name = YoutubeInfo.MusicName;
			string text = YoutubeInfo.FilePath + "/" + name;
			YoutubeBoomBoxPlugin.Logger.LogInfo((object)("Downloading to " + text + "."));
			CancellationTokenSource cts = new CancellationTokenSource();
			Task downloadTask = DownloadVideoAsync(videoId, text);
			TimeSpan timeout = TimeSpan.FromSeconds(maxTime);
			Task timeoutTask = Task.Delay(timeout, cts.Token);
			if (await Task.WhenAny(new Task[2] { downloadTask, timeoutTask }) == timeoutTask)
			{
				cts.Cancel();
				YoutubeBoomBoxPlugin.Logger.LogError((object)$"Download timed out after {timeout.TotalSeconds} seconds.");
				throw new TimeoutException("The download operation timed out.");
			}
			await downloadTask;
			return name;
		}

		private async Task DownloadVideoAsync(VideoId videoId, string fullPath)
		{
			//IL_0016: 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)
			try
			{
				await ConversionExtensions.DownloadAsync(_youtubeClient.Videos, videoId, fullPath, (Action<ConversionRequestBuilder>)delegate(ConversionRequestBuilder o)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					o.SetContainer(Container.Mp3).SetPreset((ConversionPreset)3).SetFFmpegPath(YoutubeInfo.FilePath + "/ffmpeg");
				}, (IProgress<double>)null, default(CancellationToken));
				YoutubeBoomBoxPlugin.Logger.LogInfo((object)"Download complete.");
			}
			catch (Exception ex)
			{
				YoutubeBoomBoxPlugin.Logger.LogError((object)("An error occurred during download: " + ex.Message));
				throw;
			}
		}

		public static void ClearVideos()
		{
			string filePath = YoutubeInfo.FilePath;
			if (Directory.Exists(filePath))
			{
				string[] files = Directory.GetFiles(filePath, "*.mp3");
				foreach (string text in files)
				{
					try
					{
						File.Delete(text);
						YoutubeBoomBoxPlugin.Logger.LogInfo((object)("Deleted: " + text));
					}
					catch (IOException ex)
					{
						YoutubeBoomBoxPlugin.Logger.LogError((object)("An IO exception occurred: " + ex.Message));
					}
					catch (UnauthorizedAccessException ex2)
					{
						YoutubeBoomBoxPlugin.Logger.LogError((object)("An Unauthorized Access exception occurred: " + ex2.Message));
					}
				}
			}
			else
			{
				YoutubeBoomBoxPlugin.Logger.LogWarning((object)("The directory " + filePath + " does not exist."));
			}
		}
	}
}
namespace YoutubeBoomBox.Commands
{
	public class AddCommand : CommandBase
	{
		private readonly YoutubeService _yt = new YoutubeService();

		protected override string Key => "/add ";

		protected override async void Action(string lastChatMessage)
		{
			YoutubeService.ClearVideos();
			string query;
			try
			{
				string searchQuery = lastChatMessage.Substring(5, lastChatMessage.Length - 5);
				query = await _yt.DownloadVideoAudioAsync(searchQuery, YoutubeBoomBoxPlugin.TimeoutLength.Value);
			}
			catch (TimeoutException)
			{
				HUDManager.Instance.AddTextToChatOnServer("Download timed out.", -1);
				return;
			}
			catch (Exception ex2)
			{
				YoutubeBoomBoxPlugin.Logger.LogError((object)ex2);
				return;
			}
			((MonoBehaviour)this).StartCoroutine(LoadAudioCoroutine(query));
			HUDManager.Instance.AddTextToChatOnServer("Player loaded.", -1);
		}

		private static IEnumerator LoadAudioCoroutine(string query)
		{
			string text = "file://" + YoutubeInfo.FilePath + "/" + query;
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13);
			try
			{
				yield return www.SendWebRequest();
				Result result = www.result;
				if (result - 2 <= 1)
				{
					YoutubeBoomBoxPlugin.Logger.LogError((object)www.error);
					yield break;
				}
				YoutubeBoomBoxPlugin.Logger.LogInfo((object)$"Loading audio clip at: {www.uri}");
				AudioClip content = DownloadHandlerAudioClip.GetContent(www);
				YoutubeBoomBoxPlugin.Logger.LogInfo((object)"Loaded audio clip.");
				AudioQueue.Add(content);
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
		}
	}
	public class ClearCommand : CommandBase
	{
		protected override string Key { get; } = "/clear";


		protected override void Action(string lastChatMessage)
		{
			AudioQueue.Clear();
			YoutubeService.ClearVideos();
		}
	}
	public abstract class CommandBase : MonoBehaviour
	{
		private string _lastMessage = string.Empty;

		protected abstract string Key { get; }

		private void Update()
		{
			string lastChatMessage = HUDManager.Instance.lastChatMessage;
			if (lastChatMessage.StartsWith(Key) && _lastMessage != lastChatMessage)
			{
				Action(lastChatMessage);
				_lastMessage = lastChatMessage;
			}
		}

		protected abstract void Action(string lastChatMessage);
	}
}