Decompiled source of Config Manager v0.14.0

Sentry.System.Collections.Immutable.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using FxResources.System.Collections.Immutable;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("System.Collections.Immutable.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDefaultAlias("System.Collections.Immutable")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("System.Collections.Immutable")]
[assembly: AssemblyFileVersion("5.0.20.51904")]
[assembly: AssemblyInformationalVersion("5.0.0+cf258a14b70ad9069470a108f13765e0e5988f51")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Collections.Immutable")]
[assembly: AssemblyMetadata("RepositoryUrl", "git://github.com/dotnet/runtime")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: AssemblyVersion("5.0.0.0")]
[module: System.Runtime.CompilerServices.NullablePublicOnly(true)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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;
		}
	}
}
namespace FxResources.System.Collections.Immutable
{
	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 Arg_KeyNotFoundWithKey => GetResourceString("Arg_KeyNotFoundWithKey");

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

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

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

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

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

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

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

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

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

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

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

		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
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	internal sealed class NonVersionableAttribute : Attribute
	{
	}
}
namespace System.Linq
{
	internal static class ImmutableArrayExtensions
	{
		public static IEnumerable<TResult> Select<T, TResult>(this ImmutableArray<T> immutableArray, Func<T, TResult> selector)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			return immutableArray.array.Select(selector);
		}

		public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this ImmutableArray<TSource> immutableArray, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			if (collectionSelector == null || resultSelector == null)
			{
				return Enumerable.SelectMany(immutableArray, collectionSelector, resultSelector);
			}
			if (immutableArray.Length != 0)
			{
				return immutableArray.SelectManyIterator(collectionSelector, resultSelector);
			}
			return Enumerable.Empty<TResult>();
		}

		public static IEnumerable<T> Where<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			return immutableArray.array.Where(predicate);
		}

		public static bool Any<T>(this ImmutableArray<T> immutableArray)
		{
			return immutableArray.Length > 0;
		}

		public static bool Any<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			Requires.NotNull(predicate, "predicate");
			T[] array = immutableArray.array;
			foreach (T arg in array)
			{
				if (predicate(arg))
				{
					return true;
				}
			}
			return false;
		}

		public static bool All<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			Requires.NotNull(predicate, "predicate");
			T[] array = immutableArray.array;
			foreach (T arg in array)
			{
				if (!predicate(arg))
				{
					return false;
				}
			}
			return true;
		}

		public static bool SequenceEqual<TDerived, TBase>(this ImmutableArray<TBase> immutableArray, ImmutableArray<TDerived> items, IEqualityComparer<TBase>? comparer = null) where TDerived : TBase
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			items.ThrowNullRefIfNotInitialized();
			if (immutableArray.array == items.array)
			{
				return true;
			}
			if (immutableArray.Length != items.Length)
			{
				return false;
			}
			if (comparer == null)
			{
				comparer = EqualityComparer<TBase>.Default;
			}
			for (int i = 0; i < immutableArray.Length; i++)
			{
				if (!comparer.Equals(immutableArray.array[i], (TBase)(object)items.array[i]))
				{
					return false;
				}
			}
			return true;
		}

		public static bool SequenceEqual<TDerived, TBase>(this ImmutableArray<TBase> immutableArray, IEnumerable<TDerived> items, IEqualityComparer<TBase>? comparer = null) where TDerived : TBase
		{
			Requires.NotNull(items, "items");
			if (comparer == null)
			{
				comparer = EqualityComparer<TBase>.Default;
			}
			int num = 0;
			int length = immutableArray.Length;
			foreach (TDerived item in items)
			{
				if (num == length)
				{
					return false;
				}
				if (!comparer.Equals(immutableArray[num], (TBase)(object)item))
				{
					return false;
				}
				num++;
			}
			return num == length;
		}

		public static bool SequenceEqual<TDerived, TBase>(this ImmutableArray<TBase> immutableArray, ImmutableArray<TDerived> items, Func<TBase, TBase, bool> predicate) where TDerived : TBase
		{
			Requires.NotNull(predicate, "predicate");
			immutableArray.ThrowNullRefIfNotInitialized();
			items.ThrowNullRefIfNotInitialized();
			if (immutableArray.array == items.array)
			{
				return true;
			}
			if (immutableArray.Length != items.Length)
			{
				return false;
			}
			int i = 0;
			for (int length = immutableArray.Length; i < length; i++)
			{
				if (!predicate(immutableArray[i], (TBase)(object)items[i]))
				{
					return false;
				}
			}
			return true;
		}

		public static T? Aggregate<T>(this ImmutableArray<T> immutableArray, Func<T, T, T> func)
		{
			Requires.NotNull(func, "func");
			if (immutableArray.Length == 0)
			{
				return default(T);
			}
			T val = immutableArray[0];
			int i = 1;
			for (int length = immutableArray.Length; i < length; i++)
			{
				val = func(val, immutableArray[i]);
			}
			return val;
		}

		public static TAccumulate Aggregate<TAccumulate, T>(this ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate, T, TAccumulate> func)
		{
			Requires.NotNull(func, "func");
			TAccumulate val = seed;
			T[] array = immutableArray.array;
			foreach (T arg in array)
			{
				val = func(val, arg);
			}
			return val;
		}

		public static TResult Aggregate<TAccumulate, TResult, T>(this ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate, T, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
		{
			Requires.NotNull(resultSelector, "resultSelector");
			return resultSelector(immutableArray.Aggregate(seed, func));
		}

		public static T ElementAt<T>(this ImmutableArray<T> immutableArray, int index)
		{
			return immutableArray[index];
		}

		public static T? ElementAtOrDefault<T>(this ImmutableArray<T> immutableArray, int index)
		{
			if (index < 0 || index >= immutableArray.Length)
			{
				return default(T);
			}
			return immutableArray[index];
		}

		public static T First<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			T[] array = immutableArray.array;
			foreach (T val in array)
			{
				if (predicate(val))
				{
					return val;
				}
			}
			return Enumerable.Empty<T>().First();
		}

		public static T First<T>(this ImmutableArray<T> immutableArray)
		{
			if (immutableArray.Length <= 0)
			{
				return immutableArray.array.First();
			}
			return immutableArray[0];
		}

		public static T? FirstOrDefault<T>(this ImmutableArray<T> immutableArray)
		{
			if (immutableArray.array.Length == 0)
			{
				return default(T);
			}
			return immutableArray.array[0];
		}

		public static T? FirstOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			T[] array = immutableArray.array;
			foreach (T val in array)
			{
				if (predicate(val))
				{
					return val;
				}
			}
			return default(T);
		}

		public static T Last<T>(this ImmutableArray<T> immutableArray)
		{
			if (immutableArray.Length <= 0)
			{
				return immutableArray.array.Last();
			}
			return immutableArray[immutableArray.Length - 1];
		}

		public static T Last<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			for (int num = immutableArray.Length - 1; num >= 0; num--)
			{
				if (predicate(immutableArray[num]))
				{
					return immutableArray[num];
				}
			}
			return Enumerable.Empty<T>().Last();
		}

		public static T? LastOrDefault<T>(this ImmutableArray<T> immutableArray)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			return immutableArray.array.LastOrDefault();
		}

		public static T? LastOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			for (int num = immutableArray.Length - 1; num >= 0; num--)
			{
				if (predicate(immutableArray[num]))
				{
					return immutableArray[num];
				}
			}
			return default(T);
		}

		public static T Single<T>(this ImmutableArray<T> immutableArray)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			return immutableArray.array.Single();
		}

		public static T Single<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			bool flag = true;
			T result = default(T);
			T[] array = immutableArray.array;
			foreach (T val in array)
			{
				if (predicate(val))
				{
					if (!flag)
					{
						ImmutableArray.TwoElementArray.Single();
					}
					flag = false;
					result = val;
				}
			}
			if (flag)
			{
				Enumerable.Empty<T>().Single();
			}
			return result;
		}

		public static T? SingleOrDefault<T>(this ImmutableArray<T> immutableArray)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			return immutableArray.array.SingleOrDefault();
		}

		public static T? SingleOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
		{
			Requires.NotNull(predicate, "predicate");
			bool flag = true;
			T result = default(T);
			T[] array = immutableArray.array;
			foreach (T val in array)
			{
				if (predicate(val))
				{
					if (!flag)
					{
						ImmutableArray.TwoElementArray.Single();
					}
					flag = false;
					result = val;
				}
			}
			return result;
		}

		public static Dictionary<TKey, T> ToDictionary<TKey, T>(this ImmutableArray<T> immutableArray, Func<T, TKey> keySelector) where TKey : notnull
		{
			return immutableArray.ToDictionary(keySelector, EqualityComparer<TKey>.Default);
		}

		public static Dictionary<TKey, TElement> ToDictionary<TKey, TElement, T>(this ImmutableArray<T> immutableArray, Func<T, TKey> keySelector, Func<T, TElement> elementSelector) where TKey : notnull
		{
			return immutableArray.ToDictionary(keySelector, elementSelector, EqualityComparer<TKey>.Default);
		}

		public static Dictionary<TKey, T> ToDictionary<TKey, T>(this ImmutableArray<T> immutableArray, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer) where TKey : notnull
		{
			Requires.NotNull(keySelector, "keySelector");
			Dictionary<TKey, T> dictionary = new Dictionary<TKey, T>(immutableArray.Length, comparer);
			ImmutableArray<T>.Enumerator enumerator = immutableArray.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				dictionary.Add(keySelector(current), current);
			}
			return dictionary;
		}

		public static Dictionary<TKey, TElement> ToDictionary<TKey, TElement, T>(this ImmutableArray<T> immutableArray, Func<T, TKey> keySelector, Func<T, TElement> elementSelector, IEqualityComparer<TKey>? comparer) where TKey : notnull
		{
			Requires.NotNull(keySelector, "keySelector");
			Requires.NotNull(elementSelector, "elementSelector");
			Dictionary<TKey, TElement> dictionary = new Dictionary<TKey, TElement>(immutableArray.Length, comparer);
			T[] array = immutableArray.array;
			foreach (T arg in array)
			{
				dictionary.Add(keySelector(arg), elementSelector(arg));
			}
			return dictionary;
		}

		public static T[] ToArray<T>(this ImmutableArray<T> immutableArray)
		{
			immutableArray.ThrowNullRefIfNotInitialized();
			if (immutableArray.array.Length == 0)
			{
				return ImmutableArray<T>.Empty.array;
			}
			return (T[])immutableArray.array.Clone();
		}

		public static T First<T>(this ImmutableArray<T>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			if (!builder.Any())
			{
				throw new InvalidOperationException();
			}
			return builder[0];
		}

		public static T? FirstOrDefault<T>(this ImmutableArray<T>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			if (!builder.Any())
			{
				return default(T);
			}
			return builder[0];
		}

		public static T Last<T>(this ImmutableArray<T>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			if (!builder.Any())
			{
				throw new InvalidOperationException();
			}
			return builder[builder.Count - 1];
		}

		public static T? LastOrDefault<T>(this ImmutableArray<T>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			if (!builder.Any())
			{
				return default(T);
			}
			return builder[builder.Count - 1];
		}

		public static bool Any<T>(this ImmutableArray<T>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			return builder.Count > 0;
		}

		private static IEnumerable<TResult> SelectManyIterator<TSource, TCollection, TResult>(this ImmutableArray<TSource> immutableArray, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
		{
			TSource[] array = immutableArray.array;
			foreach (TSource item in array)
			{
				foreach (TCollection item2 in collectionSelector(item))
				{
					yield return resultSelector(item, item2);
				}
			}
		}
	}
}
namespace System.Collections.Immutable
{
	internal static class AllocFreeConcurrentStack<T>
	{
		private const int MaxSize = 35;

		private static readonly Type s_typeOfT = typeof(T);

		private static Stack<RefAsValueType<T>> ThreadLocalStack
		{
			get
			{
				Dictionary<Type, object> dictionary = AllocFreeConcurrentStack.t_stacks;
				if (dictionary == null)
				{
					dictionary = (AllocFreeConcurrentStack.t_stacks = new Dictionary<Type, object>());
				}
				if (!dictionary.TryGetValue(s_typeOfT, out var value))
				{
					value = new Stack<RefAsValueType<T>>(35);
					dictionary.Add(s_typeOfT, value);
				}
				return (Stack<RefAsValueType<T>>)value;
			}
		}

		public static void TryAdd(T item)
		{
			Stack<RefAsValueType<T>> threadLocalStack = ThreadLocalStack;
			if (threadLocalStack.Count < 35)
			{
				threadLocalStack.Push(new RefAsValueType<T>(item));
			}
		}

		public static bool TryTake([MaybeNullWhen(false)] out T item)
		{
			Stack<RefAsValueType<T>> threadLocalStack = ThreadLocalStack;
			if (threadLocalStack != null && threadLocalStack.Count > 0)
			{
				item = threadLocalStack.Pop().Value;
				return true;
			}
			item = default(T);
			return false;
		}
	}
	internal static class AllocFreeConcurrentStack
	{
		[ThreadStatic]
		internal static Dictionary<Type, object>? t_stacks;
	}
	internal sealed class DictionaryEnumerator<TKey, TValue> : IDictionaryEnumerator, IEnumerator where TKey : notnull
	{
		private readonly IEnumerator<KeyValuePair<TKey, TValue>> _inner;

		public DictionaryEntry Entry => new DictionaryEntry(_inner.Current.Key, _inner.Current.Value);

		public object Key => _inner.Current.Key;

		public object? Value => _inner.Current.Value;

		public object Current => Entry;

		internal DictionaryEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> inner)
		{
			Requires.NotNull(inner, "inner");
			_inner = inner;
		}

		public bool MoveNext()
		{
			return _inner.MoveNext();
		}

		public void Reset()
		{
			_inner.Reset();
		}
	}
	internal struct DisposableEnumeratorAdapter<T, TEnumerator> : IDisposable where TEnumerator : struct, IEnumerator<T>
	{
		private readonly IEnumerator<T> _enumeratorObject;

		private TEnumerator _enumeratorStruct;

		public T Current
		{
			get
			{
				if (_enumeratorObject == null)
				{
					return _enumeratorStruct.Current;
				}
				return _enumeratorObject.Current;
			}
		}

		internal DisposableEnumeratorAdapter(TEnumerator enumerator)
		{
			_enumeratorStruct = enumerator;
			_enumeratorObject = null;
		}

		internal DisposableEnumeratorAdapter(IEnumerator<T> enumerator)
		{
			_enumeratorStruct = default(TEnumerator);
			_enumeratorObject = enumerator;
		}

		public bool MoveNext()
		{
			if (_enumeratorObject == null)
			{
				return _enumeratorStruct.MoveNext();
			}
			return _enumeratorObject.MoveNext();
		}

		public void Dispose()
		{
			if (_enumeratorObject != null)
			{
				_enumeratorObject.Dispose();
			}
			else
			{
				_enumeratorStruct.Dispose();
			}
		}

		public DisposableEnumeratorAdapter<T, TEnumerator> GetEnumerator()
		{
			return this;
		}
	}
	internal interface IBinaryTree
	{
		int Height { get; }

		bool IsEmpty { get; }

		int Count { get; }

		IBinaryTree? Left { get; }

		IBinaryTree? Right { get; }
	}
	internal interface IBinaryTree<out T> : IBinaryTree
	{
		T Value { get; }

		new IBinaryTree<T>? Left { get; }

		new IBinaryTree<T>? Right { get; }
	}
	internal interface IImmutableArray
	{
		Array? Array { get; }
	}
	internal interface IImmutableDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IReadOnlyCollection<KeyValuePair<TKey, TValue>>
	{
		IImmutableDictionary<TKey, TValue> Clear();

		IImmutableDictionary<TKey, TValue> Add(TKey key, TValue value);

		IImmutableDictionary<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs);

		IImmutableDictionary<TKey, TValue> SetItem(TKey key, TValue value);

		IImmutableDictionary<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items);

		IImmutableDictionary<TKey, TValue> RemoveRange(IEnumerable<TKey> keys);

		IImmutableDictionary<TKey, TValue> Remove(TKey key);

		bool Contains(KeyValuePair<TKey, TValue> pair);

		bool TryGetKey(TKey equalKey, out TKey actualKey);
	}
	internal interface IImmutableDictionaryInternal<TKey, TValue>
	{
		bool ContainsValue(TValue value);
	}
	internal interface IImmutableList<T> : IReadOnlyList<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>
	{
		IImmutableList<T> Clear();

		int IndexOf(T item, int index, int count, IEqualityComparer<T>? equalityComparer);

		int LastIndexOf(T item, int index, int count, IEqualityComparer<T>? equalityComparer);

		IImmutableList<T> Add(T value);

		IImmutableList<T> AddRange(IEnumerable<T> items);

		IImmutableList<T> Insert(int index, T element);

		IImmutableList<T> InsertRange(int index, IEnumerable<T> items);

		IImmutableList<T> Remove(T value, IEqualityComparer<T>? equalityComparer);

		IImmutableList<T> RemoveAll(Predicate<T> match);

		IImmutableList<T> RemoveRange(IEnumerable<T> items, IEqualityComparer<T>? equalityComparer);

		IImmutableList<T> RemoveRange(int index, int count);

		IImmutableList<T> RemoveAt(int index);

		IImmutableList<T> SetItem(int index, T value);

		IImmutableList<T> Replace(T oldValue, T newValue, IEqualityComparer<T>? equalityComparer);
	}
	internal interface IImmutableListQueries<T> : IReadOnlyList<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>
	{
		ImmutableList<TOutput> ConvertAll<TOutput>(Func<T, TOutput> converter);

		void ForEach(Action<T> action);

		ImmutableList<T> GetRange(int index, int count);

		void CopyTo(T[] array);

		void CopyTo(T[] array, int arrayIndex);

		void CopyTo(int index, T[] array, int arrayIndex, int count);

		bool Exists(Predicate<T> match);

		T? Find(Predicate<T> match);

		ImmutableList<T> FindAll(Predicate<T> match);

		int FindIndex(Predicate<T> match);

		int FindIndex(int startIndex, Predicate<T> match);

		int FindIndex(int startIndex, int count, Predicate<T> match);

		T? FindLast(Predicate<T> match);

		int FindLastIndex(Predicate<T> match);

		int FindLastIndex(int startIndex, Predicate<T> match);

		int FindLastIndex(int startIndex, int count, Predicate<T> match);

		bool TrueForAll(Predicate<T> match);

		int BinarySearch(T item);

		int BinarySearch(T item, IComparer<T>? comparer);

		int BinarySearch(int index, int count, T item, IComparer<T>? comparer);
	}
	internal interface IImmutableQueue<T> : IEnumerable<T>, IEnumerable
	{
		bool IsEmpty { get; }

		IImmutableQueue<T> Clear();

		T Peek();

		IImmutableQueue<T> Enqueue(T value);

		IImmutableQueue<T> Dequeue();
	}
	internal interface IImmutableSet<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
	{
		IImmutableSet<T> Clear();

		bool Contains(T value);

		IImmutableSet<T> Add(T value);

		IImmutableSet<T> Remove(T value);

		bool TryGetValue(T equalValue, out T actualValue);

		IImmutableSet<T> Intersect(IEnumerable<T> other);

		IImmutableSet<T> Except(IEnumerable<T> other);

		IImmutableSet<T> SymmetricExcept(IEnumerable<T> other);

		IImmutableSet<T> Union(IEnumerable<T> other);

		bool SetEquals(IEnumerable<T> other);

		bool IsProperSubsetOf(IEnumerable<T> other);

		bool IsProperSupersetOf(IEnumerable<T> other);

		bool IsSubsetOf(IEnumerable<T> other);

		bool IsSupersetOf(IEnumerable<T> other);

		bool Overlaps(IEnumerable<T> other);
	}
	internal interface IImmutableStack<T> : IEnumerable<T>, IEnumerable
	{
		bool IsEmpty { get; }

		IImmutableStack<T> Clear();

		IImmutableStack<T> Push(T value);

		IImmutableStack<T> Pop();

		T Peek();
	}
	[DebuggerDisplay("Count = {Count}")]
	[DebuggerTypeProxy(typeof(ImmutableEnumerableDebuggerProxy<>))]
	internal sealed class ImmutableHashSet<T> : IImmutableSet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IHashKeyCollection<T>, ICollection<T>, ISet<T>, ICollection, IStrongEnumerable<T, ImmutableHashSet<T>.Enumerator>
	{
		private class HashBucketByValueEqualityComparer : IEqualityComparer<HashBucket>
		{
			private static readonly IEqualityComparer<HashBucket> s_defaultInstance = new HashBucketByValueEqualityComparer(EqualityComparer<T>.Default);

			private readonly IEqualityComparer<T> _valueComparer;

			internal static IEqualityComparer<HashBucket> DefaultInstance => s_defaultInstance;

			internal HashBucketByValueEqualityComparer(IEqualityComparer<T> valueComparer)
			{
				Requires.NotNull(valueComparer, "valueComparer");
				_valueComparer = valueComparer;
			}

			public bool Equals(HashBucket x, HashBucket y)
			{
				return x.EqualsByValue(y, _valueComparer);
			}

			public int GetHashCode(HashBucket obj)
			{
				throw new NotSupportedException();
			}
		}

		private class HashBucketByRefEqualityComparer : IEqualityComparer<HashBucket>
		{
			private static readonly IEqualityComparer<HashBucket> s_defaultInstance = new HashBucketByRefEqualityComparer();

			internal static IEqualityComparer<HashBucket> DefaultInstance => s_defaultInstance;

			private HashBucketByRefEqualityComparer()
			{
			}

			public bool Equals(HashBucket x, HashBucket y)
			{
				return x.EqualsByRef(y);
			}

			public int GetHashCode(HashBucket obj)
			{
				throw new NotSupportedException();
			}
		}

		[DebuggerDisplay("Count = {Count}")]
		public sealed class Builder : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, ISet<T>, ICollection<T>
		{
			private SortedInt32KeyNode<HashBucket> _root = SortedInt32KeyNode<HashBucket>.EmptyNode;

			private IEqualityComparer<T> _equalityComparer;

			private readonly IEqualityComparer<HashBucket> _hashBucketEqualityComparer;

			private int _count;

			private ImmutableHashSet<T> _immutable;

			private int _version;

			public int Count => _count;

			bool ICollection<T>.IsReadOnly => false;

			public IEqualityComparer<T> KeyComparer
			{
				get
				{
					return _equalityComparer;
				}
				set
				{
					Requires.NotNull(value, "value");
					if (value != _equalityComparer)
					{
						MutationResult mutationResult = ImmutableHashSet<T>.Union((IEnumerable<T>)this, new MutationInput(SortedInt32KeyNode<HashBucket>.EmptyNode, value, _hashBucketEqualityComparer, 0));
						_immutable = null;
						_equalityComparer = value;
						Root = mutationResult.Root;
						_count = mutationResult.Count;
					}
				}
			}

			internal int Version => _version;

			private MutationInput Origin => new MutationInput(Root, _equalityComparer, _hashBucketEqualityComparer, _count);

			private SortedInt32KeyNode<HashBucket> Root
			{
				get
				{
					return _root;
				}
				set
				{
					_version++;
					if (_root != value)
					{
						_root = value;
						_immutable = null;
					}
				}
			}

			internal Builder(ImmutableHashSet<T> set)
			{
				Requires.NotNull(set, "set");
				_root = set._root;
				_count = set._count;
				_equalityComparer = set._equalityComparer;
				_hashBucketEqualityComparer = set._hashBucketEqualityComparer;
				_immutable = set;
			}

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

			public ImmutableHashSet<T> ToImmutable()
			{
				if (_immutable == null)
				{
					_immutable = ImmutableHashSet<T>.Wrap(_root, _equalityComparer, _count);
				}
				return _immutable;
			}

			public bool TryGetValue(T equalValue, out T actualValue)
			{
				int key = ((equalValue != null) ? _equalityComparer.GetHashCode(equalValue) : 0);
				if (_root.TryGetValue(key, out var value))
				{
					return value.TryExchange(equalValue, _equalityComparer, out actualValue);
				}
				actualValue = equalValue;
				return false;
			}

			public bool Add(T item)
			{
				MutationResult result = ImmutableHashSet<T>.Add(item, Origin);
				Apply(result);
				return result.Count != 0;
			}

			public bool Remove(T item)
			{
				MutationResult result = ImmutableHashSet<T>.Remove(item, Origin);
				Apply(result);
				return result.Count != 0;
			}

			public bool Contains(T item)
			{
				return ImmutableHashSet<T>.Contains(item, Origin);
			}

			public void Clear()
			{
				_count = 0;
				Root = SortedInt32KeyNode<HashBucket>.EmptyNode;
			}

			public void ExceptWith(IEnumerable<T> other)
			{
				MutationResult result = ImmutableHashSet<T>.Except(other, _equalityComparer, _hashBucketEqualityComparer, _root);
				Apply(result);
			}

			public void IntersectWith(IEnumerable<T> other)
			{
				MutationResult result = ImmutableHashSet<T>.Intersect(other, Origin);
				Apply(result);
			}

			public bool IsProperSubsetOf(IEnumerable<T> other)
			{
				return ImmutableHashSet<T>.IsProperSubsetOf(other, Origin);
			}

			public bool IsProperSupersetOf(IEnumerable<T> other)
			{
				return ImmutableHashSet<T>.IsProperSupersetOf(other, Origin);
			}

			public bool IsSubsetOf(IEnumerable<T> other)
			{
				return ImmutableHashSet<T>.IsSubsetOf(other, Origin);
			}

			public bool IsSupersetOf(IEnumerable<T> other)
			{
				return ImmutableHashSet<T>.IsSupersetOf(other, Origin);
			}

			public bool Overlaps(IEnumerable<T> other)
			{
				return ImmutableHashSet<T>.Overlaps(other, Origin);
			}

			public bool SetEquals(IEnumerable<T> other)
			{
				if (this == other)
				{
					return true;
				}
				return ImmutableHashSet<T>.SetEquals(other, Origin);
			}

			public void SymmetricExceptWith(IEnumerable<T> other)
			{
				MutationResult result = ImmutableHashSet<T>.SymmetricExcept(other, Origin);
				Apply(result);
			}

			public void UnionWith(IEnumerable<T> other)
			{
				MutationResult result = ImmutableHashSet<T>.Union(other, Origin);
				Apply(result);
			}

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

			void ICollection<T>.CopyTo(T[] array, int arrayIndex)
			{
				Requires.NotNull(array, "array");
				Requires.Range(arrayIndex >= 0, "arrayIndex");
				Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
				using Enumerator enumerator = GetEnumerator();
				while (enumerator.MoveNext())
				{
					T current = enumerator.Current;
					array[arrayIndex++] = current;
				}
			}

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

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

			private void Apply(MutationResult result)
			{
				Root = result.Root;
				if (result.CountType == CountType.Adjustment)
				{
					_count += result.Count;
				}
				else
				{
					_count = result.Count;
				}
			}
		}

		public struct Enumerator : IEnumerator<T>, IEnumerator, IDisposable, IStrongEnumerator<T>
		{
			private readonly Builder _builder;

			private SortedInt32KeyNode<HashBucket>.Enumerator _mapEnumerator;

			private HashBucket.Enumerator _bucketEnumerator;

			private int _enumeratingBuilderVersion;

			public T Current
			{
				get
				{
					_mapEnumerator.ThrowIfDisposed();
					return _bucketEnumerator.Current;
				}
			}

			object? IEnumerator.Current => Current;

			internal Enumerator(SortedInt32KeyNode<HashBucket> root, Builder? builder = null)
			{
				_builder = builder;
				_mapEnumerator = new SortedInt32KeyNode<HashBucket>.Enumerator(root);
				_bucketEnumerator = default(HashBucket.Enumerator);
				_enumeratingBuilderVersion = builder?.Version ?? (-1);
			}

			public bool MoveNext()
			{
				ThrowIfChanged();
				if (_bucketEnumerator.MoveNext())
				{
					return true;
				}
				if (_mapEnumerator.MoveNext())
				{
					_bucketEnumerator = new HashBucket.Enumerator(_mapEnumerator.Current.Value);
					return _bucketEnumerator.MoveNext();
				}
				return false;
			}

			public void Reset()
			{
				_enumeratingBuilderVersion = ((_builder != null) ? _builder.Version : (-1));
				_mapEnumerator.Reset();
				_bucketEnumerator.Dispose();
				_bucketEnumerator = default(HashBucket.Enumerator);
			}

			public void Dispose()
			{
				_mapEnumerator.Dispose();
				_bucketEnumerator.Dispose();
			}

			private void ThrowIfChanged()
			{
				if (_builder != null && _builder.Version != _enumeratingBuilderVersion)
				{
					throw new InvalidOperationException(System.SR.CollectionModifiedDuringEnumeration);
				}
			}
		}

		internal enum OperationResult
		{
			SizeChanged,
			NoChangeRequired
		}

		internal readonly struct HashBucket
		{
			internal struct Enumerator : IEnumerator<T>, IEnumerator, IDisposable
			{
				private enum Position
				{
					BeforeFirst,
					First,
					Additional,
					End
				}

				private readonly HashBucket _bucket;

				private bool _disposed;

				private Position _currentPosition;

				private ImmutableList<T>.Enumerator _additionalEnumerator;

				object? IEnumerator.Current => Current;

				public T Current
				{
					get
					{
						ThrowIfDisposed();
						return _currentPosition switch
						{
							Position.First => _bucket._firstValue, 
							Position.Additional => _additionalEnumerator.Current, 
							_ => throw new InvalidOperationException(), 
						};
					}
				}

				internal Enumerator(HashBucket bucket)
				{
					_disposed = false;
					_bucket = bucket;
					_currentPosition = Position.BeforeFirst;
					_additionalEnumerator = default(ImmutableList<T>.Enumerator);
				}

				public bool MoveNext()
				{
					ThrowIfDisposed();
					if (_bucket.IsEmpty)
					{
						_currentPosition = Position.End;
						return false;
					}
					switch (_currentPosition)
					{
					case Position.BeforeFirst:
						_currentPosition = Position.First;
						return true;
					case Position.First:
						if (_bucket._additionalElements.IsEmpty)
						{
							_currentPosition = Position.End;
							return false;
						}
						_currentPosition = Position.Additional;
						_additionalEnumerator = new ImmutableList<T>.Enumerator(_bucket._additionalElements);
						return _additionalEnumerator.MoveNext();
					case Position.Additional:
						return _additionalEnumerator.MoveNext();
					case Position.End:
						return false;
					default:
						throw new InvalidOperationException();
					}
				}

				public void Reset()
				{
					ThrowIfDisposed();
					_additionalEnumerator.Dispose();
					_currentPosition = Position.BeforeFirst;
				}

				public void Dispose()
				{
					_disposed = true;
					_additionalEnumerator.Dispose();
				}

				private void ThrowIfDisposed()
				{
					if (_disposed)
					{
						Requires.FailObjectDisposed(this);
					}
				}
			}

			private readonly T _firstValue;

			private readonly ImmutableList<T>.Node _additionalElements;

			internal bool IsEmpty => _additionalElements == null;

			private HashBucket(T firstElement, ImmutableList<T>.Node additionalElements = null)
			{
				_firstValue = firstElement;
				_additionalElements = additionalElements ?? ImmutableList<T>.Node.EmptyNode;
			}

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

			public override bool Equals(object? obj)
			{
				throw new NotSupportedException();
			}

			public override int GetHashCode()
			{
				throw new NotSupportedException();
			}

			internal bool EqualsByRef(HashBucket other)
			{
				if ((object)_firstValue == (object)other._firstValue)
				{
					return _additionalElements == other._additionalElements;
				}
				return false;
			}

			internal bool EqualsByValue(HashBucket other, IEqualityComparer<T> valueComparer)
			{
				if (valueComparer.Equals(_firstValue, other._firstValue))
				{
					return _additionalElements == other._additionalElements;
				}
				return false;
			}

			internal HashBucket Add(T value, IEqualityComparer<T> valueComparer, out OperationResult result)
			{
				if (IsEmpty)
				{
					result = OperationResult.SizeChanged;
					return new HashBucket(value);
				}
				if (valueComparer.Equals(value, _firstValue) || _additionalElements.IndexOf(value, valueComparer) >= 0)
				{
					result = OperationResult.NoChangeRequired;
					return this;
				}
				result = OperationResult.SizeChanged;
				return new HashBucket(_firstValue, _additionalElements.Add(value));
			}

			internal bool Contains(T value, IEqualityComparer<T> valueComparer)
			{
				if (IsEmpty)
				{
					return false;
				}
				if (!valueComparer.Equals(value, _firstValue))
				{
					return _additionalElements.IndexOf(value, valueComparer) >= 0;
				}
				return true;
			}

			internal bool TryExchange(T value, IEqualityComparer<T> valueComparer, out T existingValue)
			{
				if (!IsEmpty)
				{
					if (valueComparer.Equals(value, _firstValue))
					{
						existingValue = _firstValue;
						return true;
					}
					int num = _additionalElements.IndexOf(value, valueComparer);
					if (num >= 0)
					{
						existingValue = _additionalElements.ItemRef(num);
						return true;
					}
				}
				existingValue = value;
				return false;
			}

			internal HashBucket Remove(T value, IEqualityComparer<T> equalityComparer, out OperationResult result)
			{
				if (IsEmpty)
				{
					result = OperationResult.NoChangeRequired;
					return this;
				}
				if (equalityComparer.Equals(_firstValue, value))
				{
					if (_additionalElements.IsEmpty)
					{
						result = OperationResult.SizeChanged;
						return default(HashBucket);
					}
					int count = _additionalElements.Left.Count;
					result = OperationResult.SizeChanged;
					return new HashBucket(_additionalElements.Key, _additionalElements.RemoveAt(count));
				}
				int num = _additionalElements.IndexOf(value, equalityComparer);
				if (num < 0)
				{
					result = OperationResult.NoChangeRequired;
					return this;
				}
				result = OperationResult.SizeChanged;
				return new HashBucket(_firstValue, _additionalElements.RemoveAt(num));
			}

			internal void Freeze()
			{
				if (_additionalElements != null)
				{
					_additionalElements.Freeze();
				}
			}
		}

		private readonly struct MutationInput
		{
			private readonly SortedInt32KeyNode<HashBucket> _root;

			private readonly IEqualityComparer<T> _equalityComparer;

			private readonly int _count;

			private readonly IEqualityComparer<HashBucket> _hashBucketEqualityComparer;

			internal SortedInt32KeyNode<HashBucket> Root => _root;

			internal IEqualityComparer<T> EqualityComparer => _equalityComparer;

			internal int Count => _count;

			internal IEqualityComparer<HashBucket> HashBucketEqualityComparer => _hashBucketEqualityComparer;

			internal MutationInput(ImmutableHashSet<T> set)
			{
				Requires.NotNull(set, "set");
				_root = set._root;
				_equalityComparer = set._equalityComparer;
				_count = set._count;
				_hashBucketEqualityComparer = set._hashBucketEqualityComparer;
			}

			internal MutationInput(SortedInt32KeyNode<HashBucket> root, IEqualityComparer<T> equalityComparer, IEqualityComparer<HashBucket> hashBucketEqualityComparer, int count)
			{
				Requires.NotNull(root, "root");
				Requires.NotNull(equalityComparer, "equalityComparer");
				Requires.Range(count >= 0, "count");
				Requires.NotNull(hashBucketEqualityComparer, "hashBucketEqualityComparer");
				_root = root;
				_equalityComparer = equalityComparer;
				_count = count;
				_hashBucketEqualityComparer = hashBucketEqualityComparer;
			}
		}

		private enum CountType
		{
			Adjustment,
			FinalValue
		}

		private readonly struct MutationResult
		{
			private readonly SortedInt32KeyNode<HashBucket> _root;

			private readonly int _count;

			private readonly CountType _countType;

			internal SortedInt32KeyNode<HashBucket> Root => _root;

			internal int Count => _count;

			internal CountType CountType => _countType;

			internal MutationResult(SortedInt32KeyNode<HashBucket> root, int count, CountType countType = CountType.Adjustment)
			{
				Requires.NotNull(root, "root");
				_root = root;
				_count = count;
				_countType = countType;
			}

			internal ImmutableHashSet<T> Finalize(ImmutableHashSet<T> priorSet)
			{
				Requires.NotNull(priorSet, "priorSet");
				int num = Count;
				if (CountType == CountType.Adjustment)
				{
					num += priorSet._count;
				}
				return priorSet.Wrap(Root, num);
			}
		}

		private readonly struct NodeEnumerable : IEnumerable<T>, IEnumerable
		{
			private readonly SortedInt32KeyNode<HashBucket> _root;

			internal NodeEnumerable(SortedInt32KeyNode<HashBucket> root)
			{
				Requires.NotNull(root, "root");
				_root = root;
			}

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

			[ExcludeFromCodeCoverage]
			IEnumerator<T> IEnumerable<T>.GetEnumerator()
			{
				return GetEnumerator();
			}

			[ExcludeFromCodeCoverage]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return GetEnumerator();
			}
		}

		public static readonly ImmutableHashSet<T> Empty = new ImmutableHashSet<T>(SortedInt32KeyNode<HashBucket>.EmptyNode, EqualityComparer<T>.Default, 0);

		private static readonly Action<KeyValuePair<int, HashBucket>> s_FreezeBucketAction = delegate(KeyValuePair<int, HashBucket> kv)
		{
			kv.Value.Freeze();
		};

		private readonly IEqualityComparer<T> _equalityComparer;

		private readonly int _count;

		private readonly SortedInt32KeyNode<HashBucket> _root;

		private readonly IEqualityComparer<HashBucket> _hashBucketEqualityComparer;

		public int Count => _count;

		public bool IsEmpty => Count == 0;

		public IEqualityComparer<T> KeyComparer => _equalityComparer;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		object ICollection.SyncRoot => this;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		bool ICollection.IsSynchronized => true;

		internal IBinaryTree Root => _root;

		private MutationInput Origin => new MutationInput(this);

		bool ICollection<T>.IsReadOnly => true;

		internal ImmutableHashSet(IEqualityComparer<T> equalityComparer)
			: this(SortedInt32KeyNode<HashBucket>.EmptyNode, equalityComparer, 0)
		{
		}

		private ImmutableHashSet(SortedInt32KeyNode<HashBucket> root, IEqualityComparer<T> equalityComparer, int count)
		{
			Requires.NotNull(root, "root");
			Requires.NotNull(equalityComparer, "equalityComparer");
			root.Freeze(s_FreezeBucketAction);
			_root = root;
			_count = count;
			_equalityComparer = equalityComparer;
			_hashBucketEqualityComparer = GetHashBucketEqualityComparer(equalityComparer);
		}

		public ImmutableHashSet<T> Clear()
		{
			if (!IsEmpty)
			{
				return Empty.WithComparer(_equalityComparer);
			}
			return this;
		}

		IImmutableSet<T> IImmutableSet<T>.Clear()
		{
			return Clear();
		}

		public Builder ToBuilder()
		{
			return new Builder(this);
		}

		public ImmutableHashSet<T> Add(T item)
		{
			return Add(item, Origin).Finalize(this);
		}

		public ImmutableHashSet<T> Remove(T item)
		{
			return Remove(item, Origin).Finalize(this);
		}

		public bool TryGetValue(T equalValue, out T actualValue)
		{
			int key = ((equalValue != null) ? _equalityComparer.GetHashCode(equalValue) : 0);
			if (_root.TryGetValue(key, out var value))
			{
				return value.TryExchange(equalValue, _equalityComparer, out actualValue);
			}
			actualValue = equalValue;
			return false;
		}

		public ImmutableHashSet<T> Union(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return Union(other, avoidWithComparer: false);
		}

		public ImmutableHashSet<T> Intersect(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return Intersect(other, Origin).Finalize(this);
		}

		public ImmutableHashSet<T> Except(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return Except(other, _equalityComparer, _hashBucketEqualityComparer, _root).Finalize(this);
		}

		public ImmutableHashSet<T> SymmetricExcept(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return SymmetricExcept(other, Origin).Finalize(this);
		}

		public bool SetEquals(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			if (this == other)
			{
				return true;
			}
			return SetEquals(other, Origin);
		}

		public bool IsProperSubsetOf(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return IsProperSubsetOf(other, Origin);
		}

		public bool IsProperSupersetOf(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return IsProperSupersetOf(other, Origin);
		}

		public bool IsSubsetOf(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return IsSubsetOf(other, Origin);
		}

		public bool IsSupersetOf(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return IsSupersetOf(other, Origin);
		}

		public bool Overlaps(IEnumerable<T> other)
		{
			Requires.NotNull(other, "other");
			return Overlaps(other, Origin);
		}

		IImmutableSet<T> IImmutableSet<T>.Add(T item)
		{
			return Add(item);
		}

		IImmutableSet<T> IImmutableSet<T>.Remove(T item)
		{
			return Remove(item);
		}

		IImmutableSet<T> IImmutableSet<T>.Union(IEnumerable<T> other)
		{
			return Union(other);
		}

		IImmutableSet<T> IImmutableSet<T>.Intersect(IEnumerable<T> other)
		{
			return Intersect(other);
		}

		IImmutableSet<T> IImmutableSet<T>.Except(IEnumerable<T> other)
		{
			return Except(other);
		}

		IImmutableSet<T> IImmutableSet<T>.SymmetricExcept(IEnumerable<T> other)
		{
			return SymmetricExcept(other);
		}

		public bool Contains(T item)
		{
			return Contains(item, Origin);
		}

		public ImmutableHashSet<T> WithComparer(IEqualityComparer<T>? equalityComparer)
		{
			if (equalityComparer == null)
			{
				equalityComparer = EqualityComparer<T>.Default;
			}
			if (equalityComparer == _equalityComparer)
			{
				return this;
			}
			ImmutableHashSet<T> immutableHashSet = new ImmutableHashSet<T>(equalityComparer);
			return immutableHashSet.Union(this, avoidWithComparer: true);
		}

		bool ISet<T>.Add(T item)
		{
			throw new NotSupportedException();
		}

		void ISet<T>.ExceptWith(IEnumerable<T> other)
		{
			throw new NotSupportedException();
		}

		void ISet<T>.IntersectWith(IEnumerable<T> other)
		{
			throw new NotSupportedException();
		}

		void ISet<T>.SymmetricExceptWith(IEnumerable<T> other)
		{
			throw new NotSupportedException();
		}

		void ISet<T>.UnionWith(IEnumerable<T> other)
		{
			throw new NotSupportedException();
		}

		void ICollection<T>.CopyTo(T[] array, int arrayIndex)
		{
			Requires.NotNull(array, "array");
			Requires.Range(arrayIndex >= 0, "arrayIndex");
			Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
			using Enumerator enumerator = GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				array[arrayIndex++] = current;
			}
		}

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

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

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

		void ICollection.CopyTo(Array array, int arrayIndex)
		{
			Requires.NotNull(array, "array");
			Requires.Range(arrayIndex >= 0, "arrayIndex");
			Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
			using Enumerator enumerator = GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				array.SetValue(current, arrayIndex++);
			}
		}

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

		IEnumerator<T> IEnumerable<T>.GetEnumerator()
		{
			if (!IsEmpty)
			{
				return GetEnumerator();
			}
			return Enumerable.Empty<T>().GetEnumerator();
		}

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

		private static bool IsSupersetOf(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				if (!Contains(item, origin))
				{
					return false;
				}
			}
			return true;
		}

		private static MutationResult Add(T item, MutationInput origin)
		{
			int num = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
			OperationResult result;
			HashBucket newBucket = origin.Root.GetValueOrDefault(num).Add(item, origin.EqualityComparer, out result);
			if (result == OperationResult.NoChangeRequired)
			{
				return new MutationResult(origin.Root, 0);
			}
			SortedInt32KeyNode<HashBucket> root = UpdateRoot(origin.Root, num, origin.HashBucketEqualityComparer, newBucket);
			return new MutationResult(root, 1);
		}

		private static MutationResult Remove(T item, MutationInput origin)
		{
			OperationResult result = OperationResult.NoChangeRequired;
			int num = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
			SortedInt32KeyNode<HashBucket> root = origin.Root;
			if (origin.Root.TryGetValue(num, out var value))
			{
				HashBucket newBucket = value.Remove(item, origin.EqualityComparer, out result);
				if (result == OperationResult.NoChangeRequired)
				{
					return new MutationResult(origin.Root, 0);
				}
				root = UpdateRoot(origin.Root, num, origin.HashBucketEqualityComparer, newBucket);
			}
			return new MutationResult(root, (result == OperationResult.SizeChanged) ? (-1) : 0);
		}

		private static bool Contains(T item, MutationInput origin)
		{
			int key = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
			if (origin.Root.TryGetValue(key, out var value))
			{
				return value.Contains(item, origin.EqualityComparer);
			}
			return false;
		}

		private static MutationResult Union(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			int num = 0;
			SortedInt32KeyNode<HashBucket> sortedInt32KeyNode = origin.Root;
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				int num2 = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
				OperationResult result;
				HashBucket newBucket = sortedInt32KeyNode.GetValueOrDefault(num2).Add(item, origin.EqualityComparer, out result);
				if (result == OperationResult.SizeChanged)
				{
					sortedInt32KeyNode = UpdateRoot(sortedInt32KeyNode, num2, origin.HashBucketEqualityComparer, newBucket);
					num++;
				}
			}
			return new MutationResult(sortedInt32KeyNode, num);
		}

		private static bool Overlaps(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			if (origin.Root.IsEmpty)
			{
				return false;
			}
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				if (Contains(item, origin))
				{
					return true;
				}
			}
			return false;
		}

		private static bool SetEquals(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			HashSet<T> hashSet = new HashSet<T>(other, origin.EqualityComparer);
			if (origin.Count != hashSet.Count)
			{
				return false;
			}
			foreach (T item in hashSet)
			{
				if (!Contains(item, origin))
				{
					return false;
				}
			}
			return true;
		}

		private static SortedInt32KeyNode<HashBucket> UpdateRoot(SortedInt32KeyNode<HashBucket> root, int hashCode, IEqualityComparer<HashBucket> hashBucketEqualityComparer, HashBucket newBucket)
		{
			bool mutated;
			if (newBucket.IsEmpty)
			{
				return root.Remove(hashCode, out mutated);
			}
			bool replacedExistingValue;
			return root.SetItem(hashCode, newBucket, hashBucketEqualityComparer, out replacedExistingValue, out mutated);
		}

		private static MutationResult Intersect(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			SortedInt32KeyNode<HashBucket> root = SortedInt32KeyNode<HashBucket>.EmptyNode;
			int num = 0;
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				if (Contains(item, origin))
				{
					MutationResult mutationResult = Add(item, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
					root = mutationResult.Root;
					num += mutationResult.Count;
				}
			}
			return new MutationResult(root, num, CountType.FinalValue);
		}

		private static MutationResult Except(IEnumerable<T> other, IEqualityComparer<T> equalityComparer, IEqualityComparer<HashBucket> hashBucketEqualityComparer, SortedInt32KeyNode<HashBucket> root)
		{
			Requires.NotNull(other, "other");
			Requires.NotNull(equalityComparer, "equalityComparer");
			Requires.NotNull(root, "root");
			int num = 0;
			SortedInt32KeyNode<HashBucket> sortedInt32KeyNode = root;
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				int num2 = ((item != null) ? equalityComparer.GetHashCode(item) : 0);
				if (sortedInt32KeyNode.TryGetValue(num2, out var value))
				{
					OperationResult result;
					HashBucket newBucket = value.Remove(item, equalityComparer, out result);
					if (result == OperationResult.SizeChanged)
					{
						num--;
						sortedInt32KeyNode = UpdateRoot(sortedInt32KeyNode, num2, hashBucketEqualityComparer, newBucket);
					}
				}
			}
			return new MutationResult(sortedInt32KeyNode, num);
		}

		private static MutationResult SymmetricExcept(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			ImmutableHashSet<T> immutableHashSet = ImmutableHashSet.CreateRange(origin.EqualityComparer, other);
			int num = 0;
			SortedInt32KeyNode<HashBucket> root = SortedInt32KeyNode<HashBucket>.EmptyNode;
			foreach (T item in new NodeEnumerable(origin.Root))
			{
				if (!immutableHashSet.Contains(item))
				{
					MutationResult mutationResult = Add(item, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
					root = mutationResult.Root;
					num += mutationResult.Count;
				}
			}
			foreach (T item2 in immutableHashSet)
			{
				if (!Contains(item2, origin))
				{
					MutationResult mutationResult2 = Add(item2, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
					root = mutationResult2.Root;
					num += mutationResult2.Count;
				}
			}
			return new MutationResult(root, num, CountType.FinalValue);
		}

		private static bool IsProperSubsetOf(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			if (origin.Root.IsEmpty)
			{
				return other.Any();
			}
			HashSet<T> hashSet = new HashSet<T>(other, origin.EqualityComparer);
			if (origin.Count >= hashSet.Count)
			{
				return false;
			}
			int num = 0;
			bool flag = false;
			foreach (T item in hashSet)
			{
				if (Contains(item, origin))
				{
					num++;
				}
				else
				{
					flag = true;
				}
				if (num == origin.Count && flag)
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsProperSupersetOf(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			if (origin.Root.IsEmpty)
			{
				return false;
			}
			int num = 0;
			foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
			{
				num++;
				if (!Contains(item, origin))
				{
					return false;
				}
			}
			return origin.Count > num;
		}

		private static bool IsSubsetOf(IEnumerable<T> other, MutationInput origin)
		{
			Requires.NotNull(other, "other");
			if (origin.Root.IsEmpty)
			{
				return true;
			}
			HashSet<T> hashSet = new HashSet<T>(other, origin.EqualityComparer);
			int num = 0;
			foreach (T item in hashSet)
			{
				if (Contains(item, origin))
				{
					num++;
				}
			}
			return num == origin.Count;
		}

		private static ImmutableHashSet<T> Wrap(SortedInt32KeyNode<HashBucket> root, IEqualityComparer<T> equalityComparer, int count)
		{
			Requires.NotNull(root, "root");
			Requires.NotNull(equalityComparer, "equalityComparer");
			Requires.Range(count >= 0, "count");
			return new ImmutableHashSet<T>(root, equalityComparer, count);
		}

		private static IEqualityComparer<HashBucket> GetHashBucketEqualityComparer(IEqualityComparer<T> valueComparer)
		{
			if (!ImmutableExtensions.IsValueType<T>())
			{
				return HashBucketByRefEqualityComparer.DefaultInstance;
			}
			if (valueComparer == EqualityComparer<T>.Default)
			{
				return HashBucketByValueEqualityComparer.DefaultInstance;
			}
			return new HashBucketByValueEqualityComparer(valueComparer);
		}

		private ImmutableHashSet<T> Wrap(SortedInt32KeyNode<HashBucket> root, int adjustedCountIfDifferentRoot)
		{
			if (root == _root)
			{
				return this;
			}
			return new ImmutableHashSet<T>(root, _equalityComparer, adjustedCountIfDifferentRoot);
		}

		private ImmutableHashSet<T> Union(IEnumerable<T> items, bool avoidWithComparer)
		{
			Requires.NotNull(items, "items");
			if (IsEmpty && !avoidWithComparer && items is ImmutableHashSet<T> immutableHashSet)
			{
				return immutableHashSet.WithComparer(KeyComparer);
			}
			return Union(items, Origin).Finalize(this);
		}
	}
	internal interface IStrongEnumerable<out T, TEnumerator> where TEnumerator : struct, IStrongEnumerator<T>
	{
		TEnumerator GetEnumerator();
	}
	internal interface IStrongEnumerator<T>
	{
		T Current { get; }

		bool MoveNext();
	}
	internal interface IOrderedCollection<out T> : IEnumerable<T>, IEnumerable
	{
		int Count { get; }

		T this[int index] { get; }
	}
	internal static class ImmutableArray
	{
		internal static readonly byte[] TwoElementArray = new byte[2];

		public static ImmutableArray<T> Create<T>()
		{
			return ImmutableArray<T>.Empty;
		}

		public static ImmutableArray<T> Create<T>(T item)
		{
			T[] items = new T[1] { item };
			return new ImmutableArray<T>(items);
		}

		public static ImmutableArray<T> Create<T>(T item1, T item2)
		{
			T[] items = new T[2] { item1, item2 };
			return new ImmutableArray<T>(items);
		}

		public static ImmutableArray<T> Create<T>(T item1, T item2, T item3)
		{
			T[] items = new T[3] { item1, item2, item3 };
			return new ImmutableArray<T>(items);
		}

		public static ImmutableArray<T> Create<T>(T item1, T item2, T item3, T item4)
		{
			T[] items = new T[4] { item1, item2, item3, item4 };
			return new ImmutableArray<T>(items);
		}

		public static ImmutableArray<T> CreateRange<T>(IEnumerable<T> items)
		{
			Requires.NotNull(items, "items");
			if (items is IImmutableArray immutableArray)
			{
				Array array = immutableArray.Array;
				if (array == null)
				{
					throw new InvalidOperationException(System.SR.InvalidOperationOnDefaultArray);
				}
				return new ImmutableArray<T>((T[])array);
			}
			if (items.TryGetCount(out var count))
			{
				return new ImmutableArray<T>(items.ToArray(count));
			}
			return new ImmutableArray<T>(items.ToArray());
		}

		public static ImmutableArray<T> Create<T>(params T[]? items)
		{
			if (items == null || items.Length == 0)
			{
				return ImmutableArray<T>.Empty;
			}
			T[] array = new T[items.Length];
			Array.Copy(items, array, items.Length);
			return new ImmutableArray<T>(array);
		}

		public static ImmutableArray<T> Create<T>(T[] items, int start, int length)
		{
			Requires.NotNull(items, "items");
			Requires.Range(start >= 0 && start <= items.Length, "start");
			Requires.Range(length >= 0 && start + length <= items.Length, "length");
			if (length == 0)
			{
				return Create<T>();
			}
			T[] array = new T[length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = items[start + i];
			}
			return new ImmutableArray<T>(array);
		}

		public static ImmutableArray<T> Create<T>(ImmutableArray<T> items, int start, int length)
		{
			Requires.Range(start >= 0 && start <= items.Length, "start");
			Requires.Range(length >= 0 && start + length <= items.Length, "length");
			if (length == 0)
			{
				return Create<T>();
			}
			if (start == 0 && length == items.Length)
			{
				return items;
			}
			T[] array = new T[length];
			Array.Copy(items.array, start, array, 0, length);
			return new ImmutableArray<T>(array);
		}

		public static ImmutableArray<TResult> CreateRange<TSource, TResult>(ImmutableArray<TSource> items, Func<TSource, TResult> selector)
		{
			Requires.NotNull(selector, "selector");
			int length = items.Length;
			if (length == 0)
			{
				return Create<TResult>();
			}
			TResult[] array = new TResult[length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = selector(items[i]);
			}
			return new ImmutableArray<TResult>(array);
		}

		public static ImmutableArray<TResult> CreateRange<TSource, TResult>(ImmutableArray<TSource> items, int start, int length, Func<TSource, TResult> selector)
		{
			int length2 = items.Length;
			Requires.Range(start >= 0 && start <= length2, "start");
			Requires.Range(length >= 0 && start + length <= length2, "length");
			Requires.NotNull(selector, "selector");
			if (length == 0)
			{
				return Create<TResult>();
			}
			TResult[] array = new TResult[length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = selector(items[i + start]);
			}
			return new ImmutableArray<TResult>(array);
		}

		public static ImmutableArray<TResult> CreateRange<TSource, TArg, TResult>(ImmutableArray<TSource> items, Func<TSource, TArg, TResult> selector, TArg arg)
		{
			Requires.NotNull(selector, "selector");
			int length = items.Length;
			if (length == 0)
			{
				return Create<TResult>();
			}
			TResult[] array = new TResult[length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = selector(items[i], arg);
			}
			return new ImmutableArray<TResult>(array);
		}

		public static ImmutableArray<TResult> CreateRange<TSource, TArg, TResult>(ImmutableArray<TSource> items, int start, int length, Func<TSource, TArg, TResult> selector, TArg arg)
		{
			int length2 = items.Length;
			Requires.Range(start >= 0 && start <= length2, "start");
			Requires.Range(length >= 0 && start + length <= length2, "length");
			Requires.NotNull(selector, "selector");
			if (length == 0)
			{
				return Create<TResult>();
			}
			TResult[] array = new TResult[length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = selector(items[i + start], arg);
			}
			return new ImmutableArray<TResult>(array);
		}

		public static ImmutableArray<T>.Builder CreateBuilder<T>()
		{
			return Create<T>().ToBuilder();
		}

		public static ImmutableArray<T>.Builder CreateBuilder<T>(int initialCapacity)
		{
			return new ImmutableArray<T>.Builder(initialCapacity);
		}

		public static ImmutableArray<TSource> ToImmutableArray<TSource>(this IEnumerable<TSource> items)
		{
			if (items is ImmutableArray<TSource>)
			{
				return (ImmutableArray<TSource>)(object)items;
			}
			return CreateRange(items);
		}

		public static ImmutableArray<TSource> ToImmutableArray<TSource>(this ImmutableArray<TSource>.Builder builder)
		{
			Requires.NotNull(builder, "builder");
			return builder.ToImmutable();
		}

		public static int BinarySearch<T>(this ImmutableArray<T> array, T value)
		{
			return Array.BinarySearch(array.array, value);
		}

		public static int BinarySearch<T>(this ImmutableArray<T> array, T value, IComparer<T>? comparer)
		{
			return Array.BinarySearch(array.array, value, comparer);
		}

		public static int BinarySearch<T>(this ImmutableArray<T> array, int index, int length, T value)
		{
			return Array.BinarySearch(array.array, index, length, value);
		}

		public static int BinarySearch<T>(this ImmutableArray<T> array, int index, int length, T value, IComparer<T>? comparer)
		{
			return Array.BinarySearch(array.array, index, length, value, comparer);
		}
	}
	[DebuggerDisplay("{DebuggerDisplay,nq}")]
	[System.Runtime.Versioning.NonVersionable]
	internal struct ImmutableArray<T> : IReadOnlyList<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>, IList<T>, ICollection<T>, IEquatable<ImmutableArray<T>>, IList, ICollection, IImmutableArray, IStructuralComparable, IStructuralEquatable, IImmutableList<T>
	{
		[DebuggerDisplay("Count = {Count}")]
		[DebuggerTypeProxy(typeof(ImmutableArrayBuilderDebuggerProxy<>))]
		public sealed class Builder : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IReadOnlyList<T>, IReadOnlyCollection<T>
		{
			private T[] _elements;

			private int _count;

			public int Capacity
			{
				get
				{
					return _elements.Length;
				}
				set
				{
					if (value < _count)
					{
						throw new ArgumentException(System.SR.CapacityMustBeGreaterThanOrEqualToCount, "value");
					}
					if (value == _elements.Length)
					{
						return;
					}
					if (value > 0)
					{
						T[] array = new T[value];
						if (_count > 0)
						{
							Array.Copy(_elements, array, _count);
						}
						_elements = array;
					}
					else
					{
						_elements = ImmutableArray<T>.Empty.array;
					}
				}
			}

			public int Count
			{
				get
				{
					return _count;
				}
				set
				{
					Requires.Range(value >= 0, "value");
					if (value < _count)
					{
						if (_count - value > 64)
						{
							Array.Clear(_elements, value, _count - value);
						}
						else
						{
							for (int i = value; i < Count; i++)
							{
								_elements[i] = default(T);
							}
						}
					}
					else if (value > _count)
					{
						EnsureCapacity(value);
					}
					_count = value;
				}
			}

			public T this[int index]
			{
				get
				{
					if (index >= Count)
					{
						ThrowIndexOutOfRangeException();
					}
					return _elements[index];
				}
				set
				{
					if (index >= Count)
					{
						ThrowIndexOutOfRangeException();
					}
					_elements[index] = value;
				}
			}

			bool ICollection<T>.IsReadOnly => false;

			internal Builder(int capacity)
			{
				Requires.Range(capacity >= 0, "capacity");
				_elements = new T[capacity];
				_count = 0;
			}

			internal Builder()
				: this(8)
			{
			}

			private static void ThrowIndexOutOfRangeException()
			{
				throw new IndexOutOfRangeException();
			}

			public ref readonly T ItemRef(int index)
			{
				if (index >= Count)
				{
					ThrowIndexOutOfRangeException();
				}
				return ref _elements[index];
			}

			public ImmutableArray<T> ToImmutable()
			{
				return new ImmutableArray<T>(ToArray());
			}

			public ImmutableArray<T> MoveToImmutable()
			{
				if (Capacity != Count)
				{
					throw new InvalidOperationException(System.SR.CapacityMustEqualCountOnMove);
				}
				T[] elements = _elements;
				_elements = ImmutableArray<T>.Empty.array;
				_count = 0;
				return new ImmutableArray<T>(elements);
			}

			public void Clear()
			{
				Count = 0;
			}

			public void Insert(int index, T item)
			{
				Requires.Range(index >= 0 && index <= Count, "index");
				EnsureCapacity(Count + 1);
				if (index < Count)
				{
					Array.Copy(_elements, index, _elements, index + 1, Count - index);
				}
				_count++;
				_elements[index] = item;
			}

			public void Add(T item)
			{
				int num = _count + 1;
				EnsureCapacity(num);
				_elements[_count] = item;
				_count = num;
			}

			public void AddRange(IEnumerable<T> items)
			{
				Requires.NotNull(items, "items");
				if (items.TryGetCount(out var count))
				{
					EnsureCapacity(Count + count);
					if (items.TryCopyTo(_elements, _count))
					{
						_count += count;
						return;
					}
				}
				foreach (T item in items)
				{
					Add(item);
				}
			}

			public void AddRange(params T[] items)
			{
				Requires.NotNull(items, "items");
				int count = Count;
				Count += items.Length;
				Array.Copy(items, 0, _elements, count, items.Length);
			}

			public void AddRange<TDerived>(TDerived[] items) where TDerived : T
			{
				Requires.NotNull(items, "items");
				int count = Count;
				Count += items.Length;
				Array.Copy(items, 0, _elements, count, items.Length);
			}

			public void AddRange(T[] items, int length)
			{
				Requires.NotNull(items, "items");
				Requires.Range(length >= 0 && length <= items.Length, "length");
				int count = Count;
				Count += length;
				Array.Copy(items, 0, _elements, count, length);
			}

			public void AddRange(ImmutableArray<T> items)
			{
				AddRange(items, items.Length);
			}

			public void AddRange(ImmutableArray<T> items, int length)
			{
				Requires.Range(length >= 0, "length");
				if (items.array != null)
				{
					AddRange(items.array, length);
				}
			}

			public void AddRange<TDerived>(ImmutableArray<TDerived> items) where TDerived : T
			{
				if (items.array != null)
				{
					this.AddRange<TDerived>(items.array);
				}
			}

			public void AddRange(Builder items)
			{
				Requires.NotNull(items, "items");
				AddRange(items._elements, items.Count);
			}

			public void AddRange<TDerived>(ImmutableArray<TDerived>.Builder items) where TDerived : T
			{
				Requires.NotNull(items, "items");
				AddRange<TDerived>(items._elements, items.Count);
			}

			public bool Remove(T element)
			{
				int num = IndexOf(element);
				if (num >= 0)
				{
					RemoveAt(num);
					return true;
				}
				return false;
			}

			public void RemoveAt(int index)
			{
				Requires.Range(index >= 0 && index < Count, "index");
				if (index < Count - 1)
				{
					Array.Copy(_elements, index + 1, _elements, index, Count - index - 1);
				}
				Count--;
			}

			public bool Contains(T item)
			{
				return IndexOf(item) >= 0;
			}

			public T[] ToArray()
			{
				if (Count == 0)
				{
					return ImmutableArray<T>.Empty.array;
				}
				T[] array = new T[Count];
				Array.Copy(_elements, array, Count);
				return array;
			}

			public void CopyTo(T[] array, int index)
			{
				Requires.NotNull(array, "array");
				Requires.Range(index >= 0 && index + Count <= array.Length, "index");
				Array.Copy(_elements, 0, array, index, Count);
			}

			private void EnsureCapacity(int capacity)
			{
				if (_elements.Length < capacity)
				{
					int newSize = Math.Max(_elements.Length * 2, capacity);
					Array.Resize(ref _elements, newSize);
				}
			}

			public int IndexOf(T item)
			{
				return IndexOf(item, 0, _count, EqualityComparer<T>.Default);
			}

			public int IndexOf(T item, int startIndex)
			{
				return IndexOf(item, startIndex, Count - startIndex, EqualityComparer<T>.Default);
			}

			public int IndexOf(T item, int startIndex, int count)
			{
				return IndexOf(item, startIndex, count, EqualityComparer<T>.Default);
			}

			public int IndexOf(T item, int startIndex, int count, IEqualityComparer<T>? equalityComparer)
			{
				if (count == 0 && startIndex == 0)
				{
					return -1;
				}
				Requires.Range(startIndex >= 0 && startIndex < Count, "startIndex");
				Requires.Range(count >= 0 && startIndex + count <= Count, "count");
				equalityComparer = equalityComparer ?? EqualityComparer<T>.Default;
				if (equalityComparer == EqualityComparer<T>.Default)
				{
					return Array.IndexOf(_elements, item, startIndex, count);
				}
				for (int i = startIndex; i < startIndex + count; i++)
				{
					if (equalityComparer.Equals(_elements[i], item))
					{
						return i;
					}
				}
				return -1;
			}

			public int LastIndexOf(T item)
			{
				if (Count == 0)
				{
					return -1;
				}
				return LastIndexOf(item, Count - 1, Count, EqualityComparer<T>.Default);
			}

			public int LastIndexOf(T item, int startIndex)
			{
				if (Count == 0 && startIndex == 0)
				{
					return -1;
				}
				Requires.Range(startIndex >= 0 && startIndex < Count, "startIndex");
				return LastIndexOf(item, startIndex, startIndex + 1, EqualityComparer<T>.Default);
			}

			public int LastIndexOf(T item, int startIndex, int count)
			{
				return LastIndexOf(item, startIndex, count, EqualityComparer<T>.Default);
			}

			public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer<T>? equalityComparer)
			{
				if (count == 0 && startIndex == 0)
				{
					return -1;
				}
				Requires.Range(startIndex >= 0 && startIndex < Count, "startIndex");
				Requires.Range(count >= 0 && startIndex - count + 1 >= 0, "count");
				equalityComparer = equalityComparer ?? EqualityComparer<T>.Default;
				if (equalityComparer == EqualityComparer<T>.Default)
				{
					return Array.LastIndexOf(_elements, item, startIndex, count);
				}
				for (int num = startIndex; num >= startIndex - count + 1; num--)
				{
					if (equalityComparer.Equals(item, _elements[num]))
					{
						return num;
					}
				}
				return -1;
			}

			public void Reverse()
			{
				int num = 0;
				int num2 = _count - 1;
				T[] elements = _elements;
				while (num < num2)
				{
					T val = elements[num];
					elements[num] = elements[num2];
					elements[num2] = val;
					num++;
					num2--;
				}
			}

			public void Sort()
			{
				if (Count > 1)
				{
					Array.Sort(_elements, 0, Count, Comparer<T>.Default);
				}
			}

			public void Sort(Comparison<T> comparison)
			{
				Requires.NotNull(comparison, "comparison");
				if (Count > 1)
				{
					Array.Sort(_elements, 0, _count, Comparer<T>.Create(comparison));
				}
			}

			public void Sort(IComparer<T>? comparer)
			{
				if (Count > 1)
				{
					Array.Sort(_elements, 0, _count, comparer);
				}
			}

			public void Sort(int index, int count, IComparer<T>? comparer)
			{
				Requires.Range(index >= 0, "index");
				Requires.Range(count >= 0 && index + count <= Count, "count");
				if (count > 1)
				{
					Array.Sort(_elements, index, count, comparer);
				}
			}

			public IEnumerator<T> GetEnumerator()
			{
				for (int i = 0; i < Count; i++)
				{
					yield return this[i];
				}
			}

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

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

			private void AddRange<TDerived>(TDerived[] items, int length) where TDerived : T
			{
				EnsureCapacity(Count + length);
				int count = Count;
				Count += length;
				T[] elements = _elements;
				for (int i = 0; i < length; i++)
				{
					elements[count + i] = (T)(object)items[i];
				}
			}
		}

		public struct Enumerator
		{
			private readonly T[] _array;

			private int _index;

			public T Current => _array[_index];

			internal Enumerator(T[] array)
			{
				_array = array;
				_index = -1;
			}

			public bool MoveNext()
			{
				return ++_index < _array.Length;
			}
		}

		private class EnumeratorObject : IEnumerator<T>, IEnumerator, IDisposable
		{
			private static readonly IEnumerator<T> s_EmptyEnumerator = new EnumeratorObject(ImmutableArray<T>.Empty.array);

			private readonly T[] _array;

			private int _index;

			public T Current
			{
				get
				{
					if ((uint)_index < (uint)_array.Length)
					{
						return _array[_index];
					}
					throw new InvalidOperationException();
				}
			}

			object IEnumerator.Current => Current;

			private EnumeratorObject(T[] array)
			{
				_index = -1;
				_array = array;
			}

			public bool MoveNext()
			{
				int num = _index + 1;
				int num2 = _array.Length;
				if ((uint)num <= (uint)num2)
				{
					_index = num;
					return (uint)num < (uint)num2;
				}
				return false;
			}

			void IEnumerator.Reset()
			{
				_index = -1;
			}

			public void Dispose()
			{
			}

			internal static IEnumerator<T> Create(T[] array)
			{
				if (array.Length != 0)
				{
					return new EnumeratorObject(array);
				}
				return s_EmptyEnumerator;
			}
		}

		public static readonly ImmutableArray<T> Empty = new ImmutableArray<T>(new T[0]);

		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
		internal T[]? array;

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

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		bool ICollection<T>.IsReadOnly => true;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		int ICollection<T>.Count
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				immutableArray.ThrowInvalidOperationIfNotInitialized();
				return immutableArray.Length;
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		int IReadOnlyCollection<T>.Count
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				immutableArray.ThrowInvalidOperationIfNotInitialized();
				return immutableArray.Length;
			}
		}

		T IReadOnlyList<T>.this[int index]
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				immutableArray.ThrowInvalidOperationIfNotInitialized();
				return immutableArray[index];
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		bool IList.IsFixedSize => true;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		bool IList.IsReadOnly => true;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		int ICollection.Count
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				immutableArray.ThrowInvalidOperationIfNotInitialized();
				return immutableArray.Length;
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		bool ICollection.IsSynchronized => true;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		object ICollection.SyncRoot
		{
			get
			{
				throw new NotSupportedException();
			}
		}

		object? IList.this[int index]
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				immutableArray.ThrowInvalidOperationIfNotInitialized();
				return immutableArray[index];
			}
			set
			{
				throw new NotSupportedException();
			}
		}

		public T this[int index]
		{
			[System.Runtime.Versioning.NonVersionable]
			get
			{
				return array[index];
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public bool IsEmpty
		{
			[System.Runtime.Versioning.NonVersionable]
			get
			{
				return array.Length == 0;
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public int Length
		{
			[System.Runtime.Versioning.NonVersionable]
			get
			{
				return array.Length;
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public bool IsDefault => array == null;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public bool IsDefaultOrEmpty
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				if (immutableArray.array != null)
				{
					return immutableArray.array.Length == 0;
				}
				return true;
			}
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		Array? IImmutableArray.Array => array;

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private string DebuggerDisplay
		{
			get
			{
				ImmutableArray<T> immutableArray = this;
				if (!immutableArray.IsDefault)
				{
					return string.Format(CultureInfo.CurrentCulture, "Length = {0}", immutableArray.Length);
				}
				return "Uninitialized";
			}
		}

		public ReadOnlySpan<T> AsSpan()
		{
			return new ReadOnlySpan<T>(array);
		}

		public ReadOnlyMemory<T> AsMemory()
		{
			return new ReadOnlyMemory<T>(array);
		}

		public int IndexOf(T item)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.IndexOf(item, 0, immutableArray.Length, EqualityComparer<T>.Default);
		}

		public int IndexOf(T item, int startIndex, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.IndexOf(item, startIndex, immutableArray.Length - startIndex, equalityComparer);
		}

		public int IndexOf(T item, int startIndex)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.IndexOf(item, startIndex, immutableArray.Length - startIndex, EqualityComparer<T>.Default);
		}

		public int IndexOf(T item, int startIndex, int count)
		{
			return IndexOf(item, startIndex, count, EqualityComparer<T>.Default);
		}

		public int IndexOf(T item, int startIndex, int count, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowNullRefIfNotInitialized();
			if (count == 0 && startIndex == 0)
			{
				return -1;
			}
			Requires.Range(startIndex >= 0 && startIndex < immutableArray.Length, "startIndex");
			Requires.Range(count >= 0 && startIndex + count <= immutableArray.Length, "count");
			equalityComparer = equalityComparer ?? EqualityComparer<T>.Default;
			if (equalityComparer == EqualityComparer<T>.Default)
			{
				return Array.IndexOf(immutableArray.array, item, startIndex, count);
			}
			for (int i = startIndex; i < startIndex + count; i++)
			{
				if (equalityComparer.Equals(immutableArray.array[i], item))
				{
					return i;
				}
			}
			return -1;
		}

		public int LastIndexOf(T item)
		{
			ImmutableArray<T> immutableArray = this;
			if (immutableArray.Length == 0)
			{
				return -1;
			}
			return immutableArray.LastIndexOf(item, immutableArray.Length - 1, immutableArray.Length, EqualityComparer<T>.Default);
		}

		public int LastIndexOf(T item, int startIndex)
		{
			ImmutableArray<T> immutableArray = this;
			if (immutableArray.Length == 0 && startIndex == 0)
			{
				return -1;
			}
			return immutableArray.LastIndexOf(item, startIndex, startIndex + 1, EqualityComparer<T>.Default);
		}

		public int LastIndexOf(T item, int startIndex, int count)
		{
			return LastIndexOf(item, startIndex, count, EqualityComparer<T>.Default);
		}

		public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowNullRefIfNotInitialized();
			if (startIndex == 0 && count == 0)
			{
				return -1;
			}
			Requires.Range(startIndex >= 0 && startIndex < immutableArray.Length, "startIndex");
			Requires.Range(count >= 0 && startIndex - count + 1 >= 0, "count");
			equalityComparer = equalityComparer ?? EqualityComparer<T>.Default;
			if (equalityComparer == EqualityComparer<T>.Default)
			{
				return Array.LastIndexOf(immutableArray.array, item, startIndex, count);
			}
			for (int num = startIndex; num >= startIndex - count + 1; num--)
			{
				if (equalityComparer.Equals(item, immutableArray.array[num]))
				{
					return num;
				}
			}
			return -1;
		}

		public bool Contains(T item)
		{
			return IndexOf(item) >= 0;
		}

		public ImmutableArray<T> Insert(int index, T item)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0 && index <= immutableArray.Length, "index");
			if (immutableArray.Length == 0)
			{
				return ImmutableArray.Create(item);
			}
			T[] array = new T[immutableArray.Length + 1];
			array[index] = item;
			if (index != 0)
			{
				Array.Copy(immutableArray.array, array, index);
			}
			if (index != immutableArray.Length)
			{
				Array.Copy(immutableArray.array, index, array, index + 1, immutableArray.Length - index);
			}
			return new ImmutableArray<T>(array);
		}

		public ImmutableArray<T> InsertRange(int index, IEnumerable<T> items)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0 && index <= result.Length, "index");
			Requires.NotNull(items, "items");
			if (result.Length == 0)
			{
				return ImmutableArray.CreateRange(items);
			}
			int count = ImmutableExtensions.GetCount(ref items);
			if (count == 0)
			{
				return result;
			}
			T[] array = new T[result.Length + count];
			if (index != 0)
			{
				Array.Copy(result.array, array, index);
			}
			if (index != result.Length)
			{
				Array.Copy(result.array, index, array, index + count, result.Length - index);
			}
			if (!items.TryCopyTo(array, index))
			{
				int num = index;
				foreach (T item in items)
				{
					array[num++] = item;
				}
			}
			return new ImmutableArray<T>(array);
		}

		public ImmutableArray<T> InsertRange(int index, ImmutableArray<T> items)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			items.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0 && index <= result.Length, "index");
			if (result.IsEmpty)
			{
				return items;
			}
			if (items.IsEmpty)
			{
				return result;
			}
			T[] array = new T[result.Length + items.Length];
			if (index != 0)
			{
				Array.Copy(result.array, array, index);
			}
			if (index != result.Length)
			{
				Array.Copy(result.array, index, array, index + items.Length, result.Length - index);
			}
			Array.Copy(items.array, 0, array, index, items.Length);
			return new ImmutableArray<T>(array);
		}

		public ImmutableArray<T> Add(T item)
		{
			ImmutableArray<T> immutableArray = this;
			if (immutableArray.Length == 0)
			{
				return ImmutableArray.Create(item);
			}
			return immutableArray.Insert(immutableArray.Length, item);
		}

		public ImmutableArray<T> AddRange(IEnumerable<T> items)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.InsertRange(immutableArray.Length, items);
		}

		public ImmutableArray<T> AddRange(ImmutableArray<T> items)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.InsertRange(immutableArray.Length, items);
		}

		public ImmutableArray<T> SetItem(int index, T item)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0 && index < immutableArray.Length, "index");
			T[] array = new T[immutableArray.Length];
			Array.Copy(immutableArray.array, array, immutableArray.Length);
			array[index] = item;
			return new ImmutableArray<T>(array);
		}

		public ImmutableArray<T> Replace(T oldValue, T newValue)
		{
			return Replace(oldValue, newValue, EqualityComparer<T>.Default);
		}

		public ImmutableArray<T> Replace(T oldValue, T newValue, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			int num = immutableArray.IndexOf(oldValue, 0, immutableArray.Length, equalityComparer);
			if (num < 0)
			{
				throw new ArgumentException(System.SR.CannotFindOldValue, "oldValue");
			}
			return immutableArray.SetItem(num, newValue);
		}

		public ImmutableArray<T> Remove(T item)
		{
			return Remove(item, EqualityComparer<T>.Default);
		}

		public ImmutableArray<T> Remove(T item, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			int num = result.IndexOf(item, 0, result.Length, equalityComparer);
			if (num >= 0)
			{
				return result.RemoveAt(num);
			}
			return result;
		}

		public ImmutableArray<T> RemoveAt(int index)
		{
			return RemoveRange(index, 1);
		}

		public ImmutableArray<T> RemoveRange(int index, int length)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0 && index <= result.Length, "index");
			Requires.Range(length >= 0 && index + length <= result.Length, "length");
			if (length == 0)
			{
				return result;
			}
			T[] array = new T[result.Length - length];
			Array.Copy(result.array, array, index);
			Array.Copy(result.array, index + length, array, index, result.Length - index - length);
			return new ImmutableArray<T>(array);
		}

		public ImmutableArray<T> RemoveRange(IEnumerable<T> items)
		{
			return RemoveRange(items, EqualityComparer<T>.Default);
		}

		public ImmutableArray<T> RemoveRange(IEnumerable<T> items, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowNullRefIfNotInitialized();
			Requires.NotNull(items, "items");
			SortedSet<int> sortedSet = new SortedSet<int>();
			foreach (T item in items)
			{
				int num = immutableArray.IndexOf(item, 0, immutableArray.Length, equalityComparer);
				while (num >= 0 && !sortedSet.Add(num) && num + 1 < immutableArray.Length)
				{
					num = immutableArray.IndexOf(item, num + 1, equalityComparer);
				}
			}
			return immutableArray.RemoveAtRange(sortedSet);
		}

		public ImmutableArray<T> RemoveRange(ImmutableArray<T> items)
		{
			return RemoveRange(items, EqualityComparer<T>.Default);
		}

		public ImmutableArray<T> RemoveRange(ImmutableArray<T> items, IEqualityComparer<T>? equalityComparer)
		{
			ImmutableArray<T> result = this;
			Requires.NotNull(items.array, "items");
			if (items.IsEmpty)
			{
				result.ThrowNullRefIfNotInitialized();
				return result;
			}
			if (items.Length == 1)
			{
				return result.Remove(items[0], equalityComparer);
			}
			return result.RemoveRange(items.array, equalityComparer);
		}

		public ImmutableArray<T> RemoveAll(Predicate<T> match)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			Requires.NotNull(match, "match");
			if (result.IsEmpty)
			{
				return result;
			}
			List<int> list = null;
			for (int i = 0; i < result.array.Length; i++)
			{
				if (match(result.array[i]))
				{
					if (list == null)
					{
						list = new List<int>();
					}
					list.Add(i);
				}
			}
			if (list == null)
			{
				return result;
			}
			return result.RemoveAtRange(list);
		}

		public ImmutableArray<T> Clear()
		{
			return Empty;
		}

		public ImmutableArray<T> Sort()
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.Sort(0, immutableArray.Length, Comparer<T>.Default);
		}

		public ImmutableArray<T> Sort(Comparison<T> comparison)
		{
			Requires.NotNull(comparison, "comparison");
			ImmutableArray<T> immutableArray = this;
			return immutableArray.Sort(Comparer<T>.Create(comparison));
		}

		public ImmutableArray<T> Sort(IComparer<T>? comparer)
		{
			ImmutableArray<T> immutableArray = this;
			return immutableArray.Sort(0, immutableArray.Length, comparer);
		}

		public ImmutableArray<T> Sort(int index, int count, IComparer<T>? comparer)
		{
			ImmutableArray<T> result = this;
			result.ThrowNullRefIfNotInitialized();
			Requires.Range(index >= 0, "index");
			Requires.Range(count >= 0 && index + count <= result.Length, "count");
			if (count > 1)
			{
				if (comparer == null)
				{
					comparer = Comparer<T>.Default;
				}
				bool flag = false;
				for (int i = index + 1; i < index + count; i++)
				{
					if (comparer.Compare(result.array[i - 1], result.array[i]) > 0)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					T[] array = new T[result.Length];
					Array.Copy(result.array, array, result.Length);
					Array.Sort(array, index, count, comparer);
					return new ImmutableArray<T>(array);
				}
			}
			return result;
		}

		public IEnumerable<TResult> OfType<TResult>()
		{
			ImmutableArray<T> immutableArray = this;
			if (immutableArray.array == null || immutableArray.array.Length == 0)
			{
				return Enumerable.Empty<TResult>();
			}
			return immutableArray.array.OfType<TResult>();
		}

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

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

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

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

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

		IImmutableList<T> IImmutableList<T>.Clear()
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Clear();
		}

		IImmutableList<T> IImmutableList<T>.Add(T value)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Add(value);
		}

		IImmutableList<T> IImmutableList<T>.AddRange(IEnumerable<T> items)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.AddRange(items);
		}

		IImmutableList<T> IImmutableList<T>.Insert(int index, T element)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Insert(index, element);
		}

		IImmutableList<T> IImmutableList<T>.InsertRange(int index, IEnumerable<T> items)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.InsertRange(index, items);
		}

		IImmutableList<T> IImmutableList<T>.Remove(T value, IEqualityComparer<T> equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Remove(value, equalityComparer);
		}

		IImmutableList<T> IImmutableList<T>.RemoveAll(Predicate<T> match)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.RemoveAll(match);
		}

		IImmutableList<T> IImmutableList<T>.RemoveRange(IEnumerable<T> items, IEqualityComparer<T> equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.RemoveRange(items, equalityComparer);
		}

		IImmutableList<T> IImmutableList<T>.RemoveRange(int index, int count)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.RemoveRange(index, count);
		}

		IImmutableList<T> IImmutableList<T>.RemoveAt(int index)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.RemoveAt(index);
		}

		IImmutableList<T> IImmutableList<T>.SetItem(int index, T value)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.SetItem(index, value);
		}

		IImmutableList<T> IImmutableList<T>.Replace(T oldValue, T newValue, IEqualityComparer<T> equalityComparer)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Replace(oldValue, newValue, equalityComparer);
		}

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

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

		bool IList.Contains(object value)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.Contains((T)value);
		}

		int IList.IndexOf(object value)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			return immutableArray.IndexOf((T)value);
		}

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

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

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

		void ICollection.CopyTo(Array array, int index)
		{
			ImmutableArray<T> immutableArray = this;
			immutableArray.ThrowInvalidOperationIfNotInitialized();
			Array.Copy(immutableArray.array, 0, array, index, immutableArray.Length);
		}

		bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
		{
			ImmutableArray<T> immutableArray = this;
			Array array = other as Array;
			if (array == null && other is IImmutableArray immutableArray2)
			{
				array = immutableArray2.Array;
				if (immutableArray.array == null && array == null)
				{
					return true;
				}
				if (imm

Sentry.System.Memory.dll

Decompiled 2 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.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: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.1.1")]
[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
{
	internal 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}")]
	internal 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;
		}
	}
	internal 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}")]
	internal 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}")]
	internal 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}")]
	internal 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;
											}
				

Sentry.System.Numerics.Vectors.dll

Decompiled 2 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.26515.06")]
[assembly: AssemblyInformationalVersion("4.6.26515.06 @BuiltBy: dlab-DDVSOWINAGE059 @Branch: release/2.1 @SrcCode: https://github.com/dotnet/corefx/tree/30ab651fcb4354552bd4891619a0bdd81e0ebdbf")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.1.4.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 Pow(float x, float y)
		{
			return (float)Math.Pow(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 static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType));

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


		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 string Arg_InsufficientNumberOfElements => GetResourceString("Arg_InsufficientNumberOfElements", 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.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field, Inherited = false)]
	internal sealed class IntrinsicAttribute : Attribute
	{
	}
	[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;
		}
	}
	[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;
	}
	[System.Runtime.CompilerServices.Intrinsic]
	internal 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> s_zero = default(Vector<T>);

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

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

		public static int Count
		{
			[System.Runtime.CompilerServices.Intrinsic]
			get
			{
				return s_count;
			}
		}

		public static Vector<T> Zero
		{
			[System.Runtime.CompilerServices.Intrinsic]
			get
			{
				return s_zero;
			}
		}

		public static Vector<T> One
		{
			[System.Runtime.CompilerServices.Intrinsic]
			get
			{
				return s_one;
			}
		}

		internal static Vector<T> AllOnes => s_allOnes;

		public unsafe T this[int index]
		{
			[System.Runtime.CompilerServices.Intrinsic]
			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;
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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;
			}
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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(System.SR.Format(System.SR.Arg_InsufficientNumberOfElements, Count, "values"));
			}
			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;
		}

		[System.Runtime.CompilerServices.Intrinsic]
		public void CopyTo(T[] destination)
		{
			CopyTo(destination, 0);
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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);
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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)(uint)Count];
					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;
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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;
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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;
		}

		[System.Runtime.CompilerServices.Intrinsic]
		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 s_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);
		}

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

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

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

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

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

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

		[CLSCompliant(false)]
		[System.Runtime.CompilerServices.Intrinsic]
		public static explicit operator Vector<ulong>(Vector<T> value)
		{
			return new Vector<ulong>(ref

Sentry.System.Reflection.Metadata.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Configuration.Assemblies;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.IO.MemoryMappedFiles;
using System.Reflection;
using System.Reflection.Internal;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
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;
using System.Threading;
using FxResources.System.Reflection.Metadata;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("System.Reflection.Metadata.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyDefaultAlias("System.Reflection.Metadata")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("System.Reflection.Metadata")]
[assembly: AssemblyFileVersion("5.0.20.51904")]
[assembly: AssemblyInformationalVersion("5.0.0+cf258a14b70ad9069470a108f13765e0e5988f51")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Reflection.Metadata")]
[assembly: AssemblyMetadata("RepositoryUrl", "git://github.com/dotnet/runtime")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("5.0.0.0")]
[module: UnverifiableCode]
[module: System.Runtime.CompilerServices.NullablePublicOnly(true)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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;
		}
	}
}
internal static class Interop
{
	internal static class Libraries
	{
		internal const string Advapi32 = "advapi32.dll";

		internal const string BCrypt = "BCrypt.dll";

		internal const string Crypt32 = "crypt32.dll";

		internal const string CryptUI = "cryptui.dll";

		internal const string Gdi32 = "gdi32.dll";

		internal const string HttpApi = "httpapi.dll";

		internal const string IpHlpApi = "iphlpapi.dll";

		internal const string Kernel32 = "kernel32.dll";

		internal const string Mswsock = "mswsock.dll";

		internal const string NCrypt = "ncrypt.dll";

		internal const string NtDll = "ntdll.dll";

		internal const string Odbc32 = "odbc32.dll";

		internal const string Ole32 = "ole32.dll";

		internal const string OleAut32 = "oleaut32.dll";

		internal const string PerfCounter = "perfcounter.dll";

		internal const string Secur32 = "secur32.dll";

		internal const string Shell32 = "shell32.dll";

		internal const string SspiCli = "sspicli.dll";

		internal const string User32 = "user32.dll";

		internal const string Version = "version.dll";

		internal const string WebSocket = "websocket.dll";

		internal const string WinHttp = "winhttp.dll";

		internal const string WinMM = "winmm.dll";

		internal const string Wldap32 = "wldap32.dll";

		internal const string Ws2_32 = "ws2_32.dll";

		internal const string Wtsapi32 = "wtsapi32.dll";

		internal const string CompressionNative = "clrcompression.dll";

		internal const string MsQuic = "msquic.dll";

		internal const string HostPolicy = "hostpolicy.dll";
	}

	internal static class Kernel32
	{
		[DllImport("kernel32.dll", SetLastError = true)]
		internal unsafe static extern int ReadFile(SafeHandle handle, byte* bytes, int numBytesToRead, out int numBytesRead, IntPtr mustBeZero);
	}
}
namespace FxResources.System.Reflection.Metadata
{
	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 ImageTooSmall => GetResourceString("ImageTooSmall");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

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

		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.Reflection
{
	internal static class BlobUtilities
	{
		public const int SizeOfSerializedDecimal = 13;

		public const int SizeOfGuid = 16;

		public unsafe static byte[] ReadBytes(byte* buffer, int byteCount)
		{
			if (byteCount == 0)
			{
				return EmptyArray<byte>.Instance;
			}
			byte[] array = new byte[byteCount];
			Marshal.Copy((IntPtr)buffer, array, 0, byteCount);
			return array;
		}

		public unsafe static ImmutableArray<byte> ReadImmutableBytes(byte* buffer, int byteCount)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = ReadBytes(buffer, byteCount);
			return ImmutableByteArrayInterop.DangerousCreateFromUnderlyingArray(ref array);
		}

		public unsafe static void WriteBytes(this byte[] buffer, int start, byte value, int byteCount)
		{
			fixed (byte* ptr = &buffer[0])
			{
				byte* ptr2 = ptr + start;
				for (int i = 0; i < byteCount; i++)
				{
					ptr2[i] = value;
				}
			}
		}

		public unsafe static void WriteDouble(this byte[] buffer, int start, double value)
		{
			buffer.WriteUInt64(start, *(ulong*)(&value));
		}

		public unsafe static void WriteSingle(this byte[] buffer, int start, float value)
		{
			buffer.WriteUInt32(start, *(uint*)(&value));
		}

		public static void WriteByte(this byte[] buffer, int start, byte value)
		{
			buffer[start] = value;
		}

		public unsafe static void WriteUInt16(this byte[] buffer, int start, ushort value)
		{
			fixed (byte* ptr = &buffer[start])
			{
				*ptr = (byte)value;
				ptr[1] = (byte)(value >> 8);
			}
		}

		public unsafe static void WriteUInt16BE(this byte[] buffer, int start, ushort value)
		{
			fixed (byte* ptr = &buffer[start])
			{
				*ptr = (byte)(value >> 8);
				ptr[1] = (byte)value;
			}
		}

		public unsafe static void WriteUInt32BE(this byte[] buffer, int start, uint value)
		{
			fixed (byte* ptr = &buffer[start])
			{
				*ptr = (byte)(value >> 24);
				ptr[1] = (byte)(value >> 16);
				ptr[2] = (byte)(value >> 8);
				ptr[3] = (byte)value;
			}
		}

		public unsafe static void WriteUInt32(this byte[] buffer, int start, uint value)
		{
			fixed (byte* ptr = &buffer[start])
			{
				*ptr = (byte)value;
				ptr[1] = (byte)(value >> 8);
				ptr[2] = (byte)(value >> 16);
				ptr[3] = (byte)(value >> 24);
			}
		}

		public static void WriteUInt64(this byte[] buffer, int start, ulong value)
		{
			buffer.WriteUInt32(start, (uint)value);
			buffer.WriteUInt32(start + 4, (uint)(value >> 32));
		}

		public static void WriteDecimal(this byte[] buffer, int start, decimal value)
		{
			value.GetBits(out var isNegative, out var scale, out var low, out var mid, out var high);
			buffer.WriteByte(start, (byte)(scale | (isNegative ? 128u : 0u)));
			buffer.WriteUInt32(start + 1, low);
			buffer.WriteUInt32(start + 5, mid);
			buffer.WriteUInt32(start + 9, high);
		}

		public unsafe static void WriteGuid(this byte[] buffer, int start, Guid value)
		{
			fixed (byte* ptr2 = &buffer[start])
			{
				byte* ptr = (byte*)(&value);
				uint num = *(uint*)ptr;
				*ptr2 = (byte)num;
				ptr2[1] = (byte)(num >> 8);
				ptr2[2] = (byte)(num >> 16);
				ptr2[3] = (byte)(num >> 24);
				ushort num2 = *(ushort*)(ptr + 4);
				ptr2[4] = (byte)num2;
				ptr2[5] = (byte)(num2 >> 8);
				ushort num3 = *(ushort*)(ptr + 6);
				ptr2[6] = (byte)num3;
				ptr2[7] = (byte)(num3 >> 8);
				ptr2[8] = ptr[8];
				ptr2[9] = ptr[9];
				ptr2[10] = ptr[10];
				ptr2[11] = ptr[11];
				ptr2[12] = ptr[12];
				ptr2[13] = ptr[13];
				ptr2[14] = ptr[14];
				ptr2[15] = ptr[15];
			}
		}

		public unsafe static void WriteUTF8(this byte[] buffer, int start, char* charPtr, int charCount, int byteCount, bool allowUnpairedSurrogates)
		{
			char* ptr = charPtr + charCount;
			fixed (byte* ptr2 = &buffer[0])
			{
				byte* ptr3 = ptr2 + start;
				if (byteCount == charCount)
				{
					while (charPtr < ptr)
					{
						*(ptr3++) = (byte)(*(charPtr++));
					}
					return;
				}
				while (charPtr < ptr)
				{
					char c = *(charPtr++);
					if (c < '\u0080')
					{
						*(ptr3++) = (byte)c;
						continue;
					}
					if (c < 'ࠀ')
					{
						*ptr3 = (byte)(((uint)((int)c >> 6) & 0x1Fu) | 0xC0u);
						ptr3[1] = (byte)((c & 0x3Fu) | 0x80u);
						ptr3 += 2;
						continue;
					}
					if (IsSurrogateChar(c))
					{
						if (IsHighSurrogateChar(c) && charPtr < ptr && IsLowSurrogateChar(*charPtr))
						{
							int num = c;
							int num2 = *(charPtr++);
							int num3 = (num - 55296 << 10) + num2 - 56320 + 65536;
							*ptr3 = (byte)(((uint)(num3 >> 18) & 7u) | 0xF0u);
							ptr3[1] = (byte)(((uint)(num3 >> 12) & 0x3Fu) | 0x80u);
							ptr3[2] = (byte)(((uint)(num3 >> 6) & 0x3Fu) | 0x80u);
							ptr3[3] = (byte)(((uint)num3 & 0x3Fu) | 0x80u);
							ptr3 += 4;
							continue;
						}
						if (!allowUnpairedSurrogates)
						{
							c = '\ufffd';
						}
					}
					*ptr3 = (byte)(((uint)((int)c >> 12) & 0xFu) | 0xE0u);
					ptr3[1] = (byte)(((uint)((int)c >> 6) & 0x3Fu) | 0x80u);
					ptr3[2] = (byte)((c & 0x3Fu) | 0x80u);
					ptr3 += 3;
				}
			}
		}

		internal unsafe static int GetUTF8ByteCount(string str)
		{
			fixed (char* str2 = str)
			{
				return GetUTF8ByteCount(str2, str.Length);
			}
		}

		internal unsafe static int GetUTF8ByteCount(char* str, int charCount)
		{
			char* remainder;
			return GetUTF8ByteCount(str, charCount, int.MaxValue, out remainder);
		}

		internal unsafe static int GetUTF8ByteCount(char* str, int charCount, int byteLimit, out char* remainder)
		{
			char* ptr = str + charCount;
			char* ptr2 = str;
			int num = 0;
			while (ptr2 < ptr)
			{
				char c = *(ptr2++);
				int num2;
				if (c < '\u0080')
				{
					num2 = 1;
				}
				else if (c < 'ࠀ')
				{
					num2 = 2;
				}
				else if (IsHighSurrogateChar(c) && ptr2 < ptr && IsLowSurrogateChar(*ptr2))
				{
					num2 = 4;
					ptr2++;
				}
				else
				{
					num2 = 3;
				}
				if (num + num2 > byteLimit)
				{
					ptr2 -= ((num2 < 4) ? 1 : 2);
					break;
				}
				num += num2;
			}
			remainder = ptr2;
			return num;
		}

		internal static bool IsSurrogateChar(int c)
		{
			return (uint)(c - 55296) <= 2047u;
		}

		internal static bool IsHighSurrogateChar(int c)
		{
			return (uint)(c - 55296) <= 1023u;
		}

		internal static bool IsLowSurrogateChar(int c)
		{
			return (uint)(c - 56320) <= 1023u;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void ValidateRange(int bufferLength, int start, int byteCount, string byteCountParameterName)
		{
			if (start < 0 || start > bufferLength)
			{
				Throw.ArgumentOutOfRange("start");
			}
			if (byteCount < 0 || byteCount > bufferLength - start)
			{
				Throw.ArgumentOutOfRange(byteCountParameterName);
			}
		}

		internal static int GetUserStringByteLength(int characterCount)
		{
			return characterCount * 2 + 1;
		}

		internal static byte GetUserStringTrailingByte(string str)
		{
			foreach (char c in str)
			{
				if (c >= '\u007f')
				{
					return 1;
				}
				switch (c)
				{
				case '\u0001':
				case '\u0002':
				case '\u0003':
				case '\u0004':
				case '\u0005':
				case '\u0006':
				case '\a':
				case '\b':
				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':
				case '\'':
				case '-':
					return 1;
				}
			}
			return 0;
		}
	}
	internal static class Throw
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidCast()
		{
			throw new InvalidCastException();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidArgument(string message, string parameterName)
		{
			throw new ArgumentException(message, parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidArgument_OffsetForVirtualHeapHandle()
		{
			throw new ArgumentException(System.SR.CantGetOffsetForVirtualHeapHandle, "handle");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static Exception InvalidArgument_UnexpectedHandleKind(HandleKind kind)
		{
			throw new ArgumentException(System.SR.Format(System.SR.UnexpectedHandleKind, kind));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static Exception InvalidArgument_Handle(string parameterName)
		{
			throw new ArgumentException(System.SR.InvalidHandle, parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void SignatureNotVarArg()
		{
			throw new InvalidOperationException(System.SR.SignatureNotVarArg);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ControlFlowBuilderNotAvailable()
		{
			throw new InvalidOperationException(System.SR.ControlFlowBuilderNotAvailable);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidOperationBuilderAlreadyLinked()
		{
			throw new InvalidOperationException(System.SR.BuilderAlreadyLinked);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidOperation(string message)
		{
			throw new InvalidOperationException(message);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidOperation_LabelNotMarked(int id)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.LabelNotMarked, id));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void LabelDoesntBelongToBuilder(string parameterName)
		{
			throw new ArgumentException(System.SR.LabelDoesntBelongToBuilder, parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void HeapHandleRequired()
		{
			throw new ArgumentException(System.SR.NotMetadataHeapHandle, "handle");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void EntityOrUserStringHandleRequired()
		{
			throw new ArgumentException(System.SR.NotMetadataTableOrUserStringHandle, "handle");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidToken()
		{
			throw new ArgumentException(System.SR.InvalidToken, "token");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ArgumentNull(string parameterName)
		{
			throw new ArgumentNullException(parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ArgumentEmptyString(string parameterName)
		{
			throw new ArgumentException(System.SR.ExpectedNonEmptyString, parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ArgumentEmptyArray(string parameterName)
		{
			throw new ArgumentException(System.SR.ExpectedNonEmptyArray, parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ValueArgumentNull()
		{
			throw new ArgumentNullException("value");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void BuilderArgumentNull()
		{
			throw new ArgumentNullException("builder");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ArgumentOutOfRange(string parameterName)
		{
			throw new ArgumentOutOfRangeException(parameterName);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ArgumentOutOfRange(string parameterName, string message)
		{
			throw new ArgumentOutOfRangeException(parameterName, message);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void BlobTooLarge(string parameterName)
		{
			throw new ArgumentOutOfRangeException(parameterName, System.SR.BlobTooLarge);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void IndexOutOfRange()
		{
			throw new ArgumentOutOfRangeException("index");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void TableIndexOutOfRange()
		{
			throw new ArgumentOutOfRangeException("tableIndex");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ValueArgumentOutOfRange()
		{
			throw new ArgumentOutOfRangeException("value");
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void OutOfBounds()
		{
			throw new BadImageFormatException(System.SR.OutOfBoundsRead);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void WriteOutOfBounds()
		{
			throw new InvalidOperationException(System.SR.OutOfBoundsWrite);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidCodedIndex()
		{
			throw new BadImageFormatException(System.SR.InvalidCodedIndex);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidHandle()
		{
			throw new BadImageFormatException(System.SR.InvalidHandle);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidCompressedInteger()
		{
			throw new BadImageFormatException(System.SR.InvalidCompressedInteger);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidSerializedString()
		{
			throw new BadImageFormatException(System.SR.InvalidSerializedString);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ImageTooSmall()
		{
			throw new BadImageFormatException(System.SR.ImageTooSmall);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ImageTooSmallOrContainsInvalidOffsetOrCount()
		{
			throw new BadImageFormatException(System.SR.ImageTooSmallOrContainsInvalidOffsetOrCount);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ReferenceOverflow()
		{
			throw new BadImageFormatException(System.SR.RowIdOrHeapOffsetTooLarge);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void TableNotSorted(TableIndex tableIndex)
		{
			throw new BadImageFormatException(System.SR.Format(System.SR.MetadataTableNotSorted, tableIndex));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidOperation_TableNotSorted(TableIndex tableIndex)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.MetadataTableNotSorted, tableIndex));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void InvalidOperation_PEImageNotAvailable()
		{
			throw new InvalidOperationException(System.SR.PEImageNotAvailable);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void TooManySubnamespaces()
		{
			throw new BadImageFormatException(System.SR.TooManySubnamespaces);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void ValueOverflow()
		{
			throw new BadImageFormatException(System.SR.ValueTooLarge);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void SequencePointValueOutOfRange()
		{
			throw new BadImageFormatException(System.SR.SequencePointValueOutOfRange);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void HeapSizeLimitExceeded(HeapIndex heap)
		{
			throw new ImageFormatLimitationException(System.SR.Format(System.SR.HeapSizeLimitExceeded, heap));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		internal static void PEReaderDisposed()
		{
			throw new ObjectDisposedException("PEReader");
		}
	}
	[Flags]
	internal enum MethodSemanticsAttributes
	{
		Setter = 1,
		Getter = 2,
		Other = 4,
		Adder = 8,
		Remover = 0x10,
		Raiser = 0x20
	}
	internal enum DeclarativeSecurityAction : short
	{
		None = 0,
		Demand = 2,
		Assert = 3,
		Deny = 4,
		PermitOnly = 5,
		LinkDemand = 6,
		InheritanceDemand = 7,
		RequestMinimum = 8,
		RequestOptional = 9,
		RequestRefuse = 10
	}
	[Flags]
	internal enum MethodImportAttributes : short
	{
		None = 0,
		ExactSpelling = 1,
		BestFitMappingDisable = 0x20,
		BestFitMappingEnable = 0x10,
		BestFitMappingMask = 0x30,
		CharSetAnsi = 2,
		CharSetUnicode = 4,
		CharSetAuto = 6,
		CharSetMask = 6,
		ThrowOnUnmappableCharEnable = 0x1000,
		ThrowOnUnmappableCharDisable = 0x2000,
		ThrowOnUnmappableCharMask = 0x3000,
		SetLastError = 0x40,
		CallingConventionWinApi = 0x100,
		CallingConventionCDecl = 0x200,
		CallingConventionStdCall = 0x300,
		CallingConventionThisCall = 0x400,
		CallingConventionFastCall = 0x500,
		CallingConventionMask = 0x700
	}
	[Flags]
	internal enum ManifestResourceAttributes
	{
		Public = 1,
		Private = 2,
		VisibilityMask = 7
	}
	internal enum AssemblyHashAlgorithm
	{
		None = 0,
		MD5 = 32771,
		Sha1 = 32772,
		Sha256 = 32780,
		Sha384 = 32781,
		Sha512 = 32782
	}
	[Flags]
	internal enum AssemblyFlags
	{
		PublicKey = 1,
		Retargetable = 0x100,
		WindowsRuntime = 0x200,
		ContentTypeMask = 0xE00,
		DisableJitCompileOptimizer = 0x4000,
		EnableJitCompileTracking = 0x8000
	}
	internal static class TypeAttributesExtensions
	{
		private const TypeAttributes Forwarder = (TypeAttributes)2097152;

		private const TypeAttributes NestedMask = TypeAttributes.NestedFamANDAssem;

		public static bool IsForwarder(this TypeAttributes flags)
		{
			return (flags & (TypeAttributes)2097152) != 0;
		}

		public static bool IsNested(this TypeAttributes flags)
		{
			return (flags & TypeAttributes.NestedFamANDAssem) != 0;
		}
	}
}
namespace System.Reflection.PortableExecutable
{
	internal class ManagedPEBuilder : PEBuilder
	{
		public const int ManagedResourcesDataAlignment = 8;

		public const int MappedFieldDataAlignment = 8;

		private const int DefaultStrongNameSignatureSize = 128;

		private const string TextSectionName = ".text";

		private const string ResourceSectionName = ".rsrc";

		private const string RelocationSectionName = ".reloc";

		private readonly PEDirectoriesBuilder _peDirectoriesBuilder;

		private readonly MetadataRootBuilder _metadataRootBuilder;

		private readonly BlobBuilder _ilStream;

		private readonly BlobBuilder _mappedFieldDataOpt;

		private readonly BlobBuilder _managedResourcesOpt;

		private readonly ResourceSectionBuilder _nativeResourcesOpt;

		private readonly int _strongNameSignatureSize;

		private readonly MethodDefinitionHandle _entryPointOpt;

		private readonly DebugDirectoryBuilder _debugDirectoryBuilderOpt;

		private readonly CorFlags _corFlags;

		private int _lazyEntryPointAddress;

		private Blob _lazyStrongNameSignature;

		public ManagedPEBuilder(PEHeaderBuilder header, MetadataRootBuilder metadataRootBuilder, BlobBuilder ilStream, BlobBuilder? mappedFieldData = null, BlobBuilder? managedResources = null, ResourceSectionBuilder? nativeResources = null, DebugDirectoryBuilder? debugDirectoryBuilder = null, int strongNameSignatureSize = 128, MethodDefinitionHandle entryPoint = default(MethodDefinitionHandle), CorFlags flags = CorFlags.ILOnly, Func<IEnumerable<Blob>, BlobContentId>? deterministicIdProvider = null)
			: base(header, deterministicIdProvider)
		{
			if (header == null)
			{
				Throw.ArgumentNull("header");
			}
			if (metadataRootBuilder == null)
			{
				Throw.ArgumentNull("metadataRootBuilder");
			}
			if (ilStream == null)
			{
				Throw.ArgumentNull("ilStream");
			}
			if (strongNameSignatureSize < 0)
			{
				Throw.ArgumentOutOfRange("strongNameSignatureSize");
			}
			_metadataRootBuilder = metadataRootBuilder;
			_ilStream = ilStream;
			_mappedFieldDataOpt = mappedFieldData;
			_managedResourcesOpt = managedResources;
			_nativeResourcesOpt = nativeResources;
			_strongNameSignatureSize = strongNameSignatureSize;
			_entryPointOpt = entryPoint;
			_debugDirectoryBuilderOpt = debugDirectoryBuilder ?? CreateDefaultDebugDirectoryBuilder();
			_corFlags = flags;
			_peDirectoriesBuilder = new PEDirectoriesBuilder();
		}

		private DebugDirectoryBuilder CreateDefaultDebugDirectoryBuilder()
		{
			if (base.IsDeterministic)
			{
				DebugDirectoryBuilder debugDirectoryBuilder = new DebugDirectoryBuilder();
				debugDirectoryBuilder.AddReproducibleEntry();
				return debugDirectoryBuilder;
			}
			return null;
		}

		protected override ImmutableArray<Section> CreateSections()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Builder<Section> val = ImmutableArray.CreateBuilder<Section>(3);
			val.Add(new Section(".text", SectionCharacteristics.ContainsCode | SectionCharacteristics.MemExecute | SectionCharacteristics.MemRead));
			if (_nativeResourcesOpt != null)
			{
				val.Add(new Section(".rsrc", SectionCharacteristics.ContainsInitializedData | SectionCharacteristics.MemRead));
			}
			if (base.Header.Machine == Machine.I386 || base.Header.Machine == Machine.Unknown)
			{
				val.Add(new Section(".reloc", SectionCharacteristics.ContainsInitializedData | SectionCharacteristics.MemDiscardable | SectionCharacteristics.MemRead));
			}
			return val.ToImmutable();
		}

		protected override BlobBuilder SerializeSection(string name, SectionLocation location)
		{
			return name switch
			{
				".text" => SerializeTextSection(location), 
				".rsrc" => SerializeResourceSection(location), 
				".reloc" => SerializeRelocationSection(location), 
				_ => throw new ArgumentException(System.SR.Format(System.SR.UnknownSectionName, name), "name"), 
			};
		}

		private BlobBuilder SerializeTextSection(SectionLocation location)
		{
			BlobBuilder blobBuilder = new BlobBuilder();
			BlobBuilder blobBuilder2 = new BlobBuilder();
			MetadataSizes sizes = _metadataRootBuilder.Sizes;
			ManagedTextSection managedTextSection = new ManagedTextSection(base.Header.ImageCharacteristics, base.Header.Machine, _ilStream.Count, sizes.MetadataSize, _managedResourcesOpt?.Count ?? 0, _strongNameSignatureSize, _debugDirectoryBuilderOpt?.Size ?? 0, _mappedFieldDataOpt?.Count ?? 0);
			int methodBodyStreamRva = location.RelativeVirtualAddress + managedTextSection.OffsetToILStream;
			int mappedFieldDataStreamRva = location.RelativeVirtualAddress + managedTextSection.CalculateOffsetToMappedFieldDataStream();
			_metadataRootBuilder.Serialize(blobBuilder2, methodBodyStreamRva, mappedFieldDataStreamRva);
			BlobBuilder blobBuilder3;
			DirectoryEntry debugTable;
			if (_debugDirectoryBuilderOpt != null)
			{
				int num = managedTextSection.ComputeOffsetToDebugDirectory();
				blobBuilder3 = new BlobBuilder(_debugDirectoryBuilderOpt.TableSize);
				_debugDirectoryBuilderOpt.Serialize(blobBuilder3, location, num);
				debugTable = new DirectoryEntry(location.RelativeVirtualAddress + num, _debugDirectoryBuilderOpt.TableSize);
			}
			else
			{
				blobBuilder3 = null;
				debugTable = default(DirectoryEntry);
			}
			_lazyEntryPointAddress = managedTextSection.GetEntryPointAddress(location.RelativeVirtualAddress);
			managedTextSection.Serialize(blobBuilder, location.RelativeVirtualAddress, (!_entryPointOpt.IsNil) ? MetadataTokens.GetToken(_entryPointOpt) : 0, _corFlags, base.Header.ImageBase, blobBuilder2, _ilStream, _mappedFieldDataOpt, _managedResourcesOpt, blobBuilder3, out _lazyStrongNameSignature);
			_peDirectoriesBuilder.AddressOfEntryPoint = _lazyEntryPointAddress;
			_peDirectoriesBuilder.DebugTable = debugTable;
			_peDirectoriesBuilder.ImportAddressTable = managedTextSection.GetImportAddressTableDirectoryEntry(location.RelativeVirtualAddress);
			_peDirectoriesBuilder.ImportTable = managedTextSection.GetImportTableDirectoryEntry(location.RelativeVirtualAddress);
			_peDirectoriesBuilder.CorHeaderTable = managedTextSection.GetCorHeaderDirectoryEntry(location.RelativeVirtualAddress);
			return blobBuilder;
		}

		private BlobBuilder SerializeResourceSection(SectionLocation location)
		{
			BlobBuilder blobBuilder = new BlobBuilder();
			_nativeResourcesOpt.Serialize(blobBuilder, location);
			_peDirectoriesBuilder.ResourceTable = new DirectoryEntry(location.RelativeVirtualAddress, blobBuilder.Count);
			return blobBuilder;
		}

		private BlobBuilder SerializeRelocationSection(SectionLocation location)
		{
			BlobBuilder blobBuilder = new BlobBuilder();
			WriteRelocationSection(blobBuilder, base.Header.Machine, _lazyEntryPointAddress);
			_peDirectoriesBuilder.BaseRelocationTable = new DirectoryEntry(location.RelativeVirtualAddress, blobBuilder.Count);
			return blobBuilder;
		}

		private static void WriteRelocationSection(BlobBuilder builder, Machine machine, int entryPointAddress)
		{
			builder.WriteUInt32((uint)(entryPointAddress + 2) / 4096u * 4096);
			builder.WriteUInt32((machine == Machine.IA64) ? 14u : 12u);
			uint num = (uint)(entryPointAddress + 2) % 4096u;
			uint num2 = ((machine == Machine.Amd64 || machine == Machine.IA64 || machine == Machine.Arm64) ? 10u : 3u);
			ushort value = (ushort)((num2 << 12) | num);
			builder.WriteUInt16(value);
			if (machine == Machine.IA64)
			{
				builder.WriteUInt32(num2 << 12);
			}
			builder.WriteUInt16(0);
		}

		protected internal override PEDirectoriesBuilder GetDirectories()
		{
			return _peDirectoriesBuilder;
		}

		public void Sign(BlobBuilder peImage, Func<IEnumerable<Blob>, byte[]> signatureProvider)
		{
			if (peImage == null)
			{
				Throw.ArgumentNull("peImage");
			}
			if (signatureProvider == null)
			{
				Throw.ArgumentNull("signatureProvider");
			}
			Sign(peImage, _lazyStrongNameSignature, signatureProvider);
		}
	}
	internal sealed class ManagedTextSection
	{
		public const int ManagedResourcesDataAlignment = 8;

		private const string CorEntryPointDll = "mscoree.dll";

		public const int MappedFieldDataAlignment = 8;

		private const int CorHeaderSize = 72;

		public Characteristics ImageCharacteristics { get; }

		public Machine Machine { get; }

		public int ILStreamSize { get; }

		public int MetadataSize { get; }

		public int ResourceDataSize { get; }

		public int StrongNameSignatureSize { get; }

		public int DebugDataSize { get; }

		public int MappedFieldDataSize { get; }

		internal bool RequiresStartupStub
		{
			get
			{
				if (Machine != Machine.I386)
				{
					return Machine == Machine.Unknown;
				}
				return true;
			}
		}

		internal bool Requires64bits
		{
			get
			{
				if (Machine != Machine.Amd64 && Machine != Machine.IA64)
				{
					return Machine == Machine.Arm64;
				}
				return true;
			}
		}

		public bool Is32Bit => !Requires64bits;

		private string CorEntryPointName
		{
			get
			{
				if ((ImageCharacteristics & Characteristics.Dll) == 0)
				{
					return "_CorExeMain";
				}
				return "_CorDllMain";
			}
		}

		private int SizeOfImportAddressTable
		{
			get
			{
				if (!RequiresStartupStub)
				{
					return 0;
				}
				if (!Is32Bit)
				{
					return 16;
				}
				return 8;
			}
		}

		private int SizeOfImportTable => 40 + (Is32Bit ? 12 : 16) + 2 + CorEntryPointName.Length + 1;

		private static int SizeOfNameTable => "mscoree.dll".Length + 1 + 2;

		private int SizeOfRuntimeStartupStub
		{
			get
			{
				if (!Is32Bit)
				{
					return 16;
				}
				return 8;
			}
		}

		public int OffsetToILStream => SizeOfImportAddressTable + 72;

		public ManagedTextSection(Characteristics imageCharacteristics, Machine machine, int ilStreamSize, int metadataSize, int resourceDataSize, int strongNameSignatureSize, int debugDataSize, int mappedFieldDataSize)
		{
			MetadataSize = metadataSize;
			ResourceDataSize = resourceDataSize;
			ILStreamSize = ilStreamSize;
			MappedFieldDataSize = mappedFieldDataSize;
			StrongNameSignatureSize = strongNameSignatureSize;
			ImageCharacteristics = imageCharacteristics;
			Machine = machine;
			DebugDataSize = debugDataSize;
		}

		public int CalculateOffsetToMappedFieldDataStream()
		{
			int num = ComputeOffsetToImportTable();
			if (RequiresStartupStub)
			{
				num += SizeOfImportTable + SizeOfNameTable;
				num = BitArithmetic.Align(num, Is32Bit ? 4 : 8);
				num += SizeOfRuntimeStartupStub;
			}
			return num;
		}

		internal int ComputeOffsetToDebugDirectory()
		{
			return ComputeOffsetToMetadata() + MetadataSize + ResourceDataSize + StrongNameSignatureSize;
		}

		private int ComputeOffsetToImportTable()
		{
			return ComputeOffsetToDebugDirectory() + DebugDataSize;
		}

		private int ComputeOffsetToMetadata()
		{
			return OffsetToILStream + BitArithmetic.Align(ILStreamSize, 4);
		}

		public int ComputeSizeOfTextSection()
		{
			return CalculateOffsetToMappedFieldDataStream() + MappedFieldDataSize;
		}

		public int GetEntryPointAddress(int rva)
		{
			if (!RequiresStartupStub)
			{
				return 0;
			}
			return rva + CalculateOffsetToMappedFieldDataStream() - (Is32Bit ? 6 : 10);
		}

		public DirectoryEntry GetImportAddressTableDirectoryEntry(int rva)
		{
			if (!RequiresStartupStub)
			{
				return default(DirectoryEntry);
			}
			return new DirectoryEntry(rva, SizeOfImportAddressTable);
		}

		public DirectoryEntry GetImportTableDirectoryEntry(int rva)
		{
			if (!RequiresStartupStub)
			{
				return default(DirectoryEntry);
			}
			return new DirectoryEntry(rva + ComputeOffsetToImportTable(), (Is32Bit ? 66 : 70) + 13);
		}

		public DirectoryEntry GetCorHeaderDirectoryEntry(int rva)
		{
			return new DirectoryEntry(rva + SizeOfImportAddressTable, 72);
		}

		public void Serialize(BlobBuilder builder, int relativeVirtualAddess, int entryPointTokenOrRelativeVirtualAddress, CorFlags corFlags, ulong baseAddress, BlobBuilder metadataBuilder, BlobBuilder ilBuilder, BlobBuilder? mappedFieldDataBuilderOpt, BlobBuilder? resourceBuilderOpt, BlobBuilder? debugDataBuilderOpt, out Blob strongNameSignature)
		{
			int relativeVirtualAddress = GetImportTableDirectoryEntry(relativeVirtualAddess).RelativeVirtualAddress;
			int relativeVirtualAddress2 = GetImportAddressTableDirectoryEntry(relativeVirtualAddess).RelativeVirtualAddress;
			if (RequiresStartupStub)
			{
				WriteImportAddressTable(builder, relativeVirtualAddress);
			}
			WriteCorHeader(builder, relativeVirtualAddess, entryPointTokenOrRelativeVirtualAddress, corFlags);
			ilBuilder.Align(4);
			builder.LinkSuffix(ilBuilder);
			builder.LinkSuffix(metadataBuilder);
			if (resourceBuilderOpt != null)
			{
				builder.LinkSuffix(resourceBuilderOpt);
			}
			strongNameSignature = builder.ReserveBytes(StrongNameSignatureSize);
			new BlobWriter(strongNameSignature).WriteBytes(0, StrongNameSignatureSize);
			if (debugDataBuilderOpt != null)
			{
				builder.LinkSuffix(debugDataBuilderOpt);
			}
			if (RequiresStartupStub)
			{
				WriteImportTable(builder, relativeVirtualAddress, relativeVirtualAddress2);
				WriteNameTable(builder);
				WriteRuntimeStartupStub(builder, relativeVirtualAddress2, baseAddress);
			}
			if (mappedFieldDataBuilderOpt != null)
			{
				builder.LinkSuffix(mappedFieldDataBuilderOpt);
			}
		}

		private void WriteImportAddressTable(BlobBuilder builder, int importTableRva)
		{
			int count = builder.Count;
			int num = importTableRva + 40;
			int num2 = num + (Is32Bit ? 12 : 16);
			if (Is32Bit)
			{
				builder.WriteUInt32((uint)num2);
				builder.WriteUInt32(0u);
			}
			else
			{
				builder.WriteUInt64((uint)num2);
				builder.WriteUInt64(0uL);
			}
		}

		private void WriteImportTable(BlobBuilder builder, int importTableRva, int importAddressTableRva)
		{
			int count = builder.Count;
			int num = importTableRva + 40;
			int num2 = num + (Is32Bit ? 12 : 16);
			int value = num2 + 12 + 2;
			builder.WriteUInt32((uint)num);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32((uint)value);
			builder.WriteUInt32((uint)importAddressTableRva);
			builder.WriteBytes(0, 20);
			if (Is32Bit)
			{
				builder.WriteUInt32((uint)num2);
				builder.WriteUInt32(0u);
				builder.WriteUInt32(0u);
			}
			else
			{
				builder.WriteUInt64((uint)num2);
				builder.WriteUInt64(0uL);
			}
			builder.WriteUInt16(0);
			string corEntryPointName = CorEntryPointName;
			foreach (char c in corEntryPointName)
			{
				builder.WriteByte((byte)c);
			}
			builder.WriteByte(0);
		}

		private static void WriteNameTable(BlobBuilder builder)
		{
			int count = builder.Count;
			string text = "mscoree.dll";
			foreach (char c in text)
			{
				builder.WriteByte((byte)c);
			}
			builder.WriteByte(0);
			builder.WriteUInt16(0);
		}

		private void WriteCorHeader(BlobBuilder builder, int textSectionRva, int entryPointTokenOrRva, CorFlags corFlags)
		{
			int num = textSectionRva + ComputeOffsetToMetadata();
			int num2 = num + MetadataSize;
			int num3 = num2 + ResourceDataSize;
			int count = builder.Count;
			builder.WriteUInt32(72u);
			builder.WriteUInt16(2);
			builder.WriteUInt16(5);
			builder.WriteUInt32((uint)num);
			builder.WriteUInt32((uint)MetadataSize);
			builder.WriteUInt32((uint)corFlags);
			builder.WriteUInt32((uint)entryPointTokenOrRva);
			builder.WriteUInt32((ResourceDataSize != 0) ? ((uint)num2) : 0u);
			builder.WriteUInt32((uint)ResourceDataSize);
			builder.WriteUInt32((StrongNameSignatureSize != 0) ? ((uint)num3) : 0u);
			builder.WriteUInt32((uint)StrongNameSignatureSize);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
		}

		private void WriteRuntimeStartupStub(BlobBuilder sectionBuilder, int importAddressTableRva, ulong baseAddress)
		{
			if (Is32Bit)
			{
				sectionBuilder.Align(4);
				sectionBuilder.WriteUInt16(0);
				sectionBuilder.WriteByte(byte.MaxValue);
				sectionBuilder.WriteByte(37);
				sectionBuilder.WriteUInt32((uint)(importAddressTableRva + (int)baseAddress));
			}
			else
			{
				sectionBuilder.Align(8);
				sectionBuilder.WriteUInt32(0u);
				sectionBuilder.WriteUInt16(0);
				sectionBuilder.WriteByte(byte.MaxValue);
				sectionBuilder.WriteByte(37);
				sectionBuilder.WriteUInt64((ulong)importAddressTableRva + baseAddress);
			}
		}
	}
	internal abstract class PEBuilder
	{
		protected readonly struct Section
		{
			public readonly string Name;

			public readonly SectionCharacteristics Characteristics;

			public Section(string name, SectionCharacteristics characteristics)
			{
				if (name == null)
				{
					Throw.ArgumentNull("name");
				}
				Name = name;
				Characteristics = characteristics;
			}
		}

		private readonly struct SerializedSection
		{
			public readonly BlobBuilder Builder;

			public readonly string Name;

			public readonly SectionCharacteristics Characteristics;

			public readonly int RelativeVirtualAddress;

			public readonly int SizeOfRawData;

			public readonly int PointerToRawData;

			public int VirtualSize => Builder.Count;

			public SerializedSection(BlobBuilder builder, string name, SectionCharacteristics characteristics, int relativeVirtualAddress, int sizeOfRawData, int pointerToRawData)
			{
				Name = name;
				Characteristics = characteristics;
				Builder = builder;
				RelativeVirtualAddress = relativeVirtualAddress;
				SizeOfRawData = sizeOfRawData;
				PointerToRawData = pointerToRawData;
			}
		}

		private readonly Lazy<ImmutableArray<Section>> _lazySections;

		private Blob _lazyChecksum;

		private static readonly byte[] s_dosHeader = new byte[128]
		{
			77, 90, 144, 0, 3, 0, 0, 0, 4, 0,
			0, 0, 255, 255, 0, 0, 184, 0, 0, 0,
			0, 0, 0, 0, 64, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			128, 0, 0, 0, 14, 31, 186, 14, 0, 180,
			9, 205, 33, 184, 1, 76, 205, 33, 84, 104,
			105, 115, 32, 112, 114, 111, 103, 114, 97, 109,
			32, 99, 97, 110, 110, 111, 116, 32, 98, 101,
			32, 114, 117, 110, 32, 105, 110, 32, 68, 79,
			83, 32, 109, 111, 100, 101, 46, 13, 13, 10,
			36, 0, 0, 0, 0, 0, 0, 0
		};

		internal static int DosHeaderSize = s_dosHeader.Length;

		public PEHeaderBuilder Header { get; }

		public Func<IEnumerable<Blob>, BlobContentId> IdProvider { get; }

		public bool IsDeterministic { get; }

		protected PEBuilder(PEHeaderBuilder header, Func<IEnumerable<Blob>, BlobContentId>? deterministicIdProvider)
		{
			if (header == null)
			{
				Throw.ArgumentNull("header");
			}
			IdProvider = deterministicIdProvider ?? BlobContentId.GetTimeBasedProvider();
			IsDeterministic = deterministicIdProvider != null;
			Header = header;
			_lazySections = new Lazy<ImmutableArray<Section>>((Func<ImmutableArray<Section>>)CreateSections);
		}

		protected ImmutableArray<Section> GetSections()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			ImmutableArray<Section> value = _lazySections.Value;
			if (value.IsDefault)
			{
				throw new InvalidOperationException(System.SR.Format(System.SR.MustNotReturnNull, "CreateSections"));
			}
			return value;
		}

		protected abstract ImmutableArray<Section> CreateSections();

		protected abstract BlobBuilder SerializeSection(string name, SectionLocation location);

		protected internal abstract PEDirectoriesBuilder GetDirectories();

		public BlobContentId Serialize(BlobBuilder builder)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			ImmutableArray<SerializedSection> val = SerializeSections();
			PEDirectoriesBuilder directories = GetDirectories();
			WritePESignature(builder);
			WriteCoffHeader(builder, val, out var stampFixup);
			WritePEHeader(builder, directories, val);
			WriteSectionHeaders(builder, val);
			builder.Align(Header.FileAlignment);
			Enumerator<SerializedSection> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				builder.LinkSuffix(enumerator.Current.Builder);
				builder.Align(Header.FileAlignment);
			}
			BlobContentId result = IdProvider(builder.GetBlobs());
			new BlobWriter(stampFixup).WriteUInt32(result.Stamp);
			return result;
		}

		private ImmutableArray<SerializedSection> SerializeSections()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			ImmutableArray<Section> sections = GetSections();
			Builder<SerializedSection> val = ImmutableArray.CreateBuilder<SerializedSection>(sections.Length);
			int position = Header.ComputeSizeOfPEHeaders(sections.Length);
			int relativeVirtualAddress = BitArithmetic.Align(position, Header.SectionAlignment);
			int pointerToRawData = BitArithmetic.Align(position, Header.FileAlignment);
			Enumerator<Section> enumerator = sections.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Section current = enumerator.Current;
				BlobBuilder blobBuilder = SerializeSection(current.Name, new SectionLocation(relativeVirtualAddress, pointerToRawData));
				SerializedSection serializedSection = new SerializedSection(blobBuilder, current.Name, current.Characteristics, relativeVirtualAddress, BitArithmetic.Align(blobBuilder.Count, Header.FileAlignment), pointerToRawData);
				val.Add(serializedSection);
				relativeVirtualAddress = BitArithmetic.Align(serializedSection.RelativeVirtualAddress + serializedSection.VirtualSize, Header.SectionAlignment);
				pointerToRawData = serializedSection.PointerToRawData + serializedSection.SizeOfRawData;
			}
			return val.MoveToImmutable();
		}

		private void WritePESignature(BlobBuilder builder)
		{
			builder.WriteBytes(s_dosHeader);
			builder.WriteUInt32(17744u);
		}

		private void WriteCoffHeader(BlobBuilder builder, ImmutableArray<SerializedSection> sections, out Blob stampFixup)
		{
			builder.WriteUInt16((ushort)((Header.Machine == Machine.Unknown) ? Machine.I386 : Header.Machine));
			builder.WriteUInt16((ushort)sections.Length);
			stampFixup = builder.ReserveBytes(4);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt16((ushort)PEHeader.Size(Header.Is32Bit));
			builder.WriteUInt16((ushort)Header.ImageCharacteristics);
		}

		private void WritePEHeader(BlobBuilder builder, PEDirectoriesBuilder directories, ImmutableArray<SerializedSection> sections)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			builder.WriteUInt16((ushort)(Header.Is32Bit ? 267 : 523));
			builder.WriteByte(Header.MajorLinkerVersion);
			builder.WriteByte(Header.MinorLinkerVersion);
			builder.WriteUInt32((uint)SumRawDataSizes(sections, SectionCharacteristics.ContainsCode));
			builder.WriteUInt32((uint)SumRawDataSizes(sections, SectionCharacteristics.ContainsInitializedData));
			builder.WriteUInt32((uint)SumRawDataSizes(sections, SectionCharacteristics.ContainsUninitializedData));
			builder.WriteUInt32((uint)directories.AddressOfEntryPoint);
			int num = IndexOfSection(sections, SectionCharacteristics.ContainsCode);
			builder.WriteUInt32((num != -1) ? ((uint)sections[num].RelativeVirtualAddress) : 0u);
			if (Header.Is32Bit)
			{
				int num2 = IndexOfSection(sections, SectionCharacteristics.ContainsInitializedData);
				builder.WriteUInt32((num2 != -1) ? ((uint)sections[num2].RelativeVirtualAddress) : 0u);
				builder.WriteUInt32((uint)Header.ImageBase);
			}
			else
			{
				builder.WriteUInt64(Header.ImageBase);
			}
			builder.WriteUInt32((uint)Header.SectionAlignment);
			builder.WriteUInt32((uint)Header.FileAlignment);
			builder.WriteUInt16(Header.MajorOperatingSystemVersion);
			builder.WriteUInt16(Header.MinorOperatingSystemVersion);
			builder.WriteUInt16(Header.MajorImageVersion);
			builder.WriteUInt16(Header.MinorImageVersion);
			builder.WriteUInt16(Header.MajorSubsystemVersion);
			builder.WriteUInt16(Header.MinorSubsystemVersion);
			builder.WriteUInt32(0u);
			SerializedSection serializedSection = sections[sections.Length - 1];
			builder.WriteUInt32((uint)BitArithmetic.Align(serializedSection.RelativeVirtualAddress + serializedSection.VirtualSize, Header.SectionAlignment));
			builder.WriteUInt32((uint)BitArithmetic.Align(Header.ComputeSizeOfPEHeaders(sections.Length), Header.FileAlignment));
			_lazyChecksum = builder.ReserveBytes(4);
			new BlobWriter(_lazyChecksum).WriteUInt32(0u);
			builder.WriteUInt16((ushort)Header.Subsystem);
			builder.WriteUInt16((ushort)Header.DllCharacteristics);
			if (Header.Is32Bit)
			{
				builder.WriteUInt32((uint)Header.SizeOfStackReserve);
				builder.WriteUInt32((uint)Header.SizeOfStackCommit);
				builder.WriteUInt32((uint)Header.SizeOfHeapReserve);
				builder.WriteUInt32((uint)Header.SizeOfHeapCommit);
			}
			else
			{
				builder.WriteUInt64(Header.SizeOfStackReserve);
				builder.WriteUInt64(Header.SizeOfStackCommit);
				builder.WriteUInt64(Header.SizeOfHeapReserve);
				builder.WriteUInt64(Header.SizeOfHeapCommit);
			}
			builder.WriteUInt32(0u);
			builder.WriteUInt32(16u);
			builder.WriteUInt32((uint)directories.ExportTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ExportTable.Size);
			builder.WriteUInt32((uint)directories.ImportTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ImportTable.Size);
			builder.WriteUInt32((uint)directories.ResourceTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ResourceTable.Size);
			builder.WriteUInt32((uint)directories.ExceptionTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ExceptionTable.Size);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt32((uint)directories.BaseRelocationTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.BaseRelocationTable.Size);
			builder.WriteUInt32((uint)directories.DebugTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.DebugTable.Size);
			builder.WriteUInt32((uint)directories.CopyrightTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.CopyrightTable.Size);
			builder.WriteUInt32((uint)directories.GlobalPointerTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.GlobalPointerTable.Size);
			builder.WriteUInt32((uint)directories.ThreadLocalStorageTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ThreadLocalStorageTable.Size);
			builder.WriteUInt32((uint)directories.LoadConfigTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.LoadConfigTable.Size);
			builder.WriteUInt32((uint)directories.BoundImportTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.BoundImportTable.Size);
			builder.WriteUInt32((uint)directories.ImportAddressTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.ImportAddressTable.Size);
			builder.WriteUInt32((uint)directories.DelayImportTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.DelayImportTable.Size);
			builder.WriteUInt32((uint)directories.CorHeaderTable.RelativeVirtualAddress);
			builder.WriteUInt32((uint)directories.CorHeaderTable.Size);
			builder.WriteUInt64(0uL);
		}

		private void WriteSectionHeaders(BlobBuilder builder, ImmutableArray<SerializedSection> serializedSections)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<SerializedSection> enumerator = serializedSections.GetEnumerator();
			while (enumerator.MoveNext())
			{
				SerializedSection current = enumerator.Current;
				WriteSectionHeader(builder, current);
			}
		}

		private static void WriteSectionHeader(BlobBuilder builder, SerializedSection serializedSection)
		{
			if (serializedSection.VirtualSize == 0)
			{
				return;
			}
			int i = 0;
			int length = serializedSection.Name.Length;
			for (; i < 8; i++)
			{
				if (i < length)
				{
					builder.WriteByte((byte)serializedSection.Name[i]);
				}
				else
				{
					builder.WriteByte(0);
				}
			}
			builder.WriteUInt32((uint)serializedSection.VirtualSize);
			builder.WriteUInt32((uint)serializedSection.RelativeVirtualAddress);
			builder.WriteUInt32((uint)serializedSection.SizeOfRawData);
			builder.WriteUInt32((uint)serializedSection.PointerToRawData);
			builder.WriteUInt32(0u);
			builder.WriteUInt32(0u);
			builder.WriteUInt16(0);
			builder.WriteUInt16(0);
			builder.WriteUInt32((uint)serializedSection.Characteristics);
		}

		private static int IndexOfSection(ImmutableArray<SerializedSection> sections, SectionCharacteristics characteristics)
		{
			for (int i = 0; i < sections.Length; i++)
			{
				if ((sections[i].Characteristics & characteristics) == characteristics)
				{
					return i;
				}
			}
			return -1;
		}

		private static int SumRawDataSizes(ImmutableArray<SerializedSection> sections, SectionCharacteristics characteristics)
		{
			int num = 0;
			for (int i = 0; i < sections.Length; i++)
			{
				if ((sections[i].Characteristics & characteristics) == characteristics)
				{
					num += sections[i].SizeOfRawData;
				}
			}
			return num;
		}

		internal static IEnumerable<Blob> GetContentToSign(BlobBuilder peImage, int peHeadersSize, int peHeaderAlignment, Blob strongNameSignatureFixup)
		{
			int remainingHeaderToSign = peHeadersSize;
			int remainingHeader = BitArithmetic.Align(peHeadersSize, peHeaderAlignment);
			foreach (Blob blob in peImage.GetBlobs())
			{
				int blobStart = blob.Start;
				int blobLength = blob.Length;
				while (blobLength > 0)
				{
					if (remainingHeader > 0)
					{
						int length;
						if (remainingHeaderToSign > 0)
						{
							length = Math.Min(remainingHeaderToSign, blobLength);
							yield return new Blob(blob.Buffer, blobStart, length);
							remainingHeaderToSign -= length;
						}
						else
						{
							length = Math.Min(remainingHeader, blobLength);
						}
						remainingHeader -= length;
						blobStart += length;
						blobLength -= length;
						continue;
					}
					if (blob.Buffer == strongNameSignatureFixup.Buffer)
					{
						yield return GetPrefixBlob(new Blob(blob.Buffer, blobStart, blobLength), strongNameSignatureFixup);
						yield return GetSuffixBlob(new Blob(blob.Buffer, blobStart, blobLength), strongNameSignatureFixup);
					}
					else
					{
						yield return new Blob(blob.Buffer, blobStart, blobLength);
					}
					break;
				}
			}
		}

		internal static Blob GetPrefixBlob(Blob container, Blob blob)
		{
			return new Blob(container.Buffer, container.Start, blob.Start - container.Start);
		}

		internal static Blob GetSuffixBlob(Blob container, Blob blob)
		{
			return new Blob(container.Buffer, blob.Start + blob.Length, container.Start + container.Length - blob.Start - blob.Length);
		}

		internal static IEnumerable<Blob> GetContentToChecksum(BlobBuilder peImage, Blob checksumFixup)
		{
			foreach (Blob blob in peImage.GetBlobs())
			{
				if (blob.Buffer == checksumFixup.Buffer)
				{
					yield return GetPrefixBlob(blob, checksumFixup);
					yield return GetSuffixBlob(blob, checksumFixup);
				}
				else
				{
					yield return blob;
				}
			}
		}

		internal void Sign(BlobBuilder peImage, Blob strongNameSignatureFixup, Func<IEnumerable<Blob>, byte[]> signatureProvider)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			int peHeadersSize = Header.ComputeSizeOfPEHeaders(GetSections().Length);
			byte[] array = signatureProvider(GetContentToSign(peImage, peHeadersSize, Header.FileAlignment, strongNameSignatureFixup));
			if (array == null || array.Length > strongNameSignatureFixup.Length)
			{
				throw new InvalidOperationException(System.SR.SignatureProviderReturnedInvalidSignature);
			}
			new BlobWriter(strongNameSignatureFixup).WriteBytes(array);
			uint value = CalculateChecksum(peImage, _lazyChecksum);
			new BlobWriter(_lazyChecksum).WriteUInt32(value);
		}

		internal static uint CalculateChecksum(BlobBuilder peImage, Blob checksumFixup)
		{
			return CalculateChecksum(GetContentToChecksum(peImage, checksumFixup)) + (uint)peImage.Count;
		}

		private unsafe static uint CalculateChecksum(IEnumerable<Blob> blobs)
		{
			uint num = 0u;
			int num2 = -1;
			foreach (Blob blob in blobs)
			{
				ArraySegment<byte> bytes = blob.GetBytes();
				fixed (byte* ptr = bytes.Array)
				{
					byte* ptr2 = ptr + bytes.Offset;
					byte* ptr3 = ptr2 + bytes.Count;
					if (num2 >= 0)
					{
						num = AggregateChecksum(num, (ushort)((*ptr2 << 8) | num2));
						ptr2++;
					}
					if ((ptr3 - ptr2) % 2 != 0L)
					{
						ptr3--;
						num2 = *ptr3;
					}
					else
					{
						num2 = -1;
					}
					for (; ptr2 < ptr3; ptr2 += 2)
					{
						num = AggregateChecksum(num, *(ushort*)ptr2);
					}
				}
			}
			if (num2 >= 0)
			{
				num = AggregateChecksum(num, (ushort)num2);
			}
			return num;
		}

		private static uint AggregateChecksum(uint checksum, ushort value)
		{
			uint num = checksum + value;
			return (num >> 16) + (ushort)num;
		}
	}
	internal sealed class DebugDirectoryBuilder
	{
		private struct Entry
		{
			public uint Stamp;

			public uint Version;

			public DebugDirectoryEntryType Type;

			public int DataSize;
		}

		private readonly List<Entry> _entries;

		private readonly BlobBuilder _dataBuilder;

		internal int TableSize => 28 * _entries.Count;

		internal int Size => (TableSize + _dataBuilder?.Count).GetValueOrDefault();

		public DebugDirectoryBuilder()
		{
			_entries = new List<Entry>(3);
			_dataBuilder = new BlobBuilder();
		}

		internal void AddEntry(DebugDirectoryEntryType type, uint version, uint stamp, int dataSize)
		{
			_entries.Add(new Entry
			{
				Stamp = stamp,
				Version = version,
				Type = type,
				DataSize = dataSize
			});
		}

		public void AddEntry(DebugDirectoryEntryType type, uint version, uint stamp)
		{
			AddEntry(type, version, stamp, 0);
		}

		public void AddEntry<TData>(DebugDirectoryEntryType type, uint version, uint stamp, TData data, Action<BlobBuilder, TData> dataSerializer)
		{
			if (dataSerializer == null)
			{
				Throw.ArgumentNull("dataSerializer");
			}
			int count = _dataBuilder.Count;
			dataSerializer(_dataBuilder, data);
			int dataSize = _dataBuilder.Count - count;
			AddEntry(type, version, stamp, dataSize);
		}

		public void AddCodeViewEntry(string pdbPath, BlobContentId pdbContentId, ushort portablePdbVersion)
		{
			AddCodeViewEntry(pdbPath, pdbContentId, portablePdbVersion, 1);
		}

		internal void AddCodeViewEntry(string pdbPath, BlobContentId pdbContentId, ushort portablePdbVersion, int age)
		{
			if (pdbPath == null)
			{
				Throw.ArgumentNull("pdbPath");
			}
			if (age < 1)
			{
				Throw.ArgumentOutOfRange("age");
			}
			if (pdbPath.Length == 0 || pdbPath.IndexOf('\0') == 0)
			{
				Throw.InvalidArgument(System.SR.ExpectedNonEmptyString, "pdbPath");
			}
			if (portablePdbVersion > 0 && portablePdbVersion < 256)
			{
				Throw.ArgumentOutOfRange("portablePdbVersion");
			}
			int dataSize = WriteCodeViewData(_dataBuilder, pdbPath, pdbContentId.Guid, age);
			AddEntry(DebugDirectoryEntryType.CodeView, (portablePdbVersion != 0) ? PortablePdbVersions.DebugDirectoryEntryVersion(portablePdbVersion) : 0u, pdbContentId.Stamp, dataSize);
		}

		public void AddReproducibleEntry()
		{
			AddEntry(DebugDirectoryEntryType.Reproducible, 0u, 0u);
		}

		private static int WriteCodeViewData(BlobBuilder builder, string pdbPath, Guid pdbGuid, int age)
		{
			int count = builder.Count;
			builder.WriteByte(82);
			builder.WriteByte(83);
			builder.WriteByte(68);
			builder.WriteByte(83);
			builder.WriteGuid(pdbGuid);
			builder.WriteInt32(age);
			builder.WriteUTF8(pdbPath);
			builder.WriteByte(0);
			return builder.Count - count;
		}

		public void AddPdbChecksumEntry(string algorithmName, ImmutableArray<byte> checksum)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (algorithmName == null)
			{
				Throw.ArgumentNull("algorithmName");
			}
			if (algorithmName.Length == 0)
			{
				Throw.ArgumentEmptyString("algorithmName");
			}
			if (checksum.IsDefault)
			{
				Throw.ArgumentNull("checksum");
			}
			if (checksum.Length == 0)
			{
				Throw.ArgumentEmptyArray("checksum");
			}
			int dataSize = WritePdbChecksumData(_dataBuilder, algorithmName, checksum);
			AddEntry(DebugDirectoryEntryType.PdbChecksum, 1u, 0u, dataSize);
		}

		private static int WritePdbChecksumData(BlobBuilder builder, string algorithmName, ImmutableArray<byte> checksum)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			int count = builder.Count;
			builder.WriteUTF8(algorithmName);
			builder.WriteByte(0);
			builder.WriteBytes(checksum);
			return builder.Count - count;
		}

		internal void Serialize(BlobBuilder builder, SectionLocation sectionLocation, int sectionOffset)
		{
			int num = sectionOffset + TableSize;
			foreach (Entry entry in _entries)
			{
				int value;
				int value2;
				if (entry.DataSize > 0)
				{
					value = sectionLocation.RelativeVirtualAddress + num;
					value2 = sectionLocation.PointerToRawData + num;
				}
				else
				{
					value = 0;
					value2 = 0;
				}
				builder.WriteUInt32(0u);
				builder.WriteUInt32(entry.Stamp);
				builder.WriteUInt32(entry.Version);
				builder.WriteInt32((int)entry.Type);
				builder.WriteInt32(entry.DataSize);
				builder.WriteInt32(value);
				builder.WriteInt32(value2);
				num += entry.DataSize;
			}
			builder.LinkSuffix(_dataBuilder);
		}

		public void AddEmbeddedPortablePdbEntry(BlobBuilder debugMetadata, ushort portablePdbVersion)
		{
			if (debugMetadata == null)
			{
				Throw.ArgumentNull("debugMetadata");
			}
			if (portablePdbVersion < 256)
			{
				Throw.ArgumentOutOfRange("portablePdbVersion");
			}
			int dataSize = WriteEmbeddedPortablePdbData(_dataBuilder, debugMetadata);
			AddEntry(DebugDirectoryEntryType.EmbeddedPortablePdb, PortablePdbVersions.DebugDirectoryEmbeddedVersion(portablePdbVersion), 0u, dataSize);
		}

		private static int WriteEmbeddedPortablePdbData(BlobBuilder builder, BlobBuilder debugMetadata)
		{
			int count = builder.Count;
			builder.WriteUInt32(1111773261u);
			builder.WriteInt32(debugMetadata.Count);
			MemoryStream memoryStream = new MemoryStream();
			using (DeflateStream deflateStream = new DeflateStream(memoryStream, CompressionLevel.Optimal, leaveOpen: true))
			{
				foreach (Blob blob in debugMetadata.GetBlobs())
				{
					ArraySegment<byte> bytes = blob.GetBytes();
					deflateStream.Write(bytes.Array, bytes.Offset, bytes.Count);
				}
			}
			builder.WriteBytes(memoryStream.ToArray());
			return builder.Count - count;
		}
	}
	internal readonly struct PdbChecksumDebugDirectoryData
	{
		public string AlgorithmName { get; }

		public ImmutableArray<byte> Checksum { get; }

		internal PdbChecksumDebugDirectoryData(string algorithmName, ImmutableArray<byte> checksum)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			AlgorithmName = algorithmName;
			Checksum = checksum;
		}
	}
	internal sealed class PEDirectoriesBuilder
	{
		public int AddressOfEntryPoint { get; set; }

		public DirectoryEntry ExportTable { get; set; }

		public DirectoryEntry ImportTable { get; set; }

		public DirectoryEntry ResourceTable { get; set; }

		public DirectoryEntry ExceptionTable { get; set; }

		public DirectoryEntry BaseRelocationTable { get; set; }

		public DirectoryEntry DebugTable { get; set; }

		public DirectoryEntry CopyrightTable { get; set; }

		public DirectoryEntry GlobalPointerTable { get; set; }

		public DirectoryEntry ThreadLocalStorageTable { get; set; }

		public DirectoryEntry LoadConfigTable { get; set; }

		public DirectoryEntry BoundImportTable { get; set; }

		public DirectoryEntry ImportAddressTable { get; set; }

		public DirectoryEntry DelayImportTable { get; set; }

		public DirectoryEntry CorHeaderTable { get; set; }
	}
	internal sealed class PEHeaderBuilder
	{
		public Machine Machine { get; }

		public Characteristics ImageCharacteristics { get; }

		public byte MajorLinkerVersion { get; }

		public byte MinorLinkerVersion { get; }

		public ulong ImageBase { get; }

		public int SectionAlignment { get; }

		public int FileAlignment { get; }

		public ushort MajorOperatingSystemVersion { get; }

		public ushort MinorOperatingSystemVersion { get; }

		public ushort MajorImageVersion { get; }

		public ushort MinorImageVersion { get; }

		public ushort MajorSubsystemVersion { get; }

		public ushort MinorSubsystemVersion { get; }

		public Subsystem Subsystem { get; }

		public DllCharacteristics DllCharacteristics { get; }

		public ulong SizeOfStackReserve { get; }

		public ulong SizeOfStackCommit { get; }

		public ulong SizeOfHeapReserve { get; }

		public ulong SizeOfHeapCommit { get; }

		internal bool Is32Bit
		{
			get
			{
				if (Machine != Machine.Amd64 && Machine != Machine.IA64)
				{
					return Machine != Machine.Arm64;
				}
				return false;
			}
		}

		public PEHeaderBuilder(Machine machine = Machine.Unknown, int sectionAlignment = 8192, int fileAlignment = 512, ulong imageBase = 4194304uL, byte majorLinkerVersion = 48, byte minorLinkerVersion = 0, ushort majorOperatingSystemVersion = 4, ushort minorOperatingSystemVersion = 0, ushort majorImageVersion = 0, ushort minorImageVersion = 0, ushort majorSubsystemVersion = 4, ushort minorSubsystemVersion = 0, Subsystem subsystem = Subsystem.WindowsCui, DllCharacteristics dllCharacteristics = DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware, Characteristics imageCharacteristics = Characteristics.Dll, ulong sizeOfStackReserve = 1048576uL, ulong sizeOfStackCommit = 4096uL, ulong sizeOfHeapReserve = 1048576uL, ulong sizeOfHeapCommit = 4096uL)
		{
			if (fileAlignment < 512 || fileAlignment > 65536 || BitArithmetic.CountBits(fileAlignment) != 1)
			{
				Throw.ArgumentOutOfRange("fileAlignment");
			}
			if (sectionAlignment < fileAlignment || BitArithmetic.CountBits(sectionAlignment) != 1)
			{
				Throw.ArgumentOutOfRange("sectionAlignment");
			}
			Machine = machine;
			SectionAlignment = sectionAlignment;
			FileAlignment = fileAlignment;
			ImageBase = imageBase;
			MajorLinkerVersion = majorLinkerVersion;
			MinorLinkerVersion = minorLinkerVersion;
			MajorOperatingSystemVersion = majorOperatingSystemVersion;
			MinorOperatingSystemVersion = minorOperatingSystemVersion;
			MajorImageVersion = majorImageVersion;
			MinorImageVersion = minorImageVersion;
			MajorSubsystemVersion = majorSubsystemVersion;
			MinorSubsystemVersion = minorSubsystemVersion;
			Subsystem = subsystem;
			DllCharacteristics = dllCharacteristics;
			ImageCharacteristics = imageCharacteristics;
			SizeOfStackReserve = sizeOfStackReserve;
			SizeOfStackCommit = sizeOfStackCommit;
			SizeOfHeapReserve = sizeOfHeapReserve;
			SizeOfHeapCommit = sizeOfHeapCommit;
		}

		public static PEHeaderBuilder CreateExecutableHeader()
		{
			return new PEHeaderBuilder(Machine.Unknown, 8192, 512, 4194304uL, 48, 0, 4, 0, 0, 0, 4, 0, Subsystem.WindowsCui, DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware, Characteristics.ExecutableImage, 1048576uL, 4096uL, 1048576uL, 4096uL);
		}

		public static PEHeaderBuilder CreateLibraryHeader()
		{
			return new PEHeaderBuilder(Machine.Unknown, 8192, 512, 4194304uL, 48, 0, 4, 0, 0, 0, 4, 0, Subsystem.WindowsCui, DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware, Characteristics.ExecutableImage | Characteristics.Dll, 1048576uL, 4096uL, 1048576uL, 4096uL);
		}

		internal int ComputeSizeOfPEHeaders(int sectionCount)
		{
			return PEBuilder.DosHeaderSize + 4 + 20 + PEHeader.Size(Is32Bit) + 40 * sectionCount;
		}
	}
	internal abstract class ResourceSectionBuilder
	{
		protected internal abstract void Serialize(BlobBuilder builder, SectionLocation location);
	}
	internal readonly struct SectionLocation
	{
		public int RelativeVirtualAddress { get; }

		public int PointerToRawData { get; }

		public SectionLocation(int relativeVirtualAddress, int pointerToRawData)
		{
			RelativeVirtualAddress = relativeVirtualAddress;
			PointerToRawData = pointerToRawData;
		}
	}
	internal sealed class CoffHeader
	{
		internal const int Size = 20;

		public Machine Machine { get; }

		public short NumberOfSections { get; }

		public int TimeDateStamp { get; }

		public int PointerToSymbolTable { get; }

		public int NumberOfSymbols { get; }

		public short SizeOfOptionalHeader { get; }

		public Characteristics Characteristics { get; }

		internal CoffHeader(ref PEBinaryReader reader)
		{
			Machine = (Machine)reader.ReadUInt16();
			NumberOfSections = reader.ReadInt16();
			TimeDateStamp = reader.ReadInt32();
			PointerToSymbolTable = reader.ReadInt32();
			NumberOfSymbols = reader.ReadInt32();
			SizeOfOptionalHeader = reader.ReadInt16();
			Characteristics = (Characteristics)reader.ReadUInt16();
		}
	}
	[Flags]
	internal enum CorFlags
	{
		ILOnly = 1,
		Requires32Bit = 2,
		ILLibrary = 4,
		StrongNameSigned = 8,
		NativeEntryPoint = 0x10,
		TrackDebugData = 0x10000,
		Prefers32Bit = 0x20000
	}
	internal sealed class CorHeader
	{
		public ushort MajorRuntimeVersion { get; }

		public ushort MinorRuntimeVersion { get; }

		public DirectoryEntry MetadataDirectory { get; }

		public CorFlags Flags { get; }

		public int EntryPointTokenOrRelativeVirtualAddress { get; }

		public DirectoryEntry ResourcesDirectory { get; }

		public DirectoryEntry StrongNameSignatureDirectory { get; }

		public DirectoryEntry CodeManagerTableDirectory { get; }

		public DirectoryEntry VtableFixupsDirectory { get; }

		public DirectoryEntry ExportAddressTableJumpsDirectory { get; }

		public DirectoryEntry ManagedNativeHeaderDirectory { get; }

		internal CorHeader(ref PEBinaryReader reader)
		{
			reader.ReadInt32();
			MajorRuntimeVersion = reader.ReadUInt16();
			MinorRuntimeVersion = reader.ReadUInt16();
			MetadataDirectory = new DirectoryEntry(ref reader);
			Flags = (CorFlags)reader.ReadUInt32();
			EntryPointTokenOrRelativeVirtualAddress = reader.ReadInt32();
			ResourcesDirectory = new DirectoryEntry(ref reader);
			StrongNameSignatureDirectory = new DirectoryEntry(ref reader);
			CodeManagerTableDirectory = new DirectoryEntry(ref reader);
			VtableFixupsDirectory = new DirectoryEntry(ref reader);
			ExportAddressTableJumpsDirectory = new DirectoryEntry(ref reader);
			ManagedNativeHeaderDirectory = new DirectoryEntry(ref reader);
		}
	}
	internal readonly struct CodeViewDebugDirectoryData
	{
		public Guid Guid { get; }

		public int Age { get; }

		public string Path { get; }

		internal CodeViewDebugDirectoryData(Guid guid, int age, string path)
		{
			Path = path;
			Guid = guid;
			Age = age;
		}
	}
	internal readonly struct DebugDirectoryEntry
	{
		internal const int Size = 28;

		public uint Stamp { get; }

		public ushort MajorVersion { get; }

		public ushort MinorVersion { get; }

		public DebugDirectoryEntryType Type { get; }

		public int DataSize { get; }

		public int DataRelativeVirtualAddress { get; }

		public int DataPointer { get; }

		public bool IsPortableCodeView => MinorVersion == 20557;

		public DebugDirectoryEntry(uint stamp, ushort majorVersion, ushort minorVersion, DebugDirectoryEntryType type, int dataSize, int dataRelativeVirtualAddress, int dataPointer)
		{
			Stamp = stamp;
			MajorVersion = majorVersion;
			MinorVersion = minorVersion;
			Type = type;
			DataSize = dataSize;
			DataRelativeVirtualAddress = dataRelativeVirtualAddress;
			DataPointer = dataPointer;
		}
	}
	internal enum DebugDirectoryEntryType
	{
		Unknown = 0,
		Coff = 1,
		CodeView = 2,
		Reproducible = 16,
		EmbeddedPortablePdb = 17,
		PdbChecksum = 19
	}
	internal readonly struct DirectoryEntry
	{
		public readonly int RelativeVirtualAddress;

		public readonly int Size;

		public DirectoryEntry(int relativeVirtualAddress, int size)
		{
			RelativeVirtualAddress = relativeVirtualAddress;
			Size = size;
		}

		internal DirectoryEntry(ref PEBinaryReader reader)
		{
			RelativeVirtualAddress = reader.ReadInt32();
			Size = reader.ReadInt32();
		}
	}
	internal enum Machine : ushort
	{
		Unknown = 0,
		I386 = 332,
		WceMipsV2 = 361,
		Alpha = 388,
		SH3 = 418,
		SH3Dsp = 419,
		SH3E = 420,
		SH4 = 422,
		SH5 = 424,
		Arm = 448,
		Thumb = 450,
		ArmThumb2 = 452,
		AM33 = 467,
		PowerPC = 496,
		PowerPCFP = 497,
		IA64 = 512,
		MIPS16 = 614,
		Alpha64 = 644,
		MipsFpu = 870,
		MipsFpu16 = 1126,
		Tricore = 1312,
		Ebc = 3772,
		Amd64 = 34404,
		M32R = 36929,
		Arm64 = 43620
	}
	internal readonly struct PEBinaryReader
	{
		private readonly long _startOffset;

		private readonly long _maxOffset;

		private readonly BinaryReader _reader;

		public int CurrentOffset => (int)(_reader.BaseStream.Position - _startOffset);

		public PEBinaryReader(Stream stream, int size)
		{
			_startOffset = stream.Position;
			_maxOffset = _startOffset + size;
			_reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true);
		}

		public void Seek(int offset)
		{
			CheckBounds(_startOffset, offset);
			_reader.BaseStream.Seek(offset, SeekOrigin.Begin);
		}

		public byte[] ReadBytes(int count)
		{
			CheckBounds(_reader.BaseStream.Position, count);
			return _reader.ReadBytes(count);
		}

		public byte ReadByte()
		{
			CheckBounds(1u);
			return _reader.ReadByte();
		}

		public short ReadInt16()
		{
			CheckBounds(2u);
			return _reader.ReadInt16();
		}

		public ushort ReadUInt16()
		{
			CheckBounds(2u);
			return _reader.ReadUInt16();
		}

		public int ReadInt32()
		{
			CheckBounds(4u);
			return _reader.ReadInt32();
		}

		public uint ReadUInt32()
		{
			CheckBounds(4u);
			return _reader.ReadUInt32();
		}

		public ulong ReadUInt64()
		{
			CheckBounds(8u);
			return _reader.ReadUInt64();
		}

		public string ReadNullPaddedUTF8(int byteCount)
		{
			byte[] array = ReadBytes(byteCount);
			int count = 0;
			for (int num = array.Length; num > 0; num--)
			{
				if (array[num - 1] != 0)
				{
					count = num;
					break;
				}
			}
			return Encoding.UTF8.GetString(array, 0, count);
		}

		private void CheckBounds(uint count)
		{
			if ((ulong)(_reader.BaseStream.Position + count) > (ulong)_maxOffset)
			{
				Throw.ImageTooSmall();
			}
		}

		private void CheckBounds(long startPosition, int count)
		{
			if ((ulong)(startPosition + (uint)count) > (ulong)_maxOffset)
			{
				Throw.ImageTooSmallOrContainsInvalidOffsetOrCount();
			}
		}
	}
	[Flags]
	internal enum Characteristics : ushort
	{
		RelocsStripped = 1,
		ExecutableImage = 2,
		LineNumsStripped = 4,
		LocalSymsStripped = 8,
		AggressiveWSTrim = 0x10,
		LargeAddressAware = 0x20,
		BytesReversedLo = 0x80,
		Bit32Machine = 0x100,
		DebugStripped = 0x200,
		RemovableRunFromSwap = 0x400,
		NetRunFromSwap = 0x800,
		System = 0x1000,
		Dll = 0x2000,
		UpSystemOnly = 0x4000,
		BytesReversedHi = 0x8000
	}
	internal enum PEMagic : ushort
	{
		PE32 = 267,
		PE32Plus = 523
	}
	internal enum Subsystem : ushort
	{
		Unknown = 0,
		Native = 1,
		WindowsGui = 2,
		WindowsCui = 3,
		OS2Cui = 5,
		PosixCui = 7,
		NativeWindows = 8,
		WindowsCEGui = 9,
		EfiApplication = 10,
		EfiBootServiceDriver = 11,
		EfiRuntimeDriver = 12,
		EfiRom = 13,
		Xbox = 14,
		WindowsBootApplication = 16
	}
	[Flags]
	internal enum DllCharacteristics : ushort
	{
		ProcessInit = 1,
		ProcessTerm = 2,
		ThreadInit = 4,
		ThreadTerm = 8,
		HighEntropyVirtualAddressSpace = 0x20,
		DynamicBase = 0x40,
		NxCompatible = 0x100,
		NoIsolation = 0x200,
		NoSeh = 0x400,
		NoBind = 0x800,
		AppContainer = 0x1000,
		WdmDriver = 0x2000,
		TerminalServerAware = 0x8000
	}
	[Flags]
	internal enum SectionCharacteristics : uint
	{
		TypeReg = 0u,
		TypeDSect = 1u,
		TypeNoLoad = 2u,
		TypeGroup = 4u,
		TypeNoPad = 8u,
		TypeCopy = 0x10u,
		ContainsCode = 0x20u,
		ContainsInitializedData = 0x40u,
		ContainsUninitializedData = 0x80u,
		LinkerOther = 0x100u,
		LinkerInfo = 0x200u,
		TypeOver = 0x400u,
		LinkerRemove = 0x800u,
		LinkerComdat = 0x1000u,
		MemProtected = 0x4000u,
		NoDeferSpecExc = 0x4000u,
		GPRel = 0x8000u,
		MemFardata = 0x8000u,
		MemSysheap = 0x10000u,
		MemPurgeable = 0x20000u,
		Mem16Bit = 0x20000u,
		MemLocked = 0x40000u,
		MemPreload = 0x80000u,
		Align1Bytes = 0x100000u,
		Align2Bytes = 0x200000u,
		Align4Bytes = 0x300000u,
		Align8Bytes = 0x400000u,
		Align16Bytes = 0x500000u,
		Align32Bytes = 0x600000u,
		Align64Bytes = 0x700000u,
		Align128Bytes = 0x800000u,
		Align256Bytes = 0x900000u,
		Align512Bytes = 0xA00000u,
		Align1024Bytes = 0xB00000u,
		Align2048Bytes = 0xC00000u,
		Align4096Bytes = 0xD00000u,
		Align8192Bytes = 0xE00000u,
		AlignMask = 0xF00000u,
		LinkerNRelocOvfl = 0x1000000u,
		MemDiscardable = 0x2000000u,
		MemNotCached = 0x4000000u,
		MemNotPaged = 0x8000000u,
		MemShared = 0x10000000u,
		MemExecute = 0x20000000u,
		MemRead = 0x40000000u,
		MemWrite = 0x80000000u
	}
	internal sealed class PEHeader
	{
		internal const int OffsetOfChecksum = 64;

		public PEMagic Magic { get; }

		public byte MajorLinkerVersion { get; }

		public byte MinorLinkerVersion { get; }

		public int SizeOfCode { get; }

		public int SizeOfInitializedData { get; }

		public int SizeOfUninitializedData { get; }

		public int AddressOfEntryPoint { get; }

		public int BaseOfCode { get; }

		public int BaseOfData { get; }

		public ulong ImageBase { get; }

		public int SectionAlignment { get; }

		public int FileAlignment { get; }

		public ushort MajorOperatingSystemVersion { get; }

		public ushort MinorOperatingSystemVersion { get; }

		public ushort MajorImageVersion { get; }

		public ushort MinorImageVersion { get; }

		public ushort MajorSubsystemVersion { get; }

		public ushort MinorSubsystemVersion { get; }

		public int SizeOfImage { get; }

		public int SizeOfHeaders { get; }

		public uint CheckSum { get; }

		public Subsystem Subsystem { get; }

		public DllCharacteristics DllCharacteristics { get; }

		public ulong SizeOfStackReserve { get; }

		public ulong SizeOfStackCommit { get; }

		public ulong SizeOfHeapReserve { get; }

		public ulong SizeOfHeapCommit { get; }

		public int NumberOfRvaAndSizes { get; }

		public DirectoryEntry ExportTableDirectory { get; }

		public DirectoryEntry ImportTableDirectory { get; }

		public DirectoryEntry ResourceTableDirectory { get; }

		public DirectoryEntry ExceptionTableDirectory { get; }

		public DirectoryEntry CertificateTableDirectory { get; }

		public DirectoryEntry BaseRelocationTableDirectory { get; }

		public DirectoryEntry DebugTableDirectory { get; }

		public DirectoryEntry CopyrightTableDirectory { get; }

		public DirectoryEntry GlobalPointerTableDirectory { get; }

		public DirectoryEntry ThreadLocalStorageTableDirectory { get; }

		public DirectoryEntry LoadConfigTableDirectory { get; }

		public DirectoryEntry BoundImportTableDirectory { get; }

		public DirectoryEntry ImportAddressTableDirectory { get; }

		public DirectoryEntry DelayImportTableDirectory { get; }

		public DirectoryEntry CorHeaderTableDirectory { get; }

		internal static int Size(bool is32Bit)
		{
			return 72 + 4 * (is32Bit ? 4 : 8) + 4 + 4 + 128;
		}

		internal PEHeader(ref PEBinaryReader reader)
		{
			PEMagic pEMagic = (PEMagic)reader.ReadUInt16();
			if (pEMagic != PEMagic.PE32 && pEMagic != PEMagic.PE32Plus)
			{
				throw new BadImageFormatException(System.SR.UnknownPEMagicValue);
			}
			Magic = pEMagic;
			MajorLinkerVersion = reader.ReadByte();
			MinorLinkerVersion = reader.ReadByte();
			SizeOfCode = reader.ReadInt32();
			SizeOfInitializedData = reader.ReadInt32();
			SizeOfUninitializedData = reader.ReadInt32();
			AddressOfEntryPoint = reader.ReadInt32();
			BaseOfCode = reader.ReadInt32();
			if (pEMagic == PEMagic.PE32Plus)
			{
				BaseOfData = 0;
			}
			else
			{
				BaseOfData = reader.ReadInt32();
			}
			if (pEMagic == PEMagic.PE32Plus)
			{
				ImageBase = reader.ReadUInt64();
			}
			else
			{
				ImageBase = reader.ReadUInt32();
			}
			SectionAlignment = reader.ReadInt32();
			FileAlignment = reader.ReadInt32();
			MajorOperatingSystemVersion = reader.ReadUInt16();
			MinorOperatingSystemVersion = reader.ReadUInt16();
			MajorImageVersion = reader.ReadUInt16();
			MinorImageVersion = reader.ReadUInt16();
			MajorSubsystemVersion = reader.ReadUInt16();
			MinorSubsystemVersion = reader.ReadUInt16();
			reader.ReadUInt32();
			SizeOfImage = reader.ReadInt32();
			SizeOfHeaders = reader.ReadInt32();
			CheckSum = reader.ReadUInt32();
			Subsystem = (Subsystem)reader.ReadUInt16();
			DllCharacteristics = (DllCharacteristics)reader.ReadUInt16();
			if (pEMagic == PEMagic.PE32Plus)
			{
				SizeOfStackReserve = reader.ReadUInt64();
				SizeOfStackCommit = reader.ReadUInt64();
				SizeOfHeapReserve = reader.ReadUInt64();
				SizeOfHeapCommit = reader.ReadUInt64();
			}
			else
			{
				SizeOfStackReserve = reader.ReadUInt32();
				SizeOfStackCommit = reader.ReadUInt32();
				SizeOfHeapReserve = reader.ReadUInt32();
				SizeOfHeapCommit = reader.ReadUInt32();
			}
			reader.ReadUInt32();
			NumberOfRvaAndSizes = reader.ReadInt32();
			ExportTableDirectory = new DirectoryEntry(ref reader);
			ImportTableDirectory = new DirectoryEntry(ref reader);
			ResourceTableDirectory = new DirectoryEntry(ref reader);
			ExceptionTableDirectory = new DirectoryEntry(ref reader);
			CertificateTableDirectory = new DirectoryEntry(ref reader);
			BaseRelocationTableDirectory = new DirectoryEntry(ref reader);
			DebugTableDirectory = new DirectoryEntry(ref reader);
			CopyrightTableDirectory = new DirectoryEntry(ref reader);
			GlobalPointerTableDirectory = new DirectoryEntry(ref reader);
			ThreadLocalStorageTableDirectory = new DirectoryEntry(ref reader);
			LoadConfigTableDirectory = new DirectoryEntry(ref reader);
			BoundImportTableDirectory = new DirectoryEntry(ref reader);
			ImportAddressTableDirectory = new DirectoryEntry(ref reader);
			DelayImportTableDirectory = new DirectoryEntry(ref reader);
			CorHeaderTableDirectory = new DirectoryEntry(ref reader);
			new DirectoryEntry(ref reader);
		}
	}
	internal sealed class PEHeaders
	{
		private readonly CoffHeader _coffHeader;

		private readonly PEHeader _peHeader;

		private readonly ImmutableArray<SectionHeader> _sectionHeaders;

		private readonly CorHeader _corHeader;

		private readonly bool _isLoadedImage;

		private readonly int _metadataSt

Sentry.System.Runtime.CompilerServices.Unsafe.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;

[assembly: CLSCompliant(false)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyFileVersion("5.0.20.51904")]
[assembly: AssemblyInformationalVersion("5.0.0")]
[assembly: AssemblyTitle("System.Runtime.CompilerServices.Unsafe")]
[assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyCopyright("© Microsoft Corporation.  All rights reserved.")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyProduct("Microsoft® .NET Framework")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: AssemblyVersion("5.0.0.0")]
namespace System.Runtime.CompilerServices
{
	internal 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)]
		public static ref T Unbox<T>(object box)
		{
			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)]
		[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)]
		[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)]
		[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)]
		[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
	{
	}
}

Sentry.System.Text.Encodings.Web.dll

Decompiled 2 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.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.Internal;
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 = "")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDefaultAlias("System.Text.Encodings.Web")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("System.Text.Encodings.Web")]
[assembly: AssemblyFileVersion("5.0.421.11614")]
[assembly: AssemblyInformationalVersion("5.0.4+f27d33729518f5aa478aa818b7b4f54a4d50bef1")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Encodings.Web")]
[assembly: AssemblyMetadata("RepositoryUrl", "git://github.com/dotnet/runtime")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("5.0.0.1")]
[module: UnverifiableCode]
[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;
		}
	}
}
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 = default(Span<char>);
			if (bytes.Length > 16)
			{
				char[] array = new char[bytes.Length * 2];
				span = array.AsSpan();
			}
			else
			{
				span = stackalloc char[bytes.Length * 2];
			}
			int num = 0;
			ReadOnlySpan<byte> readOnlySpan = bytes;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				byte value = readOnlySpan[i];
				ToCharsBuffer(value, span, num, casing);
				num += 2;
			}
			return span.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)
		{
			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");

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

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

		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.Text
{
	internal static class UnicodeDebug
	{
		[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 (capacity > _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;
			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)
		{
			char[] array = ArrayPool<char>.Shared.Rent(Math.Max(_pos + additionalCapacityBeyondPos, _chars.Length * 2));
			_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);
			}
		}
	}
}
namespace System.Text.Unicode
{
	internal static class UnicodeHelpers
	{
		internal const int UNICODE_LAST_CODEPOINT = 1114111;

		private static readonly uint[] _definedCharacterBitmapBigEndian = (BitConverter.IsLittleEndian ? null : CreateDefinedCharacterBitmapMachineEndian());

		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, 223, 255, 255, 255, 255,
			255, 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,
			0, 0, 0, 0, 0, 0, 255, 255, 223, 255,
			255, 0, 248, 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, 227, 223, 61, 96, 7, 207, 255, 128, 255,
			255, 223, 253, 255, 255, 253, 239, 243, 223, 61,
			96, 64, 207, 255, 6, 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, 63, 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, 223, 31, 0,
			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, 127,
			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, 1, 0, 0, 0,
			0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 15, 255, 255, 255, 255, 255, 31,
			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, 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, 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, 0, 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, 127, 255, 255, 255, 255, 255, 127,
			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, 7, 0, 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, 31,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
			255, 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, 252, 7,
			0, 0, 0, 0, 224, 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, 3, 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, 0, 0, 255, 255, 255, 255,
			255, 255, 255, 255, 252, 255, 255, 255, 255, 255,
			255, 0, 0, 0, 0, 0, 255, 63, 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
		};

		private static uint[] CreateDefinedCharacterBitmapMachineEndian()
		{
			ReadOnlySpan<byte> source = DefinedCharsBitmapSpan;
			uint[] array = new uint[source.Length / 4];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = BinaryPrimitives.ReadUInt32LittleEndian(source);
				source = source.Slice(4);
			}
			return array;
		}

		public static OperationStatus DecodeScalarValueFromUtf8(ReadOnlySpan<byte> source, out uint 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_0150;
					}
					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_0150;
							}
							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_0150;
									}
									num3 = (sbyte)source[num];
									if (num3 >= -64)
									{
										goto IL_0144;
									}
									num2 <<= 6;
									num2 += (uint)num3;
									num2 += 128;
									num2 -= 4194304;
								}
								goto IL_0021;
							}
						}
					}
				}
				else
				{
					num = 1;
				}
				goto IL_0144;
			}
			goto IL_0150;
			IL_0021:
			bytesConsumed = num + 1;
			result = num2;
			return OperationStatus.Done;
			IL_0144:
			bytesConsumed = num;
			result = 65533u;
			return OperationStatus.InvalidData;
			IL_0150:
			bytesConsumed = num;
			result = 65533u;
			return OperationStatus.NeedMoreData;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static ReadOnlySpan<uint> GetDefinedCharacterBitmap()
		{
			if (BitConverter.IsLittleEndian)
			{
				return MemoryMarshal.Cast<byte, uint>(DefinedCharsBitmapSpan);
			}
			return _definedCharacterBitmapBigEndian;
		}

		internal static void GetUtf16SurrogatePairFromAstralScalarValue(int scalar, out char highSurrogate, out char lowSurrogate)
		{
			int num = scalar & 0xFFFF;
			int num2 = scalar >> 16;
			int num3 = num2 - 1;
			highSurrogate = (char)(0xD800u | (uint)(num3 << 6) | (uint)(num >> 10));
			lowSurrogate = (char)(0xDC00u | ((uint)num & 0x3FFu));
		}

		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;
		}
	}
	internal 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));
		}
	}
	internal 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 _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 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.Internal
{
	internal readonly struct AllowedCharactersBitmap
	{
		private const int ALLOWED_CHARS_BITMAP_LENGTH = 2048;

		private readonly uint[] _allowedCharacters;

		public static AllowedCharactersBitmap CreateNew()
		{
			return new AllowedCharactersBitmap(new uint[2048]);
		}

		private AllowedCharactersBitmap(uint[] allowedCharacters)
		{
			if (allowedCharacters == null)
			{
				throw new ArgumentNullException("allowedCharacters");
			}
			_allowedCharacters = allowedCharacters;
		}

		public void AllowCharacter(char character)
		{
			int num = (int)character >> 5;
			int num2 = character & 0x1F;
			_allowedCharacters[num] |= (uint)(1 << num2);
		}

		public void ForbidCharacter(char character)
		{
			int num = (int)character >> 5;
			int num2 = character & 0x1F;
			_allowedCharacters[num] &= (uint)(~(1 << num2));
		}

		public void ForbidUndefinedCharacters()
		{
			ReadOnlySpan<uint> definedCharacterBitmap = UnicodeHelpers.GetDefinedCharacterBitmap();
			for (int i = 0; i < _allowedCharacters.Length; i++)
			{
				_allowedCharacters[i] &= definedCharacterBitmap[i];
			}
		}

		public void Clear()
		{
			Array.Clear(_allowedCharacters, 0, _allowedCharacters.Length);
		}

		public AllowedCharactersBitmap Clone()
		{
			return new AllowedCharactersBitmap((uint[])_allowedCharacters.Clone());
		}

		public bool IsCharacterAllowed(char character)
		{
			return IsUnicodeScalarAllowed(character);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool IsUnicodeScalarAllowed(int unicodeScalar)
		{
			int num = unicodeScalar >> 5;
			int num2 = unicodeScalar & 0x1F;
			return (_allowedCharacters[num] & (uint)(1 << num2)) != 0;
		}

		public unsafe int FindFirstCharacterToEncode(char* text, int textLength)
		{
			int num = 0;
			while (true)
			{
				if (num <= textLength - 8)
				{
					if (!IsCharacterAllowed(text[num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]))
					{
						break;
					}
					num++;
					continue;
				}
				while (true)
				{
					if (num <= textLength - 4)
					{
						if (!IsCharacterAllowed(text[num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]) || !IsCharacterAllowed(text[++num]))
						{
							break;
						}
						num++;
						continue;
					}
					while (true)
					{
						if (num < textLength)
						{
							if (!IsCharacterAllowed(text[num]))
							{
								break;
							}
							num++;
							continue;
						}
						num = -1;
						break;
					}
					break;
				}
				break;
			}
			return num;
		}
	}
}
namespace System.Text.Encodings.Web
{
	internal sealed class DefaultJavaScriptEncoder : JavaScriptEncoder
	{
		private readonly AllowedCharactersBitmap _allowedCharacters;

		private readonly int[] _asciiNeedsEscaping = new int[128];

		private static readonly char[] s_b = new char[2] { '\\', 'b' };

		private static readonly char[] s_t = new char[2] { '\\', 't' };

		private static readonly char[] s_n = new char[2] { '\\', 'n' };

		private static readonly char[] s_f = new char[2] { '\\', 'f' };

		private static readonly char[] s_r = new char[2] { '\\', 'r' };

		private static readonly char[] s_back = new char[2] { '\\', '\\' };

		public override int MaxOutputCharactersPerInputCharacter => 12;

		public DefaultJavaScriptEncoder(TextEncoderSettings filter)
		{
			if (filter == null)
			{
				throw new ArgumentNullException("filter");
			}
			_allowedCharacters = filter.GetAllowedCharacters();
			_allowedCharacters.ForbidUndefinedCharacters();
			DefaultHtmlEncoder.ForbidHtmlCharacters(_allowedCharacters);
			_allowedCharacters.ForbidCharacter('\\');
			_allowedCharacters.ForbidCharacter('`');
			for (int i = 0; i < _asciiNeedsEscaping.Length; i++)
			{
				_asciiNeedsEscaping[i] = (WillEncode(i) ? 1 : (-1));
			}
		}

		public DefaultJavaScriptEncoder(params UnicodeRange[] allowedRanges)
			: this(new TextEncoderSettings(allowedRanges))
		{
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public override bool WillEncode(int unicodeScalar)
		{
			if (UnicodeHelpers.IsSupplementaryCodePoint(unicodeScalar))
			{
				return true;
			}
			return !_allowedCharacters.IsUnicodeScalarAllowed(unicodeScalar);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe override int FindFirstCharacterToEncode(char* text, int textLength)
		{
			if (text == null)
			{
				throw new ArgumentNullException("text");
			}
			return _allowedCharacters.FindFirstCharacterToEncode(text, textLength);
		}

		public unsafe override int FindFirstCharacterToEncodeUtf8(ReadOnlySpan<byte> utf8Text)
		{
			fixed (byte* ptr = utf8Text)
			{
				int num = 0;
				while (true)
				{
					if (num < utf8Text.Length)
					{
						if (System.Text.UnicodeUtility.IsAsciiCodePoint(ptr[num]))
						{
							if (DoesAsciiNeedEncoding(ptr[num]) == 1)
							{
								break;
							}
							num++;
						}
						else
						{
							if (UnicodeHelpers.DecodeScalarValueFromUtf8(utf8Text.Slice(num), out var result, out var bytesConsumed) != 0 || WillEncode((int)result))
							{
								break;
							}
							num += bytesConsumed;
						}
						continue;
					}
					num = -1;
					break;
				}
				return num;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private int DoesAsciiNeedEncoding(byte value)
		{
			return _asciiNeedsEscaping[value];
		}

		public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten)
		{
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (!WillEncode(unicodeScalar))
			{
				return TextEncoder.TryWriteScalarAsChar(unicodeScalar, buffer, bufferLength, out numberOfCharactersWritten);
			}
			char[] source;
			switch (unicodeScalar)
			{
			case 8:
				source = s_b;
				break;
			case 9:
				source = s_t;
				break;
			case 10:
				source = s_n;
				break;
			case 12:
				source = s_f;
				break;
			case 13:
				source = s_r;
				break;
			case 92:
				source = s_back;
				break;
			default:
				return JavaScriptEncoderHelper.TryWriteEncodedScalarAsNumericEntity(unicodeScalar, buffer, bufferLength, out numberOfCharactersWritten);
			}
			return TextEncoder.TryCopyCharacters(source, buffer, bufferLength, out numberOfCharactersWritten);
		}
	}
	internal sealed class DefaultJavaScriptEncoderBasicLatin : JavaScriptEncoder
	{
		internal static readonly DefaultJavaScriptEncoderBasicLatin s_singleton = new DefaultJavaScriptEncoderBasicLatin();

		private static readonly char[] s_b = new char[2] { '\\', 'b' };

		private static readonly char[] s_t = new char[2] { '\\', 't' };

		private static readonly char[] s_n = new char[2] { '\\', 'n' };

		private static readonly char[] s_f = new char[2] { '\\', 'f' };

		private static readonly char[] s_r = new char[2] { '\\', 'r' };

		private static readonly char[] s_back = new char[2] { '\\', '\\' };

		public const int LastAsciiCharacter = 127;

		public override int MaxOutputCharactersPerInputCharacter => 12;

		private static ReadOnlySpan<byte> AllowList => new byte[256]
		{
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 1, 1, 0, 1, 1, 1, 0, 0,
			1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
			0, 1, 0, 1, 1, 1, 1, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
			1, 1, 0, 1, 1, 1, 0, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
			1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0
		};

		private DefaultJavaScriptEncoderBasicLatin()
		{
			TextEncoderSettings textEncoderSettings = new TextEncoderSettings(UnicodeRanges.BasicLatin);
			AllowedCharactersBitmap allowedCharacters = textEncoderSettings.GetAllowedCharacters();
			allowedCharacters.ForbidUndefinedCharacters();
			DefaultHtmlEncoder.ForbidHtmlCharacters(allowedCharacters);
			allowedCharacters.ForbidCharacter('\\');
			allowedCharacters.ForbidCharacter('`');
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public override bool WillEncode(int unicodeScalar)
		{
			if (UnicodeHelpers.IsSupplementaryCodePoint(unicodeScalar))
			{
				return true;
			}
		

Sentry.System.Text.Json.dll

Decompiled 2 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.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.Serialization;
using System.Text.Json.Serialization.Converters;
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 = "")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDefaultAlias("System.Text.Json")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("System.Text.Json")]
[assembly: AssemblyFileVersion("5.0.521.16609")]
[assembly: AssemblyInformationalVersion("5.0.5+2f740adc1457e8a28c1c072993b66f515977eb51")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("System.Text.Json")]
[assembly: AssemblyMetadata("RepositoryUrl", "git://github.com/dotnet/runtime")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("5.0.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
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 = default(Span<char>);
			if (bytes.Length > 16)
			{
				char[] array = new char[bytes.Length * 2];
				span = array.AsSpan();
			}
			else
			{
				span = stackalloc char[bytes.Length * 2];
			}
			int num = 0;
			ReadOnlySpan<byte> readOnlySpan = bytes;
			for (int i = 0; i < readOnlySpan.Length; i++)
			{
				byte value = readOnlySpan[i];
				ToCharsBuffer(value, span, num, casing);
				num += 2;
			}
			return span.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)
		{
			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 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 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 InvalidEndOfJsonNonPrimitive => GetResourceString("InvalidEndOfJsonNonPrimitive");

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

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

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

		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 FormatDateTime => GetResourceString("FormatDateTime");

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

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

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

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

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

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

		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 DeserializeDuplicateKey => GetResourceString("DeserializeDuplicateKey");

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

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

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

		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 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 EmptyStringToInitializeNumber => GetResourceString("EmptyStringToInitializeNumber");

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

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

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

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

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

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

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

		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 MetadataPreservedArrayInvalidProperty => GetResourceString("MetadataPreservedArrayInvalidProperty");

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

		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 MultipleMembersBindWithConstructorParameter => GetResourceString("MultipleMembersBindWithConstructorParameter");

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

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

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

		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 JsonIncludeOnNonPublicInvalid => GetResourceString("JsonIncludeOnNonPublicInvalid");

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

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

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

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

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

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

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

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

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

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

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

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

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

		private static bool UsingResourceKeys()
		{
			return s_usingResourceKeys;
		}

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

		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.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.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.Method | AttributeTargets.Property | AttributeTargets.Field | 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,
		All = -1
	}
	[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.Buffers
{
	internal sealed class ArrayBufferWriter<T> : IBufferWriter<T>
	{
		private T[] _buffer;

		private int _index;

		private const int DefaultInitialBufferSize = 256;

		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 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)
			{
				num3 = num + sizeHint;
				if ((uint)num3 > 2147483647u)
				{
					ThrowOutOfMemoryException((uint)num3);
				}
			}
			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 ReadOnlyMemory<byte> WrittenMemory => _rentedBuffer.AsMemory(0, _index);

		public int WrittenCount => _index;

		public int Capacity => _rentedBuffer.Length;

		public int FreeCapacity => _rentedBuffer.Length - _index;

		public PooledByteBufferWriter(int initialCapacity)
		{
			_rentedBuffer = ArrayPool<byte>.Shared.Rent(initialCapacity);
			_index = 0;
		}

		public void Clear()
		{
			ClearHelper();
		}

		private void ClearHelper()
		{
			_rentedBuffer.AsSpan(0, _index).Clear();
			_index = 0;
		}

		public void Dispose()
		{
			if (_rentedBuffer != null)
			{
				ClearHelper();
				ArrayPool<byte>.Shared.Return(_rentedBuffer);
				_rentedBuffer = null;
			}
		}

		public void Advance(int count)
		{
			_index += count;
		}

		public Memory<byte> GetMemory(int sizeHint = 0)
		{
			CheckAndResizeBuffer(sizeHint);
			return _rentedBuffer.AsMemory(_index);
		}

		public Span<byte> GetSpan(int sizeHint = 0)
		{
			CheckAndResizeBuffer(sizeHint);
			return _rentedBuffer.AsSpan(_index);
		}

		internal Task WriteToStreamAsync(Stream destination, CancellationToken cancellationToken)
		{
			return destination.WriteAsync(_rentedBuffer, 0, _index, cancellationToken);
		}

		private void CheckAndResizeBuffer(int sizeHint)
		{
			if (sizeHint == 0)
			{
				sizeHint = 256;
			}
			int num = _rentedBuffer.Length - _index;
			if (sizeHint <= num)
			{
				return;
			}
			int num2 = _rentedBuffer.Length;
			int num3 = Math.Max(sizeHint, num2);
			int num4 = num2 + num3;
			if ((uint)num4 > 2147483647u)
			{
				num4 = num2 + sizeHint;
				if ((uint)num4 > 2147483647u)
				{
					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));
		}

		public static ArgumentOutOfRangeException GetArgumentOutOfRangeException_MaxDepthMustBePositive(string parameterName)
		{
			return GetArgumentOutOfRangeException(parameterName, System.SR.MaxDepthMustBePositive);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(string parameterName, string message)
		{
			return new ArgumentOutOfRangeException(parameterName, message);
		}

		public static ArgumentOutOfRangeException GetArgumentOutOfRangeException_CommentEnumMustBeInRange(string parameterName)
		{
			return GetArgumentOutOfRangeException(parameterName, System.SR.CommentHandlingMustBeValid);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		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_PropertyNameTooLarge(int tokenLength)
		{
			throw GetArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, tokenLength));
		}

		[DoesNotReturn]
		public static void ThrowArgumentException_ValueTooLarge(int 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 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)
		{
			currentDepth &= 0x7FFFFFFF;
			if (currentDepth >= 1000)
			{
				ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, 1000));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException(int currentDepth)
		{
			currentDepth &= 0x7FFFFFFF;
			ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, 1000));
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException(string message)
		{
			throw GetInvalidOperationException(message);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static InvalidOperationException GetInvalidOperationException(string message)
		{
			InvalidOperationException ex = new InvalidOperationException(message);
			ex.Source = "System.Text.Json.Rethrowable";
			return ex;
		}

		[DoesNotReturn]
		public static void ThrowInvalidOperationException_DepthNonZeroOrEmptyJson(int currentDepth)
		{
			throw GetInvalidOperationException(currentDepth);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		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)
		{
			currentDepth &= 0x7FFFFFFF;
			if (currentDepth >= 1000)
			{
				ThrowInvalidOperationException(System.SR.Format(System.SR.DepthTooLarge, currentDepth, 1000));
			}
			else
			{
				ThrowArgumentException(System.SR.Format(System.SR.PropertyNameTooLarge, propertyName.Length));
			}
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("number", tokenType);
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedBoolean(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("boolean", tokenType);
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedString(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("string", tokenType);
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedStringComparison(JsonTokenType tokenType)
		{
			return GetInvalidOperationException(tokenType);
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedComment(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("comment", tokenType);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static InvalidOperationException GetInvalidOperationException_CannotSkipOnPartial()
		{
			return GetInvalidOperationException(System.SR.CannotSkip);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static InvalidOperationException GetInvalidOperationException(string message, JsonTokenType tokenType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.InvalidCast, tokenType, message));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static InvalidOperationException GetInvalidOperationException(JsonTokenType tokenType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.InvalidComparison, tokenType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static InvalidOperationException GetJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
		{
			return GetJsonElementWrongTypeException(expectedType.ToValueKind(), actualType.ToValueKind());
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static InvalidOperationException GetJsonElementWrongTypeException(string expectedTypeName, JsonTokenType actualType)
		{
			return GetJsonElementWrongTypeException(expectedTypeName, actualType.ToValueKind());
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static InvalidOperationException GetJsonElementWrongTypeException(JsonValueKind expectedType, JsonValueKind actualType)
		{
			return GetInvalidOperationException(System.SR.Format(System.SR.JsonElementHasWrongType, expectedType, actualType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		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, byte token, JsonTokenType tokenType)
		{
			throw GetInvalidOperationException(resource, currentDepth, 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_ReadInvalidUTF16()
		{
			throw GetInvalidOperationException(System.SR.CannotReadIncompleteUTF16);
		}

		public static InvalidOperationException GetInvalidOperationException_ReadInvalidUTF8(DecoderFallbackException innerException)
		{
			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, byte token, JsonTokenType tokenType)
		{
			string resourceString = GetResourceString(resource, currentDepth, token, tokenType);
			InvalidOperationException invalidOperationException = GetInvalidOperationException(resourceString);
			invalidOperationException.Source = "System.Text.Json.Rethrowable";
			return invalidOperationException;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static string GetResourceString(ExceptionResource resource, int currentDepth, 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, 1000);
				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;
		}

		public static FormatException GetFormatException()
		{
			FormatException ex = new FormatException();
			ex.Source = "System.Text.Json.Rethrowable";
			return ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static FormatException GetFormatException(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.UInt16:
				message = System.SR.FormatUInt16;
				break;
			case NumericType.UInt32:
				message = System.SR.FormatUInt32;
				break;
			case NumericType.UInt64:
				message = System.SR.FormatUInt64;
				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;
			}
			FormatException ex = new FormatException(message);
			ex.Source = "System.Text.Json.Rethrowable";
			return ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static FormatException GetFormatException(DataType dateType)
		{
			string message = "";
			switch (dateType)
			{
			case DataType.Boolean:
				message = System.SR.FormatBoolean;
				break;
			case DataType.DateTime:
				message = System.SR.FormatDateTime;
				break;
			case DataType.DateTimeOffset:
				message = System.SR.FormatDateTimeOffset;
				break;
			case DataType.Base64String:
				message = System.SR.CannotDecodeInvalidBase64;
				break;
			case DataType.Guid:
				message = System.SR.FormatGuid;
				break;
			}
			FormatException ex = new FormatException(message);
			ex.Source = "System.Text.Json.Rethrowable";
			return ex;
		}

		public static InvalidOperationException GetInvalidOperationException_ExpectedChar(JsonTokenType tokenType)
		{
			return GetInvalidOperationException("char", tokenType);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowArgumentException_DeserializeWrongType(Type type, object value)
		{
			throw new ArgumentException(System.SR.Format(System.SR.DeserializeWrongType, type, value.GetType()));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_SerializationNotSupported(Type propertyType)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.SerializationNotSupportedType, propertyType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_ConstructorMaxOf64Parameters(ConstructorInfo constructorInfo, Type type)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.ConstructorMaxOf64Parameters, constructorInfo, type));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_DictionaryKeyTypeNotSupported(Type keyType)
		{
			throw new NotSupportedException(System.SR.Format(System.SR.DictionaryKeyTypeNotSupported, keyType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
		{
			JsonException ex = new JsonException(System.SR.Format(System.SR.DeserializeUnableToConvertValue, propertyType));
			ex.AppendPathInformation = true;
			throw ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidCastException_DeserializeUnableToAssignValue(Type typeOfValue, Type declaredType)
		{
			throw new InvalidCastException(System.SR.Format(System.SR.DeserializeUnableToAssignValue, typeOfValue, declaredType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_DeserializeUnableToAssignNull(Type declaredType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.DeserializeUnableToAssignNull, declaredType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_SerializationConverterRead(JsonConverter converter)
		{
			JsonException ex = new JsonException(System.SR.Format(System.SR.SerializationConverterRead, converter));
			ex.AppendPathInformation = true;
			throw ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_SerializationConverterWrite(JsonConverter converter)
		{
			JsonException ex = new JsonException(System.SR.Format(System.SR.SerializationConverterWrite, converter));
			ex.AppendPathInformation = true;
			throw ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_SerializerCycleDetected(int maxDepth)
		{
			throw new JsonException(System.SR.Format(System.SR.SerializerCycleDetected, maxDepth));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException(string message = null)
		{
			JsonException ex;
			if (string.IsNullOrEmpty(message))
			{
				ex = new JsonException();
			}
			else
			{
				ex = new JsonException(message);
				ex.AppendPathInformation = true;
			}
			throw ex;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_CannotSerializeInvalidType(Type type, Type parentClassType, MemberInfo memberInfo)
		{
			if (parentClassType == null)
			{
				throw new InvalidOperationException(System.SR.Format(System.SR.CannotSerializeInvalidType, type));
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.CannotSerializeInvalidMember, type, memberInfo.Name, parentClassType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationConverterNotCompatible(Type converterType, Type type)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationConverterNotCompatible, converterType, type));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[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));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[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));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerOptionsImmutable()
		{
			throw new InvalidOperationException(System.SR.SerializerOptionsImmutable);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerPropertyNameConflict(Type type, JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializerPropertyNameConflict, type, jsonPropertyInfo.MemberInfo?.Name));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializerPropertyNameNull(Type parentType, JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializerPropertyNameNull, parentType, jsonPropertyInfo.MemberInfo?.Name));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[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.SerializerConverterFactoryReturnsNull, converterType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_MultiplePropertiesBindToConstructorParameters(Type parentType, string parameterName, string firstMatchName, string secondMatchName, ConstructorInfo constructorInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.MultipleMembersBindWithConstructorParameter, firstMatchName, secondMatchName, parentType, parameterName, constructorInfo));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ConstructorParameterIncompleteBinding(ConstructorInfo constructorInfo, Type parentType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ConstructorParamIncompleteBinding, constructorInfo, parentType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ExtensionDataCannotBindToCtorParam(MemberInfo memberInfo, Type classType, ConstructorInfo constructorInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ExtensionDataCannotBindToCtorParam, memberInfo, classType, constructorInfo));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_JsonIncludeOnNonPublicInvalid(MemberInfo memberInfo, Type parentType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.JsonIncludeOnNonPublicInvalid, memberInfo.Name, parentType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_IgnoreConditionOnValueTypeInvalid(JsonPropertyInfo jsonPropertyInfo)
		{
			MemberInfo memberInfo = jsonPropertyInfo.MemberInfo;
			throw new InvalidOperationException(System.SR.Format(System.SR.IgnoreConditionOnValueTypeInvalid, memberInfo.Name, memberInfo.DeclaringType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_NumberHandlingOnPropertyInvalid(JsonPropertyInfo jsonPropertyInfo)
		{
			MemberInfo memberInfo = jsonPropertyInfo.MemberInfo;
			if (!jsonPropertyInfo.ConverterBase.IsInternalConverter)
			{
				throw new InvalidOperationException(System.SR.Format(System.SR.NumberHandlingConverterMustBeBuiltIn, jsonPropertyInfo.ConverterBase.GetType(), jsonPropertyInfo.IsForClassInfo ? jsonPropertyInfo.DeclaredPropertyType : memberInfo.DeclaringType));
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.NumberHandlingOnPropertyTypeMustBeNumberOrCollection, memberInfo.Name, memberInfo.DeclaringType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_ConverterCanConvertNullableRedundant(Type runtimePropertyType, JsonConverter jsonConverter)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.ConverterCanConvertNullableRedundant, jsonConverter.GetType(), jsonConverter.TypeToConvert, runtimePropertyType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_ObjectWithParameterizedCtorRefMetadataNotHonored(ReadOnlySpan<byte> propertyName, ref Utf8JsonReader reader, ref ReadStack state)
		{
			state.Current.JsonPropertyName = propertyName.ToArray();
			NotSupportedException ex = new NotSupportedException(System.SR.Format(System.SR.ObjectWithParameterizedCtorRefMetadataNotHonored, state.Current.JsonClassInfo.Type));
			ThrowNotSupportedException(in state, in reader, ex);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ReThrowWithPath(in ReadStack state, JsonReaderException ex)
		{
			string text = state.JsonPath();
			string message = ex.Message;
			int num = message.LastIndexOf(" LineNumber: ", StringComparison.InvariantCulture);
			message = ((num < 0) ? (message + " Path: " + text + ".") : (message.Substring(0, num) + " Path: " + text + " |" + message.Substring(num)));
			throw new JsonException(message, text, ex.LineNumber, ex.BytePositionInLine, ex);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ReThrowWithPath(in ReadStack state, in Utf8JsonReader reader, Exception ex)
		{
			JsonException ex2 = new JsonException(null, ex);
			AddJsonExceptionInformation(in state, in reader, ex2);
			throw ex2;
		}

		public static void AddJsonExceptionInformation(in ReadStack state, in Utf8JsonReader reader, JsonException ex)
		{
			long lineNumber = reader.CurrentState._lineNumber;
			ex.LineNumber = lineNumber;
			long bytePositionInLine = reader.CurrentState._bytePositionInLine;
			ex.BytePositionInLine = bytePositionInLine;
			string arg = (ex.Path = state.JsonPath());
			string text2 = ex._message;
			if (string.IsNullOrEmpty(text2))
			{
				Type type = state.Current.JsonPropertyInfo?.RuntimePropertyType;
				if (type == null)
				{
					type = state.Current.JsonClassInfo?.Type;
				}
				text2 = System.SR.Format(System.SR.DeserializeUnableToConvertValue, type);
				ex.AppendPathInformation = true;
			}
			if (ex.AppendPathInformation)
			{
				text2 += $" Path: {arg} | LineNumber: {lineNumber} | BytePositionInLine: {bytePositionInLine}.";
				ex.SetMessage(text2);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ReThrowWithPath(in WriteStack state, Exception ex)
		{
			JsonException ex2 = new JsonException(null, ex);
			AddJsonExceptionInformation(in state, ex2);
			throw ex2;
		}

		public static void AddJsonExceptionInformation(in WriteStack state, JsonException ex)
		{
			string text2 = (ex.Path = state.PropertyPath());
			string text3 = ex._message;
			if (string.IsNullOrEmpty(text3))
			{
				text3 = System.SR.Format(System.SR.SerializeUnableToSerialize);
				ex.AppendPathInformation = true;
			}
			if (ex.AppendPathInformation)
			{
				text3 = text3 + " Path: " + text2 + ".";
				ex.SetMessage(text3);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationDuplicateAttribute(Type attribute, Type classType, MemberInfo memberInfo)
		{
			string text = classType.ToString();
			if (memberInfo != null)
			{
				text = text + "." + memberInfo.Name;
			}
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationDuplicateAttribute, attribute, text));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(Type classType, Type attribute)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationDuplicateTypeAttribute, classType, attribute));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationDuplicateTypeAttribute<TAttribute>(Type classType)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationDuplicateTypeAttribute, classType, typeof(Attribute)));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_SerializationDataExtensionPropertyInvalid(Type type, JsonPropertyInfo jsonPropertyInfo)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.SerializationDataExtensionPropertyInvalid, type, jsonPropertyInfo.MemberInfo?.Name));
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException(in ReadStack state, in Utf8JsonReader reader, NotSupportedException ex)
		{
			string text = ex.Message;
			Type type = state.Current.JsonPropertyInfo?.RuntimePropertyType;
			if (type == null)
			{
				type = state.Current.JsonClassInfo.Type;
			}
			if (!text.Contains(type.ToString()))
			{
				if (text.Length > 0)
				{
					text += " ";
				}
				text += System.SR.Format(System.SR.SerializationNotSupportedParentType, type);
			}
			long lineNumber = reader.CurrentState._lineNumber;
			long bytePositionInLine = reader.CurrentState._bytePositionInLine;
			text += $" Path: {state.JsonPath()} | LineNumber: {lineNumber} | BytePositionInLine: {bytePositionInLine}.";
			throw new NotSupportedException(text, ex);
		}

		[DoesNotReturn]
		public static void ThrowNotSupportedException(in WriteStack state, NotSupportedException ex)
		{
			string text = ex.Message;
			Type type = state.Current.DeclaredJsonPropertyInfo?.RuntimePropertyType;
			if (type == null)
			{
				type = state.Current.JsonClassInfo.Type;
			}
			if (!text.Contains(type.ToString()))
			{
				if (text.Length > 0)
				{
					text += " ";
				}
				text += System.SR.Format(System.SR.SerializationNotSupportedParentType, type);
			}
			text = text + " Path: " + state.PropertyPath() + ".";
			throw new NotSupportedException(text, ex);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_DeserializeNoConstructor(Type type, ref Utf8JsonReader reader, ref ReadStack state)
		{
			string message = ((!type.IsInterface) ? System.SR.Format(System.SR.DeserializeNoConstructor, "JsonConstructorAttribute", type) : System.SR.Format(System.SR.DeserializePolymorphicInterface, type));
			ThrowNotSupportedException(in state, in reader, new NotSupportedException(message));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowNotSupportedException_CannotPopulateCollection(Type type, ref Utf8JsonReader reader, ref ReadStack state)
		{
			ThrowNotSupportedException(in state, in reader, new NotSupportedException(System.SR.Format(System.SR.CannotPopulateCollection, type)));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataValuesInvalidToken(JsonTokenType tokenType)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataInvalidTokenAfterValues, tokenType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataReferenceNotFound(string id)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataReferenceNotFound, id));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataValueWasNotString(JsonTokenType tokenType)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataValueWasNotString, tokenType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataValueWasNotString(JsonValueKind valueKind)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataValueWasNotString, valueKind));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties(ReadOnlySpan<byte> propertyName, ref ReadStack state)
		{
			state.Current.JsonPropertyName = propertyName.ToArray();
			ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties()
		{
			ThrowJsonException(System.SR.MetadataReferenceCannotContainOtherProperties);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataIdIsNotFirstProperty(ReadOnlySpan<byte> propertyName, ref ReadStack state)
		{
			state.Current.JsonPropertyName = propertyName.ToArray();
			ThrowJsonException(System.SR.MetadataIdIsNotFirstProperty);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataMissingIdBeforeValues(ref ReadStack state, ReadOnlySpan<byte> propertyName)
		{
			state.Current.JsonPropertyName = propertyName.ToArray();
			ThrowJsonException(System.SR.MetadataPreservedArrayPropertyNotFound);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataInvalidPropertyWithLeadingDollarSign(ReadOnlySpan<byte> propertyName, ref ReadStack state, in Utf8JsonReader reader)
		{
			if (state.Current.IsProcessingDictionary())
			{
				state.Current.JsonPropertyNameAsString = reader.GetString();
			}
			else
			{
				state.Current.JsonPropertyName = propertyName.ToArray();
			}
			ThrowJsonException(System.SR.MetadataInvalidPropertyWithLeadingDollarSign);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataDuplicateIdFound(string id)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataDuplicateIdFound, id));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataInvalidReferenceToValueType(Type propertyType)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataInvalidReferenceToValueType, propertyType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataPreservedArrayInvalidProperty(ref ReadStack state, Type propertyType, in Utf8JsonReader reader)
		{
			ref ReadStackFrame current = ref state.Current;
			byte[] jsonPropertyName;
			if (!reader.HasValueSequence)
			{
				jsonPropertyName = reader.ValueSpan.ToArray();
			}
			else
			{
				ReadOnlySequence<byte> sequence = reader.ValueSequence;
				jsonPropertyName = BuffersExtensions.ToArray(in sequence);
			}
			current.JsonPropertyName = jsonPropertyName;
			string @string = reader.GetString();
			ThrowJsonException(System.SR.Format(System.SR.MetadataPreservedArrayFailed, System.SR.Format(System.SR.MetadataPreservedArrayInvalidProperty, @string), System.SR.Format(System.SR.DeserializeUnableToConvertValue, propertyType)));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataPreservedArrayValuesNotFound(ref ReadStack state, Type propertyType)
		{
			state.Current.JsonPropertyName = null;
			ThrowJsonException(System.SR.Format(System.SR.MetadataPreservedArrayFailed, System.SR.MetadataPreservedArrayPropertyNotFound, System.SR.Format(System.SR.DeserializeUnableToConvertValue, propertyType)));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowJsonException_MetadataCannotParsePreservedObjectIntoImmutable(Type propertyType)
		{
			ThrowJsonException(System.SR.Format(System.SR.MetadataCannotParsePreservedObjectToImmutable, propertyType));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[DoesNotReturn]
		public static void ThrowInvalidOperationException_MetadataReferenceOfTypeCannotBeAssignedToType(string referenceId, Type currentType, Type typeToConvert)
		{
			throw new InvalidOperationException(System.SR.Format(System.SR.MetadataReferenceOfTypeCannotBeAssignedToType, referenceId, currentType, typeToConvert));
		}

		[DoesNotReturn]
		internal static void ThrowUnexpectedMetadataException(ReadOnlySpan<byte> propertyName, ref Utf8JsonReader reader, ref ReadStack state)
		{
			if (state.Current.JsonClassInfo.PropertyInfoForClassInfo.ConverterBase.ConstructorIsParameterized)
			{
				ThrowNotSupportedException_ObjectWithParameterizedCtorRefMetadataNotHonored(propertyName, ref reader, ref state);
			}
			switch (JsonSerializer.GetMetadataPropertyName(propertyName))
			{
			case MetadataPropertyName.Id:
				ThrowJsonException_MetadataIdIsNotFirstProperty(propertyName, ref state);
				break;
			case MetadataPropertyName.Ref:
				ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties(propertyName, ref state);
				break;
			default:
				ThrowJsonException_MetadataInvalidPropertyWithLeadingDollarSign(propertyName, ref state, in reader);
				break;
			}
		}
	}
	internal struct BitStack
	{
		private const int AllocationFreeMaxDepth = 64;

		private const int DefaultInitialArraySize = 2;

		private int[] _array;

		private ulong _allocationFreeContainer;

		private int _currentDepth;

		public int CurrentDepth => _currentDepth;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void PushTrue()
		{
			if (_currentDepth < 64)
			{
				_allocationFreeContainer = (_allocationFreeContainer << 1) | 1;
			}
			else
			{
				PushToArray(value: true);
			}
			_currentDepth++;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void PushFalse()
		{
			if (_currentDepth < 64)
			{
				_allocationFreeContainer <<= 1;
			}
			else
			{
				PushToArray(value: false);
			}
			_currentDepth++;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void PushToArray(bool value)
		{
			if (_array == null)
			{
				_array = new int[2];
			}
			int number = _currentDepth - 64;
			int remainder;
			int num = Div32Rem(number, out remainder);
			if (num >= _array.Length)
			{
				DoubleArray(num);
			}
			int num2 = _array[num];
			num2 = ((!value) ? (num2 & ~(1 << remainder)) : (num2 | (1 << remainder)));
			_array[num] = num2;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool Pop()
		{
			_currentDepth--;
			bool flag = false;
			if (_currentDepth < 64)
			{
				_allocationFreeContainer >>= 1;
				return (_allocationFreeContainer & 1) != 0;
			}
			if (_currentDepth == 64)
			{
				return (_allocationFreeContainer & 1) != 0;
			}
			return PopFromArray();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private bool PopFromArray()
		{
			int number = _currentDepth - 64 - 1;
			int remainder;
			int num = Div32Rem(number, out remainder);
			return (_array[num] & (1 << remainder)) != 0;
		}

		private void DoubleArray(int minSize)
		{
			int newSize = Math.Max(minSize + 1, _array.Length * 2);
			Array.Resize(ref _array, newSize);
		}

		public void SetFirstBit()
		{
			_currentDepth++;
			_allocationFreeContainer = 1uL;
		}

		public void ResetFirstBit()
		{
			_currentDepth++;
			_allocationFreeContainer = 0uL;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static int Div32Rem(int number, out int remainder)
		{
			uint result = (uint)number / 32u;
			remainder = number & 0x1F;
			return (int)result;
		}
	}
	internal sealed class JsonDocument : IDisposable
	{
		internal readonly struct DbRow
		{
			internal const int Size = 12;

			private readonly int _location;

			private readonly int _sizeOrLengthUnion;

			private readonly int _numberOfRowsAndTypeUnion;

			internal const int UnknownSize = -1;

			internal int Location => _location;

			internal int SizeOrLength => _sizeOrLengthUnion & 0x7FFFFFFF;

			internal bool IsUnknownSize => _sizeOrLengthUnion == -1;

			internal bool HasComplexChildren => _sizeOrLengthUnion < 0;

			internal int NumberOfRows => _numberOfRowsAndTypeUnion & 0xFFFFFFF;

			internal JsonTokenType TokenType => (JsonTokenType)((uint)_numberOfRowsAndTypeUnion >> 28);

			internal bool IsSimpleValue => (int)TokenType >= 5;

			internal DbRow(JsonTokenType jsonTokenType, int location, int sizeOrLength)
			{
				_location = location;
				_sizeOrLengthUnion = sizeOrLength;
				_numberOfRowsAndTypeUnion = (int)((uint)jsonTokenType << 28);
			}
		}

		private struct MetadataDb : IDisposable
		{
			private const int SizeOrLengthOffset = 4;

			private const int NumberOfRowsOffset = 8;

			private byte[] _data;

			internal int Length { get; private set; }

			internal MetadataDb(byte[] completeDb)
			{
				_data = completeDb;
				Length = completeDb.Length;
			}

			internal MetadataDb(int payloadLength)
			{
				int num = 12 + payloadLength;
				if (num > 1048576 && num <= 4194304)
				{
					num = 1048576;
				}
				_data = ArrayPool<byte>.Shared.Rent(num);
				Length = 0;
			}

			internal MetadataDb(MetadataDb source, bool useArrayPools)
			{
				Length = source.Length;
				if (useArrayPools)
				{
					_data = ArrayPool<byte>.Shared.Rent(Length);
					source._data.AsSpan(0, Length).CopyTo(_data);
				}
				else
				{
					_data = source._data.AsSpan(0, Length).ToArray();
				}
			}

			public void Dispose()
			{
				byte[] array = Interlocked.Exchange(ref _data, null);
				if (array != null)
				{
					ArrayPool<byte>.Shared.Return(array);
					Length = 0;
				}
			}

			internal void TrimExcess()
			{
				if (Length <= _data.Length / 2)
				{
					byte[] array = ArrayPool<byte>.Shared.Rent(Length);
					byte[] array2 = array;
					if (array.Length < _data.Length)
					{
						Buffer.BlockCopy(_data, 0, array, 0, Length);
						array2 = _data;
						_data = array;
					}
					ArrayPool<byte>.Shared.Return(array2);
				}
			}

			internal void Append(JsonTokenType tokenType, int startLocation, int length)
			{
				if (Length >= _data.Length - 12)
				{
					Enlarge();
				}
				DbRow value = new DbRow(tokenType, startLocation, length);
				MemoryMarshal.Write(_data.AsSpan(Length), ref value);
				Length += 12;
			}

			private void Enlarge()
			{
				byte[] data = _data;
				_data = ArrayPool<byte>.Shared.Rent(data.Length * 2);
				Buffer.BlockCopy(data, 0, _data, 0, data.Length);
				ArrayPool<byte>.Shared.Return(data);
			}

			[Conditional("DEBUG")]
			private void AssertValidIndex(int index)
			{
			}

			internal void SetLength(int index, int length)
			{
				Span<byte> destination = _data.AsSpan(index + 4);
				MemoryMarshal.Write(destination, ref length);
			}

			internal void SetNumberOfRows(int index, int numberOfRows)
			{
				Span<byte> span = _data.AsSpan(index + 8);
				int num = MemoryMarshal.Read<int>(span);
				int value = (num & -268435456) | numberOfRows;
				MemoryMarshal.Write(span, ref value);
			}

			internal void SetHasComplexChildren(int index)
			{
				Span<byte> span = _data.AsSpan(index + 4);
				int num = MemoryMarshal.Read<int>(span);
				int value = num | int.MinValue;
				MemoryMarshal.Write(span, ref value);
			}

			internal int FindIndexOfFirstUnsetSizeOrLength(JsonTokenType lookupType)
			{
				return FindOpenElement(lookupType);
			}

			private int FindOpenElement(JsonTokenType lookupType)
			{
				Span<byte> span = _data.AsSpan(0, Length);
				for (int num = Length - 12; num >= 0; num -= 12)
				{
					DbRow dbRow = MemoryMarshal.Read<DbRow>(span.Slice(num));
					if (dbRow.IsUnknownSize && dbRow.TokenType == lookupType)
					{
						return num;
					}
				}
				return -1;
			}

			internal DbRow Get(int index)
			{
				return MemoryMarshal.Read<DbRow>(_data.AsSpan(index));
			}

			internal JsonTokenType GetJsonTokenType(int index)
			{
				uint num = MemoryMarshal.Read<uint>(_data.AsSpan(index + 8));
				return (JsonTokenType)(num >> 28);
			}

			internal MetadataDb CopySegment(int startIndex, int endIndex)
			{
				DbRow dbRow = Get(startIndex);
				int num = endIndex - startIndex;
				byte[] array = new byte[num];
				_data.AsSpan(startIndex, num).CopyTo(array);
				Span<int> span = MemoryMarshal.Cast<byte, int>(array);
				int num2 = span[0];
				if (dbRow.TokenType == JsonTokenType.String)
				{
					num2--;
				}
				for (int num3 = (num - 12) / 4; num3 >= 0; num3 -= 3)
				{
					span[num3] -= num2;
				}
				return new MetadataDb(array);
			}
		}

		private struct StackRow
		{
			internal const int Size = 8;

			internal int SizeOrLength;

			internal int NumberOfRows;

			internal StackRow(int sizeOrLength = 0, int numberOfRows = -1)
			{
				SizeOrLength = sizeOrLength;
				NumberOfRows = numberOfRows;
			}
		}

		private struct StackRowStack : IDisposable
		{
			private byte[] _rentedBuffer;

			private int _topOfStack;

			internal StackRowStack(int initialSize)
			{
				_rentedBuffer = ArrayPool<byte>.Shared.Rent(initialSize);
				_topOfStack = _rentedBuffer.Length;
			}

			public void Dispose()
			{
				byte[] rentedBuffer = _rentedBuffer;
				_rentedBuffer = null;
				_topOfStack = 0;
				if (rentedBuffer != null)
				{
					ArrayPool<byte>.Shared.Return(rentedBuffer);
				}
			}

			internal void Push(StackRow row)
			{
				if (_topOfStack < 8)
				{
					Enlarge();
				}
				_topOfStack -= 8;
				MemoryMarshal.Write(_rentedBuffer.AsSpan(_topOfStack), ref row);
			}

			internal StackRow Pop()
			{
				StackRow result = MemoryMarshal.Read<StackRow>(_rentedBuffer.AsSpan(_topOfStack));
				_topOfStack += 8;
				return result;
			}

			private void Enlarge()
			{
				byte[] rentedBuffer = _rentedBuffer;
				_rentedBuffer = ArrayPool<byte>.Shared.Rent(rentedBuffer.Length * 2);
				Buffer.BlockCopy(rentedBuffer, _topOfStack, _rentedBuffer, _rentedBuffer.Length - rentedBuffer.Length + _topOfStack, rentedBuffer.Length - _topOfStack);
				_topOfStack += _rentedBuffer.Length - rentedBuffer.Length;
				ArrayPool<byte>.Shared.Return(rentedBuffer);
			}
		}

		private ReadOnlyMemory<byte> _utf8Json;

		private MetadataDb _parsedData;

		private byte[] _extraRentedBytes;

		private (int, string) _lastIndexAndString = (-1, null);

		private const int UnseekableStreamInitialRentSize = 4096;

		internal bool IsDisposable { get; }

		public JsonElement RootElement => new JsonElement(this, 0);

		private JsonDocument(ReadOnlyMemory<byte> utf8Json, MetadataDb parsedData, byte[] extraRentedBytes, bool isDisposable = true)
		{
			_utf8Json = utf8Json;
			_parsedData = parsedData;
			_extraRentedBytes = extraRentedBytes;
			IsDisposable = isDisposable;
		}

		public void Dispose()
		{
			int length = _utf8Json.Length;
			if (length != 0 && IsDisposable)
			{
				_parsedData.Dispose();
				_utf8Json = ReadOnlyMemory<byte>.Empty;
				byte[] array = Interlocked.Exchange(ref _extraRentedBytes, null);
				if (array != null)
				{
					array.AsSpan(0, length).Clear();
					ArrayPool<byte>.Shared.Return(array);
				}
			}
		}

		public void WriteTo(Utf8JsonWriter writer)
		{
			if (writer == null)
			{
				throw new ArgumentNullException("writer");
			}
			RootElement.WriteTo(writer);
		}

		internal JsonTokenType GetJsonTokenType(int index)
		{
			CheckNotDisposed();
			return _parsedData.GetJsonTokenType(index);
		}

		internal int GetArrayLength(int index)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.StartArray, dbRow.TokenType);
			return dbRow.SizeOrLength;
		}

		internal JsonElement GetArrayIndexElement(int currentIndex, int arrayIndex)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(currentIndex);
			CheckExpectedType(JsonTokenType.StartArray, dbRow.TokenType);
			int sizeOrLength = dbRow.SizeOrLength;
			if ((uint)arrayIndex >= (uint)sizeOrLength)
			{
				throw new IndexOutOfRangeException();
			}
			if (!dbRow.HasComplexChildren)
			{
				return new JsonElement(this, currentIndex + (arrayIndex + 1) * 12);
			}
			int num = 0;
			for (int i = currentIndex + 12; i < _parsedData.Length; i += 12)
			{
				if (arrayIndex == num)
				{
					return new JsonElement(this, i);
				}
				dbRow = _parsedData.Get(i);
				if (!dbRow.IsSimpleValue)
				{
					i += 12 * dbRow.NumberOfRows;
				}
				num++;
			}
			throw new IndexOutOfRangeException();
		}

		internal int GetEndIndex(int index, bool includeEndElement)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			if (dbRow.IsSimpleValue)
			{
				return index + 12;
			}
			int num = index + 12 * dbRow.NumberOfRows;
			if (includeEndElement)
			{
				num += 12;
			}
			return num;
		}

		private ReadOnlyMemory<byte> GetRawValue(int index, bool includeQuotes)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			if (dbRow.IsSimpleValue)
			{
				if (includeQuotes && dbRow.TokenType == JsonTokenType.String)
				{
					return _utf8Json.Slice(dbRow.Location - 1, dbRow.SizeOrLength + 2);
				}
				return _utf8Json.Slice(dbRow.Location, dbRow.SizeOrLength);
			}
			int endIndex = GetEndIndex(index, includeEndElement: false);
			int location = dbRow.Location;
			dbRow = _parsedData.Get(endIndex);
			return _utf8Json.Slice(location, dbRow.Location - location + dbRow.SizeOrLength);
		}

		private ReadOnlyMemory<byte> GetPropertyRawValue(int valueIndex)
		{
			CheckNotDisposed();
			int num = _parsedData.Get(valueIndex - 12).Location - 1;
			DbRow dbRow = _parsedData.Get(valueIndex);
			int num2;
			if (dbRow.IsSimpleValue)
			{
				num2 = dbRow.Location + dbRow.SizeOrLength;
				if (dbRow.TokenType == JsonTokenType.String)
				{
					num2++;
				}
				return _utf8Json.Slice(num, num2 - num);
			}
			int endIndex = GetEndIndex(valueIndex, includeEndElement: false);
			dbRow = _parsedData.Get(endIndex);
			num2 = dbRow.Location + dbRow.SizeOrLength;
			return _utf8Json.Slice(num, num2 - num);
		}

		internal string GetString(int index, JsonTokenType expectedType)
		{
			CheckNotDisposed();
			int num;
			string result;
			(num, result) = _lastIndexAndString;
			if (num == index)
			{
				return result;
			}
			DbRow dbRow = _parsedData.Get(index);
			JsonTokenType tokenType = dbRow.TokenType;
			if (tokenType == JsonTokenType.Null)
			{
				return null;
			}
			CheckExpectedType(expectedType, tokenType);
			ReadOnlySpan<byte> readOnlySpan = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (dbRow.HasComplexChildren)
			{
				int idx = readOnlySpan.IndexOf<byte>(92);
				result = JsonReaderHelper.GetUnescapedString(readOnlySpan, idx);
			}
			else
			{
				result = JsonReaderHelper.TranscodeHelper(readOnlySpan);
			}
			_lastIndexAndString = (index, result);
			return result;
		}

		internal bool TextEquals(int index, ReadOnlySpan<char> otherText, bool isPropertyName)
		{
			CheckNotDisposed();
			int num = (isPropertyName ? (index - 12) : index);
			var (num2, text) = _lastIndexAndString;
			if (num2 == num)
			{
				return otherText.SequenceEqual(text.AsSpan());
			}
			byte[] array = null;
			int num3 = checked(otherText.Length * 3);
			Span<byte> span = ((num3 > 256) ? ((Span<byte>)(array = ArrayPool<byte>.Shared.Rent(num3))) : stackalloc byte[256]);
			Span<byte> utf8Destination = span;
			ReadOnlySpan<byte> utf16Source = MemoryMarshal.AsBytes(otherText);
			int bytesConsumed;
			int bytesWritten;
			OperationStatus operationStatus = JsonWriterHelper.ToUtf8(utf16Source, utf8Destination, out bytesConsumed, out bytesWritten);
			bool result = operationStatus <= OperationStatus.DestinationTooSmall && TextEquals(index, utf8Destination.Slice(0, bytesWritten), isPropertyName, shouldUnescape: true);
			if (array != null)
			{
				utf8Destination.Slice(0, bytesWritten).Clear();
				ArrayPool<byte>.Shared.Return(array);
			}
			return result;
		}

		internal bool TextEquals(int index, ReadOnlySpan<byte> otherUtf8Text, bool isPropertyName, bool shouldUnescape)
		{
			CheckNotDisposed();
			int index2 = (isPropertyName ? (index - 12) : index);
			DbRow dbRow = _parsedData.Get(index2);
			CheckExpectedType(isPropertyName ? JsonTokenType.PropertyName : JsonTokenType.String, dbRow.TokenType);
			ReadOnlySpan<byte> span = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (otherUtf8Text.Length > span.Length || (!shouldUnescape && otherUtf8Text.Length != span.Length))
			{
				return false;
			}
			if (dbRow.HasComplexChildren && shouldUnescape)
			{
				if (otherUtf8Text.Length < span.Length / 6)
				{
					return false;
				}
				int num = span.IndexOf<byte>(92);
				if (!otherUtf8Text.StartsWith(span.Slice(0, num)))
				{
					return false;
				}
				return JsonReaderHelper.UnescapeAndCompare(span.Slice(num), otherUtf8Text.Slice(num));
			}
			return span.SequenceEqual(otherUtf8Text);
		}

		internal string GetNameOfPropertyValue(int index)
		{
			return GetString(index - 12, JsonTokenType.PropertyName);
		}

		internal bool TryGetValue(int index, [NotNullWhen(true)] out byte[] value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.String, dbRow.TokenType);
			ReadOnlySpan<byte> readOnlySpan = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (dbRow.HasComplexChildren)
			{
				int idx = readOnlySpan.IndexOf<byte>(92);
				return JsonReaderHelper.TryGetUnescapedBase64Bytes(readOnlySpan, idx, out value);
			}
			return JsonReaderHelper.TryDecodeBase64(readOnlySpan, out value);
		}

		internal bool TryGetValue(int index, out sbyte value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out sbyte value2, out int bytesConsumed, '\0') && bytesConsumed == source.Length)
			{
				value = value2;
				return true;
			}
			value = 0;
			return false;
		}

		internal bool TryGetValue(int index, out byte value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out byte value2, out int bytesConsumed, '\0') && bytesConsumed == source.Length)
			{
				value = value2;
				return true;
			}
			value = 0;
			return false;
		}

		internal bool TryGetValue(int index, out short value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out short value2, out int bytesConsumed, '\0') && bytesConsumed == source.Length)
			{
				value = value2;
				return true;
			}
			value = 0;
			return false;
		}

		internal bool TryGetValue(int index, out ushort value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out ushort value2, out int bytesConsumed, '\0') && bytesConsumed == source.Length)
			{
				value = value2;
				return true;
			}
			value = 0;
			return false;
		}

		internal bool TryGetValue(int index, out int value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out int value2, out int bytesConsumed, '\0') && bytesConsumed == source.Length)
			{
				value = value2;
				return true;
			}
			value = 0;
			return false;
		}

		internal bool TryGetValue(int index, out uint value)
		{
			CheckNotDisposed();
			DbRow dbRow = _parsedData.Get(index);
			CheckExpectedType(JsonTokenType.Number, dbRow.TokenType);
			ReadOnlySpan<byte> source = _utf8Json.Span.Slice(dbRow.Location, dbRow.SizeOrLength);
			if (Utf8Parser.TryParse(source, out uint value2, out int bytesConsumed, '\0') 

Sentry.System.Threading.Tasks.Extensions.dll

Decompiled 2 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: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[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))]
	internal 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<>))]
	internal 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]
	internal enum ValueTaskSourceOnCompletedFlags
	{
		None = 0,
		UseSchedulingContext = 1,
		FlowExecutionContext = 2
	}
	internal enum ValueTaskSourceStatus
	{
		Pending,
		Succeeded,
		Faulted,
		Canceled
	}
	internal interface IValueTaskSource
	{
		ValueTaskSourceStatus GetStatus(short token);

		void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags);

		void GetResult(short token);
	}
	internal 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)]
	internal sealed class AsyncMethodBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public AsyncMethodBuilderAttribute(Type builderType)
		{
			BuilderType = builderType;
		}
	}
	[StructLayout(LayoutKind.Auto)]
	internal 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)]
	internal 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)]
	internal 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)]
	internal 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);
		}
	}
	internal 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);
			}
		}
	}
	internal 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
	{
	}
}

Sentry.Unity.Android.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using Sentry.Extensibility;
using Sentry.Unity.Integrations;
using Sentry.Unity.NativeUtils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Sentry.Unity.Android.Tests")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Sentry.Unity.Android")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.23.1.0")]
[assembly: AssemblyInformationalVersion("0.23.1")]
[assembly: AssemblyProduct("Sentry.Unity.Android")]
[assembly: AssemblyTitle("Sentry.Unity.Android")]
[assembly: AssemblyVersion("0.23.1.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

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

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace Sentry.Unity.Android
{
	public class AndroidJavaScopeObserver : ScopeObserver
	{
		public AndroidJavaScopeObserver(SentryOptions options)
			: base("Android", options)
		{
		}

		private AndroidJavaObject GetSentryJava()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			return (AndroidJavaObject)new AndroidJavaClass("io.sentry.Sentry");
		}

		public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				AndroidJavaObject val = new AndroidJavaObject("io.sentry.Breadcrumb", Array.Empty<object>());
				try
				{
					val.Set<string>("message", breadcrumb.Message);
					val.Set<string>("type", breadcrumb.Type);
					val.Set<string>("category", breadcrumb.Category);
					AndroidJavaObject val2 = breadcrumb.Level.ToJavaSentryLevel();
					try
					{
						val.Set<AndroidJavaObject>("level", val2);
						sentryJava.CallStatic("addBreadcrumb", new object[2] { val, null });
					}
					finally
					{
						((IDisposable)val2)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public override void SetExtraImpl(string key, string? value)
		{
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				sentryJava.CallStatic("setExtra", new object[2] { key, value });
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public override void SetTagImpl(string key, string value)
		{
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				sentryJava.CallStatic("setTag", new object[2] { key, value });
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public override void UnsetTagImpl(string key)
		{
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				sentryJava.CallStatic("removeTag", new object[1] { key });
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public override void SetUserImpl(User user)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject val = null;
			try
			{
				val = new AndroidJavaObject("io.sentry.protocol.User", Array.Empty<object>());
				val.Set<string>("email", user.Email);
				val.Set<string>("id", user.Id);
				val.Set<string>("username", user.Username);
				val.Set<string>("ipAddress", user.IpAddress);
				AndroidJavaObject sentryJava = GetSentryJava();
				try
				{
					sentryJava.CallStatic("setUser", new object[1] { val });
				}
				finally
				{
					((IDisposable)sentryJava)?.Dispose();
				}
			}
			finally
			{
				if (val != null)
				{
					val.Dispose();
				}
			}
		}

		public override void UnsetUserImpl()
		{
			AndroidJNI.AttachCurrentThread();
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				sentryJava.CallStatic("setUser", (object[])null);
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}
	}
	public static class BreadcrumbExtensions
	{
		public static AndroidJavaObject ToJavaSentryLevel(this BreadcrumbLevel level)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected I4, but got Unknown
			AndroidJavaClass val = new AndroidJavaClass("io.sentry.SentryLevel");
			try
			{
				return (AndroidJavaObject)((level - -1) switch
				{
					4 => ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("FATAL"), 
					3 => ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("ERROR"), 
					2 => ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("WARNING"), 
					0 => ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("DEBUG"), 
					_ => ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("INFO"), 
				});
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	internal class NativeContextWriter : ContextWriter
	{
		protected override void WriteScope(string? AppStartTime, string? AppBuildType, string? OperatingSystemRawDescription, int? DeviceProcessorCount, string? DeviceCpuDescription, string? DeviceTimezone, bool? DeviceSupportsVibration, string? DeviceName, bool? DeviceSimulator, string? DeviceDeviceUniqueIdentifier, string? DeviceDeviceType, string? DeviceModel, long? DeviceMemorySize, int? GpuId, string? GpuName, string? GpuVendorName, int? GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int? GpuMaxTextureSize, bool? GpuSupportsDrawCallInstancing, bool? GpuSupportsRayTracing, bool? GpuSupportsComputeShaders, bool? GpuSupportsGeometryShaders, string? GpuVendorId, bool? GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel, string? UnityInstallMode, string? UnityTargetFrameRate, string? UnityCopyTextureSupport, string? UnityRenderingThreadingMode)
		{
			SentryJava.WriteScope(GpuId, GpuName, GpuVendorName, GpuMemorySize, GpuNpotSupport, GpuVersion, GpuApiType, GpuMaxTextureSize, GpuSupportsDrawCallInstancing, GpuSupportsRayTracing, GpuSupportsComputeShaders, GpuSupportsGeometryShaders, GpuVendorId, GpuMultiThreadedRendering, GpuGraphicsShaderLevel);
			ContextWriter.WriteGpu(GpuId, GpuName, GpuVendorName, GpuMemorySize, GpuNpotSupport, GpuVersion, GpuApiType, GpuMaxTextureSize, GpuSupportsDrawCallInstancing, GpuSupportsRayTracing, GpuSupportsComputeShaders, GpuSupportsGeometryShaders, GpuVendorId, GpuMultiThreadedRendering, GpuGraphicsShaderLevel);
			ContextWriter.WriteUnity(UnityInstallMode, UnityTargetFrameRate, UnityCopyTextureSupport, UnityRenderingThreadingMode);
		}
	}
	internal static class SentryJava
	{
		internal class ScopeCallback : AndroidJavaProxy
		{
			private readonly Action<AndroidJavaObject> _callback;

			public ScopeCallback(Action<AndroidJavaObject> callback)
				: base("io.sentry.ScopeCallback")
			{
				_callback = callback;
			}

			public override AndroidJavaObject? Invoke(string methodName, AndroidJavaObject[] args)
			{
				try
				{
					if (methodName != "run" || args.Length != 1)
					{
						throw new Exception($"Invalid invocation: {methodName}({args.Length} args)");
					}
					_callback(args[0]);
				}
				catch (Exception arg)
				{
					Debug.LogError((object)string.Format("{0}Error in SentryJava.ScopeCallback: {1}", "Sentry: ", arg));
				}
				return null;
			}
		}

		internal static string? GetInstallationId()
		{
			if (!Attach())
			{
				return null;
			}
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				AndroidJavaObject val = sentryJava.CallStatic<AndroidJavaObject>("getCurrentHub", Array.Empty<object>());
				try
				{
					AndroidJavaObject val2 = ((val != null) ? val.Call<AndroidJavaObject>("getOptions", Array.Empty<object>()) : null);
					try
					{
						return (val2 != null) ? val2.Call<string>("getDistinctId", Array.Empty<object>()) : null;
					}
					finally
					{
						((IDisposable)val2)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public static bool? CrashedLastRun()
		{
			if (!Attach())
			{
				return null;
			}
			AndroidJavaObject sentryJava = GetSentryJava();
			try
			{
				AndroidJavaObject val = sentryJava.CallStatic<AndroidJavaObject>("isCrashedLastRun", Array.Empty<object>());
				try
				{
					return (val != null) ? new bool?(val.Call<bool>("booleanValue", Array.Empty<object>())) : null;
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
			finally
			{
				((IDisposable)sentryJava)?.Dispose();
			}
		}

		public static void Close()
		{
			if (Attach())
			{
				AndroidJavaObject sentryJava = GetSentryJava();
				try
				{
					sentryJava.CallStatic("close", Array.Empty<object>());
				}
				finally
				{
					((IDisposable)sentryJava)?.Dispose();
				}
			}
		}

		private static bool Attach()
		{
			return AndroidJNI.AttachCurrentThread() == 0;
		}

		private static AndroidJavaObject GetSentryJava()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			return (AndroidJavaObject)new AndroidJavaClass("io.sentry.Sentry");
		}

		public static void WriteScope(int? GpuId, string? GpuName, string? GpuVendorName, int? GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int? GpuMaxTextureSize, bool? GpuSupportsDrawCallInstancing, bool? GpuSupportsRayTracing, bool? GpuSupportsComputeShaders, bool? GpuSupportsGeometryShaders, string? GpuVendorId, bool? GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if (!Attach())
			{
				return;
			}
			AndroidJavaObject gpu = new AndroidJavaObject("io.sentry.protocol.Gpu", Array.Empty<object>());
			try
			{
				gpu.SetIfNotNull("name", GpuName);
				gpu.SetIfNotNull("id", GpuId);
				if (GpuVendorId != null && int.TryParse(GpuVendorId, out var result) && result != 0)
				{
					AndroidJavaObject val = new AndroidJavaObject("java.lang.Integer", new object[1] { result });
					try
					{
						gpu.Set<AndroidJavaObject>("vendorId", val);
					}
					finally
					{
						((IDisposable)val)?.Dispose();
					}
				}
				gpu.SetIfNotNull("vendorName", GpuVendorName);
				gpu.SetIfNotNull("memorySize", GpuMemorySize);
				gpu.SetIfNotNull("apiType", GpuApiType);
				gpu.SetIfNotNull("multiThreadedRendering", GpuMultiThreadedRendering);
				gpu.SetIfNotNull("version", GpuVersion);
				gpu.SetIfNotNull("npotSupport", GpuNpotSupport);
				AndroidJavaObject sentryJava = GetSentryJava();
				try
				{
					sentryJava.CallStatic("configureScope", new object[1]
					{
						new ScopeCallback(delegate(AndroidJavaObject scope)
						{
							AndroidJavaObject val2 = scope.Call<AndroidJavaObject>("getContexts", Array.Empty<object>());
							try
							{
								val2.Call("setGpu", new object[1] { gpu });
							}
							finally
							{
								((IDisposable)val2)?.Dispose();
							}
						})
					});
				}
				finally
				{
					((IDisposable)sentryJava)?.Dispose();
				}
			}
			finally
			{
				if (gpu != null)
				{
					((IDisposable)gpu).Dispose();
				}
			}
		}

		private static void SetIfNotNull<T>(this AndroidJavaObject javaObject, string property, T? value, string? valueClass = null)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (value == null)
			{
				return;
			}
			if (valueClass == null)
			{
				javaObject.Set<T>(property, value);
				return;
			}
			AndroidJavaObject val = new AndroidJavaObject(valueClass, new object[1] { value });
			try
			{
				javaObject.Set<AndroidJavaObject>(property, val);
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}

		private static void SetIfNotNull(this AndroidJavaObject javaObject, string property, int? value)
		{
			javaObject.SetIfNotNull(property, value, "java.lang.Integer");
		}

		private static void SetIfNotNull(this AndroidJavaObject javaObject, string property, bool? value)
		{
			javaObject.SetIfNotNull(property, value, "java.lang.Boolean");
		}
	}
	public static class SentryNative
	{
		internal static Action ReinstallSentryNativeBackendStrategy = sentry_reinstall_backend;

		public static void ReinstallBackend()
		{
			ReinstallSentryNativeBackendStrategy();
		}

		[DllImport("sentry")]
		private static extern void sentry_reinstall_backend();
	}
	public static class SentryNativeAndroid
	{
		public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo)
		{
			SentryUnityOptions options2 = options;
			if (!options2.AndroidNativeSupportEnabled)
			{
				return;
			}
			options2.NativeContextWriter = (ContextWriter)(object)new NativeContextWriter();
			((SentryOptions)options2).ScopeObserver = (IScopeObserver)(object)new AndroidJavaScopeObserver((SentryOptions)(object)options2);
			((SentryOptions)options2).EnableScopeSync = true;
			((SentryOptions)options2).CrashedLastRun = delegate
			{
				bool? flag = SentryJava.CrashedLastRun();
				if (!flag.HasValue)
				{
					IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger4 != null)
					{
						DiagnosticLoggerExtensions.LogWarning(diagnosticLogger4, "Unclear from the native SDK if the previous run was a crash. Assuming it was not.");
					}
					flag = false;
				}
				else
				{
					IDiagnosticLogger diagnosticLogger5 = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger5 != null)
					{
						DiagnosticLoggerExtensions.LogDebug<bool?>(diagnosticLogger5, "Native Android SDK reported: 'crashedLastRun': '{0}'", flag);
					}
				}
				return flag.Value;
			};
			try
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger, "Reinstalling native backend.");
				}
				SentryNative.ReinstallBackend();
			}
			catch (Exception ex)
			{
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogError(diagnosticLogger2, "Failed to reinstall backend. Captured native crashes will miss scope data and tag.", ex);
				}
			}
			ApplicationAdapter.Instance.Quitting += delegate
			{
				IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger3 != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger3, "Closing the sentry-java SDK");
				}
				SentryJava.Close();
			};
			options2.DefaultUserId = SentryJava.GetInstallationId();
		}
	}
}

Sentry.Unity.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
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.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Sentry.Extensibility;
using Sentry.Http;
using Sentry.Infrastructure;
using Sentry.Integrations;
using Sentry.Protocol;
using Sentry.Protocol.Envelopes;
using Sentry.Reflection;
using Sentry.Unity.Extensions;
using Sentry.Unity.Integrations;
using Sentry.Unity.Json;
using Sentry.Unity.NativeUtils;
using Sentry.Unity.Protocol;
using UnityEngine;
using UnityEngine.Analytics;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Unity.Tests")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.Tests")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.iOS")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.iOS.Tests")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS.Tests")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android.Tests")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Sentry.Unity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.23.1.0")]
[assembly: AssemblyInformationalVersion("0.23.1")]
[assembly: AssemblyProduct("Sentry.Unity")]
[assembly: AssemblyTitle("Sentry.Unity")]
[assembly: AssemblyVersion("0.23.1.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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;
		}
	}
}
public class SentryBehavior : MonoBehaviour
{
	public void Disable()
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

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

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace Sentry.Unity
{
	internal abstract class ContextWriter
	{
		public void Write(Scope scope)
		{
			Sentry.Unity.Protocol.Unity unity = (Sentry.Unity.Protocol.Unity)((ConcurrentDictionary<string, object>)(object)scope.Contexts).GetOrAdd("unity", (Func<string, object>)((string _) => new Sentry.Unity.Protocol.Unity()));
			WriteScope(scope.Contexts.App.StartTime?.ToString("o"), scope.Contexts.App.BuildType, scope.Contexts.OperatingSystem.RawDescription, scope.Contexts.Device.ProcessorCount, scope.Contexts.Device.CpuDescription, scope.Contexts.Device.Timezone?.Id, scope.Contexts.Device.SupportsVibration, scope.Contexts.Device.Name, scope.Contexts.Device.Simulator, scope.Contexts.Device.DeviceUniqueIdentifier, scope.Contexts.Device.DeviceType, scope.Contexts.Device.Model, scope.Contexts.Device.MemorySize, scope.Contexts.Gpu.Id, scope.Contexts.Gpu.Name, scope.Contexts.Gpu.VendorName, scope.Contexts.Gpu.MemorySize, scope.Contexts.Gpu.NpotSupport, scope.Contexts.Gpu.Version, scope.Contexts.Gpu.ApiType, scope.Contexts.Gpu.MaxTextureSize, scope.Contexts.Gpu.SupportsDrawCallInstancing, scope.Contexts.Gpu.SupportsRayTracing, scope.Contexts.Gpu.SupportsComputeShaders, scope.Contexts.Gpu.SupportsGeometryShaders, scope.Contexts.Gpu.VendorId, scope.Contexts.Gpu.MultiThreadedRendering, scope.Contexts.Gpu.GraphicsShaderLevel, unity.InstallMode, unity.TargetFrameRate, unity.CopyTextureSupport, unity.RenderingThreadingMode);
		}

		protected abstract void WriteScope(string? AppStartTime, string? AppBuildType, string? OperatingSystemRawDescription, int? DeviceProcessorCount, string? DeviceCpuDescription, string? DeviceTimezone, bool? DeviceSupportsVibration, string? DeviceName, bool? DeviceSimulator, string? DeviceDeviceUniqueIdentifier, string? DeviceDeviceType, string? DeviceModel, long? DeviceMemorySize, int? GpuId, string? GpuName, string? GpuVendorName, int? GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int? GpuMaxTextureSize, bool? GpuSupportsDrawCallInstancing, bool? GpuSupportsRayTracing, bool? GpuSupportsComputeShaders, bool? GpuSupportsGeometryShaders, string? GpuVendorId, bool? GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel, string? UnityInstallMode, string? UnityTargetFrameRate, string? UnityCopyTextureSupport, string? UnityRenderingThreadingMode);
	}
	internal interface IEventCapture
	{
		SentryId Capture(SentryEvent sentryEvent);
	}
	internal class UnityIl2CppEventExceptionProcessor : ISentryEventExceptionProcessor
	{
		private class DebugImageInfo
		{
			public readonly DebugImage Image;

			public readonly ulong StartAddress;

			public readonly ulong EndAddress;

			public DebugImageInfo(DebugImage image)
			{
				Image = image;
				StartAddress = Convert.ToUInt64(image.ImageAddress, 16);
				EndAddress = StartAddress + (ulong)image.ImageSize.Value;
			}

			public bool ContainsAddress(ulong address)
			{
				if (StartAddress <= address)
				{
					return address <= EndAddress;
				}
				return false;
			}
		}

		private readonly SentryUnityOptions _options;

		private readonly ISentryUnityInfo _sentryUnityInfo;

		private readonly Il2CppMethods _il2CppMethods;

		private static IDiagnosticLogger? _logger;

		private static readonly Lazy<List<DebugImageInfo>> DebugImagesSorted = new Lazy<List<DebugImageInfo>>(delegate
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			List<DebugImageInfo> list = new List<DebugImageInfo>();
			RuntimePlatform platform = ApplicationAdapter.Instance.Platform;
			if ((int)platform == 2 || (int)platform == 11 || (int)platform == 13)
			{
				foreach (DebugImage item in C.DebugImages.Value)
				{
					if (!item.ImageSize.HasValue)
					{
						IDiagnosticLogger? logger = _logger;
						if (logger != null)
						{
							logger.Log((SentryLevel)0, "Skipping debug image '{0}' (CodeId {1} | DebugId: {2}) because its size is NULL", (Exception)null, new object[3] { item.CodeFile, item.CodeId, item.DebugId });
						}
					}
					else
					{
						DebugImageInfo debugImageInfo = new DebugImageInfo(item);
						int i;
						for (i = 0; i < list.Count && debugImageInfo.StartAddress >= list[i].StartAddress; i++)
						{
						}
						list.Insert(i, debugImageInfo);
						IDiagnosticLogger? logger2 = _logger;
						if (logger2 != null)
						{
							logger2.Log((SentryLevel)0, "Found debug image '{0}' (CodeId {1} | DebugId: {2}) with addresses between {3:X8} and {4:X8}", (Exception)null, new object[5] { item.CodeFile, item.CodeId, item.DebugId, debugImageInfo.StartAddress, debugImageInfo.EndAddress });
						}
					}
				}
			}
			return list;
		});

		public UnityIl2CppEventExceptionProcessor(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo, Il2CppMethods il2CppMethods)
		{
			_options = options;
			_sentryUnityInfo = sentryUnityInfo;
			_il2CppMethods = il2CppMethods;
			_options.SdkIntegrationNames.Add("IL2CPPLineNumbers");
		}

		public void Process(Exception incomingException, SentryEvent sentryEvent)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			IDiagnosticLogger diagnosticLogger = ((SentryOptions)_options).DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				DiagnosticLoggerExtensions.LogDebug<SentryId>(diagnosticLogger, "Running Unity IL2CPP event exception processor on: Event {0}", sentryEvent.EventId);
			}
			IEnumerable<SentryException> sentryExceptions = sentryEvent.SentryExceptions;
			if (sentryExceptions == null)
			{
				return;
			}
			IEnumerable<Exception> second = EnumerateChainedExceptions(incomingException);
			HashSet<DebugImage> hashSet = new HashSet<DebugImage>();
			_logger = ((SentryOptions)_options).DiagnosticLogger;
			foreach (var item3 in sentryExceptions.Zip(second, (SentryException se, Exception ex) => (se, ex)))
			{
				SentryException item = item3.Item1;
				Exception item2 = item3.Item2;
				SentryStackTrace stacktrace = item.Stacktrace;
				if (stacktrace == null)
				{
					continue;
				}
				NativeStackTrace nativeStackTrace = GetNativeStackTrace(item2);
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)_options).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string, string>(diagnosticLogger2, "NativeStackTrace Image: '{0}' (UUID: {1})", nativeStackTrace.ImageName, nativeStackTrace.ImageUuid);
				}
				ulong num = 9223372036854775808uL;
				DebugImage val = null;
				int num2 = nativeStackTrace.Frames.Length;
				int num3 = Math.Min(stacktrace.Frames.Count, num2);
				if (num2 != num3)
				{
					IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)_options).DiagnosticLogger;
					if (diagnosticLogger3 != null)
					{
						DiagnosticLoggerExtensions.LogWarning<int, int>(diagnosticLogger3, "Native and sentry stack trace lengths don't match '({0} != {1})' - this may cause invalid stack traces.", num2, stacktrace.Frames.Count);
					}
				}
				for (int i = 0; i < num3; i++)
				{
					SentryStackFrame val2 = stacktrace.Frames[i];
					IntPtr intPtr = nativeStackTrace.Frames[num2 - 1 - i];
					string mainImageUUID = NormalizeUUID(nativeStackTrace.ImageUuid);
					ulong num4 = (ulong)(intPtr.ToInt64() - 1);
					bool flag = val2.Package != null && (val2.Package.StartsWith("UnityEngine.", StringComparison.InvariantCultureIgnoreCase) || val2.Package.StartsWith("Assembly-CSharp", StringComparison.InvariantCultureIgnoreCase));
					string text = null;
					DebugImage val3 = null;
					bool? flag2 = null;
					if (!flag)
					{
						val3 = FindDebugImageContainingAddress(num4);
						if (val3 == null)
						{
							flag2 = true;
							text = "because it looks like a relative address.";
						}
						else
						{
							flag2 = false;
							text = "because it looks like an absolute address inside the range of this debug image.";
						}
					}
					if (val3 == null)
					{
						if (mainImageUUID == null)
						{
							IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)_options).DiagnosticLogger;
							if (diagnosticLogger4 != null)
							{
								DiagnosticLoggerExtensions.LogWarning(diagnosticLogger4, "Couldn't process stack trace - main image UUID reported as NULL by Unity");
							}
							continue;
						}
						if (val == null)
						{
							val = DebugImagesSorted.Value.Find((DebugImageInfo info) => string.Equals(NormalizeUUID(info.Image.DebugId), mainImageUUID))?.Image;
						}
						if (val == null)
						{
							val = new DebugImage
							{
								Type = _sentryUnityInfo.Platform,
								CodeFile = (string.IsNullOrEmpty(nativeStackTrace.ImageName) ? "GameAssembly.fallback" : nativeStackTrace.ImageName),
								DebugId = mainImageUUID,
								ImageAddress = $"0x{num:X8}"
							};
						}
						val3 = val;
						if (flag && text == null)
						{
							text = "based on frame package name (" + val2.Package + ").";
						}
					}
					ulong num5 = Convert.ToUInt64(val3.ImageAddress, 16);
					bool valueOrDefault = flag2.GetValueOrDefault();
					if (!flag2.HasValue)
					{
						valueOrDefault = num4 < num5;
						flag2 = valueOrDefault;
					}
					if (flag2 ?? false)
					{
						num4 += num5;
						val2.InstructionAddress = $"0x{num4:X8}";
					}
					SentryLevel val4 = (SentryLevel)0;
					if (val3.ImageSize.HasValue && (num4 < num5 || num4 > (ulong)((long)num5 + val3.ImageSize.Value)))
					{
						val4 = (SentryLevel)2;
						if (text == null)
						{
							text = ".";
						}
						text += " However, the instruction address falls out of the range of the debug image.";
					}
					IDiagnosticLogger diagnosticLogger5 = ((SentryOptions)_options).DiagnosticLogger;
					if (diagnosticLogger5 != null)
					{
						diagnosticLogger5.Log(val4, "Stack frame '{0}' at {1:X8} (originally {2:X8}) belongs to {3} {4}", (Exception)null, new object[5]
						{
							val2.Function,
							num4,
							intPtr.ToInt64(),
							val3.CodeFile,
							text ?? ""
						});
					}
					hashSet.Add(val3);
				}
			}
			if (sentryEvent.DebugImages == null)
			{
				List<DebugImage> list2 = (sentryEvent.DebugImages = new List<DebugImage>());
			}
			sentryEvent.DebugImages.AddRange(hashSet);
		}

		private static string? NormalizeUUID(string? value)
		{
			return value?.ToLowerInvariant().Replace("-", "").TrimEnd(new char[1] { '0' });
		}

		private static DebugImage? FindDebugImageContainingAddress(ulong instructionAddress)
		{
			List<DebugImageInfo> value = DebugImagesSorted.Value;
			int num = 0;
			int num2 = value.Count - 1;
			while (num <= num2)
			{
				int num3 = (num + num2) / 2;
				DebugImageInfo debugImageInfo = value[num3];
				if (debugImageInfo.StartAddress <= instructionAddress)
				{
					if (instructionAddress <= debugImageInfo.EndAddress)
					{
						return debugImageInfo.Image;
					}
					num = num3 + 1;
				}
				else
				{
					num2 = num3 - 1;
				}
			}
			return null;
		}

		private IEnumerable<Exception> EnumerateChainedExceptions(Exception exception)
		{
			if (exception is AggregateException ex)
			{
				foreach (Exception item in ex.InnerExceptions.SelectMany(EnumerateChainedExceptions))
				{
					yield return item;
				}
			}
			else if (exception.InnerException != null)
			{
				foreach (Exception item2 in EnumerateChainedExceptions(exception.InnerException))
				{
					yield return item2;
				}
			}
			yield return exception;
		}

		private NativeStackTrace GetNativeStackTrace(Exception e)
		{
			GCHandle value = GCHandle.Alloc(e);
			IntPtr addresses = IntPtr.Zero;
			try
			{
				int gchandle = GCHandle.ToIntPtr(value).ToInt32();
				IntPtr exc = _il2CppMethods.Il2CppGcHandleGetTarget(gchandle);
				int numFrames = 0;
				string imageUUID = null;
				string imageName = null;
				_il2CppMethods.Il2CppNativeStackTrace(exc, out addresses, out numFrames, out imageUUID, out imageName);
				IntPtr[] array = new IntPtr[numFrames];
				Marshal.Copy(addresses, array, 0, numFrames);
				return new NativeStackTrace
				{
					Frames = array,
					ImageUuid = imageUUID,
					ImageName = imageName
				};
			}
			finally
			{
				value.Free();
				if (addresses != IntPtr.Zero)
				{
					_il2CppMethods.Il2CppFree(addresses);
				}
			}
		}
	}
	internal class NativeStackTrace
	{
		public IntPtr[] Frames { get; set; } = Array.Empty<IntPtr>();


		public string? ImageUuid { get; set; }

		public string? ImageName { get; set; }
	}
	internal class AnrIntegration : ISdkIntegration
	{
		private static readonly object Lock = new object();

		private static AnrWatchDog? Watchdog;

		private readonly SentryMonoBehaviour _monoBehaviour;

		public AnrIntegration(SentryMonoBehaviour monoBehaviour)
		{
			_monoBehaviour = monoBehaviour;
		}

		public void Register(IHub hub, SentryOptions sentryOptions)
		{
			IHub hub2 = hub;
			SentryUnityOptions sentryUnityOptions = (SentryUnityOptions)(object)sentryOptions;
			lock (Lock)
			{
				if (Watchdog == null)
				{
					if (sentryUnityOptions.MultiThreading)
					{
						Watchdog = new AnrWatchDogMultiThreaded(((SentryOptions)sentryUnityOptions).DiagnosticLogger, _monoBehaviour);
					}
					else
					{
						Watchdog = new AnrWatchDogSingleThreaded(((SentryOptions)sentryUnityOptions).DiagnosticLogger, _monoBehaviour);
					}
				}
			}
			Watchdog.OnApplicationNotResponding += delegate(object _, ApplicationNotResponding e)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				SentryClientExtensions.CaptureException((ISentryClient)(object)hub2, (Exception)e);
			};
		}
	}
	internal abstract class AnrWatchDog
	{
		protected readonly int DetectionTimeoutMs;

		protected readonly int SleepIntervalMs;

		protected readonly IDiagnosticLogger? Logger;

		protected readonly SentryMonoBehaviour MonoBehaviour;

		protected bool Paused { get; private set; }

		internal event EventHandler<ApplicationNotResponding> OnApplicationNotResponding = delegate
		{
		};

		internal AnrWatchDog(IDiagnosticLogger? logger, SentryMonoBehaviour monoBehaviour, int detectionTimeoutMilliseconds = 5000)
		{
			MonoBehaviour = monoBehaviour;
			Logger = logger;
			DetectionTimeoutMs = detectionTimeoutMilliseconds;
			SleepIntervalMs = Math.Max(1, DetectionTimeoutMs / 5);
			MonoBehaviour.ApplicationPausing += delegate
			{
				Paused = true;
			};
			MonoBehaviour.ApplicationResuming += delegate
			{
				Paused = false;
			};
			MonoBehaviour.Application.Quitting += delegate
			{
				Stop();
			};
		}

		internal abstract void Stop(bool wait = false);

		protected void Report()
		{
			if (!Paused)
			{
				string text = $"Application not responding for at least {DetectionTimeoutMs} ms.";
				IDiagnosticLogger? logger = Logger;
				if (logger != null)
				{
					DiagnosticLoggerExtensions.LogInfo<string>(logger, "Detected an ANR event: {0}", text);
				}
				this.OnApplicationNotResponding?.Invoke(this, new ApplicationNotResponding(text));
			}
		}
	}
	internal class AnrWatchDogMultiThreaded : AnrWatchDog
	{
		private int _ticksSinceUiUpdate;

		private bool _reported;

		private bool _stop;

		private readonly Thread _thread;

		internal AnrWatchDogMultiThreaded(IDiagnosticLogger? logger, SentryMonoBehaviour monoBehaviour, int detectionTimeoutMilliseconds = 5000)
			: base(logger, monoBehaviour, detectionTimeoutMilliseconds)
		{
			_thread = new Thread(Run)
			{
				Name = "Sentry-ANR-WatchDog",
				IsBackground = true,
				Priority = ThreadPriority.BelowNormal
			};
			_thread.Start();
			((MonoBehaviour)MonoBehaviour).StartCoroutine(UpdateUiStatus());
		}

		internal override void Stop(bool wait = false)
		{
			_stop = true;
			if (wait)
			{
				_thread.Join();
			}
		}

		private IEnumerator UpdateUiStatus()
		{
			WaitForSeconds waitForSeconds = new WaitForSeconds((float)SleepIntervalMs / 1000f);
			yield return waitForSeconds;
			while (!_stop)
			{
				_ticksSinceUiUpdate = 0;
				_reported = false;
				yield return waitForSeconds;
			}
		}

		private void Run()
		{
			try
			{
				int num = DetectionTimeoutMs / SleepIntervalMs;
				IDiagnosticLogger? logger = Logger;
				if (logger != null)
				{
					logger.Log((SentryLevel)1, "Starting an ANR WatchDog - detection timeout: {0} ms, check every {1} ms => report after {2} failed checks", (Exception)null, new object[3] { DetectionTimeoutMs, SleepIntervalMs, num });
				}
				while (!_stop)
				{
					_ticksSinceUiUpdate++;
					Thread.Sleep(SleepIntervalMs);
					if (base.Paused)
					{
						_ticksSinceUiUpdate = 0;
					}
					else if (_ticksSinceUiUpdate >= num && !_reported)
					{
						Report();
						_reported = true;
					}
				}
			}
			catch (ThreadAbortException ex)
			{
				IDiagnosticLogger? logger2 = Logger;
				if (logger2 != null)
				{
					logger2.Log((SentryLevel)0, "ANR watchdog thread aborted.", (Exception)ex, Array.Empty<object>());
				}
			}
			catch (Exception ex2)
			{
				IDiagnosticLogger? logger3 = Logger;
				if (logger3 != null)
				{
					logger3.Log((SentryLevel)3, "Exception in the ANR watchdog.", ex2, Array.Empty<object>());
				}
			}
		}
	}
	internal class AnrWatchDogSingleThreaded : AnrWatchDog
	{
		private readonly Stopwatch _watch = new Stopwatch();

		private bool _stop;

		internal AnrWatchDogSingleThreaded(IDiagnosticLogger? logger, SentryMonoBehaviour monoBehaviour, int detectionTimeoutMilliseconds = 5000)
			: base(logger, monoBehaviour, detectionTimeoutMilliseconds)
		{
			_watch.Start();
			((MonoBehaviour)MonoBehaviour).StartCoroutine(UpdateUiStatus());
		}

		internal override void Stop(bool wait = false)
		{
			_stop = true;
		}

		private IEnumerator UpdateUiStatus()
		{
			WaitForSeconds waitForSeconds = new WaitForSeconds((float)SleepIntervalMs / 1000f);
			while (!_stop)
			{
				if (_watch.ElapsedMilliseconds >= DetectionTimeoutMs)
				{
					Report();
				}
				_watch.Restart();
				yield return waitForSeconds;
			}
		}
	}
	internal class ApplicationNotResponding : Exception
	{
		internal ApplicationNotResponding()
		{
		}

		internal ApplicationNotResponding(string message)
			: base(message)
		{
		}

		internal ApplicationNotResponding(string message, Exception innerException)
			: base(message, innerException)
		{
		}
	}
	internal readonly struct SceneAdapter
	{
		public string Name { get; }

		public SceneAdapter(string name)
		{
			Name = name;
		}
	}
	internal interface ISceneManager
	{
		event Action<SceneAdapter, LoadSceneMode> SceneLoaded;

		event Action<SceneAdapter> SceneUnloaded;

		event Action<SceneAdapter, SceneAdapter> ActiveSceneChanged;
	}
	internal sealed class SceneManagerAdapter : ISceneManager
	{
		public static readonly SceneManagerAdapter Instance = new SceneManagerAdapter();

		public event Action<SceneAdapter, LoadSceneMode>? SceneLoaded;

		public event Action<SceneAdapter>? SceneUnloaded;

		public event Action<SceneAdapter, SceneAdapter>? ActiveSceneChanged;

		private SceneManagerAdapter()
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				this.SceneLoaded?.Invoke(new SceneAdapter(((Scene)(ref scene)).name), mode);
			};
			SceneManager.sceneUnloaded += delegate(Scene scene)
			{
				this.SceneUnloaded?.Invoke(new SceneAdapter(((Scene)(ref scene)).name));
			};
			SceneManager.activeSceneChanged += delegate(Scene sceneFrom, Scene sceneTo)
			{
				this.ActiveSceneChanged?.Invoke(new SceneAdapter(((Scene)(ref sceneFrom)).name), new SceneAdapter(((Scene)(ref sceneTo)).name));
			};
		}
	}
	internal class SceneManagerIntegration : ISdkIntegration
	{
		private readonly ISceneManager _sceneManager;

		public SceneManagerIntegration()
			: this(SceneManagerAdapter.Instance)
		{
		}

		internal SceneManagerIntegration(ISceneManager sceneManager)
		{
			_sceneManager = sceneManager;
		}

		public void Register(IHub hub, SentryOptions options)
		{
			IHub hub2 = hub;
			IDiagnosticLogger diagnosticLogger = options.DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				diagnosticLogger.Log((SentryLevel)0, "Registering SceneManager integration.", (Exception)null, Array.Empty<object>());
			}
			_sceneManager.SceneLoaded += OnSceneManagerOnSceneLoaded;
			_sceneManager.SceneUnloaded += SceneManagerOnSceneUnloaded;
			_sceneManager.ActiveSceneChanged += SceneManagerOnActiveSceneChanged;
			void OnSceneManagerOnSceneLoaded(SceneAdapter scene, LoadSceneMode mode)
			{
				if (((ISentryClient)hub2).IsEnabled)
				{
					HubExtensions.AddBreadcrumb(hub2, "Scene '" + scene.Name + "' was loaded", "scene.loaded", (string)null, (IDictionary<string, string>)null, (BreadcrumbLevel)0);
				}
			}
			void SceneManagerOnActiveSceneChanged(SceneAdapter fromScene, SceneAdapter toScene)
			{
				if (((ISentryClient)hub2).IsEnabled)
				{
					HubExtensions.AddBreadcrumb(hub2, (fromScene.Name == null) ? ("Changed active scene to '" + toScene.Name + "'") : ("Changed active scene '" + fromScene.Name + "' to '" + toScene.Name + "'"), "scene.changed", (string)null, (IDictionary<string, string>)null, (BreadcrumbLevel)0);
				}
			}
			void SceneManagerOnSceneUnloaded(SceneAdapter scene)
			{
				if (((ISentryClient)hub2).IsEnabled)
				{
					HubExtensions.AddBreadcrumb(hub2, "Scene '" + scene.Name + "' was unloaded", "scene.unloaded", (string)null, (IDictionary<string, string>)null, (BreadcrumbLevel)0);
				}
			}
		}
	}
	internal static class UnitySdkInfo
	{
		public const string Name = "sentry.dotnet.unity";

		public const string PackageName = "upm:sentry.unity";

		public static string Version { get; } = AssemblyExtensions.GetNameAndVersion(typeof(UnitySdkInfo).Assembly).Version ?? "0.0.0";

	}
	internal class UnityScopeIntegration : ISdkIntegration
	{
		private readonly MainThreadData _mainThreadData;

		private readonly IApplication _application;

		public UnityScopeIntegration(SentryMonoBehaviour monoBehaviour, IApplication application)
		{
			_mainThreadData = monoBehaviour.MainThreadData;
			_application = application;
		}

		public void Register(IHub hub, SentryOptions options)
		{
			UnityScopeUpdater @object = new UnityScopeUpdater((SentryUnityOptions)(object)options, _mainThreadData, _application);
			((ISentryScopeManager)hub).ConfigureScope((Action<Scope>)@object.ConfigureScope);
		}
	}
	internal class UnityScopeUpdater
	{
		private readonly SentryUnityOptions _options;

		private readonly MainThreadData _mainThreadData;

		private readonly IApplication _application;

		public UnityScopeUpdater(SentryUnityOptions options, MainThreadData mainThreadData, IApplication application)
		{
			_options = options;
			_mainThreadData = mainThreadData;
			_application = application;
		}

		public void ConfigureScope(Scope scope)
		{
			PopulateSdk(scope.Sdk);
			PopulateApp(scope.Contexts.App);
			PopulateOperatingSystem(scope.Contexts.OperatingSystem);
			PopulateDevice(scope.Contexts.Device);
			PopulateGpu(scope.Contexts.Gpu);
			PopulateUnity((Sentry.Unity.Protocol.Unity)((ConcurrentDictionary<string, object>)(object)scope.Contexts).GetOrAdd("unity", (Func<string, object>)((string _) => new Sentry.Unity.Protocol.Unity())));
			PopulateTags((Action<string, string>)scope.SetTag);
			PopulateUser(scope);
		}

		private static void PopulateSdk(SdkVersion sdk)
		{
			sdk.AddPackage("upm:sentry.unity", UnitySdkInfo.Version);
			sdk.Name = "sentry.dotnet.unity";
			sdk.Version = UnitySdkInfo.Version;
		}

		private void PopulateApp(App app)
		{
			app.StartTime = _mainThreadData.StartTime;
			bool? isDebugBuild = _mainThreadData.IsDebugBuild;
			app.BuildType = ((!isDebugBuild.HasValue) ? null : (isDebugBuild.Value ? "debug" : "release"));
		}

		private void PopulateOperatingSystem(OperatingSystem operatingSystem)
		{
			operatingSystem.RawDescription = _mainThreadData.OperatingSystem;
		}

		private void PopulateDevice(Device device)
		{
			device.ProcessorCount = _mainThreadData.ProcessorCount;
			device.CpuDescription = _mainThreadData.CpuDescription;
			device.Timezone = TimeZoneInfo.Local;
			device.SupportsVibration = _mainThreadData.SupportsVibration;
			device.Name = _mainThreadData.DeviceName;
			device.Simulator = (_application.IsEditor ? new bool?(true) : null);
			device.DeviceUniqueIdentifier = (((SentryOptions)_options).SendDefaultPii ? _mainThreadData.DeviceUniqueIdentifier : null);
			device.DeviceType = _mainThreadData.DeviceType;
			device.Model = _mainThreadData.DeviceModel;
			if (_mainThreadData.SystemMemorySize > 0)
			{
				device.MemorySize = (long?)_mainThreadData.SystemMemorySize * 1048576L;
			}
		}

		private void PopulateGpu(Gpu gpu)
		{
			gpu.Id = _mainThreadData.GraphicsDeviceId;
			gpu.Name = _mainThreadData.GraphicsDeviceName;
			gpu.VendorName = _mainThreadData.GraphicsDeviceVendor;
			gpu.MemorySize = _mainThreadData.GraphicsMemorySize;
			gpu.NpotSupport = _mainThreadData.NpotSupport;
			gpu.Version = _mainThreadData.GraphicsDeviceVersion;
			gpu.ApiType = _mainThreadData.GraphicsDeviceType;
			gpu.MaxTextureSize = _mainThreadData.MaxTextureSize;
			gpu.SupportsDrawCallInstancing = _mainThreadData.SupportsDrawCallInstancing;
			gpu.SupportsRayTracing = _mainThreadData.SupportsRayTracing;
			gpu.SupportsComputeShaders = _mainThreadData.SupportsComputeShaders;
			gpu.SupportsGeometryShaders = _mainThreadData.SupportsGeometryShaders;
			gpu.VendorId = _mainThreadData.GraphicsDeviceVendorId;
			gpu.MultiThreadedRendering = _mainThreadData.GraphicsMultiThreaded;
			gpu.GraphicsShaderLevel = _mainThreadData.GraphicsShaderLevel switch
			{
				null => null, 
				-1 => null, 
				20 => "Shader Model 2.0", 
				25 => "Shader Model 2.5", 
				30 => "Shader Model 3.0", 
				35 => "OpenGL ES 3.0", 
				40 => "Shader Model 4.0", 
				45 => "Metal / OpenGL ES 3.1", 
				46 => "OpenGL 4.1", 
				50 => "Shader Model 5.0", 
				_ => _mainThreadData.GraphicsShaderLevel.ToString(), 
			};
		}

		private void PopulateUnity(Sentry.Unity.Protocol.Unity unity)
		{
			unity.InstallMode = _mainThreadData.InstallMode;
			unity.TargetFrameRate = _mainThreadData.TargetFrameRate;
			unity.CopyTextureSupport = _mainThreadData.CopyTextureSupport;
			unity.RenderingThreadingMode = _mainThreadData.RenderingThreadingMode;
		}

		private void PopulateTags(Action<string, string> setTag)
		{
			string installMode = _mainThreadData.InstallMode;
			if (installMode != null)
			{
				setTag("unity.install_mode", installMode);
			}
			if (_mainThreadData.SupportsDrawCallInstancing.HasValue)
			{
				setTag("unity.gpu.supports_instancing", _mainThreadData.SupportsDrawCallInstancing.Value.ToTagValue());
			}
			string deviceType = _mainThreadData.DeviceType;
			if (deviceType != null)
			{
				setTag("unity.device.device_type", deviceType);
			}
			if (((SentryOptions)_options).SendDefaultPii)
			{
				string deviceUniqueIdentifier = _mainThreadData.DeviceUniqueIdentifier;
				if (deviceUniqueIdentifier != null)
				{
					setTag("unity.device.unique_identifier", deviceUniqueIdentifier);
				}
			}
		}

		private void PopulateUser(Scope scope)
		{
			if (_options.DefaultUserId != null && scope.User.Id == null)
			{
				scope.User.Id = _options.DefaultUserId;
			}
		}
	}
	public interface ISentryUnityInfo
	{
		bool IL2CPP { get; }

		string? Platform { get; }

		Il2CppMethods? Il2CppMethods { get; }
	}
	public class Il2CppMethods
	{
		public Il2CppGcHandleGetTarget Il2CppGcHandleGetTarget { get; }

		public Il2CppNativeStackTrace Il2CppNativeStackTrace { get; }

		public Il2CppFree Il2CppFree { get; }

		public Il2CppMethods(Il2CppGcHandleGetTarget il2CppGcHandleGetTarget, Il2CppNativeStackTrace il2CppNativeStackTrace, Il2CppFree il2CppFree)
		{
			Il2CppGcHandleGetTarget = il2CppGcHandleGetTarget;
			Il2CppNativeStackTrace = il2CppNativeStackTrace;
			Il2CppFree = il2CppFree;
		}
	}
	public delegate IntPtr Il2CppGcHandleGetTarget(int gchandle);
	public delegate void Il2CppNativeStackTrace(IntPtr exc, out IntPtr addresses, out int numFrames, out string? imageUUID, out string? imageName);
	public delegate void Il2CppFree(IntPtr ptr);
	internal sealed class MainThreadData
	{
		internal int? MainThreadId { get; set; }

		public string? OperatingSystem { get; set; }

		public int? ProcessorCount { get; set; }

		public bool? SupportsVibration { get; set; }

		public string? DeviceType { get; set; }

		public string? CpuDescription { get; set; }

		public string? DeviceName { get; set; }

		public string? DeviceUniqueIdentifier { get; set; }

		public string? DeviceModel { get; set; }

		public int? SystemMemorySize { get; set; }

		public int? GraphicsDeviceId { get; set; }

		public string? GraphicsDeviceName { get; set; }

		public string? GraphicsDeviceVendorId { get; set; }

		public string? GraphicsDeviceVendor { get; set; }

		public int? GraphicsMemorySize { get; set; }

		public bool? GraphicsMultiThreaded { get; set; }

		public string? NpotSupport { get; set; }

		public string? GraphicsDeviceVersion { get; set; }

		public string? GraphicsDeviceType { get; set; }

		public int? MaxTextureSize { get; set; }

		public bool? SupportsDrawCallInstancing { get; set; }

		public bool? SupportsRayTracing { get; set; }

		public bool? SupportsComputeShaders { get; set; }

		public bool? SupportsGeometryShaders { get; set; }

		public int? GraphicsShaderLevel { get; set; }

		public bool? IsDebugBuild { get; set; }

		public string? InstallMode { get; set; }

		public string? TargetFrameRate { get; set; }

		public string? CopyTextureSupport { get; set; }

		public string? RenderingThreadingMode { get; set; }

		public DateTimeOffset? StartTime { get; set; }

		public bool IsMainThread()
		{
			if (MainThreadId.HasValue)
			{
				return Thread.CurrentThread.ManagedThreadId == MainThreadId;
			}
			return false;
		}
	}
	public abstract class ScopeObserver : IScopeObserver
	{
		private readonly SentryOptions _options;

		private readonly string _name;

		public ScopeObserver(string name, SentryOptions options)
		{
			_name = name;
			_options = options;
		}

		public void AddBreadcrumb(Breadcrumb breadcrumb)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			IDiagnosticLogger diagnosticLogger = _options.DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				diagnosticLogger.Log((SentryLevel)0, "{0} Scope Sync - Adding breadcrumb m:\"{1}\" l:\"{2}\"", (Exception)null, new object[3] { _name, breadcrumb.Message, breadcrumb.Level });
			}
			AddBreadcrumbImpl(breadcrumb);
		}

		public abstract void AddBreadcrumbImpl(Breadcrumb breadcrumb);

		public void SetExtra(string key, object? value)
		{
			string text = ((value == null) ? null : SafeSerializer.SerializeSafely(value));
			if (value != null && text == null)
			{
				IDiagnosticLogger diagnosticLogger = _options.DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					diagnosticLogger.Log((SentryLevel)2, "{0} Scope Sync - SetExtra k:\"{1}\" v:\"{2}\" - value was serialized as null", (Exception)null, new object[3] { _name, key, value });
				}
			}
			else
			{
				IDiagnosticLogger diagnosticLogger2 = _options.DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					diagnosticLogger2.Log((SentryLevel)0, "{0} Scope Sync - Setting Extra k:\"{1}\" v:\"{2}\"", (Exception)null, new object[3] { _name, key, value });
				}
			}
			SetExtraImpl(key, text);
		}

		public abstract void SetExtraImpl(string key, string? value);

		public void SetTag(string key, string value)
		{
			IDiagnosticLogger diagnosticLogger = _options.DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				diagnosticLogger.Log((SentryLevel)0, "{0} Scope Sync - Setting Tag k:\"{1}\" v:\"{2}\"", (Exception)null, new object[3] { _name, key, value });
			}
			SetTagImpl(key, value);
		}

		public abstract void SetTagImpl(string key, string value);

		public void UnsetTag(string key)
		{
			IDiagnosticLogger diagnosticLogger = _options.DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				diagnosticLogger.Log((SentryLevel)0, "{0} Scope Sync - Unsetting Tag k:\"{1}\"", (Exception)null, new object[2] { _name, key });
			}
			UnsetTagImpl(key);
		}

		public abstract void UnsetTagImpl(string key);

		public void SetUser(User? user)
		{
			if (user == null)
			{
				IDiagnosticLogger diagnosticLogger = _options.DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					diagnosticLogger.Log((SentryLevel)0, "{0} Scope Sync - Unsetting User", (Exception)null, new object[1] { _name });
				}
				UnsetUserImpl();
				return;
			}
			IDiagnosticLogger diagnosticLogger2 = _options.DiagnosticLogger;
			if (diagnosticLogger2 != null)
			{
				diagnosticLogger2.Log((SentryLevel)0, "{0} Scope Sync - Setting User i:\"{1}\" n:\"{2}\"", (Exception)null, new object[3] { _name, user.Id, user.Username });
			}
			SetUserImpl(user);
		}

		public abstract void SetUserImpl(User user);

		public abstract void UnsetUserImpl();
	}
	internal class ScreenshotAttachment : Attachment
	{
		public ScreenshotAttachment(IAttachmentContent content)
			: base((AttachmentType)0, content, "screenshot.jpg", "image/jpeg")
		{
		}
	}
	internal class ScreenshotAttachmentContent : IAttachmentContent
	{
		private readonly SentryMonoBehaviour _behaviour;

		private readonly SentryUnityOptions _options;

		public ScreenshotAttachmentContent(SentryUnityOptions options, SentryMonoBehaviour behaviour)
		{
			_behaviour = behaviour;
			_options = options;
		}

		public Stream GetStream()
		{
			if (!_behaviour.MainThreadData.IsMainThread())
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)_options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger, "Can't capture screenshots on other than main (UI) thread.");
				}
				return Stream.Null;
			}
			return new MemoryStream(CaptureScreenshot());
		}

		private int GetTargetResolution(ScreenshotQuality quality)
		{
			return quality switch
			{
				ScreenshotQuality.High => 1920, 
				ScreenshotQuality.Medium => 1280, 
				ScreenshotQuality.Low => 854, 
				_ => 854, 
			};
		}

		private byte[] CaptureScreenshot()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Invalid comparison between Unknown and I4
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			int num = Screen.width;
			int num2 = Screen.height;
			if (_options.ScreenshotQuality != 0)
			{
				int targetResolution = GetTargetResolution(_options.ScreenshotQuality);
				float num3 = (float)targetResolution / (float)num;
				float num4 = Mathf.Min((float)targetResolution / (float)num2, num3);
				if (num4 > 0f && num4 < 1f)
				{
					num = Mathf.FloorToInt((float)num * num4);
					num2 = Mathf.FloorToInt((float)num2 * num4);
				}
			}
			Texture2D val = new Texture2D(num, num2, (TextureFormat)3, false);
			RenderTexture temporary = RenderTexture.GetTemporary(Screen.width, Screen.height);
			ScreenCapture.CaptureScreenshotIntoRenderTexture(temporary);
			RenderTexture temporary2 = RenderTexture.GetTemporary(num, num2);
			RuntimePlatform platform = ApplicationAdapter.Instance.Platform;
			if ((int)platform == 11 || (int)platform == 13)
			{
				Graphics.Blit((Texture)(object)temporary, temporary2);
			}
			else
			{
				Graphics.Blit((Texture)(object)temporary, temporary2, new Vector2(1f, -1f), new Vector2(0f, 1f));
			}
			RenderTexture.ReleaseTemporary(temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary2;
			try
			{
				val.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
				val.Apply();
			}
			finally
			{
				RenderTexture.active = active;
			}
			byte[] array = ImageConversion.EncodeToJPG(val, _options.ScreenshotCompression);
			IDiagnosticLogger diagnosticLogger = ((SentryOptions)_options).DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				diagnosticLogger.Log((SentryLevel)0, "Screenshot captured at {0}x{1}: {2} bytes", (Exception)null, new object[3] { num, num2, array.Length });
			}
			return array;
		}
	}
	public abstract class ScriptableOptionsConfiguration : ScriptableObject
	{
		public abstract void Configure(SentryUnityOptions options);
	}
	public class ScriptableSentryUnityOptions : ScriptableObject
	{
		internal const string ConfigRootFolder = "Sentry";

		internal const string ConfigName = "SentryOptions";

		[field: SerializeField]
		public bool Enabled { get; set; } = true;


		[field: SerializeField]
		public string? Dsn { get; set; }

		[field: SerializeField]
		public bool CaptureInEditor { get; set; } = true;


		[field: SerializeField]
		public bool EnableLogDebouncing { get; set; }

		[field: SerializeField]
		public double TracesSampleRate { get; set; }

		[field: SerializeField]
		public bool AutoSessionTracking { get; set; } = true;


		[field: SerializeField]
		public int AutoSessionTrackingInterval { get; set; } = (int)TimeSpan.FromSeconds(30.0).TotalMilliseconds;


		[field: SerializeField]
		public string ReleaseOverride { get; set; } = string.Empty;


		[field: SerializeField]
		public string EnvironmentOverride { get; set; } = string.Empty;


		[field: SerializeField]
		public bool AttachStacktrace { get; set; }

		[field: SerializeField]
		public bool AttachScreenshot { get; set; }

		[field: SerializeField]
		public ScreenshotQuality ScreenshotQuality { get; set; } = ScreenshotQuality.High;


		[field: SerializeField]
		public int ScreenshotCompression { get; set; } = 75;


		[field: SerializeField]
		public int MaxBreadcrumbs { get; set; } = 100;


		[field: SerializeField]
		public ReportAssembliesMode ReportAssembliesMode { get; set; } = (ReportAssembliesMode)1;


		[field: SerializeField]
		public bool SendDefaultPii { get; set; }

		[field: SerializeField]
		public bool IsEnvironmentUser { get; set; }

		[field: SerializeField]
		public bool EnableOfflineCaching { get; set; } = true;


		[field: SerializeField]
		public int MaxCacheItems { get; set; } = 30;


		[field: SerializeField]
		public int InitCacheFlushTimeout { get; set; }

		[field: SerializeField]
		public float SampleRate { get; set; }

		[field: SerializeField]
		public int ShutdownTimeout { get; set; }

		[field: SerializeField]
		public int MaxQueueItems { get; set; }

		[field: SerializeField]
		public bool IosNativeSupportEnabled { get; set; }

		[field: SerializeField]
		public bool AndroidNativeSupportEnabled { get; set; }

		[field: SerializeField]
		public bool WindowsNativeSupportEnabled { get; set; }

		[field: SerializeField]
		public bool MacosNativeSupportEnabled { get; set; }

		[field: SerializeField]
		public bool LinuxNativeSupportEnabled { get; set; }

		[field: SerializeField]
		public bool Il2CppLineNumberSupportEnabled { get; set; }

		[field: SerializeField]
		public ScriptableOptionsConfiguration? OptionsConfiguration { get; set; }

		[field: SerializeField]
		public bool Debug { get; set; }

		[field: SerializeField]
		public bool DebugOnlyInEditor { get; set; }

		[field: SerializeField]
		public SentryLevel DiagnosticLevel { get; set; }

		public static string GetConfigPath(string? notDefaultConfigName = null)
		{
			return "Assets/Resources/Sentry/" + (notDefaultConfigName ?? "SentryOptions") + ".asset";
		}

		public static SentryUnityOptions? LoadSentryUnityOptions(ISentryUnityInfo unityInfo)
		{
			return Resources.Load<ScriptableSentryUnityOptions>("Sentry/SentryOptions")?.ToSentryUnityOptions(isBuilding: false, unityInfo);
		}

		internal SentryUnityOptions ToSentryUnityOptions(bool isBuilding, ISentryUnityInfo? unityInfo = null, IApplication? application = null)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (application == null)
			{
				application = ApplicationAdapter.Instance;
			}
			SentryUnityOptions obj = new SentryUnityOptions(isBuilding, unityInfo, application)
			{
				Enabled = Enabled
			};
			((SentryOptions)obj).Dsn = Dsn;
			obj.CaptureInEditor = CaptureInEditor;
			obj.EnableLogDebouncing = EnableLogDebouncing;
			((SentryOptions)obj).TracesSampleRate = TracesSampleRate;
			((SentryOptions)obj).AutoSessionTracking = AutoSessionTracking;
			((SentryOptions)obj).AutoSessionTrackingInterval = TimeSpan.FromMilliseconds(AutoSessionTrackingInterval);
			((SentryOptions)obj).AttachStacktrace = AttachStacktrace;
			obj.AttachScreenshot = AttachScreenshot;
			obj.ScreenshotQuality = ScreenshotQuality;
			obj.ScreenshotCompression = ScreenshotCompression;
			((SentryOptions)obj).MaxBreadcrumbs = MaxBreadcrumbs;
			((SentryOptions)obj).ReportAssembliesMode = ReportAssembliesMode;
			((SentryOptions)obj).SendDefaultPii = SendDefaultPii;
			((SentryOptions)obj).IsEnvironmentUser = IsEnvironmentUser;
			((SentryOptions)obj).MaxCacheItems = MaxCacheItems;
			((SentryOptions)obj).InitCacheFlushTimeout = TimeSpan.FromMilliseconds(InitCacheFlushTimeout);
			((SentryOptions)obj).SampleRate = ((SampleRate == 1f) ? null : new float?(SampleRate));
			((SentryOptions)obj).ShutdownTimeout = TimeSpan.FromMilliseconds(ShutdownTimeout);
			((SentryOptions)obj).MaxQueueItems = MaxQueueItems;
			((SentryOptions)obj).Debug = ShouldDebug(application.IsEditor && !isBuilding);
			((SentryOptions)obj).DiagnosticLevel = DiagnosticLevel;
			obj.IosNativeSupportEnabled = IosNativeSupportEnabled;
			obj.AndroidNativeSupportEnabled = AndroidNativeSupportEnabled;
			obj.WindowsNativeSupportEnabled = WindowsNativeSupportEnabled;
			obj.MacosNativeSupportEnabled = MacosNativeSupportEnabled;
			obj.LinuxNativeSupportEnabled = LinuxNativeSupportEnabled;
			obj.Il2CppLineNumberSupportEnabled = Il2CppLineNumberSupportEnabled;
			SentryUnityOptions sentryUnityOptions = obj;
			if (!string.IsNullOrWhiteSpace(ReleaseOverride))
			{
				((SentryOptions)sentryUnityOptions).Release = ReleaseOverride;
			}
			if (!string.IsNullOrWhiteSpace(EnvironmentOverride))
			{
				((SentryOptions)sentryUnityOptions).Environment = EnvironmentOverride;
			}
			sentryUnityOptions.SetupLogging();
			if (IsKnownPlatform(application))
			{
				((SentryOptions)sentryUnityOptions).CacheDirectoryPath = (EnableOfflineCaching ? application.PersistentDataPath : null);
			}
			else
			{
				if (((SentryOptions)sentryUnityOptions).BackgroundWorker == null)
				{
					IDiagnosticLogger diagnosticLogger = ((SentryOptions)sentryUnityOptions).DiagnosticLogger;
					if (diagnosticLogger != null)
					{
						DiagnosticLoggerExtensions.LogDebug(diagnosticLogger, "Platform support for background thread execution is unknown: using WebBackgroundWorker.");
					}
					((SentryOptions)sentryUnityOptions).BackgroundWorker = (IBackgroundWorker)(object)new WebBackgroundWorker(sentryUnityOptions, SentryMonoBehaviour.Instance);
				}
				if (EnableOfflineCaching)
				{
					IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)sentryUnityOptions).DiagnosticLogger;
					if (diagnosticLogger2 != null)
					{
						DiagnosticLoggerExtensions.LogDebug(diagnosticLogger2, "Platform support for offline caching is unknown: disabling.");
					}
					((SentryOptions)sentryUnityOptions).CacheDirectoryPath = null;
				}
				if (((SentryOptions)sentryUnityOptions).AutoSessionTracking)
				{
					IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)sentryUnityOptions).DiagnosticLogger;
					if (diagnosticLogger3 != null)
					{
						DiagnosticLoggerExtensions.LogDebug(diagnosticLogger3, "Platform support for automatic session tracking is unknown: disabling.");
					}
					((SentryOptions)sentryUnityOptions).AutoSessionTracking = false;
				}
			}
			OptionsConfiguration?.Configure(sentryUnityOptions);
			if (!isBuilding && sentryUnityOptions.Il2CppLineNumberSupportEnabled && unityInfo != null)
			{
				sentryUnityOptions.AddIl2CppExceptionProcessor(unityInfo);
			}
			return sentryUnityOptions;
		}

		internal bool ShouldDebug(bool isEditorPlayer)
		{
			if (!isEditorPlayer)
			{
				if (!DebugOnlyInEditor)
				{
					return Debug;
				}
				return false;
			}
			return Debug;
		}

		internal bool IsKnownPlatform(IApplication? application = null)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			if (application == null)
			{
				application = ApplicationAdapter.Instance;
			}
			RuntimePlatform platform = application.Platform;
			return (int)platform == 11 || (int)platform == 8 || (int)platform == 7 || (int)platform == 2 || (int)platform == 0 || (int)platform == 1 || (int)platform == 16 || (int)platform == 13 || (int)platform == 17;
		}

		public ScriptableSentryUnityOptions()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			TimeSpan zero = TimeSpan.Zero;
			InitCacheFlushTimeout = (int)zero.TotalMilliseconds;
			SampleRate = 1f;
			ShutdownTimeout = 2000;
			MaxQueueItems = 30;
			IosNativeSupportEnabled = true;
			AndroidNativeSupportEnabled = true;
			WindowsNativeSupportEnabled = true;
			MacosNativeSupportEnabled = true;
			LinuxNativeSupportEnabled = true;
			Il2CppLineNumberSupportEnabled = true;
			Debug = true;
			DebugOnlyInEditor = true;
			DiagnosticLevel = (SentryLevel)2;
			((ScriptableObject)this)..ctor();
		}
	}
	[AddComponentMenu("")]
	internal class SentryMonoBehaviour : MonoBehaviour
	{
		private static SentryMonoBehaviour? _instance;

		private bool _isRunning = true;

		private IApplication? _application;

		internal readonly MainThreadData MainThreadData = new MainThreadData();

		private ISentrySystemInfo? _sentrySystemInfo;

		public static SentryMonoBehaviour Instance
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = new GameObject("SentryMonoBehaviour")
					{
						hideFlags = (HideFlags)61
					}.AddComponent<SentryMonoBehaviour>();
				}
				return _instance;
			}
		}

		internal IApplication Application
		{
			get
			{
				if (_application == null)
				{
					_application = ApplicationAdapter.Instance;
				}
				return _application;
			}
			set
			{
				_application = value;
			}
		}

		internal ISentrySystemInfo SentrySystemInfo
		{
			get
			{
				if (_sentrySystemInfo == null)
				{
					_sentrySystemInfo = SentrySystemInfoAdapter.Instance;
				}
				return _sentrySystemInfo;
			}
			set
			{
				_sentrySystemInfo = value;
			}
		}

		public event Action? ApplicationResuming;

		public event Action? ApplicationPausing;

		internal void UpdatePauseStatus(bool paused)
		{
			if (paused && _isRunning)
			{
				_isRunning = false;
				this.ApplicationPausing?.Invoke();
			}
			else if (!paused && !_isRunning)
			{
				_isRunning = true;
				this.ApplicationResuming?.Invoke();
			}
		}

		internal void OnApplicationPause(bool pauseStatus)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if ((int)Application.Platform == 11)
			{
				UpdatePauseStatus(pauseStatus);
			}
		}

		internal void OnApplicationFocus(bool hasFocus)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if ((int)Application.Platform != 11)
			{
				UpdatePauseStatus(!hasFocus);
			}
		}

		private void OnApplicationQuit()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void Awake()
		{
			CollectData();
		}

		internal void CollectData()
		{
			MainThreadData.MainThreadId = SentrySystemInfo.MainThreadId;
			MainThreadData.ProcessorCount = SentrySystemInfo.ProcessorCount;
			MainThreadData.OperatingSystem = SentrySystemInfo.OperatingSystem;
			MainThreadData.CpuDescription = SentrySystemInfo.CpuDescription;
			MainThreadData.SupportsVibration = SentrySystemInfo.SupportsVibration;
			MainThreadData.DeviceName = SentrySystemInfo.DeviceName;
			MainThreadData.SystemMemorySize = SentrySystemInfo.SystemMemorySize;
			MainThreadData.GraphicsDeviceId = SentrySystemInfo.GraphicsDeviceId;
			MainThreadData.GraphicsDeviceName = SentrySystemInfo.GraphicsDeviceName;
			MainThreadData.GraphicsDeviceVendor = SentrySystemInfo.GraphicsDeviceVendor;
			MainThreadData.GraphicsMemorySize = SentrySystemInfo.GraphicsMemorySize;
			MainThreadData.NpotSupport = SentrySystemInfo.NpotSupport;
			MainThreadData.GraphicsDeviceVersion = SentrySystemInfo.GraphicsDeviceVersion;
			MainThreadData.GraphicsDeviceType = SentrySystemInfo.GraphicsDeviceType;
			MainThreadData.MaxTextureSize = SentrySystemInfo.MaxTextureSize;
			MainThreadData.SupportsDrawCallInstancing = SentrySystemInfo.SupportsDrawCallInstancing;
			MainThreadData.SupportsRayTracing = SentrySystemInfo.SupportsRayTracing;
			MainThreadData.SupportsComputeShaders = SentrySystemInfo.SupportsComputeShaders;
			MainThreadData.SupportsGeometryShaders = SentrySystemInfo.SupportsGeometryShaders;
			MainThreadData.GraphicsShaderLevel = SentrySystemInfo.GraphicsShaderLevel;
			MainThreadData.InstallMode = SentrySystemInfo.InstallMode;
			if (MainThreadData.IsMainThread())
			{
				MainThreadData.DeviceType = SentrySystemInfo.DeviceType?.Value;
				MainThreadData.DeviceUniqueIdentifier = SentrySystemInfo.DeviceUniqueIdentifier?.Value;
				MainThreadData.DeviceModel = SentrySystemInfo.DeviceModel?.Value;
				MainThreadData.GraphicsDeviceVendorId = SentrySystemInfo.GraphicsDeviceVendorId?.Value;
				MainThreadData.GraphicsMultiThreaded = SentrySystemInfo.GraphicsMultiThreaded?.Value;
				MainThreadData.IsDebugBuild = SentrySystemInfo.IsDebugBuild?.Value;
				MainThreadData.TargetFrameRate = SentrySystemInfo.TargetFrameRate?.Value;
				MainThreadData.CopyTextureSupport = SentrySystemInfo.CopyTextureSupport?.Value;
				MainThreadData.RenderingThreadingMode = SentrySystemInfo.RenderingThreadingMode?.Value;
				MainThreadData.StartTime = SentrySystemInfo.StartTime?.Value;
			}
			else
			{
				MainThreadData.DeviceType = null;
				MainThreadData.DeviceUniqueIdentifier = null;
				MainThreadData.DeviceModel = null;
				MainThreadData.GraphicsDeviceVendorId = null;
				MainThreadData.GraphicsMultiThreaded = null;
				MainThreadData.IsDebugBuild = null;
				MainThreadData.TargetFrameRate = null;
				MainThreadData.CopyTextureSupport = null;
				MainThreadData.RenderingThreadingMode = null;
				MainThreadData.StartTime = null;
			}
		}
	}
	public static class SentryUnity
	{
		private static FileStream? LockFile;

		public static void Init(Action<SentryUnityOptions> sentryUnityOptionsConfigure)
		{
			SentryUnityOptions sentryUnityOptions = new SentryUnityOptions();
			sentryUnityOptionsConfigure(sentryUnityOptions);
			Init(sentryUnityOptions);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void Init(SentryUnityOptions options)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			SentryUnityOptions options2 = options;
			options2.SetupLogging();
			if (!options2.ShouldInitializeSdk())
			{
				return;
			}
			if ((int)ApplicationAdapter.Instance.Platform == 2 && ((SentryOptions)options2).CacheDirectoryPath != null)
			{
				try
				{
					LockFile = new FileStream(Path.Combine(((SentryOptions)options2).CacheDirectoryPath, "sentry-unity.lock"), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
				}
				catch (Exception ex)
				{
					IDiagnosticLogger diagnosticLogger = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger != null)
					{
						DiagnosticLoggerExtensions.LogWarning<Exception>(diagnosticLogger, "An exception was thrown while trying to acquire a lockfile on the config directory: .NET event cache will be disabled.", ex);
					}
					((SentryOptions)options2).CacheDirectoryPath = null;
					((SentryOptions)options2).AutoSessionTracking = false;
				}
			}
			IDisposable sentryDotNet = SentrySdk.Init((SentryOptions)(object)options2);
			if (options2.AttachScreenshot)
			{
				SentrySdk.ConfigureScope((Action<Scope>)delegate(Scope s)
				{
					s.AddAttachment((Attachment)(object)new ScreenshotAttachment((IAttachmentContent)(object)new ScreenshotAttachmentContent(options2, SentryMonoBehaviour.Instance)));
				});
			}
			ContextWriter contextWriter = options2.NativeContextWriter;
			if (contextWriter != null)
			{
				SentrySdk.ConfigureScope((Action<Scope>)delegate(Scope scope)
				{
					Scope scope2 = scope;
					Task.Run(delegate
					{
						contextWriter.Write(scope2);
					}).ContinueWith(delegate(Task t)
					{
						if (t.Exception != null)
						{
							IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)options2).DiagnosticLogger;
							if (diagnosticLogger4 != null)
							{
								DiagnosticLoggerExtensions.LogWarning<AggregateException>(diagnosticLogger4, "Failed to synchronize scope to the native SDK: {0}", t.Exception);
							}
						}
					});
				});
			}
			ApplicationAdapter.Instance.Quitting += delegate
			{
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger2, "Closing the sentry-dotnet SDK");
				}
				try
				{
					sentryDotNet.Dispose();
				}
				finally
				{
					try
					{
						LockFile?.Close();
					}
					catch (Exception ex2)
					{
						IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options2).DiagnosticLogger;
						if (diagnosticLogger3 != null)
						{
							diagnosticLogger3.Log((SentryLevel)2, "Exception while releasing the lockfile on the config directory.", ex2, Array.Empty<object>());
						}
					}
				}
			};
		}
	}
	public sealed class SentryUnityOptions : SentryOptions
	{
		public const string PackageName = "io.sentry.unity";

		private CompressionLevelWithAuto _requestBodyCompressionLevel = CompressionLevelWithAuto.Auto;

		internal string? _defaultUserId;

		internal bool MultiThreading = true;

		public bool Enabled { get; set; } = true;


		public bool CaptureInEditor { get; set; } = true;


		public bool EnableLogDebouncing { get; set; }

		public CompressionLevelWithAuto RequestBodyCompressionLevel
		{
			get
			{
				return _requestBodyCompressionLevel;
			}
			set
			{
				_requestBodyCompressionLevel = value;
				if (value == CompressionLevelWithAuto.Auto)
				{
					((SentryOptions)this).RequestBodyCompressionLevel = CompressionLevel.NoCompression;
				}
				else
				{
					((SentryOptions)this).RequestBodyCompressionLevel = (CompressionLevel)value;
				}
			}
		}

		public bool AttachScreenshot { get; set; }

		public ScreenshotQuality ScreenshotQuality { get; set; } = ScreenshotQuality.High;


		public int ScreenshotCompression { get; set; } = 75;


		public bool IosNativeSupportEnabled { get; set; } = true;


		public bool AndroidNativeSupportEnabled { get; set; } = true;


		public bool WindowsNativeSupportEnabled { get; set; } = true;


		public bool MacosNativeSupportEnabled { get; set; } = true;


		public bool LinuxNativeSupportEnabled { get; set; } = true;


		public bool Il2CppLineNumberSupportEnabled { get; set; } = true;


		internal string? DefaultUserId
		{
			get
			{
				return _defaultUserId;
			}
			set
			{
				_defaultUserId = value;
				if (_defaultUserId == null)
				{
					IDiagnosticLogger diagnosticLogger = ((SentryOptions)this).DiagnosticLogger;
					if (diagnosticLogger != null)
					{
						DiagnosticLoggerExtensions.LogWarning(diagnosticLogger, "Couldn't set the default user ID - the value is NULL.");
					}
				}
				else
				{
					IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)this).DiagnosticLogger;
					if (diagnosticLogger2 != null)
					{
						DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger2, "Setting '{0}' as the default user ID.", _defaultUserId);
					}
				}
			}
		}

		internal ContextWriter? NativeContextWriter { get; set; }

		internal List<string> SdkIntegrationNames { get; set; } = new List<string>();


		public SentryUnityOptions()
			: this(isBuilding: false, null, ApplicationAdapter.Instance)
		{
		}

		internal SentryUnityOptions(bool isBuilding, ISentryUnityInfo? unityInfo, IApplication application)
			: this(SentryMonoBehaviour.Instance, application, unityInfo, isBuilding)
		{
		}

		internal SentryUnityOptions(SentryMonoBehaviour behaviour, IApplication application, ISentryUnityInfo? unityInfo, bool isBuilding)
		{
			((SentryOptions)this).DetectStartupTime = (StartupTimeDetectionMode)1;
			SentryOptionsExtensions.AddInAppExclude((SentryOptions)(object)this, "UnityEngine");
			SentryOptionsExtensions.AddInAppExclude((SentryOptions)(object)this, "UnityEditor");
			SentryOptionsExtensions.AddEventProcessor((SentryOptions)(object)this, (ISentryEventProcessor)(object)new UnityEventProcessor(this, behaviour));
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new UnityLogHandlerIntegration());
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new AnrIntegration(behaviour));
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new UnityScopeIntegration(behaviour, application));
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new UnityBeforeSceneLoadIntegration());
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new SceneManagerIntegration());
			SentryOptionsExtensions.AddIntegration((SentryOptions)(object)this, (ISdkIntegration)(object)new SessionIntegration(behaviour));
			((SentryOptions)this).IsGlobalModeEnabled = true;
			((SentryOptions)this).AutoSessionTracking = true;
			RequestBodyCompressionLevel = CompressionLevelWithAuto.NoCompression;
			((SentryOptions)this).InitCacheFlushTimeout = TimeSpan.Zero;
			((SentryOptions)this).StackTraceMode = (StackTraceMode)0;
			((SentryOptions)this).IsEnvironmentUser = false;
			string productName = application.ProductName;
			if (productName != null && !string.IsNullOrWhiteSpace(productName) && productName.Any((char c) => c != '.'))
			{
				productName = Regex.Replace(productName, "\\n|\\r|\\t|\\/|\\\\|\\.{2}|@", "_");
				((SentryOptions)this).Release = productName + "@" + application.Version;
			}
			else
			{
				((SentryOptions)this).Release = application.Version;
			}
			if (!string.IsNullOrWhiteSpace(application.BuildGUID))
			{
				((SentryOptions)this).Release = ((SentryOptions)this).Release + "+" + application.BuildGUID;
			}
			((SentryOptions)this).Environment = ((application.IsEditor && !isBuilding) ? "editor" : "production");
		}

		public override string ToString()
		{
			return string.Format("Sentry SDK Options:\nCapture In Editor: {0}\nRelease: {1}\nEnvironment: {2}\nOffline Caching: {3}\n", CaptureInEditor, ((SentryOptions)this).Release, ((SentryOptions)this).Environment, (((SentryOptions)this).CacheDirectoryPath == null) ? "disabled" : "enabled");
		}
	}
	public enum CompressionLevelWithAuto
	{
		Auto = -1,
		Optimal,
		Fastest,
		NoCompression
	}
	public enum ScreenshotQuality
	{
		Full,
		High,
		Medium,
		Low
	}
	public static class SentryUnityOptionsExtensions
	{
		public static bool ShouldInitializeSdk(this SentryUnityOptions? options)
		{
			return options.ShouldInitializeSdk(null);
		}

		internal static bool ShouldInitializeSdk(this SentryUnityOptions? options, IApplication? application = null)
		{
			if (options == null)
			{
				return false;
			}
			if (!options.IsValid())
			{
				return false;
			}
			if (application == null)
			{
				application = ApplicationAdapter.Instance;
			}
			if (!options.CaptureInEditor && application.IsEditor)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogInfo(diagnosticLogger, "Disabled while in the Editor.");
				}
				return false;
			}
			return true;
		}

		internal static bool IsValid(this SentryUnityOptions options)
		{
			if (!options.Enabled)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger, "Sentry SDK has been disabled.\nYou can disable this log by raising the debug verbosity level above 'Debug'.");
				}
				return false;
			}
			if (string.IsNullOrWhiteSpace(((SentryOptions)options).Dsn))
			{
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogWarning(diagnosticLogger2, "No Sentry DSN configured. Sentry will be disabled.");
				}
				return false;
			}
			return true;
		}

		internal static void SetupLogging(this SentryUnityOptions options)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (((SentryOptions)options).Debug)
			{
				if (((SentryOptions)options).DiagnosticLogger == null)
				{
					((SentryOptions)options).DiagnosticLogger = (IDiagnosticLogger)(object)new UnityLogger(options);
					DiagnosticLoggerExtensions.LogDebug<SentryLevel>(((SentryOptions)options).DiagnosticLogger, "Logging enabled with 'UnityLogger' min level: {0}", ((SentryOptions)options).DiagnosticLevel);
				}
			}
			else
			{
				((SentryOptions)options).DiagnosticLogger = null;
			}
		}

		internal static void AddIl2CppExceptionProcessor(this SentryUnityOptions options, ISentryUnityInfo unityInfo)
		{
			if (unityInfo.Il2CppMethods != null)
			{
				SentryOptionsExtensions.AddExceptionProcessor((SentryOptions)(object)options, (ISentryEventExceptionProcessor)(object)new UnityIl2CppEventExceptionProcessor(options, unityInfo, unityInfo.Il2CppMethods));
				return;
			}
			IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				DiagnosticLoggerExtensions.LogWarning(diagnosticLogger, "Failed to find required IL2CPP methods - Skipping line number support");
			}
		}

		public static void DisableUnityApplicationLoggingIntegration(this SentryUnityOptions options)
		{
			SentryOptionsExtensions.RemoveIntegration<UnityLogHandlerIntegration>((SentryOptions)(object)options);
		}

		public static void DisableAnrIntegration(this SentryUnityOptions options)
		{
			SentryOptionsExtensions.RemoveIntegration<AnrIntegration>((SentryOptions)(object)options);
		}
	}
	internal interface ISentrySystemInfo
	{
		int? MainThreadId { get; }

		string? OperatingSystem { get; }

		int? ProcessorCount { get; }

		bool? SupportsVibration { get; }

		Lazy<string>? DeviceType { get; }

		string? CpuDescription { get; }

		string? DeviceName { get; }

		Lazy<string>? DeviceUniqueIdentifier { get; }

		Lazy<string>? DeviceModel { get; }

		int? SystemMemorySize { get; }

		int? GraphicsDeviceId { get; }

		string? GraphicsDeviceName { get; }

		Lazy<string>? GraphicsDeviceVendorId { get; }

		string? GraphicsDeviceVendor { get; }

		int? GraphicsMemorySize { get; }

		Lazy<bool>? GraphicsMultiThreaded { get; }

		string? NpotSupport { get; }

		string? GraphicsDeviceVersion { get; }

		string? GraphicsDeviceType { get; }

		int? MaxTextureSize { get; }

		bool? SupportsDrawCallInstancing { get; }

		bool? SupportsRayTracing { get; }

		bool? SupportsComputeShaders { get; }

		bool? SupportsGeometryShaders { get; }

		int? GraphicsShaderLevel { get; }

		Lazy<bool>? IsDebugBuild { get; }

		string? InstallMode { get; }

		Lazy<string>? TargetFrameRate { get; }

		Lazy<string>? CopyTextureSupport { get; }

		Lazy<string>? RenderingThreadingMode { get; }

		Lazy<DateTimeOffset>? StartTime { get; }
	}
	internal sealed class SentrySystemInfoAdapter : ISentrySystemInfo
	{
		public static readonly SentrySystemInfoAdapter Instance = new SentrySystemInfoAdapter();

		public int? MainThreadId => Thread.CurrentThread.ManagedThreadId;

		public string? OperatingSystem => SystemInfo.operatingSystem;

		public int? ProcessorCount => SystemInfo.processorCount;

		public bool? SupportsVibration => SystemInfo.supportsVibration;

		public Lazy<string>? DeviceType => new Lazy<string>(delegate
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			DeviceType deviceType = SystemInfo.deviceType;
			return ((object)(DeviceType)(ref deviceType)).ToString();
		});

		public string? CpuDescription => SystemInfo.processorType;

		public string? DeviceName => SystemInfo.deviceName;

		public Lazy<string> DeviceUniqueIdentifier => new Lazy<string>(() => SystemInfo.deviceUniqueIdentifier);

		public Lazy<string> DeviceModel => new Lazy<string>(() => SystemInfo.deviceModel);

		public int? SystemMemorySize => SystemInfo.systemMemorySize;

		public int? GraphicsDeviceId => SystemInfo.graphicsDeviceID;

		public string? GraphicsDeviceName => SystemInfo.graphicsDeviceName;

		public Lazy<string>? GraphicsDeviceVendorId => new Lazy<string>(() => SystemInfo.graphicsDeviceVendorID.ToString());

		public string? GraphicsDeviceVendor => SystemInfo.graphicsDeviceVendor;

		public int? GraphicsMemorySize => SystemInfo.graphicsMemorySize;

		public Lazy<bool>? GraphicsMultiThreaded => new Lazy<bool>(() => SystemInfo.graphicsMultiThreaded);

		public string? NpotSupport
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				NPOTSupport npotSupport = SystemInfo.npotSupport;
				return ((object)(NPOTSupport)(ref npotSupport)).ToString();
			}
		}

		public string? GraphicsDeviceVersion => SystemInfo.graphicsDeviceVersion;

		public string? GraphicsDeviceType
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				GraphicsDeviceType graphicsDeviceType = SystemInfo.graphicsDeviceType;
				return ((object)(GraphicsDeviceType)(ref graphicsDeviceType)).ToString();
			}
		}

		public int? MaxTextureSize => SystemInfo.maxTextureSize;

		public bool? SupportsDrawCallInstancing => SystemInfo.supportsInstancing;

		public bool? SupportsRayTracing => SystemInfo.supportsRayTracing;

		public bool? SupportsComputeShaders => SystemInfo.supportsComputeShaders;

		public bool? SupportsGeometryShaders => SystemInfo.supportsGeometryShaders;

		public int? GraphicsShaderLevel => SystemInfo.graphicsShaderLevel;

		public Lazy<bool> IsDebugBuild => new Lazy<bool>(() => Debug.isDebugBuild);

		public string? InstallMode
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				ApplicationInstallMode installMode = Application.installMode;
				return ((object)(ApplicationInstallMode)(ref installMode)).ToString();
			}
		}

		public Lazy<string> TargetFrameRate => new Lazy<string>(() => Application.targetFrameRate.ToString());

		public Lazy<string> CopyTextureSupport => new Lazy<string>(delegate
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CopyTextureSupport copyTextureSupport = SystemInfo.copyTextureSupport;
			return ((object)(CopyTextureSupport)(ref copyTextureSupport)).ToString();
		});

		public Lazy<string> RenderingThreadingMode => new Lazy<string>(delegate
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			RenderingThreadingMode renderingThreadingMode = SystemInfo.renderingThreadingMode;
			return ((object)(RenderingThreadingMode)(ref renderingThreadingMode)).ToString();
		});

		public Lazy<DateTimeOffset>? StartTime => new Lazy<DateTimeOffset>(() => DateTimeOffset.UtcNow.AddSeconds(0f - Time.realtimeSinceStartup));

		private SentrySystemInfoAdapter()
		{
		}
	}
	public interface IUnityLogMessageDebounce
	{
		bool Debounced();
	}
	internal class TimeDebounceBase : IUnityLogMessageDebounce
	{
		protected TimeSpan DebounceOffset;

		private DateTimeOffset? _barrierOffset;

		private static DateTimeOffset Now => DateTimeOffset.UtcNow;

		public bool Debounced()
		{
			if (_barrierOffset.HasValue)
			{
				DateTimeOffset now = Now;
				DateTimeOffset? barrierOffset = _barrierOffset;
				if (now < barrierOffset)
				{
					return false;
				}
			}
			_barrierOffset = Now.Add(DebounceOffset);
			return true;
		}
	}
	internal sealed class LogTimeDebounce : TimeDebounceBase
	{
		public LogTimeDebounce(TimeSpan debounceOffset)
		{
			DebounceOffset = debounceOffset;
		}
	}
	internal sealed class ErrorTimeDebounce : TimeDebounceBase
	{
		public ErrorTimeDebounce(TimeSpan debounceOffset)
		{
			DebounceOffset = debounceOffset;
		}
	}
	internal sealed class WarningTimeDebounce : TimeDebounceBase
	{
		public WarningTimeDebounce(TimeSpan debounceOffset)
		{
			DebounceOffset = debounceOffset;
		}
	}
	internal class UnityEventProcessor : ISentryEventProcessor
	{
		private readonly SentryUnityOptions _sentryOptions;

		private readonly MainThreadData _mainThreadData;

		public UnityEventProcessor(SentryUnityOptions sentryOptions, SentryMonoBehaviour sentryMonoBehaviour)
		{
			_sentryOptions = sentryOptions;
			_mainThreadData = sentryMonoBehaviour.MainThreadData;
		}

		public SentryEvent Process(SentryEvent @event)
		{
			try
			{
				PopulateDevice(@event.Contexts.Device);
				PopulateSdkIntegrations(@event.Sdk);
				@event.SetTag("unity.is_main_thread", _mainThreadData.IsMainThread().ToTagValue());
			}
			catch (Exception ex)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)_sentryOptions).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogError<string>(diagnosticLogger, "{0} processing failed.", ex, "SentryEvent");
				}
			}
			@event.ServerName = null;
			return @event;
		}

		private void PopulateDevice(Device device)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected I4, but got Unknown
			if (_mainThreadData.IsMainThread())
			{
				BatteryStatus batteryStatus = SystemInfo.batteryStatus;
				device.BatteryStatus = ((object)(BatteryStatus)(ref batteryStatus)).ToString();
				float batteryLevel = SystemInfo.batteryLevel;
				if ((double)batteryLevel > 0.0)
				{
					device.BatteryLevel = (short)(batteryLevel * 100f);
				}
				DeviceOrientation deviceOrientation = Input.deviceOrientation;
				switch (deviceOrientation - 1)
				{
				case 0:
				case 1:
					device.Orientation = (DeviceOrientation)0;
					break;
				case 2:
				case 3:
					device.Orientation = (DeviceOrientation)1;
					break;
				case 4:
				case 5:
					break;
				}
			}
		}

		private void PopulateSdkIntegrations(SdkVersion sdkVersion)
		{
			foreach (string sdkIntegrationName in _sentryOptions.SdkIntegrationNames)
			{
				sdkVersion.AddIntegration(sdkIntegrationName);
			}
		}
	}
	internal static class TagValueNormalizer
	{
		internal static string ToTagValue(this bool value)
		{
			if (!value)
			{
				return "false";
			}
			return "true";
		}
	}
	internal interface IUnityLoggerInterceptor
	{
		void Intercept(SentryLevel logLevel, string logMessage);
	}
	public class UnityLogger : IDiagnosticLogger
	{
		public const string LogPrefix = "Sentry: ";

		private readonly SentryOptions _sentryOptions;

		private readonly IUnityLoggerInterceptor? _interceptor;

		public bool IsEnabled(SentryLevel level)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return level >= _sentryOptions.DiagnosticLevel;
		}

		public UnityLogger(SentryUnityOptions sentryUnityOptions)
			: this((SentryOptions)(object)sentryUnityOptions)
		{
		}

		internal UnityLogger(SentryOptions sentryOptions, IUnityLoggerInterceptor? interceptor = null)
		{
			_sentryOptions = sentryOptions;
			_interceptor = interceptor;
		}

		public void Log(SentryLevel logLevel, string? message, Exception? exception = null, params object?[] args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected I4, but got Unknown
			string message2 = message;
			object?[] args2 = args;
			Exception exception2 = exception;
			if (IsEnabled(logLevel))
			{
				SentryLevel val = logLevel;
				switch ((int)val)
				{
				case 0:
				case 1:
					Debug.Log((object)GetLog());
					break;
				case 2:
					Debug.LogWarning((object)GetLog());
					break;
				case 3:
				case 4:
					Debug.LogError((object)GetLog());
					break;
				default:
					Debug.Log((object)GetLog());
					break;
				}
			}
			string GetLog()
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				string text = string.Format("{0}({1}) {2} {3}", "Sentry: ", logLevel, string.Format(message2, args2), exception2);
				_interceptor?.Intercept(logLevel, text);
				return text;
			}
		}

		public override string ToString()
		{
			return "UnityLogger";
		}
	}
	internal class WebBackgroundWorker : IBackgroundWorker
	{
		private readonly SentryMonoBehaviour _behaviour;

		private readonly UnityWebRequestTransport _transport;

		public int QueuedItems { get; }

		public WebBackgroundWorker(SentryUnityOptions options, SentryMonoBehaviour behaviour)
		{
			_behaviour = behaviour;
			_transport = new UnityWebRequestTransport(options);
		}

		public bool EnqueueEnvelope(Envelope envelope)
		{
			((MonoBehaviour)_behaviour).StartCoroutine(_transport.SendEnvelopeAsync(envelope));
			return true;
		}

		public Task FlushAsync(TimeSpan timeout)
		{
			return Task.CompletedTask;
		}
	}
	internal class UnityWebRequestTransport : HttpTransportBase
	{
		private readonly SentryUnityOptions _options;

		public UnityWebRequestTransport(SentryUnityOptions options)
			: base((SentryOptions)(object)options, (Func<string, string>)null, (ISystemClock)null)
		{
			_options = options;
		}

		internal IEnumerator SendEnvelopeAsync(Envelope envelope)
		{
			Envelope processedEnvelope = ((HttpTransportBase)this).ProcessEnvelope(envelope);
			try
			{
				if (processedEnvelope.Items.Count > 0)
				{
					HttpRequestMessage message = ((HttpTransportBase)this).CreateRequest(processedEnvelope);
					UnityWebRequest www = CreateWebRequest(message);
					yield return www.SendWebRequest();
					HttpResponseMessage response = GetResponse(www);
					if (response != null)
					{
						((HttpTransportBase)this).HandleResponse(response, processedEnvelope);
					}
				}
			}
			finally
			{
				((IDisposable)processedEnvelope)?.Dispose();
			}
		}

		private UnityWebRequest CreateWebRequest(HttpRequestMessage message)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0073: Expected O, but got Unknown
			using Stream stream = ((HttpTransportBase)this).ReadStreamFromHttpContent(message.Content);
			MemoryStream memoryStream = stream as MemoryStream;
			if (memoryStream == null)
			{
				memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				memoryStream.Flush();
			}
			UnityWebRequest val = new UnityWebRequest
			{
				url = message.RequestUri.ToString(),
				method = message.Method.Method.ToUpperInvariant(),
				uploadHandler = (UploadHandler)new UploadHandlerRaw(memoryStream.ToArray()),
				downloadHandler = (DownloadHandler)new DownloadHandlerBuffer()
			};
			foreach (KeyValuePair<string, IEnumerable<string>> header in message.Headers)
			{
				val.SetRequestHeader(header.Key, string.Join(",", header.Value));
			}
			return val;
		}

		private HttpResponseMessage? GetResponse(UnityWebRequest www)
		{
			if (www.isNetworkError)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)_options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogWarning<string>(diagnosticLogger, "Failed to send request: {0}", www.error);
				}
				return null;
			}
			HttpResponseMessage httpResponseMessage = new HttpResponseMessage((HttpStatusCode)www.responseCode);
			foreach (KeyValuePair<string, string> responseHeader in www.GetResponseHeaders())
			{
				string text = responseHeader.Key.ToLowerInvariant();
				if (!(text == "content-length") && !(text == "content-type"))
				{
					httpResponseMessage.Headers.Add(responseHeader.Key, responseHeader.Value);
				}
			}
			httpResponseMessage.Content = new StringContent(www.downloadHandler.text);
			return httpResponseMessage;
		}
	}
}
namespace Sentry.Unity.WebGL
{
	public static class SentryWebGL
	{
		public static void Configure(SentryUnityOptions options)
		{
			IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger != null)
			{
				DiagnosticLoggerExtensions.LogDebug(diagnosticLogger, "Updating configuration for Unity WebGL.");
			}
			((SentryOptions)options).BackgroundWorker = (IBackgroundWorker)(object)new WebBackgroundWorker(options, SentryMonoBehaviour.Instance);
			((SentryOptions)options).CrashedLastRun = () => false;
			((SentryOptions)options).UseAsyncFileIO = false;
			if (options.AttachScreenshot)
			{
				options.AttachScreenshot = false;
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogWarning(diagnosticLogger2, "Attaching screenshots on WebGL is disabled - it currently produces blank screenshots mid-frame.");
				}
			}
			options.DefaultUserId = AnalyticsSessionInfo.userId;
			options.MultiThreading = false;
		}
	}
}
namespace Sentry.Unity.Protocol
{
	public sealed class Unity : IJsonSerializable
	{
		public const string Type = "unity";

		public string? InstallMode { get; set; }

		public string? CopyTextureSupport { get; set; }

		public string? RenderingThreadingMode { get; set; }

		public string? TargetFrameRate { get; set; }

		internal Unity Clone()
		{
			return new Unity
			{
				InstallMode = InstallMode,
				CopyTextureSupport = CopyTextureSupport,
				RenderingThreadingMode = RenderingThreadingMode,
				TargetFrameRate = TargetFrameRate
			};
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteString("type", "unity");
			if (!string.IsNullOrWhiteSpace(InstallMode))
			{
				writer.WriteString("install_mode", InstallMode);
			}
			if (!string.IsNullOrWhiteSpace(CopyTextureSupport))
			{
				writer.WriteString("copy_texture_support", CopyTextureSupport);
			}
			if (!string.IsNullOrWhiteSpace(RenderingThreadingMode))
			{
				writer.WriteString("rendering_threading_mode", RenderingThreadingMode);
			}
			if (!string.IsNullOrWhiteSpace(TargetFrameRate))
			{
				writer.WriteString("target_frame_rate", TargetFrameRate);
			}
			writer.WriteEndObject();
		}

		public static Unity FromJson(JsonElement json)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			Unity unity = new Unity();
			JsonElement? propertyOrNull = json.GetPropertyOrNull("install_mode");
			object installMode;
			JsonElement valueOrDefault;
			if (!propertyOrNull.HasValue)
			{
				installMode = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				installMode = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			unity.InstallMode = (string?)installMode;
			propertyOrNull = json.GetPropertyOrNull("copy_texture_support");
			object copyTextureSupport;
			if (!propertyOrNull.HasValue)
			{
				copyTextureSupport = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				copyTextureSupport = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			unity.CopyTextureSupport = (string?)copyTextureSupport;
			propertyOrNull = json.GetPropertyOrNull("rendering_threading_mode");
			object renderingThreadingMode;
			if (!propertyOrNull.HasValue)
			{
				renderingThreadingMode = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				renderingThreadingMode = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			unity.RenderingThreadingMode = (string?)renderingThreadingMode;
			propertyOrNull = json.GetPropertyOrNull("target_frame_rate");
			object targetFrameRate;
			if (!propertyOrNull.HasValue)
			{
				targetFrameRate = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				targetFrameRate = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			unity.TargetFrameRate = (string?)targetFrameRate;
			return unity;
		}

		public string ToJsonString(IDiagnosticLogger? logger = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			using MemoryStream memoryStream = new MemoryStream();
			Utf8JsonWriter val = new Utf8JsonWriter((Stream)memoryStream, default(JsonWriterOptions));
			try
			{
				WriteTo(val, logger);
				val.Flush();
				return Encoding.UTF8.GetString(memoryStream.ToArray());
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
}
namespace Sentry.Unity.NativeUtils
{
	internal static class C
	{
		[StructLayout(LayoutKind.Explicit)]
		internal struct sentry_value_t
		{
			[FieldOffset(0)]
			internal ulong _bits;

			[FieldOffset(0)]
			internal double _double;
		}

		internal static readonly Lazy<IEnumerable<DebugImage>> DebugImages = new Lazy<IEnumerable<DebugImage>>(LoadDebugImages);

		internal static void SetValueIfNotNull(sentry_value_t obj, string key, string? value)
		{
			if (value != null)
			{
				sentry_value_set_by_key(obj, key, sentry_value_new_string(value));
			}
		}

		internal static void SetValueIfNotNull(sentry_value_t obj, string key, int? value)
		{
			if (value.HasValue)
			{
				sentry_value_set_by_key(obj, key, sentry_value_new_int32(value.Value));
			}
		}

		internal static void SetValueIfNotNull(sentry_value_t obj, string key, bool? value)
		{
			if (value.HasValue)
			{
				sentry_value_set_by_key(obj, key, sentry_value_new_bool(value.Value ? 1 : 0));
			}
		}

		internal static void SetValueIfNotNull(sentry_value_t obj, string key, double? value)
		{
			if (value.HasValue)
			{
				sentry_value_set_by_key(obj, key, sentry_value_new_double(value.Value));
			}
		}

		internal static sentry_value_t? GetValueOrNul(sentry_value_t obj, string key)
		{
			sentry_value_t value = sentry_value_get_by_key(obj, key);
			if (sentry_value_is_null(value) != 0)
			{
				return null;
			}
			return value;
		}

		internal static string? GetValueString(sentry_value_t obj, string key)
		{
			sentry_value_t? valueOrNul = GetValueOrNul(obj, key);
			if (valueOrNul.HasValue)
			{
				sentry_value_t valueOrDefault = valueOrNul.GetValueOrDefault();
				IntPtr intPtr = sentry_value_as_string(valueOrDefault);
				if (intPtr != IntPtr.Zero)
				{
					return Marshal.PtrToStringAnsi(intPtr);
				}
			}
			return null;
		}

		internal static int? GetValueInt(sentry_value_t obj, string key)
		{
			sentry_value_t? valueOrNul = GetValueOrNul(obj, key);
			if (valueOrNul.HasValue)
			{
				sentry_value_t valueOrDefault = valueOrNul.GetValueOrDefault();
				return sentry_value_as_int32(valueOrDefault);
			}
			return null;
		}

		internal static double? GetValueDouble(sentry_value_t obj, string key)
		{
			sentry_value_t? valueOrNul = GetValueOrNul(obj, key);
			if (valueOrNul.HasValue)
			{
				sentry_value_t valueOrDefault = valueOrNul.GetValueOrDefault();
				return sentry_value_as_double(valueOrDefault);
			}
			return null;
		}

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_object();

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_null();

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_bool(int value);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_double(double value);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_int32(int value);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_string(string value);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_new_breadcrumb(string? type, string? message);

		[DllImport("sentry")]
		internal static extern int sentry_value_set_by_key(sentry_value_t value, string k, sentry_value_t v);

		internal static bool IsNull(sentry_value_t value)
		{
			return sentry_value_is_null(value) != 0;
		}

		[DllImport("sentry")]
		internal static extern int sentry_value_is_null(sentry_value_t value);

		[DllImport("sentry")]
		internal static extern int sentry_value_as_int32(sentry_value_t value);

		[DllImport("sentry")]
		internal static extern double sentry_value_as_double(sentry_value_t value);

		[DllImport("sentry")]
		internal static extern IntPtr sentry_value_as_string(sentry_value_t value);

		[DllImport("sentry")]
		internal static extern UIntPtr sentry_value_get_length(sentry_value_t value);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_get_by_index(sentry_value_t value, UIntPtr index);

		[DllImport("sentry")]
		internal static extern sentry_value_t sentry_value_get_by_key(sentry_value_t value, string key);

		[DllImport("sentry")]
		internal static extern void sentry_set_context(string key, sentry_value_t value);

		[DllImport("sentry")]
		internal static extern void sentry_add_breadcrumb(sentry_value_t breadcrumb);

		[DllImport("sentry")]
		internal static extern void sentry_set_tag(string key, string value);

		[DllImport("sentry")]
		internal static extern void sentry_remove_tag(string key);

		[DllImport("sentry")]
		internal static extern void sentry_set_user(sentry_value_t user);

		[DllImport("sentry")]
		internal static extern void sentry_remove_user();

		[DllImport("sentry")]
		internal static extern void sentry_set_extra(string key, sentry_value_t value);

		[DllImport("sentry")]
		internal static extern void sentry_remove_extra(string key);

		private static IEnumerable<DebugImage> LoadDebugImages()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			List<DebugImage> list = new List<DebugImage>();
			try
			{
				sentry_value_t value = sentry_get_modules_list();
				try
				{
					if (!IsNull(value))
					{
						uint num = sentry_value_get_length(value).ToUInt32();
						for (uint num2 = 0u; num2 < num; num2++)
						{
							sentry_value_t sentry_value_t = sentry_value_get_by_index(value, (UIntPtr)num2);
							if (!IsNull(sentry_value_t))
							{
								list.Add(new DebugImage
								{
									CodeFile = GetValueString(sentry_value_t, "code_file"),
									ImageAddress = GetValueString(sentry_value_t, "image_addr"),
									ImageSize = GetValueInt(sentry_value_t, "image_size"),
									DebugFile = GetValueString(sentry_value_t, "debug_file"),
									DebugId = GetValueString(sentry_value_t, "debug_id"),
									CodeId = GetValueString(sentry_value_t, "code_id"),
									Type = GetValueString(sentry_value_t, "type")
								});
							}
						}
					}
				}
				finally
				{
					sentry_value_decref(value);
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)string.Format("{0}Error loading the list of debug images: {1}", "Sentry: ", arg));
			}
			return list;
		}

		[DllImport("sentry")]
		private static extern sentry_value_t sentry_get_modules_list();

		[DllImport("sentry")]
		internal static extern void sentry_value_decref(sentry_value_t value);
	}
	internal static class ContextWriter
	{
		internal static void WriteApp(string? AppStartTime, string? AppBuildType)
		{
			C.sentry_value_t sentry_value_t = C.sentry_value_new_object();
			C.SetValueIfNotNull(sentry_value_t, "app_start_time", AppStartTime);
			C.SetValueIfNotNull(sentry_value_t, "build_type", AppBuildType);
			C.sentry_set_context("app", sentry_value_t);
		}

		internal static void WriteOS(string? OperatingSystemRawDescription)
		{
			C.sentry_value_t sentry_value_t = C.sentry_value_new_object();
			C.SetValueIfNotNull(sentry_value_t, "raw_description", OperatingSystemRawDescription);
			C.sentry_set_context("os", sentry_value_t);
		}

		internal static void WriteDevice(int? DeviceProcessorCount, string? DeviceCpuDescription, string? DeviceTimezone, bool? DeviceSupportsVibration, string? DeviceName, bool? DeviceSimulator, string? DeviceDeviceUniqueIdentifier, string? DeviceDeviceType, string? DeviceModel, long? DeviceMemorySize)
		{
			C.sentry_value_t sentry_value_t = C.sentry_value_new_object();

Sentry.Unity.iOS.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using Sentry.Extensibility;
using Sentry.Unity.Integrations;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS.Tests")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Sentry.Unity.iOS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.23.1.0")]
[assembly: AssemblyInformationalVersion("0.23.1")]
[assembly: AssemblyProduct("Sentry.Unity.iOS")]
[assembly: AssemblyTitle("Sentry.Unity.iOS")]
[assembly: AssemblyVersion("0.23.1.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

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

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace Sentry.Unity.iOS
{
	internal class NativeContextWriter : ContextWriter
	{
		protected override void WriteScope(string? AppStartTime, string? AppBuildType, string? OperatingSystemRawDescription, int? DeviceProcessorCount, string? DeviceCpuDescription, string? DeviceTimezone, bool? DeviceSupportsVibration, string? DeviceName, bool? DeviceSimulator, string? DeviceDeviceUniqueIdentifier, string? DeviceDeviceType, string? DeviceModel, long? DeviceMemorySize, int? GpuId, string? GpuName, string? GpuVendorName, int? GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int? GpuMaxTextureSize, bool? GpuSupportsDrawCallInstancing, bool? GpuSupportsRayTracing, bool? GpuSupportsComputeShaders, bool? GpuSupportsGeometryShaders, string? GpuVendorId, bool? GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel, string? UnityInstallMode, string? UnityTargetFrameRate, string? UnityCopyTextureSupport, string? UnityRenderingThreadingMode)
		{
			SentryNativeBridgeWriteScope(GpuId.GetValueOrDefault(), GpuName, GpuVendorName, GpuMemorySize.GetValueOrDefault(), GpuNpotSupport, GpuVersion, GpuApiType, GpuMaxTextureSize.GetValueOrDefault(), marshallNullableBool(GpuSupportsDrawCallInstancing), marshallNullableBool(GpuSupportsRayTracing), marshallNullableBool(GpuSupportsComputeShaders), marshallNullableBool(GpuSupportsGeometryShaders), GpuVendorId, marshallNullableBool(GpuMultiThreadedRendering), GpuGraphicsShaderLevel, UnityInstallMode, UnityTargetFrameRate, UnityCopyTextureSupport, UnityRenderingThreadingMode);
		}

		private static sbyte marshallNullableBool(bool? value)
		{
			return (sbyte)((!value.HasValue) ? (-1) : (value.Value ? 1 : 0));
		}

		[DllImport("__Internal")]
		private static extern void SentryNativeBridgeWriteScope(int GpuId, string? GpuName, string? GpuVendorName, int GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int GpuMaxTextureSize, sbyte GpuSupportsDrawCallInstancing, sbyte GpuSupportsRayTracing, sbyte GpuSupportsComputeShaders, sbyte GpuSupportsGeometryShaders, string? GpuVendorId, sbyte GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel, string? UnityInstallMode, string? UnityTargetFrameRate, string? UnityCopyTextureSupport, string? UnityRenderingThreadingMode);
	}
	public class NativeScopeObserver : ScopeObserver
	{
		public NativeScopeObserver(string name, SentryOptions options)
			: base(name, options)
		{
		}

		public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			int breadcrumbLevel = GetBreadcrumbLevel(breadcrumb.Level);
			SentryCocoaBridgeProxy.SentryNativeBridgeAddBreadcrumb(GetTimestamp(breadcrumb.Timestamp), breadcrumb.Message, breadcrumb.Type, breadcrumb.Category, breadcrumbLevel);
		}

		public override void SetExtraImpl(string key, string? value)
		{
			SentryCocoaBridgeProxy.SentryNativeBridgeSetExtra(key, value);
		}

		public override void SetTagImpl(string key, string value)
		{
			SentryCocoaBridgeProxy.SentryNativeBridgeSetTag(key, value);
		}

		public override void UnsetTagImpl(string key)
		{
			SentryCocoaBridgeProxy.SentryNativeBridgeUnsetTag(key);
		}

		public override void SetUserImpl(User user)
		{
			SentryCocoaBridgeProxy.SentryNativeBridgeSetUser(user.Email, user.Id, user.IpAddress, user.Username);
		}

		public override void UnsetUserImpl()
		{
			SentryCocoaBridgeProxy.SentryNativeBridgeUnsetUser();
		}

		internal static string GetTimestamp(DateTimeOffset timestamp)
		{
			return timestamp.ToString("o");
		}

		internal static int GetBreadcrumbLevel(BreadcrumbLevel breadcrumbLevel)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected I4, but got Unknown
			return (breadcrumbLevel - -1) switch
			{
				0 => 1, 
				1 => 2, 
				2 => 3, 
				3 => 4, 
				4 => 5, 
				_ => 0, 
			};
		}
	}
	internal static class SentryCocoaBridgeProxy
	{
		public static bool Init(SentryUnityOptions options)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			if (LoadLibrary() != 1)
			{
				return false;
			}
			IntPtr options2 = OptionsNew();
			OptionsSetString(options2, "dsn", ((SentryOptions)options).Dsn);
			if (((SentryOptions)options).Release != null)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger, "Setting Release: {0}", ((SentryOptions)options).Release);
				}
				OptionsSetString(options2, "release", ((SentryOptions)options).Release);
			}
			if (((SentryOptions)options).Environment != null)
			{
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger2, "Setting Environment: {0}", ((SentryOptions)options).Environment);
				}
				OptionsSetString(options2, "environment", ((SentryOptions)options).Environment);
			}
			IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger3 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<bool>(diagnosticLogger3, "Setting Debug: {0}", ((SentryOptions)options).Debug);
			}
			OptionsSetInt(options2, "debug", ((SentryOptions)options).Debug ? 1 : 0);
			SentryLevel diagnosticLevel = ((SentryOptions)options).DiagnosticLevel;
			string text = ((object)(SentryLevel)(ref diagnosticLevel)).ToString().ToLowerInvariant();
			IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger4 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger4, "Setting DiagnosticLevel: {0}", text);
			}
			OptionsSetString(options2, "diagnosticLevel", text);
			IDiagnosticLogger diagnosticLogger5 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger5 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<bool>(diagnosticLogger5, "Setting SendDefaultPii: {0}", ((SentryOptions)options).SendDefaultPii);
			}
			OptionsSetInt(options2, "sendDefaultPii", ((SentryOptions)options).SendDefaultPii ? 1 : 0);
			OptionsSetInt(options2, "attachScreenshot", 0);
			IDiagnosticLogger diagnosticLogger6 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger6 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<int>(diagnosticLogger6, "Setting MaxBreadcrumbs: {0}", ((SentryOptions)options).MaxBreadcrumbs);
			}
			OptionsSetInt(options2, "maxBreadcrumbs", ((SentryOptions)options).MaxBreadcrumbs);
			IDiagnosticLogger diagnosticLogger7 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger7 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<int>(diagnosticLogger7, "Setting MaxCacheItems: {0}", ((SentryOptions)options).MaxCacheItems);
			}
			OptionsSetInt(options2, "maxCacheItems", ((SentryOptions)options).MaxCacheItems);
			StartWithOptions(options2);
			return true;
		}

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeLoadLibrary")]
		private static extern int LoadLibrary();

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeOptionsNew")]
		private static extern IntPtr OptionsNew();

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeOptionsSetString")]
		private static extern void OptionsSetString(IntPtr options, string name, string value);

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeOptionsSetInt")]
		private static extern void OptionsSetInt(IntPtr options, string name, int value);

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeStartWithOptions")]
		private static extern void StartWithOptions(IntPtr options);

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeCrashedLastRun")]
		public static extern int CrashedLastRun();

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeClose")]
		public static extern void Close();

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeAddBreadcrumb(string timestamp, string? message, string? type, string? category, int level);

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeSetExtra(string key, string? value);

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeSetTag(string key, string value);

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeUnsetTag(string key);

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeSetUser(string? email, string? userId, string? ipAddress, string? username);

		[DllImport("__Internal")]
		public static extern void SentryNativeBridgeUnsetUser();

		[DllImport("__Internal", EntryPoint = "SentryNativeBridgeGetInstallationId")]
		public static extern string GetInstallationId();
	}
	public static class SentryNativeCocoa
	{
		public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Configure(options, sentryUnityInfo, ApplicationAdapter.Instance.Platform);
		}

		internal static void Configure(SentryUnityOptions options, ISentryUnityInfo sentryUnityInfo, RuntimePlatform platform)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			SentryUnityOptions options2 = options;
			if ((int)platform != 1)
			{
				if ((int)platform != 8)
				{
					IDiagnosticLogger diagnosticLogger = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger != null)
					{
						DiagnosticLoggerExtensions.LogWarning<RuntimePlatform>(diagnosticLogger, "Cocoa SentryNative.Configure() called for unsupported platform: '{0}'", platform);
					}
					return;
				}
				if (!options2.IosNativeSupportEnabled)
				{
					return;
				}
				((SentryOptions)options2).ScopeObserver = (IScopeObserver)(object)new NativeScopeObserver("iOS", (SentryOptions)(object)options2);
			}
			else
			{
				if (!options2.MacosNativeSupportEnabled)
				{
					return;
				}
				if (!SentryCocoaBridgeProxy.Init(options2))
				{
					IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger2 != null)
					{
						DiagnosticLoggerExtensions.LogWarning(diagnosticLogger2, "Failed to initialize the native SDK");
					}
					return;
				}
				((SentryOptions)options2).ScopeObserver = (IScopeObserver)(object)new NativeScopeObserver("macOS", (SentryOptions)(object)options2);
			}
			options2.NativeContextWriter = (ContextWriter)(object)new NativeContextWriter();
			((SentryOptions)options2).EnableScopeSync = true;
			((SentryOptions)options2).CrashedLastRun = delegate
			{
				bool flag = SentryCocoaBridgeProxy.CrashedLastRun() == 1;
				IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger4 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<bool>(diagnosticLogger4, "Native SDK reported: 'crashedLastRun': '{0}'", flag);
				}
				return flag;
			};
			ApplicationAdapter.Instance.Quitting += delegate
			{
				IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger3 != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger3, "Closing the sentry-cocoa SDK");
				}
				SentryCocoaBridgeProxy.Close();
			};
			if (sentryUnityInfo.IL2CPP)
			{
				options2.DefaultUserId = SentryCocoaBridgeProxy.GetInstallationId();
			}
		}
	}
}

Sentry.Unity.Native.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AOT;
using Microsoft.CodeAnalysis;
using Sentry.Extensibility;
using Sentry.Unity.Integrations;
using Sentry.Unity.NativeUtils;
using UnityEngine;
using UnityEngine.Analytics;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Sentry.Unity.Native.Tests")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Sentry.Unity.Native")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.23.1.0")]
[assembly: AssemblyInformationalVersion("0.23.1")]
[assembly: AssemblyProduct("Sentry.Unity.Native")]
[assembly: AssemblyTitle("Sentry.Unity.Native")]
[assembly: AssemblyVersion("0.23.1.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

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

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

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

		public string[] Members { get; }

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

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace Sentry.Unity.Native
{
	internal class NativeContextWriter : ContextWriter
	{
		protected override void WriteScope(string? AppStartTime, string? AppBuildType, string? OperatingSystemRawDescription, int? DeviceProcessorCount, string? DeviceCpuDescription, string? DeviceTimezone, bool? DeviceSupportsVibration, string? DeviceName, bool? DeviceSimulator, string? DeviceDeviceUniqueIdentifier, string? DeviceDeviceType, string? DeviceModel, long? DeviceMemorySize, int? GpuId, string? GpuName, string? GpuVendorName, int? GpuMemorySize, string? GpuNpotSupport, string? GpuVersion, string? GpuApiType, int? GpuMaxTextureSize, bool? GpuSupportsDrawCallInstancing, bool? GpuSupportsRayTracing, bool? GpuSupportsComputeShaders, bool? GpuSupportsGeometryShaders, string? GpuVendorId, bool? GpuMultiThreadedRendering, string? GpuGraphicsShaderLevel, string? UnityInstallMode, string? UnityTargetFrameRate, string? UnityCopyTextureSupport, string? UnityRenderingThreadingMode)
		{
			ContextWriter.WriteApp(AppStartTime, AppBuildType);
			ContextWriter.WriteOS(OperatingSystemRawDescription);
			ContextWriter.WriteDevice(DeviceProcessorCount, DeviceCpuDescription, DeviceTimezone, DeviceSupportsVibration, DeviceName, DeviceSimulator, DeviceDeviceUniqueIdentifier, DeviceDeviceType, DeviceModel, DeviceMemorySize);
			ContextWriter.WriteGpu(GpuId, GpuName, GpuVendorName, GpuMemorySize, GpuNpotSupport, GpuVersion, GpuApiType, GpuMaxTextureSize, GpuSupportsDrawCallInstancing, GpuSupportsRayTracing, GpuSupportsComputeShaders, GpuSupportsGeometryShaders, GpuVendorId, GpuMultiThreadedRendering, GpuGraphicsShaderLevel);
			ContextWriter.WriteUnity(UnityInstallMode, UnityTargetFrameRate, UnityCopyTextureSupport, UnityRenderingThreadingMode);
		}
	}
	public class NativeScopeObserver : ScopeObserver
	{
		public NativeScopeObserver(SentryOptions options)
			: base("Native", options)
		{
		}

		public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			sentry_value_t val = C.sentry_value_new_breadcrumb(breadcrumb.Type, breadcrumb.Message);
			BreadcrumbLevel level = breadcrumb.Level;
			C.sentry_value_set_by_key(val, "level", C.sentry_value_new_string(((object)(BreadcrumbLevel)(ref level)).ToString().ToLower()));
			C.sentry_value_set_by_key(val, "timestamp", C.sentry_value_new_string(GetTimestamp(breadcrumb.Timestamp)));
			C.SetValueIfNotNull(val, "category", breadcrumb.Category);
			C.sentry_add_breadcrumb(val);
		}

		public override void SetExtraImpl(string key, string? value)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			C.sentry_set_extra(key, (value == null) ? C.sentry_value_new_null() : C.sentry_value_new_string(value));
		}

		public override void SetTagImpl(string key, string value)
		{
			C.sentry_set_tag(key, value);
		}

		public override void UnsetTagImpl(string key)
		{
			C.sentry_remove_tag(key);
		}

		public override void SetUserImpl(User user)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			sentry_value_t val = C.sentry_value_new_object();
			C.SetValueIfNotNull(val, "id", user.Id);
			C.SetValueIfNotNull(val, "username", user.Username);
			C.SetValueIfNotNull(val, "email", user.Email);
			C.SetValueIfNotNull(val, "ip_address", user.IpAddress);
			C.sentry_set_user(val);
		}

		public override void UnsetUserImpl()
		{
			C.sentry_remove_user();
		}

		private static string GetTimestamp(DateTimeOffset timestamp)
		{
			return timestamp.ToString("o");
		}
	}
	public static class SentryNative
	{
		private static readonly Dictionary<string, bool> PerDirectoryCrashInfo = new Dictionary<string, bool>();

		public static void Configure(SentryUnityOptions options)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			SentryUnityOptions options2 = options;
			RuntimePlatform platform = ApplicationAdapter.Instance.Platform;
			if (!(((int)platform == 2) ? options2.WindowsNativeSupportEnabled : ((int)platform == 13 && options2.LinuxNativeSupportEnabled)))
			{
				return;
			}
			if (!SentryNativeBridge.Init(options2))
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogWarning(diagnosticLogger, "Sentry native initialization failed - native crashes are not captured.");
				}
				return;
			}
			ApplicationAdapter.Instance.Quitting += delegate
			{
				IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options2).DiagnosticLogger;
				if (diagnosticLogger3 != null)
				{
					DiagnosticLoggerExtensions.LogDebug(diagnosticLogger3, "Closing the sentry-native SDK");
				}
				SentryNativeBridge.Close();
			};
			((SentryOptions)options2).ScopeObserver = (IScopeObserver)(object)new NativeScopeObserver((SentryOptions)(object)options2);
			((SentryOptions)options2).EnableScopeSync = true;
			options2.NativeContextWriter = (ContextWriter)(object)new NativeContextWriter();
			options2.DefaultUserId = AnalyticsSessionInfo.userId;
			if (options2.DefaultUserId != null)
			{
				((SentryOptions)options2).ScopeObserver.SetUser(new User
				{
					Id = options2.DefaultUserId
				});
			}
			string cacheDirectory = SentryNativeBridge.GetCacheDirectory(options2);
			bool crashedLastRun = false;
			lock (PerDirectoryCrashInfo)
			{
				if (!PerDirectoryCrashInfo.TryGetValue(cacheDirectory, out crashedLastRun))
				{
					crashedLastRun = SentryNativeBridge.HandleCrashedLastRun(options2);
					PerDirectoryCrashInfo.Add(cacheDirectory, crashedLastRun);
					IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options2).DiagnosticLogger;
					if (diagnosticLogger2 != null)
					{
						DiagnosticLoggerExtensions.LogDebug<bool>(diagnosticLogger2, "Native SDK reported: 'crashedLastRun': '{0}'", crashedLastRun);
					}
				}
			}
			((SentryOptions)options2).CrashedLastRun = () => crashedLastRun;
		}
	}
	public static class SentryNativeBridge
	{
		[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
		private delegate void sentry_logger_function_t(int level, IntPtr message, IntPtr argsAddress, IntPtr userData);

		[StructLayout(LayoutKind.Sequential, Pack = 4)]
		private struct VaListLinux64
		{
			private uint gp_offset;

			private uint fp_offset;

			private IntPtr overflow_arg_area;

			private IntPtr reg_save_area;
		}

		public static bool CrashedLastRun;

		private static IDiagnosticLogger? _logger;

		private static bool _isLinux;

		public static bool Init(SentryUnityOptions options)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Invalid comparison between Unknown and I4
			_isLinux = (int)ApplicationAdapter.Instance.Platform == 13;
			IntPtr options2 = sentry_options_new();
			sentry_options_set_dsn(options2, ((SentryOptions)options).Dsn);
			if (((SentryOptions)options).Release != null)
			{
				IDiagnosticLogger diagnosticLogger = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger, "Setting Release: {0}", ((SentryOptions)options).Release);
				}
				sentry_options_set_release(options2, ((SentryOptions)options).Release);
			}
			if (((SentryOptions)options).Environment != null)
			{
				IDiagnosticLogger diagnosticLogger2 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger2 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger2, "Setting Environment: {0}", ((SentryOptions)options).Environment);
				}
				sentry_options_set_environment(options2, ((SentryOptions)options).Environment);
			}
			IDiagnosticLogger diagnosticLogger3 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger3 != null)
			{
				DiagnosticLoggerExtensions.LogDebug<bool>(diagnosticLogger3, "Setting Debug: {0}", ((SentryOptions)options).Debug);
			}
			sentry_options_set_debug(options2, ((SentryOptions)options).Debug ? 1 : 0);
			if (((SentryOptions)options).SampleRate.HasValue)
			{
				IDiagnosticLogger diagnosticLogger4 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger4 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<float>(diagnosticLogger4, "Setting Sample Rate: {0}", ((SentryOptions)options).SampleRate.Value);
				}
				sentry_options_set_sample_rate(options2, ((SentryOptions)options).SampleRate.Value);
			}
			IDiagnosticLogger diagnosticLogger5 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger5 != null)
			{
				DiagnosticLoggerExtensions.LogDebug(diagnosticLogger5, "Disabling native auto session tracking");
			}
			sentry_options_set_auto_session_tracking(options2, 0);
			string cacheDirectory = GetCacheDirectory(options);
			if ((int)ApplicationAdapter.Instance.Platform == 2)
			{
				IDiagnosticLogger diagnosticLogger6 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger6 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger6, "Setting CacheDirectoryPath on Windows: {0}", cacheDirectory);
				}
				sentry_options_set_database_pathw(options2, cacheDirectory);
			}
			else
			{
				IDiagnosticLogger diagnosticLogger7 = ((SentryOptions)options).DiagnosticLogger;
				if (diagnosticLogger7 != null)
				{
					DiagnosticLoggerExtensions.LogDebug<string>(diagnosticLogger7, "Setting CacheDirectoryPath: {0}", cacheDirectory);
				}
				sentry_options_set_database_path(options2, cacheDirectory);
			}
			if (((SentryOptions)options).DiagnosticLogger == null)
			{
				IDiagnosticLogger? logger = _logger;
				if (logger != null)
				{
					DiagnosticLoggerExtensions.LogDebug(logger, "Unsetting the current native logger");
				}
				_logger = null;
			}
			else
			{
				DiagnosticLoggerExtensions.LogDebug(((SentryOptions)options).DiagnosticLogger, ((_logger == null) ? "Setting a" : "Replacing the") + " native logger");
				_logger = ((SentryOptions)options).DiagnosticLogger;
				sentry_options_set_logger(options2, nativeLog, IntPtr.Zero);
			}
			IDiagnosticLogger diagnosticLogger8 = ((SentryOptions)options).DiagnosticLogger;
			if (diagnosticLogger8 != null)
			{
				DiagnosticLoggerExtensions.LogDebug(diagnosticLogger8, "Initializing sentry native");
			}
			return sentry_init(options2) == 0;
		}

		public static void Close()
		{
			sentry_close();
		}

		internal static bool HandleCrashedLastRun(SentryUnityOptions options)
		{
			bool result = sentry_get_crashed_last_run() == 1;
			sentry_clear_crashed_last_run();
			return result;
		}

		internal static string GetCacheDirectory(SentryUnityOptions options)
		{
			if (((SentryOptions)options).CacheDirectoryPath == null)
			{
				return Path.Combine(Directory.GetCurrentDirectory(), ".sentry-native");
			}
			return Path.Combine(((SentryOptions)options).CacheDirectoryPath, "SentryNative");
		}

		[DllImport("sentry")]
		private static extern IntPtr sentry_options_new();

		[DllImport("sentry")]
		private static extern void sentry_options_set_dsn(IntPtr options, string dsn);

		[DllImport("sentry")]
		private static extern void sentry_options_set_release(IntPtr options, string release);

		[DllImport("sentry")]
		private static extern void sentry_options_set_debug(IntPtr options, int debug);

		[DllImport("sentry")]
		private static extern void sentry_options_set_environment(IntPtr options, string environment);

		[DllImport("sentry")]
		private static extern void sentry_options_set_sample_rate(IntPtr options, double rate);

		[DllImport("sentry")]
		private static extern void sentry_options_set_database_path(IntPtr options, string path);

		[DllImport("sentry")]
		private static extern void sentry_options_set_database_pathw(IntPtr options, [MarshalAs(UnmanagedType.LPWStr)] string path);

		[DllImport("sentry")]
		private static extern void sentry_options_set_auto_session_tracking(IntPtr options, int debug);

		[DllImport("sentry")]
		private static extern void sentry_options_set_logger(IntPtr options, sentry_logger_function_t logger, IntPtr userData);

		[MonoPInvokeCallback(typeof(sentry_logger_function_t))]
		private static void nativeLog(int cLevel, IntPtr format, IntPtr args, IntPtr userData)
		{
			try
			{
				nativeLogImpl(cLevel, format, args, userData);
			}
			catch
			{
			}
		}

		private static void nativeLogImpl(int cLevel, IntPtr format, IntPtr args, IntPtr userData)
		{
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			IDiagnosticLogger logger = _logger;
			if (logger == null || format == IntPtr.Zero || args == IntPtr.Zero)
			{
				return;
			}
			SentryLevel val = (SentryLevel)(cLevel switch
			{
				-1 => 0, 
				0 => 1, 
				1 => 2, 
				2 => 3, 
				3 => 4, 
				_ => 1, 
			});
			if (!logger.IsEnabled(val))
			{
				return;
			}
			string message = null;
			try
			{
				if (_isLinux)
				{
					VaListLinux64 argsStruct = Marshal.PtrToStructure<VaListLinux64>(args);
					int formattedLength2 = 0;
					WithMarshalledStruct(argsStruct, delegate(IntPtr argsPtr)
					{
						formattedLength2 = 1 + vsnprintf_linux(IntPtr.Zero, UIntPtr.Zero, format, argsPtr);
					});
					WithAllocatedPtr(formattedLength2, delegate(IntPtr buffer)
					{
						WithMarshalledStruct(argsStruct, delegate(IntPtr argsPtr)
						{
							vsnprintf_linux(buffer, (UIntPtr)(ulong)formattedLength2, format, argsPtr);
							message = Marshal.PtrToStringAnsi(buffer);
						});
					});
				}
				else
				{
					int formattedLength = 1 + vsnprintf_windows(IntPtr.Zero, UIntPtr.Zero, format, args);
					WithAllocatedPtr(formattedLength, delegate(IntPtr buffer)
					{
						vsnprintf_windows(buffer, (UIntPtr)(ulong)formattedLength, format, args);
						message = Marshal.PtrToStringAnsi(buffer);
					});
				}
			}
			catch (Exception ex)
			{
				DiagnosticLoggerExtensions.LogError(logger, "Exception in native log forwarder.", ex);
			}
			if (message == null)
			{
				message = Marshal.PtrToStringAnsi(format);
			}
			if (message != null)
			{
				logger.Log(val, "Native: " + message, (Exception)null, Array.Empty<object>());
			}
		}

		[DllImport("msvcrt", EntryPoint = "vsnprintf")]
		private static extern int vsnprintf_windows(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);

		[DllImport("libc", EntryPoint = "vsnprintf")]
		private static extern int vsnprintf_linux(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);

		private static void WithAllocatedPtr(int size, Action<IntPtr> action)
		{
			IntPtr intPtr = IntPtr.Zero;
			try
			{
				intPtr = Marshal.AllocHGlobal(size);
				action(intPtr);
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}

		private static void WithMarshalledStruct<T>(T structure, Action<IntPtr> action) where T : notnull
		{
			T structure2 = structure;
			Action<IntPtr> action2 = action;
			WithAllocatedPtr(Marshal.SizeOf(structure2), delegate(IntPtr ptr)
			{
				Marshal.StructureToPtr(structure2, ptr, fDeleteOld: false);
				action2(ptr);
			});
		}

		[DllImport("sentry")]
		private static extern int sentry_init(IntPtr options);

		[DllImport("sentry")]
		private static extern int sentry_close();

		[DllImport("sentry")]
		private static extern int sentry_get_crashed_last_run();

		[DllImport("sentry")]
		private static extern int sentry_clear_crashed_last_run();
	}
}

ConfigurationManager.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurationManager.Patches.GameSetting;
using ConfigurationManager.Patches.UI;
using ConfigurationManager.UIFactory.CustomBehaviours;
using ConfigurationManager.Utilities;
using HarmonyLib;
using LordAshes;
using ModdingTales;
using SRF;
using Sentry;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyProduct("BepInEx.ConfigurationManager")]
[assembly: AssemblyTitle("BepInEx.ConfigurationManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("https://github.com/BepInEx/BepInEx.ConfigurationManager")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.14.0.0")]
public sealed class ConfigurationManagerAttributes
{
	public bool? Browsable;

	public Action<object> CallbackAction;

	public string Category;

	public Func<ConfigEntryBase, GameObject> CustomDrawer;

	public object DefaultValue;

	public string Description;

	public string DispName;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public bool? IsAdvanced;

	public bool? IsJSON;

	public Func<object, string> ObjToStr;

	public int? Order;

	public bool? ReadOnly;

	public bool? ShowRangeAsPercent;

	public Func<string, object> StrToObj;
}
namespace ConfigurationManager
{
	[BepInPlugin("com.hf.hollofox.configurationmanager", "Config Manager", "0.14.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class ConfigurationManager : BaseUnityPlugin
	{
		public enum logToSentry
		{
			Inherited,
			Disabled,
			Enabled
		}

		public const string Guid = "com.hf.hollofox.configurationmanager";

		public const string Version = "0.14.0.0";

		internal static ManualLogSource _logger;

		internal static ConfigurationManager _instance;

		internal static SentryOptions _sentryOptions = new SentryOptions
		{
			Dsn = "https://[email protected]/6778961",
			Debug = true,
			TracesSampleRate = 0.2,
			IsGlobalModeEnabled = true,
			AttachStacktrace = true
		};

		internal static Action<Scope> _scope = delegate(Scope scope)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			scope.User = new User
			{
				Username = UserNameManager.Username
			};
			scope.Release = "0.14.0.0";
		};

		private static ConfigEntry<LogLevel> _logLevel;

		public static ConfigEntry<logToSentry> _useSentry;

		internal static LogLevel LogLevel
		{
			get
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				if ((int)_logLevel.Value != 0)
				{
					return _logLevel.Value;
				}
				return ModdingUtils.LogLevelConfig.Value;
			}
		}

		internal static logToSentry useSentry => _useSentry.Value;

		public ConfigurationManager()
		{
			_instance = this;
			_useSentry = ((BaseUnityPlugin)this).Config.Bind<logToSentry>("Filtering", "Send Errors to Dashboard", logToSentry.Disabled, (ConfigDescription)null);
			_logger = ((BaseUnityPlugin)this).Logger;
			Utils.SentryInvoke(Setup);
		}

		private void Setup()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			_logLevel = ((BaseUnityPlugin)this).Config.Bind<LogLevel>("Filtering", "Show Logs", (LogLevel)0, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					IsAdvanced = true
				}
			}));
			_logger.LogEvent += logFowarding;
			new Harmony("com.hf.hollofox.configurationmanager").PatchAll();
			ModdingUtils.Initialize((BaseUnityPlugin)(object)this, ((BaseUnityPlugin)this).Logger, "HolloFoxes'", false);
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void logFowarding(object o, LogEventArgs e)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (useSentry != logToSentry.Enabled)
			{
				return;
			}
			LogLevel level = e.Level;
			if ((int)level != 1)
			{
				if ((int)level == 2)
				{
					SentrySdk.CaptureMessage(e.Data.ToString(), _scope, (SentryLevel)3);
				}
			}
			else
			{
				SentrySdk.CaptureMessage(e.Data.ToString(), _scope, (SentryLevel)4);
			}
		}

		public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			GameSettingsSetupPatch.AlreadyRan = false;
		}
	}
	internal static class SettingSearcher
	{
		public static void CollectSettings(out IEnumerable<ConfigEntryBase> results, out List<string> modsWithoutSettings, out BaseUnityPlugin[] plugins)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			modsWithoutSettings = new List<string>();
			List<ConfigEntryBase> list = new List<ConfigEntryBase>();
			try
			{
				list.AddRange(GetBepInExCoreConfig());
			}
			catch (Exception ex)
			{
				results = Enumerable.Empty<ConfigEntryBase>();
				if ((int)ConfigurationManager.LogLevel != 1)
				{
					ConfigurationManager._logger.LogError((object)ex);
				}
			}
			plugins = Utils.FindPlugins();
			results = list.AsEnumerable();
		}

		private static IEnumerable<ConfigEntryBase> GetBepInExCoreConfig()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			//IL_007c: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			PropertyInfo? property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic);
			if (property == null)
			{
				throw new ArgumentNullException("coreConfigProp");
			}
			ConfigFile val = (ConfigFile)property.GetValue(null, null);
			if ((int)ConfigurationManager.LogLevel == 5)
			{
				BepInPlugin val2 = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString());
				ConfigurationManager._logger.LogInfo((object)val2);
			}
			return from c in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)val).ToArray()
				select c.Value;
		}

		internal static IEnumerable<ConfigEntryBase> GetPluginConfig(BaseUnityPlugin plugin)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)ConfigurationManager.LogLevel != 1)
			{
				ConfigurationManager._logger.LogInfo((object)plugin);
			}
			return from c in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).ToArray()
				select c.Value;
		}
	}
}
namespace ConfigurationManager.Utilities
{
	public static class Utils
	{
		private static Stopwatch _timer = new Stopwatch();

		internal static void SentryInvoke(Action a)
		{
			SentryInvoke(a, ConfigurationManager._sentryOptions, ConfigurationManager._logger);
		}

		public static void SentryInvoke(Action a, SentryOptions sentryOptions, ManualLogSource logger)
		{
			if (ConfigurationManager.useSentry > ConfigurationManager.logToSentry.Disabled)
			{
				using (SentrySdk.Init(sentryOptions))
				{
					_timer.Restart();
					try
					{
						a();
						_timer.Stop();
						if (_timer.ElapsedMilliseconds > 10)
						{
							logger.LogWarning((object)$"Action ({a.Method.Name}) took: {_timer.ElapsedTicks} µs");
						}
						return;
					}
					catch (Exception item)
					{
						_timer.Stop();
						logger.LogError((object)(item, _timer.ElapsedTicks));
						return;
					}
				}
			}
			a();
		}

		public static BaseUnityPlugin[] FindPlugins()
		{
			return Chainloader.Plugins.Concat(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).Distinct().ToArray();
		}

		public static bool IsNumber(this object value)
		{
			if (!(value is sbyte) && !(value is byte) && !(value is short) && !(value is ushort) && !(value is int) && !(value is uint) && !(value is long) && !(value is ulong) && !(value is float) && !(value is double))
			{
				return value is decimal;
			}
			return true;
		}
	}
}
namespace ConfigurationManager.UIFactory.CustomBehaviours
{
	public sealed class ColorBehaviour : MonoBehaviour
	{
		public Action<object> CallbackAction;
	}
	public sealed class DropDownBehaviour : MonoBehaviour
	{
		internal ConfigurationManagerAttributes Attributes;

		internal ConfigEntryBase Entry;

		private void Awake()
		{
			Utils.SentryInvoke(Setup);
		}

		internal void Setup()
		{
			if (Entry == null)
			{
				return;
			}
			SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
			((Component)this).gameObject.GetComponent<UI_LabelReference>().SetText(Entry.Definition.Key);
			TMP_Dropdown tmp_dropdown = ((Component)this).gameObject.GetComponent<TMP_Dropdown>();
			tmp_dropdown.ClearOptions();
			Array values = Enum.GetValues(Entry.BoxedValue.GetType());
			List<string> list = new List<string>();
			foreach (object item in values)
			{
				list.Add(item.ToString());
			}
			tmp_dropdown.AddOptions(list);
			int value = -1;
			for (int j = 0; j < values.Length; j++)
			{
				if (list[j] == Entry.BoxedValue.ToString())
				{
					value = j;
				}
			}
			((UnityEventBase)tmp_dropdown.onValueChanged).RemoveAllListeners();
			((UnityEvent<int>)(object)tmp_dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int i)
			{
				Utils.SentryInvoke(delegate
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Invalid comparison between Unknown and I4
					//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c1: Invalid comparison between Unknown and I4
					if ((int)ConfigurationManager.LogLevel >= 4)
					{
						ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
					}
					Entry.BoxedValue = Enum.Parse(Entry.BoxedValue.GetType(), tmp_dropdown.options[i].text);
					Attributes?.CallbackAction?.Invoke(i);
					if ((int)ConfigurationManager.LogLevel >= 4)
					{
						ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
					}
				});
			});
			tmp_dropdown.value = value;
			if (Entry.Description.Tags.Length == 0)
			{
				return;
			}
			object[] tags = Entry.Description.Tags;
			for (int k = 0; k < tags.Length; k++)
			{
				if (tags[k] is ConfigurationManagerAttributes attributes)
				{
					Attributes = attributes;
				}
			}
		}

		private void RevertToDefault()
		{
			Entry.BoxedValue = Entry.DefaultValue;
			((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
		}
	}
	public sealed class KeybindBehaviour : MonoBehaviour
	{
		internal ConfigurationManagerAttributes Attributes;

		internal ConfigEntryBase Entry;

		private void Awake()
		{
			Utils.SentryInvoke(Setup);
		}

		internal void Setup()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
			SRFGameObjectExtensions.RemoveComponentIfExists<UIListItemClickEvents>(((Component)((Component)this).gameObject.transform.GetChild(0)).gameObject);
			if (Entry == null)
			{
				return;
			}
			if (Entry.Description.Tags.Length != 0)
			{
				object[] tags = Entry.Description.Tags;
				for (int i = 0; i < tags.Length; i++)
				{
					if (tags[i] is ConfigurationManagerAttributes attributes)
					{
						Attributes = attributes;
					}
				}
			}
			((UnityEventBase)((Component)((Component)this).gameObject.transform.GetChild(1)).GetComponent<Button>().onClick).RemoveAllListeners();
			((UnityEvent)((Component)((Component)this).gameObject.transform.GetChild(1)).GetComponent<Button>().onClick).AddListener(new UnityAction(RevertToDefault));
			((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
			((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(2)).GetComponent<TextMeshProUGUI>()).SetText(Entry.Definition.Key, true);
		}

		private void RevertToDefault()
		{
			Entry.BoxedValue = Entry.DefaultValue;
			((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
		}

		private void Update()
		{
			if (((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(2)).GetComponent<TextMeshProUGUI>()).text != Entry.Definition.Key)
			{
				Setup();
			}
		}
	}
	public sealed class NumberBehaviour : MonoBehaviour
	{
		internal ConfigurationManagerAttributes Attributes;

		internal ConfigEntryBase Entry;

		internal float posy;

		private void Awake()
		{
			Utils.SentryInvoke(Setup);
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.localPosition.y != posy)
			{
				((Component)this).transform.localPosition = new Vector3(20f, posy);
			}
		}

		internal void Setup()
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
			SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
			if (Entry == null)
			{
				return;
			}
			if (Entry.Description.Tags.Length != 0)
			{
				object[] tags = Entry.Description.Tags;
				for (int i = 0; i < tags.Length; i++)
				{
					if (tags[i] is ConfigurationManagerAttributes attributes)
					{
						Attributes = attributes;
					}
				}
			}
			((TMP_Text)((Component)((Component)this).transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.Definition.Key;
			TextMeshProUGUI value = ((Component)((Component)this).transform.GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)value).text = Entry.BoxedValue.ToString();
			Button component = ((Component)((Component)this).transform.GetChild(1).GetChild(1)).GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				Utils.SentryInvoke(delegate
				{
					SystemMessage.AskForTextInput("Update " + Entry.Definition.Key + " Config", "Enter the desired number", "OK", (Action<string>)delegate(string t)
					{
						Utils.SentryInvoke(delegate
						{
							//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
							//IL_00c8: Invalid comparison between Unknown and I4
							//IL_0394: Unknown result type (might be due to invalid IL or missing references)
							//IL_039a: Invalid comparison between Unknown and I4
							Dictionary<Type, int> obj = new Dictionary<Type, int>
							{
								{
									typeof(sbyte),
									0
								},
								{
									typeof(byte),
									1
								},
								{
									typeof(short),
									2
								},
								{
									typeof(ushort),
									3
								},
								{
									typeof(int),
									4
								},
								{
									typeof(uint),
									5
								},
								{
									typeof(long),
									6
								},
								{
									typeof(ulong),
									7
								},
								{
									typeof(float),
									8
								},
								{
									typeof(double),
									9
								},
								{
									typeof(decimal),
									10
								}
							};
							if ((int)ConfigurationManager.LogLevel >= 4)
							{
								ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
							}
							switch (obj[Entry.BoxedValue.GetType()])
							{
							case 0:
							{
								if (sbyte.TryParse(t, out var result6))
								{
									Entry.BoxedValue = result6;
								}
								break;
							}
							case 1:
							{
								if (byte.TryParse(t, out var result10))
								{
									Entry.BoxedValue = result10;
								}
								break;
							}
							case 2:
							{
								if (short.TryParse(t, out var result2))
								{
									Entry.BoxedValue = result2;
								}
								break;
							}
							case 3:
							{
								if (ushort.TryParse(t, out var result8))
								{
									Entry.BoxedValue = result8;
								}
								break;
							}
							case 4:
							{
								if (int.TryParse(t, out var result4))
								{
									Entry.BoxedValue = result4;
								}
								break;
							}
							case 5:
							{
								if (uint.TryParse(t, out var result11))
								{
									Entry.BoxedValue = result11;
								}
								break;
							}
							case 6:
							{
								if (long.TryParse(t, out var result9))
								{
									Entry.BoxedValue = result9;
								}
								break;
							}
							case 7:
							{
								if (ulong.TryParse(t, out var result7))
								{
									Entry.BoxedValue = result7;
								}
								break;
							}
							case 8:
							{
								if (float.TryParse(t, out var result5))
								{
									Entry.BoxedValue = result5;
								}
								break;
							}
							case 9:
							{
								if (double.TryParse(t, out var result3))
								{
									Entry.BoxedValue = result3;
								}
								break;
							}
							case 10:
							{
								if (decimal.TryParse(t, out var result))
								{
									Entry.BoxedValue = result;
								}
								break;
							}
							}
							((TMP_Text)value).text = Entry.BoxedValue.ToString();
							if ((int)ConfigurationManager.LogLevel >= 4)
							{
								ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
							}
						});
						Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
					}, (Action)null, "Cancel", (Action)null, Entry.BoxedValue.ToString());
				});
			});
		}
	}
	public sealed class SliderBehaviour : MonoBehaviour
	{
		public Action<object> CallbackAction;
	}
	public sealed class TextBehaviour : MonoBehaviour
	{
		internal ConfigurationManagerAttributes Attributes;

		internal ConfigEntryBase Entry;

		internal float posy;

		internal TextMeshProUGUI value;

		private void Awake()
		{
			Utils.SentryInvoke(Setup);
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.localPosition.y != posy)
			{
				((Component)this).transform.localPosition = new Vector3(20f, posy);
			}
		}

		private void OnGUI()
		{
			ConfigEditorPlugin.Render();
		}

		internal void Setup()
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
			SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
			if (Entry == null)
			{
				return;
			}
			if (Entry.Description.Tags.Length != 0)
			{
				object[] tags = Entry.Description.Tags;
				for (int i = 0; i < tags.Length; i++)
				{
					if (tags[i] is ConfigurationManagerAttributes attributes)
					{
						Attributes = attributes;
					}
				}
			}
			((TMP_Text)((Component)((Component)this).transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.Definition.Key;
			value = ((Component)((Component)this).transform.GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)value).text = Entry.BoxedValue.ToString();
			Button component = ((Component)((Component)this).transform.GetChild(1).GetChild(1)).GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			ConfigurationManagerAttributes attributes2 = Attributes;
			if (attributes2 != null && attributes2.IsJSON.HasValue && Attributes.IsJSON.Value)
			{
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEvent)component.onClick).AddListener((UnityAction)delegate
				{
					Utils.SentryInvoke(delegate
					{
						SystemMessage.ClosePendingMessage();
						ConfigEditorPlugin.Subscribe((Action<string, string>)delegate(string s1, string s2)
						{
							Utils.SentryInvoke(delegate
							{
								EditorCallback(s1, s2);
							});
							Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
						});
						ConfigEditorPlugin.offsetXToEntry = 120;
						ConfigEditorPlugin.Open(Entry.Definition.Key, (string)Entry.BoxedValue, new string[2] { "Cancel", "Save" });
					});
				});
				return;
			}
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				Utils.SentryInvoke(delegate
				{
					SystemMessage.AskForTextInput("Update " + Entry.Definition.Key + " Config", "Enter the desired text", "OK", (Action<string>)delegate(string t)
					{
						Utils.SentryInvoke(delegate
						{
							Save(t);
						});
						Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
					}, (Action)null, "Cancel", (Action)null, Entry.BoxedValue.ToString());
				});
			});
		}

		private void EditorCallback(string button, string json)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			if (!(button == "Save"))
			{
				if (button == "Cancel")
				{
					ConfigEditorPlugin.Close();
				}
				else if ((int)ConfigurationManager.LogLevel >= 2)
				{
					ConfigurationManager._logger.LogInfo((object)("Editor Callback for " + Entry.Definition.Key + " had a button with wrong text."));
				}
			}
			else
			{
				Save(json);
				ConfigEditorPlugin.Close();
			}
		}

		private void Save(string t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			if ((int)ConfigurationManager.LogLevel >= 4)
			{
				ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
			}
			Entry.BoxedValue = t;
			((TMP_Text)value).text = t;
			if ((int)ConfigurationManager.LogLevel >= 4)
			{
				ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
			}
		}
	}
	public sealed class ToggleBehaviour : MonoBehaviour
	{
		internal ConfigurationManagerAttributes Attributes;

		internal ConfigEntryBase Entry;

		private void Awake()
		{
			Utils.SentryInvoke(Setup);
		}

		internal void Setup()
		{
			if (Entry == null)
			{
				return;
			}
			SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
			((Component)this).gameObject.GetComponent<UI_LabelReference>().SetText(Entry.Definition.Key);
			Toggle component = ((Component)this).gameObject.GetComponent<Toggle>();
			((UnityEventBase)component.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)component.onValueChanged).AddListener((UnityAction<bool>)delegate(bool b)
			{
				Utils.SentryInvoke(delegate
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Invalid comparison between Unknown and I4
					//IL_0078: Unknown result type (might be due to invalid IL or missing references)
					//IL_007e: Invalid comparison between Unknown and I4
					if ((int)ConfigurationManager.LogLevel >= 4)
					{
						ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
					}
					Entry.BoxedValue = b;
					Attributes?.CallbackAction?.Invoke(b);
					if ((int)ConfigurationManager.LogLevel >= 4)
					{
						ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
					}
				});
			});
			component.isOn = (bool)Entry.BoxedValue;
			((Component)this).gameObject.GetComponentInChildren<UI_ToggleSwitchGraphic>().Toggle((bool)Entry.BoxedValue);
			if (Entry.Description.Tags.Length == 0)
			{
				return;
			}
			object[] tags = Entry.Description.Tags;
			for (int i = 0; i < tags.Length; i++)
			{
				if (tags[i] is ConfigurationManagerAttributes attributes)
				{
					Attributes = attributes;
				}
			}
		}
	}
}
namespace ConfigurationManager.Patches.UI
{
	internal static class UI_SwitchButtonGroupStartPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__10_0;

			public static Func<ConfigEntryBase, string> <>9__13_0;

			internal void <AddButton>b__10_0()
			{
				Utils.SentryInvoke(Click);
			}

			internal string <AddContent>b__13_0(ConfigEntryBase e)
			{
				return e.Definition.Section;
			}
		}

		internal static Button clone;

		internal static GameObject content;

		internal static GameObject original;

		private static GameObject _modNameHeader;

		private static GameObject _sectionHeader;

		private static GameObject _keybindTemplate;

		private static GameObject _dropDownTemplate;

		private static GameObject _toggleTemplate;

		private static GameObject _textFieldTemplate;

		private static Vector3 pos;

		private static void AddButton(UI_SwitchButtonGroup __instance, int i, Button template, string key, ref List<Button> ____buttons, float distance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			clone = Object.Instantiate<Button>(template);
			((Component)clone).transform.SetParent(((Component)__instance).transform, false);
			if (i >= ____buttons.Count)
			{
				____buttons.Add(clone);
			}
			else
			{
				____buttons[i] = clone;
			}
			((Object)((Component)clone).gameObject).name = key;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(((Component)clone).transform.position.x + distance * (float)i, ((Component)clone).transform.position.y, ((Component)clone).transform.position.z);
			Quaternion rotation = ((Component)clone).transform.rotation;
			((Component)clone).transform.SetPositionAndRotation(val, rotation);
			((UnityEventBase)clone.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick = clone.onClick;
			object obj = <>c.<>9__10_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					Utils.SentryInvoke(Click);
				};
				<>c.<>9__10_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			((Component)clone).gameObject.GetComponent<MouseTextOnHover>().mouseHoverText = "Plugin Configurations";
			((Component)clone).GetComponentsInChildren<Image>()[2].sprite = Image.LoadSprite("Images/Icons/plug.png", (CacheType)999);
			Transform child = ((Component)template).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0)
				.GetChild(2);
			_sectionHeader = ((Component)child.GetChild(2).GetChild(0).GetChild(0)).gameObject;
			_keybindTemplate = ((Component)child.GetChild(2).GetChild(0).GetChild(1)
				.GetChild(0)).gameObject;
			Transform child2 = ((Component)template).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0)
				.GetChild(0);
			_toggleTemplate = ((Component)child2.GetChild(4).GetChild(1)).gameObject;
			_dropDownTemplate = ((Component)child2.GetChild(5).GetChild(1)).gameObject;
			_textFieldTemplate = ((Component)child2.GetChild(2).GetChild(2)).gameObject;
		}

		private static void Click()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			content.transform.SetPositionAndRotation(original.transform.position, original.transform.rotation);
			((Component)content.transform).GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f - pos.y);
			((Component)((Component)clone).transform.parent.parent.parent).gameObject.GetComponent<GameSettings>().SwitchTab(3);
		}

		internal static void Postfix(UI_SwitchButtonGroup __instance, ref List<Button> ____buttons, BaseUnityPlugin[] plugins)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).gameObject).name == "ToggleGroup" && ((Object)((Component)__instance).transform.parent).name == "Settings")
			{
				Button val = ____buttons[0];
				Button obj = ____buttons[1];
				Transform child = ((Component)val).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0);
				Transform child2 = child.GetChild(4);
				child2.SetParent((Transform)null);
				Object.Destroy((Object)(object)child2);
				float distance = ((Component)obj).transform.localPosition.x - ((Component)val).transform.localPosition.x;
				AddButton(__instance, 4, val, "Mod Config", ref ____buttons, distance);
				AddContent(child, plugins);
				((UnityEvent)obj.onClick).Invoke();
				((UnityEvent)val.onClick).Invoke();
			}
		}

		private static void AddContent(Transform scrollView, BaseUnityPlugin[] plugins)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Invalid comparison between Unknown and I4
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			original = ((Component)scrollView.GetChild(0)).gameObject;
			content = Object.Instantiate<GameObject>(original);
			content.transform.SetParent(scrollView);
			((Object)content).name = "MOD OPTIONS";
			Transform child = content.transform.GetChild(0);
			Transform child2 = child.GetChild(0);
			pos = child2.position;
			Quaternion rotation = child2.rotation;
			_modNameHeader = ((Component)child).gameObject;
			content.transform.DetachChildren();
			foreach (BaseUnityPlugin val in plugins)
			{
				IEnumerable<ConfigEntryBase> pluginConfig = SettingSearcher.GetPluginConfig(val);
				IEnumerable<string> enumerable = pluginConfig.Select((ConfigEntryBase e) => e.Definition.Section).Distinct();
				if (!pluginConfig.Any())
				{
					continue;
				}
				Transform transform = Object.Instantiate<GameObject>(_modNameHeader).transform;
				((Object)((Component)transform).gameObject).name = val.Info.Metadata.Name;
				Transform child3 = transform.GetChild(0);
				((TMP_Text)((Component)child3).GetComponent<TextMeshProUGUI>()).text = val.Info.Metadata.Name;
				transform.SetParent(content.transform);
				((Component)transform).transform.DetachChildren();
				child3.SetParent(transform);
				child3.SetPositionAndRotation(pos, rotation);
				pos += 53.1f * Vector3.down;
				_ = ((Component)child3).GetComponent<RectTransform>().anchoredPosition;
				foreach (string section in enumerable)
				{
					GameObject obj = Object.Instantiate<GameObject>(_sectionHeader);
					obj.transform.SetParent(content.transform);
					obj.transform.localPosition = new Vector3(0f, pos.y);
					((TMP_Text)obj.GetComponent<TextMeshProUGUI>()).text = section;
					pos += 22f * Vector3.down;
					((Object)obj.gameObject).name = val.Info.Metadata.Name + "_" + section;
					foreach (ConfigEntryBase item in pluginConfig.Where((ConfigEntryBase e) => e.Definition.Section == section))
					{
						if ((int)ConfigurationManager.LogLevel == 5)
						{
							ConfigurationManager._logger.LogInfo((object)$"{item.Definition.Section}:{item.Definition.Key}:{item.BoxedValue}");
						}
						if (item.BoxedValue is KeyboardShortcut || item.BoxedValue is KeyCode)
						{
							GameObject obj2 = Object.Instantiate<GameObject>(_keybindTemplate);
							obj2.transform.SetParent(content.transform);
							obj2.transform.localPosition = new Vector3(20f, pos.y);
							KeybindBehaviour keybindBehaviour = obj2.AddComponent<KeybindBehaviour>();
							keybindBehaviour.Entry = item;
							keybindBehaviour.Setup();
							pos += 28f * Vector3.down;
						}
						else if (item.BoxedValue.IsNumber())
						{
							GameObject obj3 = Object.Instantiate<GameObject>(_textFieldTemplate);
							obj3.transform.SetParent(content.transform);
							obj3.transform.localPosition = new Vector3(20f, pos.y - 14f);
							NumberBehaviour numberBehaviour = obj3.AddComponent<NumberBehaviour>();
							numberBehaviour.posy = pos.y - 14f;
							numberBehaviour.Entry = item;
							numberBehaviour.Setup();
							pos += 28f * Vector3.down;
						}
						else if (item.BoxedValue is string)
						{
							GameObject obj4 = Object.Instantiate<GameObject>(_textFieldTemplate);
							obj4.transform.SetParent(content.transform);
							obj4.transform.localPosition = new Vector3(20f, pos.y - 14f);
							TextBehaviour textBehaviour = obj4.AddComponent<TextBehaviour>();
							textBehaviour.posy = pos.y - 14f;
							textBehaviour.Entry = item;
							textBehaviour.Setup();
							pos += 28f * Vector3.down;
						}
						else if (item.BoxedValue is bool)
						{
							GameObject obj5 = Object.Instantiate<GameObject>(_toggleTemplate);
							obj5.transform.SetParent(content.transform);
							obj5.transform.localPosition = new Vector3(5f, pos.y);
							pos += 28f * Vector3.down;
							ToggleBehaviour toggleBehaviour = obj5.AddComponent<ToggleBehaviour>();
							toggleBehaviour.Entry = item;
							toggleBehaviour.Setup();
						}
						else if (item.BoxedValue.GetType().IsEnum)
						{
							GameObject obj6 = Object.Instantiate<GameObject>(_dropDownTemplate);
							obj6.transform.SetParent(content.transform);
							obj6.transform.localPosition = new Vector3(108f, pos.y);
							pos += 28f * Vector3.down;
							DropDownBehaviour dropDownBehaviour = obj6.AddComponent<DropDownBehaviour>();
							dropDownBehaviour.Entry = item;
							dropDownBehaviour.Setup();
						}
						else
						{
							_ = item.BoxedValue is Color;
						}
					}
					pos += 11f * Vector3.down;
				}
				pos += 11f * Vector3.down;
			}
		}
	}
}
namespace ConfigurationManager.Patches.GameSetting
{
	[HarmonyPatch(typeof(GameSettings), "OnInstanceSetup")]
	internal sealed class GameSettingsSetupPatch
	{
		internal static bool AlreadyRan;

		private static BaseUnityPlugin[] _plugins;

		public static void Postfix()
		{
			Utils.SentryInvoke(Setup);
		}

		private static void Setup()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Invalid comparison between Unknown and I4
			if ((int)ConfigurationManager.LogLevel == 5)
			{
				ConfigurationManager._logger.LogInfo((object)$"GameSettings.OnInstanceSetup: {AlreadyRan}");
			}
			if (AlreadyRan)
			{
				return;
			}
			SettingSearcher.CollectSettings(out var results, out var _, out _plugins);
			if ((int)ConfigurationManager.LogLevel == 5)
			{
				foreach (ConfigEntryBase item in results)
				{
					ConfigurationManager._logger.LogInfo((object)("Settings Found: " + item.Definition.Section + ", " + item.Definition.Key + " "));
				}
				BaseUnityPlugin[] plugins = _plugins;
				foreach (BaseUnityPlugin val in plugins)
				{
					foreach (ConfigEntryBase item2 in SettingSearcher.GetPluginConfig(val))
					{
						ConfigurationManager._logger.LogInfo((object)("Settings Found in " + val.Info.Metadata.Name + " : " + item2.Definition.Section + ", " + item2.Definition.Key + " "));
					}
				}
			}
			UI_SwitchButtonGroup componentInChildren = ((Component)SingletonBehaviour<GameSettings>.Instance).gameObject.GetComponentInChildren<UI_SwitchButtonGroup>();
			List<Button> ____buttons = ((Component)componentInChildren).gameObject.GetComponentsInChildren<Button>().ToList();
			UI_SwitchButtonGroupStartPatch.Postfix(componentInChildren, ref ____buttons, _plugins);
			if ((int)ConfigurationManager.LogLevel >= 3)
			{
				ConfigurationManager._logger.LogInfo((object)"GameSettings SetUp Patch completed");
			}
			AlreadyRan = true;
		}
	}
}

Sentry.dll

Decompiled 2 months ago
#define TRACE
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Generic.Enumerable;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Internal;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Reflection.Emit;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Runtime;
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.Authentication;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Sentry;
using Sentry.Extensibility;
using Sentry.Http;
using Sentry.Infrastructure;
using Sentry.Integrations;
using Sentry.Internal;
using Sentry.Internal.Extensions;
using Sentry.Internal.Http;
using Sentry.Internal.ScopeStack;
using Sentry.PlatformAbstractions;
using Sentry.Protocol;
using Sentry.Protocol.Envelopes;
using Sentry.Reflection;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Sentry.Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Testing, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Log4Net, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Log4Net.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.NLog, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.NLog.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Serilog.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNet.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Grpc, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Grpc.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Google.Cloud.Functions, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Google.Cloud.Functions.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.DiagnosticSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.DiagnosticSource.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.DiagnosticSource.IntegrationTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.EntityFramework.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Extensions.Logging, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Extensions.Logging.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.Extensions.Logging.EfCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
[assembly: CLSCompliant(true)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Sentry.io")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Official SDK for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.")]
[assembly: AssemblyFileVersion("3.21.0.0")]
[assembly: AssemblyInformationalVersion("3.21.0")]
[assembly: AssemblyProduct("Sentry")]
[assembly: AssemblyTitle("Sentry")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/getsentry/sentry-dotnet")]
[assembly: AssemblyVersion("3.21.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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;
		}
	}
}
internal static class PolyfillExtensions
{
	public static string[] Split(this string str, char c, StringSplitOptions options = StringSplitOptions.None)
	{
		return str.Split(new char[1] { c }, options);
	}

	public static bool Contains(this string str, char c)
	{
		return str.IndexOf(c) >= 0;
	}

	public static Task CopyToAsync(this Stream stream, Stream destination, CancellationToken cancellationToken)
	{
		return stream.CopyToAsync(destination, 81920, cancellationToken);
	}

	public static Task<int> ReadAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken)
	{
		return stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken);
	}

	public static Task WriteAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken)
	{
		return stream.WriteAsync(buffer, 0, buffer.Length, cancellationToken);
	}

	public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value)
	{
		key = pair.Key;
		value = pair.Value;
	}

	public static Task<string> ReadAsStringAsync(this HttpContent content, CancellationToken cancellationToken = default(CancellationToken))
	{
		if (cancellationToken.IsCancellationRequested)
		{
			return Task.FromCanceled<string>(cancellationToken);
		}
		return content.ReadAsStringAsync();
	}

	public static Task<Stream> ReadAsStreamAsync(this HttpContent content, CancellationToken cancellationToken = default(CancellationToken))
	{
		if (cancellationToken.IsCancellationRequested)
		{
			return Task.FromCanceled<Stream>(cancellationToken);
		}
		return content.ReadAsStreamAsync();
	}

	public static Stream ReadAsStream(this HttpContent content)
	{
		if (content is EnvelopeHttpContent envelopeHttpContent)
		{
			MemoryStream memoryStream = new MemoryStream();
			envelopeHttpContent.SerializeToStream(memoryStream);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return memoryStream;
		}
		return content.ReadAsStreamAsync().Result;
	}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static class SentryExceptionExtensions
{
	public static void AddSentryTag(this Exception ex, string name, string value)
	{
		ex.Data.Add(MainExceptionProcessor.ExceptionDataTagKey + name, value);
	}

	[EditorBrowsable(EditorBrowsableState.Never)]
	public static IEnumerable<Exception> EnumerateChainedExceptions(this Exception exception, SentryOptions options)
	{
		if (exception is AggregateException aggregateException)
		{
			foreach (Exception item in EnumerateInner(options, aggregateException))
			{
				yield return item;
			}
			if (!options.KeepAggregateException)
			{
				yield break;
			}
		}
		else if (exception.InnerException != null)
		{
			foreach (Exception item2 in exception.InnerException.EnumerateChainedExceptions(options))
			{
				yield return item2;
			}
		}
		yield return exception;
	}

	private static IEnumerable<Exception> EnumerateInner(SentryOptions options, AggregateException aggregateException)
	{
		SentryOptions options2 = options;
		return aggregateException.InnerExceptions.SelectMany((Exception exception) => exception.EnumerateChainedExceptions(options2));
	}

	public static void AddSentryContext(this Exception ex, string name, IReadOnlyDictionary<string, object> data)
	{
		ex.Data.Add(MainExceptionProcessor.ExceptionDataContextKey + name, data);
	}
}
namespace Sentry
{
	public enum AttachmentType
	{
		Default,
		Minidump,
		AppleCrashReport,
		UnrealContext,
		UnrealLogs
	}
	[DebuggerDisplay("{FileName}")]
	public class Attachment
	{
		public AttachmentType Type { get; }

		public IAttachmentContent Content { get; }

		public string FileName { get; }

		public string? ContentType { get; }

		public Attachment(AttachmentType type, IAttachmentContent content, string fileName, string? contentType)
		{
			Type = type;
			Content = content;
			FileName = fileName;
			ContentType = contentType;
		}
	}
	internal static class AttributeReader
	{
		public static bool TryGetProjectDirectory(Assembly assembly, out string? projectDirectory)
		{
			projectDirectory = assembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault((AssemblyMetadataAttribute x) => x.Key == "Sentry.ProjectDirectory")?.Value;
			return projectDirectory != null;
		}
	}
	[DebuggerDisplay("Message: {Message}, Type: {Type}")]
	public sealed class Breadcrumb : IJsonSerializable
	{
		public DateTimeOffset Timestamp { get; }

		public string? Message { get; }

		public string? Type { get; }

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

		public string? Category { get; }

		public BreadcrumbLevel Level { get; }

		public Breadcrumb(string message, string type, IReadOnlyDictionary<string, string>? data = null, string? category = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
			: this(null, message, type, data, category, level)
		{
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		internal Breadcrumb(DateTimeOffset? timestamp = null, string? message = null, string? type = null, IReadOnlyDictionary<string, string>? data = null, string? category = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			Timestamp = timestamp ?? DateTimeOffset.UtcNow;
			Message = message;
			Type = type;
			Data = data;
			Category = category;
			Level = level;
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteString("timestamp", Timestamp.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffZ", DateTimeFormatInfo.InvariantInfo));
			writer.WriteStringIfNotWhiteSpace("message", Message);
			writer.WriteStringIfNotWhiteSpace("type", Type);
			writer.WriteStringDictionaryIfNotEmpty("data", Data);
			writer.WriteStringIfNotWhiteSpace("category", Category);
			writer.WriteStringIfNotWhiteSpace("level", Level.NullIfDefault()?.ToString().ToLowerInvariant());
			writer.WriteEndObject();
		}

		public static Breadcrumb FromJson(JsonElement json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			JsonElement? propertyOrNull = json.GetPropertyOrNull("timestamp");
			DateTimeOffset? timestamp;
			JsonElement valueOrDefault;
			if (!propertyOrNull.HasValue)
			{
				timestamp = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				timestamp = ((JsonElement)(ref valueOrDefault)).GetDateTimeOffset();
			}
			propertyOrNull = json.GetPropertyOrNull("message");
			object obj;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string message = (string)obj;
			propertyOrNull = json.GetPropertyOrNull("type");
			object obj2;
			if (!propertyOrNull.HasValue)
			{
				obj2 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj2 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string type = (string)obj2;
			Dictionary<string, string> data = json.GetPropertyOrNull("data")?.GetStringDictionaryOrNull();
			propertyOrNull = json.GetPropertyOrNull("category");
			object obj3;
			if (!propertyOrNull.HasValue)
			{
				obj3 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj3 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string category = (string)obj3;
			propertyOrNull = json.GetPropertyOrNull("level");
			BreadcrumbLevel? obj4;
			if (!propertyOrNull.HasValue)
			{
				obj4 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj4 = ((JsonElement)(ref valueOrDefault)).GetString()?.ParseEnum<BreadcrumbLevel>();
			}
			BreadcrumbLevel? breadcrumbLevel = obj4;
			BreadcrumbLevel valueOrDefault2 = breadcrumbLevel.GetValueOrDefault();
			return new Breadcrumb(timestamp, message, type, data, category, valueOrDefault2);
		}
	}
	public enum BreadcrumbLevel
	{
		[EnumMember(Value = "debug")]
		Debug = -1,
		[EnumMember(Value = "info")]
		Info,
		[EnumMember(Value = "warning")]
		Warning,
		[EnumMember(Value = "error")]
		Error,
		[EnumMember(Value = "critical")]
		Critical
	}
	public class ByteAttachmentContent : IAttachmentContent
	{
		private readonly byte[] _bytes;

		public ByteAttachmentContent(byte[] bytes)
		{
			_bytes = bytes;
		}

		public Stream GetStream()
		{
			return new MemoryStream(_bytes);
		}
	}
	public static class Constants
	{
		public const string DisableSdkDsnValue = "";

		public const int DefaultMaxBreadcrumbs = 100;

		public const int ProtocolVersion = 7;

		public const string Platform = "csharp";
	}
	[Obsolete("WARNING: This method deliberately causes a crash, and should not be used in a real application.")]
	public enum CrashType
	{
		Managed,
		ManagedBackgroundThread
	}
	public sealed class DebugImage : IJsonSerializable
	{
		public string? Type { get; set; }

		public string? ImageAddress { get; set; }

		public long? ImageSize { get; set; }

		public string? DebugId { get; set; }

		public string? DebugFile { get; set; }

		public string? CodeId { get; set; }

		public string? CodeFile { get; set; }

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteStringIfNotWhiteSpace("type", Type);
			writer.WriteStringIfNotWhiteSpace("image_addr", ImageAddress);
			writer.WriteNumberIfNotNull("image_size", ImageSize);
			writer.WriteStringIfNotWhiteSpace("debug_id", DebugId);
			writer.WriteStringIfNotWhiteSpace("debug_file", DebugFile);
			writer.WriteStringIfNotWhiteSpace("code_id", CodeId);
			writer.WriteStringIfNotWhiteSpace("code_file", CodeFile);
			writer.WriteEndObject();
		}

		public static DebugImage FromJson(JsonElement json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			JsonElement? propertyOrNull = json.GetPropertyOrNull("type");
			object obj;
			JsonElement valueOrDefault;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string type = (string)obj;
			propertyOrNull = json.GetPropertyOrNull("image_addr");
			object obj2;
			if (!propertyOrNull.HasValue)
			{
				obj2 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj2 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string imageAddress = (string)obj2;
			propertyOrNull = json.GetPropertyOrNull("image_size");
			long? obj3;
			if (!propertyOrNull.HasValue)
			{
				obj3 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj3 = ((JsonElement)(ref valueOrDefault)).GetInt64();
			}
			long? imageSize = obj3;
			propertyOrNull = json.GetPropertyOrNull("debug_id");
			object obj4;
			if (!propertyOrNull.HasValue)
			{
				obj4 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj4 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string debugId = (string)obj4;
			propertyOrNull = json.GetPropertyOrNull("debug_file");
			object obj5;
			if (!propertyOrNull.HasValue)
			{
				obj5 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj5 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string debugFile = (string)obj5;
			propertyOrNull = json.GetPropertyOrNull("code_id");
			object obj6;
			if (!propertyOrNull.HasValue)
			{
				obj6 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj6 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string codeId = (string)obj6;
			propertyOrNull = json.GetPropertyOrNull("code_file");
			object obj7;
			if (!propertyOrNull.HasValue)
			{
				obj7 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj7 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string codeFile = (string)obj7;
			return new DebugImage
			{
				Type = type,
				ImageAddress = imageAddress,
				ImageSize = imageSize,
				DebugId = debugId,
				DebugFile = debugFile,
				CodeId = codeId,
				CodeFile = codeFile
			};
		}
	}
	[Flags]
	public enum DeduplicateMode
	{
		SameEvent = 1,
		SameExceptionInstance = 2,
		InnerException = 4,
		AggregateException = 8,
		All = int.MaxValue
	}
	public class DefaultSentryScopeStateProcessor : ISentryScopeStateProcessor
	{
		private static readonly char[] TrimFilter = new char[2] { '{', '}' };

		public void Apply(Scope scope, object state)
		{
			if (!(state is string value))
			{
				if (!(state is IEnumerable<KeyValuePair<string, string>> source))
				{
					if (!(state is IEnumerable<KeyValuePair<string, object>> source2))
					{
						if (state is (string, string) tuple)
						{
							if (!string.IsNullOrEmpty(tuple.Item2))
							{
								scope.SetTag(tuple.Item1, tuple.Item2);
							}
						}
						else
						{
							scope.SetExtra("state", state);
						}
					}
					else
					{
						scope.SetTags(from kv in source2
							where !string.IsNullOrEmpty(kv.Value as string)
							select kv into k
							select new KeyValuePair<string, string>(k.Key.Trim(TrimFilter), k.Value.ToString()));
					}
				}
				else
				{
					scope.SetTags(source.Where((KeyValuePair<string, string> kv) => !string.IsNullOrEmpty(kv.Value)));
				}
			}
			else
			{
				scope.SetTag("scope", value);
			}
		}
	}
	internal sealed class Dsn
	{
		public string Source { get; }

		public string ProjectId { get; }

		public string? Path { get; }

		public string? SecretKey { get; }

		public string PublicKey { get; }

		private Uri ApiBaseUri { get; }

		private Dsn(string source, string projectId, string? path, string? secretKey, string publicKey, Uri apiBaseUri)
		{
			Source = source;
			ProjectId = projectId;
			Path = path;
			SecretKey = secretKey;
			PublicKey = publicKey;
			ApiBaseUri = apiBaseUri;
		}

		public Uri GetStoreEndpointUri()
		{
			return new Uri(ApiBaseUri, "store/");
		}

		public Uri GetEnvelopeEndpointUri()
		{
			return new Uri(ApiBaseUri, "envelope/");
		}

		public override string ToString()
		{
			return Source;
		}

		public static bool IsDisabled(string? dsn)
		{
			return "".Equals(dsn, StringComparison.OrdinalIgnoreCase);
		}

		public static Dsn Parse(string dsn)
		{
			Uri uri = new Uri(dsn);
			if (string.IsNullOrWhiteSpace(uri.UserInfo))
			{
				throw new ArgumentException("Invalid DSN: No public key provided.");
			}
			string[] array = uri.UserInfo.Split(new char[1] { ':' });
			string text = array[0];
			if (string.IsNullOrWhiteSpace(text))
			{
				throw new ArgumentException("Invalid DSN: No public key provided.");
			}
			string secretKey = ((array.Length > 1) ? array[1] : null);
			string text2 = uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/'));
			string text3 = uri.AbsoluteUri.Substring(uri.AbsoluteUri.LastIndexOf('/') + 1);
			if (string.IsNullOrWhiteSpace(text3))
			{
				throw new ArgumentException("Invalid DSN: A Project Id is required.");
			}
			Uri uri2 = new UriBuilder
			{
				Scheme = uri.Scheme,
				Host = uri.DnsSafeHost,
				Port = uri.Port,
				Path = text2 + "/api/" + text3 + "/"
			}.Uri;
			return new Dsn(dsn, text3, text2, secretKey, text, uri2);
		}

		public static Dsn? TryParse(string? dsn)
		{
			if (string.IsNullOrWhiteSpace(dsn))
			{
				return null;
			}
			try
			{
				return Parse(dsn);
			}
			catch
			{
				return null;
			}
		}
	}
	[AttributeUsage(AttributeTargets.Assembly)]
	public class DsnAttribute : Attribute
	{
		public string Dsn { get; }

		public DsnAttribute(string dsn)
		{
			Dsn = dsn;
		}
	}
	public sealed class SentryStackFrame : IJsonSerializable
	{
		internal List<string>? InternalPreContext { get; private set; }

		internal List<string>? InternalPostContext { get; private set; }

		internal Dictionary<string, string>? InternalVars { get; private set; }

		internal List<int>? InternalFramesOmitted { get; private set; }

		public string? FileName { get; set; }

		public string? Function { get; set; }

		public string? Module { get; set; }

		public int? LineNumber { get; set; }

		public int? ColumnNumber { get; set; }

		public string? AbsolutePath { get; set; }

		public string? ContextLine { get; set; }

		public IList<string> PreContext => InternalPreContext ?? (InternalPreContext = new List<string>());

		public IList<string> PostContext => InternalPostContext ?? (InternalPostContext = new List<string>());

		public bool? InApp { get; set; }

		public IDictionary<string, string> Vars => InternalVars ?? (InternalVars = new Dictionary<string, string>());

		public IList<int> FramesOmitted => InternalFramesOmitted ?? (InternalFramesOmitted = new List<int>());

		public string? Package { get; set; }

		public string? Platform { get; set; }

		public long ImageAddress { get; set; }

		public long? SymbolAddress { get; set; }

		public string? InstructionAddress { get; set; }

		public long? InstructionOffset { get; set; }

		public string? AddressMode { get; set; }

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteStringArrayIfNotEmpty("pre_context", InternalPreContext);
			writer.WriteStringArrayIfNotEmpty("post_context", InternalPostContext);
			writer.WriteStringDictionaryIfNotEmpty("vars", InternalVars);
			writer.WriteArrayIfNotEmpty("frames_omitted", InternalFramesOmitted?.Cast<object>(), logger);
			writer.WriteStringIfNotWhiteSpace("filename", FileName);
			writer.WriteStringIfNotWhiteSpace("function", Function);
			writer.WriteStringIfNotWhiteSpace("module", Module);
			writer.WriteNumberIfNotNull("lineno", LineNumber);
			writer.WriteNumberIfNotNull("colno", ColumnNumber);
			writer.WriteStringIfNotWhiteSpace("abs_path", AbsolutePath);
			writer.WriteStringIfNotWhiteSpace("context_line", ContextLine);
			writer.WriteBooleanIfNotNull("in_app", InApp);
			writer.WriteStringIfNotWhiteSpace("package", Package);
			writer.WriteStringIfNotWhiteSpace("platform", Platform);
			writer.WriteStringIfNotWhiteSpace("image_addr", ImageAddress.NullIfDefault()?.ToHexString());
			writer.WriteStringIfNotWhiteSpace("symbol_addr", SymbolAddress?.ToHexString());
			writer.WriteStringIfNotWhiteSpace("instruction_addr", InstructionAddress);
			writer.WriteNumberIfNotNull("instruction_offset", InstructionOffset);
			writer.WriteStringIfNotWhiteSpace("addr_mode", AddressMode);
			writer.WriteEndObject();
		}

		public void ConfigureAppFrame(SentryOptions options)
		{
			string parameterName = Module ?? Function;
			if (InApp.HasValue)
			{
				return;
			}
			if (string.IsNullOrEmpty(parameterName))
			{
				InApp = true;
				return;
			}
			List<string>? inAppInclude = options.InAppInclude;
			int value;
			if (inAppInclude == null || !inAppInclude.Any((string include) => parameterName.StartsWith(include, StringComparison.Ordinal)))
			{
				List<string>? inAppExclude = options.InAppExclude;
				value = ((inAppExclude == null || !inAppExclude.Any((string exclude) => parameterName.StartsWith(exclude, StringComparison.Ordinal))) ? 1 : 0);
			}
			else
			{
				value = 1;
			}
			InApp = (byte)value != 0;
		}

		public static SentryStackFrame FromJson(JsonElement json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			JsonElement? propertyOrNull = json.GetPropertyOrNull("pre_context");
			object obj;
			JsonElement valueOrDefault;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((IEnumerable<JsonElement>)(object)((JsonElement)(ref valueOrDefault)).EnumerateArray()).Select((JsonElement j) => ((JsonElement)(ref j)).GetString()).ToList();
			}
			List<string> internalPreContext = (List<string>)obj;
			propertyOrNull = json.GetPropertyOrNull("post_context");
			object obj2;
			if (!propertyOrNull.HasValue)
			{
				obj2 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj2 = ((IEnumerable<JsonElement>)(object)((JsonElement)(ref valueOrDefault)).EnumerateArray()).Select((JsonElement j) => ((JsonElement)(ref j)).GetString()).ToList();
			}
			List<string> internalPostContext = (List<string>)obj2;
			Dictionary<string, string> dictionary = json.GetPropertyOrNull("vars")?.GetStringDictionaryOrNull();
			propertyOrNull = json.GetPropertyOrNull("frames_omitted");
			object obj3;
			if (!propertyOrNull.HasValue)
			{
				obj3 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj3 = ((IEnumerable<JsonElement>)(object)((JsonElement)(ref valueOrDefault)).EnumerateArray()).Select((JsonElement j) => ((JsonElement)(ref j)).GetInt32()).ToList();
			}
			List<int> internalFramesOmitted = (List<int>)obj3;
			propertyOrNull = json.GetPropertyOrNull("filename");
			object obj4;
			if (!propertyOrNull.HasValue)
			{
				obj4 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj4 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string fileName = (string)obj4;
			propertyOrNull = json.GetPropertyOrNull("function");
			object obj5;
			if (!propertyOrNull.HasValue)
			{
				obj5 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj5 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string function = (string)obj5;
			propertyOrNull = json.GetPropertyOrNull("module");
			object obj6;
			if (!propertyOrNull.HasValue)
			{
				obj6 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj6 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string module = (string)obj6;
			propertyOrNull = json.GetPropertyOrNull("lineno");
			int? obj7;
			if (!propertyOrNull.HasValue)
			{
				obj7 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj7 = ((JsonElement)(ref valueOrDefault)).GetInt32();
			}
			int? lineNumber = obj7;
			propertyOrNull = json.GetPropertyOrNull("colno");
			int? obj8;
			if (!propertyOrNull.HasValue)
			{
				obj8 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj8 = ((JsonElement)(ref valueOrDefault)).GetInt32();
			}
			int? columnNumber = obj8;
			propertyOrNull = json.GetPropertyOrNull("abs_path");
			object obj9;
			if (!propertyOrNull.HasValue)
			{
				obj9 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj9 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string absolutePath = (string)obj9;
			propertyOrNull = json.GetPropertyOrNull("context_line");
			object obj10;
			if (!propertyOrNull.HasValue)
			{
				obj10 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj10 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string contextLine = (string)obj10;
			propertyOrNull = json.GetPropertyOrNull("in_app");
			bool? obj11;
			if (!propertyOrNull.HasValue)
			{
				obj11 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj11 = ((JsonElement)(ref valueOrDefault)).GetBoolean();
			}
			bool? inApp = obj11;
			propertyOrNull = json.GetPropertyOrNull("package");
			object obj12;
			if (!propertyOrNull.HasValue)
			{
				obj12 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj12 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string package = (string)obj12;
			propertyOrNull = json.GetPropertyOrNull("platform");
			object obj13;
			if (!propertyOrNull.HasValue)
			{
				obj13 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj13 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string platform = (string)obj13;
			long valueOrDefault2 = (json.GetPropertyOrNull("image_addr")?.GetAddressAsLong()).GetValueOrDefault();
			long? symbolAddress = json.GetPropertyOrNull("symbol_addr")?.GetAddressAsLong();
			propertyOrNull = json.GetPropertyOrNull("instruction_addr");
			object obj14;
			if (!propertyOrNull.HasValue)
			{
				obj14 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj14 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string instructionAddress = (string)obj14;
			propertyOrNull = json.GetPropertyOrNull("instruction_offset");
			long? obj15;
			if (!propertyOrNull.HasValue)
			{
				obj15 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj15 = ((JsonElement)(ref valueOrDefault)).GetInt64();
			}
			long? instructionOffset = obj15;
			propertyOrNull = json.GetPropertyOrNull("addr_mode");
			object obj16;
			if (!propertyOrNull.HasValue)
			{
				obj16 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj16 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string addressMode = (string)obj16;
			return new SentryStackFrame
			{
				InternalPreContext = internalPreContext,
				InternalPostContext = internalPostContext,
				InternalVars = dictionary?.WhereNotNullValue().ToDictionary(),
				InternalFramesOmitted = internalFramesOmitted,
				FileName = fileName,
				Function = function,
				Module = module,
				LineNumber = lineNumber,
				ColumnNumber = columnNumber,
				AbsolutePath = absolutePath,
				ContextLine = contextLine,
				InApp = inApp,
				Package = package,
				Platform = platform,
				ImageAddress = valueOrDefault2,
				SymbolAddress = symbolAddress,
				InstructionAddress = instructionAddress,
				InstructionOffset = instructionOffset,
				AddressMode = addressMode
			};
		}
	}
	public sealed class SentryStackTrace : IJsonSerializable
	{
		internal IList<SentryStackFrame>? InternalFrames { get; private set; }

		public IList<SentryStackFrame> Frames
		{
			get
			{
				return InternalFrames ?? (InternalFrames = new List<SentryStackFrame>());
			}
			set
			{
				InternalFrames = value;
			}
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteArrayIfNotEmpty("frames", InternalFrames, logger);
			writer.WriteEndObject();
		}

		public static SentryStackTrace FromJson(JsonElement json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			JsonElement? propertyOrNull = json.GetPropertyOrNull("frames");
			object obj;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				JsonElement valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((IEnumerable<JsonElement>)(object)((JsonElement)(ref valueOrDefault)).EnumerateArray()).Select(SentryStackFrame.FromJson).ToArray();
			}
			SentryStackFrame[] internalFrames = (SentryStackFrame[])obj;
			return new SentryStackTrace
			{
				InternalFrames = internalFrames
			};
		}
	}
	public class FileAttachmentContent : IAttachmentContent
	{
		private readonly string _filePath;

		private readonly bool _readFileAsynchronously;

		public FileAttachmentContent(string filePath)
			: this(filePath, readFileAsynchronously: true)
		{
		}

		public FileAttachmentContent(string filePath, bool readFileAsynchronously)
		{
			_filePath = filePath;
			_readFileAsynchronously = readFileAsynchronously;
		}

		public Stream GetStream()
		{
			return new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, _readFileAsynchronously);
		}
	}
	internal class GlobalSessionManager : ISessionManager
	{
		private const string PersistedSessionFileName = ".session";

		private readonly object _installationIdLock = new object();

		private readonly ISystemClock _clock;

		private readonly Func<string, PersistedSessionUpdate> _persistedSessionProvider;

		private readonly SentryOptions _options;

		private readonly string? _persistenceDirectoryPath;

		private string? _resolvedInstallationId;

		private Session? _currentSession;

		private DateTimeOffset? _lastPauseTimestamp;

		internal Session? CurrentSession => _currentSession;

		public bool IsSessionActive => _currentSession != null;

		public GlobalSessionManager(SentryOptions options, ISystemClock? clock = null, Func<string, PersistedSessionUpdate>? persistedSessionProvider = null)
		{
			_options = options;
			_clock = clock ?? SystemClock.Clock;
			_persistedSessionProvider = persistedSessionProvider ?? ((Func<string, PersistedSessionUpdate>)((string filePath) => Json.Load(filePath, PersistedSessionUpdate.FromJson)));
			_persistenceDirectoryPath = options.TryGetDsnSpecificCacheDirectoryPath();
		}

		private string? TryGetPersistentInstallationId()
		{
			try
			{
				string text = _persistenceDirectoryPath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Sentry", _options.Dsn.GetHashString());
				Directory.CreateDirectory(text);
				_options.LogDebug("Created directory for installation ID file ({0}).", text);
				string text2 = Path.Combine(text, ".installation");
				try
				{
					return File.ReadAllText(text2);
				}
				catch (FileNotFoundException)
				{
					_options.LogDebug("File containing installation ID does not exist ({0}).", text2);
				}
				catch (DirectoryNotFoundException)
				{
					_options.LogDebug("Directory containing installation ID does not exist ({0}).", text2);
				}
				string text3 = Guid.NewGuid().ToString();
				File.WriteAllText(text2, text3);
				_options.LogDebug("Saved installation ID '{0}' to file '{1}'.", text3, text2);
				return text3;
			}
			catch (Exception exception)
			{
				_options.LogError("Failed to resolve persistent installation ID.", exception);
				return null;
			}
		}

		private string? TryGetHardwareInstallationId()
		{
			try
			{
				string text = (from nic in NetworkInterface.GetAllNetworkInterfaces()
					where nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback
					select nic.GetPhysicalAddress().ToString()).FirstOrDefault();
				if (string.IsNullOrWhiteSpace(text))
				{
					_options.LogError("Failed to find an appropriate network interface for installation ID.");
					return null;
				}
				return text;
			}
			catch (Exception exception)
			{
				_options.LogError("Failed to resolve hardware installation ID.", exception);
				return null;
			}
		}

		internal static string GetMachineNameInstallationId()
		{
			return Environment.MachineName.GetHashString();
		}

		private string? TryGetInstallationId()
		{
			if (!string.IsNullOrWhiteSpace(_resolvedInstallationId))
			{
				return _resolvedInstallationId;
			}
			lock (_installationIdLock)
			{
				if (!string.IsNullOrWhiteSpace(_resolvedInstallationId))
				{
					return _resolvedInstallationId;
				}
				string text = TryGetPersistentInstallationId() ?? TryGetHardwareInstallationId() ?? GetMachineNameInstallationId();
				if (!string.IsNullOrWhiteSpace(text))
				{
					_options.LogDebug("Resolved installation ID '{0}'.", text);
				}
				else
				{
					_options.LogDebug("Failed to resolve installation ID.");
				}
				return _resolvedInstallationId = text;
			}
		}

		private void PersistSession(SessionUpdate update, DateTimeOffset? pauseTimestamp = null)
		{
			_options.LogDebug("Persisting session (SID: '{0}') to a file.", update.Id);
			if (string.IsNullOrWhiteSpace(_persistenceDirectoryPath))
			{
				_options.LogDebug("Persistence directory is not set, returning.");
				return;
			}
			try
			{
				Directory.CreateDirectory(_persistenceDirectoryPath);
				_options.LogDebug("Created persistence directory for session file '{0}'.", _persistenceDirectoryPath);
				string text = Path.Combine(_persistenceDirectoryPath, ".session");
				new PersistedSessionUpdate(update, pauseTimestamp).WriteToFile(text, _options.DiagnosticLogger);
				_options.LogDebug("Persisted session to a file '{0}'.", text);
			}
			catch (Exception exception)
			{
				_options.LogError("Failed to persist session on the file system.", exception);
			}
		}

		private void DeletePersistedSession()
		{
			if (string.IsNullOrWhiteSpace(_persistenceDirectoryPath))
			{
				_options.LogDebug("Persistence directory is not set, not deleting any persisted session file.");
				return;
			}
			string text = Path.Combine(_persistenceDirectoryPath, ".session");
			try
			{
				IDiagnosticLogger? diagnosticLogger = _options.DiagnosticLogger;
				if (diagnosticLogger != null && diagnosticLogger.IsEnabled(SentryLevel.Debug))
				{
					try
					{
						_options.LogDebug("Deleting persisted session file with contents: {0}", File.ReadAllText(text));
					}
					catch (Exception exception)
					{
						_options.LogError("Failed to read the contents of persisted session file '{0}'.", exception, text);
					}
				}
				File.Delete(text);
				_options.LogInfo("Deleted persisted session file '{0}'.", text);
			}
			catch (Exception exception2)
			{
				_options.LogError("Failed to delete persisted session from the file system: '{0}'", exception2, text);
			}
		}

		public SessionUpdate? TryRecoverPersistedSession()
		{
			_options.LogDebug("Attempting to recover persisted session from file.");
			if (string.IsNullOrWhiteSpace(_persistenceDirectoryPath))
			{
				_options.LogDebug("Persistence directory is not set, returning.");
				return null;
			}
			string text = Path.Combine(_persistenceDirectoryPath, ".session");
			try
			{
				PersistedSessionUpdate persistedSessionUpdate = _persistedSessionProvider(text);
				SessionEndStatus? endStatus = null;
				try
				{
					SessionEndStatus value = ((_options.CrashedLastRun?.Invoke() ?? false) ? SessionEndStatus.Crashed : ((!persistedSessionUpdate.PauseTimestamp.HasValue) ? SessionEndStatus.Abnormal : SessionEndStatus.Exited));
					endStatus = value;
				}
				catch (Exception exception)
				{
					_options.LogError("Invoking CrashedLastRun failed.", exception);
				}
				SessionUpdate sessionUpdate = new SessionUpdate(persistedSessionUpdate.Update, isInitial: false, persistedSessionUpdate.PauseTimestamp ?? _clock.GetUtcNow(), persistedSessionUpdate.Update.SequenceNumber + 1, endStatus);
				_options.LogInfo("Recovered session: EndStatus: {0}. PauseTimestamp: {1}", sessionUpdate.EndStatus, persistedSessionUpdate.PauseTimestamp);
				return sessionUpdate;
			}
			catch (Exception ex) when (ex is FileNotFoundException || ex is DirectoryNotFoundException)
			{
				_options.LogDebug("A persisted session does not exist ({0}) at {1}.", ex.GetType().Name, text);
				return null;
			}
			catch (Exception exception2)
			{
				_options.LogError("Failed to recover persisted session from the file system '{0}'.", exception2, text);
				return null;
			}
		}

		public SessionUpdate? StartSession()
		{
			string release = _options.SettingLocator.GetRelease();
			if (string.IsNullOrWhiteSpace(release))
			{
				_options.LogError("Failed to start a session because there is no release information.");
				return null;
			}
			string environment = _options.SettingLocator.GetEnvironment();
			Session session = new Session(TryGetInstallationId(), release, environment);
			Session session2 = Interlocked.Exchange(ref _currentSession, session);
			if (session2 != null)
			{
				_options.LogWarning("Starting a new session while an existing one is still active.");
				EndSession(session2, _clock.GetUtcNow(), SessionEndStatus.Exited);
			}
			AddSessionBreadcrumb("Starting Sentry Session");
			_options.LogInfo("Started new session (SID: {0}; DID: {1}).", session.Id, session.DistinctId);
			SessionUpdate sessionUpdate = session.CreateUpdate(isInitial: true, _clock.GetUtcNow());
			PersistSession(sessionUpdate);
			return sessionUpdate;
		}

		private SessionUpdate EndSession(Session session, DateTimeOffset timestamp, SessionEndStatus status)
		{
			AddSessionBreadcrumb("Ending Sentry Session");
			_options.LogInfo("Ended session (SID: {0}; DID: {1}) with status '{2}'.", session.Id, session.DistinctId, status);
			SessionUpdate result = session.CreateUpdate(isInitial: false, timestamp, status);
			DeletePersistedSession();
			return result;
		}

		public SessionUpdate? EndSession(DateTimeOffset timestamp, SessionEndStatus status)
		{
			Session session = Interlocked.Exchange(ref _currentSession, null);
			if (session == null)
			{
				_options.LogDebug("Failed to end session because there is none active.");
				return null;
			}
			return EndSession(session, timestamp, status);
		}

		public SessionUpdate? EndSession(SessionEndStatus status)
		{
			return EndSession(_clock.GetUtcNow(), status);
		}

		public void PauseSession()
		{
			Session currentSession = _currentSession;
			if (currentSession != null)
			{
				AddSessionBreadcrumb("Pausing Sentry Session");
				DateTimeOffset utcNow = _clock.GetUtcNow();
				_lastPauseTimestamp = utcNow;
				PersistSession(currentSession.CreateUpdate(isInitial: false, utcNow), utcNow);
			}
		}

		public IReadOnlyList<SessionUpdate> ResumeSession()
		{
			DateTimeOffset? lastPauseTimestamp = _lastPauseTimestamp;
			if (lastPauseTimestamp.HasValue)
			{
				DateTimeOffset valueOrDefault = lastPauseTimestamp.GetValueOrDefault();
				AddSessionBreadcrumb("Resuming Sentry Session");
				_lastPauseTimestamp = null;
				TimeSpan timeSpan = (_clock.GetUtcNow() - valueOrDefault).Duration();
				if (timeSpan >= _options.AutoSessionTrackingInterval)
				{
					_options.LogDebug("Paused session has been paused for {0}, which is longer than the configured timeout. Starting a new session instead of resuming this one.", timeSpan);
					List<SessionUpdate> list = new List<SessionUpdate>(2);
					SessionUpdate sessionUpdate = EndSession(valueOrDefault, SessionEndStatus.Exited);
					if (sessionUpdate != null)
					{
						list.Add(sessionUpdate);
					}
					SessionUpdate sessionUpdate2 = StartSession();
					if (sessionUpdate2 != null)
					{
						list.Add(sessionUpdate2);
					}
					return list;
				}
				_options.LogDebug("Paused session has been paused for {0}, which is shorter than the configured timeout.", timeSpan);
				return Array.Empty<SessionUpdate>();
			}
			_options.LogDebug("Attempted to resume a session, but the current session hasn't been paused.");
			return Array.Empty<SessionUpdate>();
		}

		public SessionUpdate? ReportError()
		{
			Session currentSession = _currentSession;
			if (currentSession != null)
			{
				currentSession.ReportError();
				if (currentSession.ErrorCount > 1)
				{
					_options.LogDebug("Reported an error on a session that already contains errors. Not creating an update.");
					return null;
				}
				return currentSession.CreateUpdate(isInitial: false, _clock.GetUtcNow());
			}
			_options.LogDebug("Failed to report an error on a session because there is none active.");
			return null;
		}

		private static void AddSessionBreadcrumb(string message)
		{
			SentrySdk.AddBreadcrumb(message, "app.lifecycle", "session");
		}
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class HubExtensions
	{
		private sealed class LockedScope : IDisposable
		{
			private readonly IDisposable _scope;

			public LockedScope(IHub hub)
			{
				_scope = hub.PushScope();
				hub.LockScope();
			}

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

		public static ITransaction StartTransaction(this IHub hub, ITransactionContext context)
		{
			return hub.StartTransaction(context, new Dictionary<string, object>());
		}

		public static ITransaction StartTransaction(this IHub hub, string name, string operation)
		{
			return hub.StartTransaction(new TransactionContext(name, operation));
		}

		public static ITransaction StartTransaction(this IHub hub, string name, string operation, string? description)
		{
			ITransaction transaction = hub.StartTransaction(name, operation);
			transaction.Description = description;
			return transaction;
		}

		public static ITransaction StartTransaction(this IHub hub, string name, string operation, SentryTraceHeader traceHeader)
		{
			return hub.StartTransaction(new TransactionContext(name, operation, traceHeader));
		}

		public static void AddBreadcrumb(this IHub hub, string message, string? category = null, string? type = null, IDictionary<string, string>? data = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			if (!hub.IsNull())
			{
				hub.AddBreadcrumb(null, message, category, type, (data != null) ? new Dictionary<string, string>(data) : null, level);
			}
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void AddBreadcrumb(this IHub hub, ISystemClock? clock, string message, string? category = null, string? type = null, IDictionary<string, string>? data = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			ISystemClock clock2 = clock;
			string message2 = message;
			string category2 = category;
			string type2 = type;
			IDictionary<string, string> data2 = data;
			if (!hub.IsNull())
			{
				hub.ConfigureScope(delegate(Scope s)
				{
					s.AddBreadcrumb((clock2 ?? SystemClock.Clock).GetUtcNow(), message2, category2, type2, (data2 != null) ? new Dictionary<string, string>(data2) : null, level);
				});
			}
		}

		public static IDisposable PushAndLockScope(this IHub hub)
		{
			return new LockedScope(hub);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void LockScope(this IHub hub)
		{
			hub.ConfigureScope(delegate(Scope c)
			{
				c.Locked = true;
			});
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void UnlockScope(this IHub hub)
		{
			hub.ConfigureScope(delegate(Scope c)
			{
				c.Locked = false;
			});
		}

		public static SentryId CaptureException(this IHub hub, Exception ex, Action<Scope> configureScope)
		{
			if (hub.IsEnabled)
			{
				return hub.CaptureEvent(new SentryEvent(ex), configureScope);
			}
			return default(SentryId);
		}

		public static SentryId CaptureMessage(this IHub hub, string message, Action<Scope> configureScope, SentryLevel level = SentryLevel.Info)
		{
			if (hub.IsEnabled && !string.IsNullOrWhiteSpace(message))
			{
				return hub.CaptureEvent(new SentryEvent
				{
					Message = message,
					Level = level
				}, configureScope);
			}
			return default(SentryId);
		}
	}
	public interface IAttachmentContent
	{
		Stream GetStream();
	}
	public interface IEventLike : IHasBreadcrumbs, IHasTags, IHasExtra
	{
		SentryLevel? Level { get; set; }

		Request Request { get; set; }

		Contexts Contexts { get; set; }

		User User { get; set; }

		string? Platform { get; set; }

		string? Release { get; set; }

		string? Environment { get; set; }

		string? TransactionName { get; set; }

		SdkVersion Sdk { get; }

		IReadOnlyList<string> Fingerprint { get; set; }
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class EventLikeExtensions
	{
		public static bool HasUser(this IEventLike eventLike)
		{
			if (eventLike.User.Email == null && eventLike.User.Id == null && eventLike.User.Username == null)
			{
				IDictionary<string, string>? internalOther = eventLike.User.InternalOther;
				if (internalOther == null || internalOther.Count <= 0)
				{
					return eventLike.User.IpAddress != null;
				}
			}
			return true;
		}

		public static void SetFingerprint(this IEventLike eventLike, IEnumerable<string> fingerprint)
		{
			eventLike.Fingerprint = (fingerprint as IReadOnlyList<string>) ?? fingerprint.ToArray();
		}

		public static void SetFingerprint(this IEventLike eventLike, params string[] fingerprint)
		{
			eventLike.Fingerprint = fingerprint;
		}
	}
	public interface IHasBreadcrumbs
	{
		IReadOnlyCollection<Breadcrumb> Breadcrumbs { get; }

		void AddBreadcrumb(Breadcrumb breadcrumb);
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class HasBreadcrumbsExtensions
	{
		public static void AddBreadcrumb(this IHasBreadcrumbs hasBreadcrumbs, string message, string? category, string? type, (string, string)? dataPair = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			if (!hasBreadcrumbs.IsNull())
			{
				Dictionary<string, string> data = null;
				if (dataPair.HasValue)
				{
					data = new Dictionary<string, string> { 
					{
						dataPair.Value.Item1,
						dataPair.Value.Item2
					} };
				}
				hasBreadcrumbs.AddBreadcrumb(null, message, category, type, data, level);
			}
		}

		public static void AddBreadcrumb(this IHasBreadcrumbs hasBreadcrumbs, string message, string? category = null, string? type = null, IReadOnlyDictionary<string, string>? data = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			if (!hasBreadcrumbs.IsNull())
			{
				hasBreadcrumbs.AddBreadcrumb(null, message, category, type, data, level);
			}
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static void AddBreadcrumb(this IHasBreadcrumbs hasBreadcrumbs, DateTimeOffset? timestamp, string message, string? category = null, string? type = null, IReadOnlyDictionary<string, string>? data = null, BreadcrumbLevel level = BreadcrumbLevel.Info)
		{
			if (!hasBreadcrumbs.IsNull())
			{
				hasBreadcrumbs.AddBreadcrumb(new Breadcrumb(timestamp, message, type, data, category, level));
			}
		}
	}
	public interface IHasExtra
	{
		IReadOnlyDictionary<string, object?> Extra { get; }

		void SetExtra(string key, object? value);
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class HasExtraExtensions
	{
		public static void SetExtras(this IHasExtra hasExtra, IEnumerable<KeyValuePair<string, object?>> values)
		{
			foreach (var (key, value) in values)
			{
				hasExtra.SetExtra(key, value);
			}
		}
	}
	public interface IHasTags
	{
		IReadOnlyDictionary<string, string> Tags { get; }

		void SetTag(string key, string value);

		void UnsetTag(string key);
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class HasTagsExtensions
	{
		public static void SetTags(this IHasTags hasTags, IEnumerable<KeyValuePair<string, string>> tags)
		{
			foreach (var (key, value) in tags)
			{
				hasTags.SetTag(key, value);
			}
		}
	}
	public interface IHub : ISentryClient, ISentryScopeManager
	{
		SentryId LastEventId { get; }

		ITransaction StartTransaction(ITransactionContext context, IReadOnlyDictionary<string, object?> customSamplingContext);

		void BindException(Exception exception, ISpan span);

		ISpan? GetSpan();

		SentryTraceHeader? GetTraceHeader();

		void StartSession();

		void PauseSession();

		void ResumeSession();

		void EndSession(SessionEndStatus status = SessionEndStatus.Exited);

		SentryId CaptureEvent(SentryEvent evt, Action<Scope> configureScope);
	}
	public interface IJsonSerializable
	{
		void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger);
	}
	internal static class JsonSerializableExtensions
	{
		public static void WriteToFile(this IJsonSerializable serializable, string filePath, IDiagnosticLogger? logger)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			using FileStream fileStream = File.Create(filePath);
			Utf8JsonWriter val = new Utf8JsonWriter((Stream)fileStream, default(JsonWriterOptions));
			try
			{
				serializable.WriteTo(val, logger);
				val.Flush();
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	internal sealed class ThreadPoolInfo : IJsonSerializable
	{
		public int MinWorkerThreads { get; }

		public int MinCompletionPortThreads { get; }

		public int MaxWorkerThreads { get; }

		public int MaxCompletionPortThreads { get; }

		public int AvailableWorkerThreads { get; }

		public int AvailableCompletionPortThreads { get; }

		public ThreadPoolInfo(int minWorkerThreads, int minCompletionPortThreads, int maxWorkerThreads, int maxCompletionPortThreads, int availableWorkerThreads, int availableCompletionPortThreads)
		{
			MinWorkerThreads = minWorkerThreads;
			MinCompletionPortThreads = minCompletionPortThreads;
			MaxWorkerThreads = maxWorkerThreads;
			MaxCompletionPortThreads = maxCompletionPortThreads;
			AvailableWorkerThreads = availableWorkerThreads;
			AvailableCompletionPortThreads = availableCompletionPortThreads;
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteNumber("min_worker_threads", MinWorkerThreads);
			writer.WriteNumber("min_completion_port_threads", MinCompletionPortThreads);
			writer.WriteNumber("max_worker_threads", MaxWorkerThreads);
			writer.WriteNumber("max_completion_port_threads", MaxCompletionPortThreads);
			writer.WriteNumber("available_worker_threads", AvailableWorkerThreads);
			writer.WriteNumber("available_completion_port_threads", AvailableCompletionPortThreads);
			writer.WriteEndObject();
		}
	}
	public interface IScopeObserver
	{
		void AddBreadcrumb(Breadcrumb breadcrumb);

		void SetExtra(string key, object? value);

		void SetTag(string key, string value);

		void UnsetTag(string key);

		void SetUser(User? user);
	}
	public interface ISentryClient
	{
		bool IsEnabled { get; }

		SentryId CaptureEvent(SentryEvent evt, Scope? scope = null);

		void CaptureUserFeedback(UserFeedback userFeedback);

		void CaptureTransaction(Transaction transaction);

		void CaptureSession(SessionUpdate sessionUpdate);

		Task FlushAsync(TimeSpan timeout);
	}
	public interface ISentryScopeManager
	{
		void ConfigureScope(Action<Scope> configureScope);

		Task ConfigureScopeAsync(Func<Scope, Task> configureScope);

		void BindClient(ISentryClient client);

		IDisposable PushScope();

		IDisposable PushScope<TState>(TState state);

		void WithScope(Action<Scope> scopeCallback);
	}
	public interface ISentryScopeStateProcessor
	{
		void Apply(Scope scope, object state);
	}
	public interface ISession
	{
		SentryId Id { get; }

		string? DistinctId { get; }

		DateTimeOffset StartTimestamp { get; }

		string Release { get; }

		string? Environment { get; }

		string? IpAddress { get; }

		string? UserAgent { get; }

		int ErrorCount { get; }
	}
	internal interface ISessionManager
	{
		bool IsSessionActive { get; }

		SessionUpdate? TryRecoverPersistedSession();

		SessionUpdate? StartSession();

		SessionUpdate? EndSession(DateTimeOffset timestamp, SessionEndStatus status);

		SessionUpdate? EndSession(SessionEndStatus status);

		void PauseSession();

		IReadOnlyList<SessionUpdate> ResumeSession();

		SessionUpdate? ReportError();
	}
	public interface ISpan : ISpanData, ISpanContext, ITraceContext, IHasTags, IHasExtra
	{
		new string? Description { get; set; }

		new string Operation { get; set; }

		new SpanStatus? Status { get; set; }

		ISpan StartChild(string operation);

		void Finish();

		void Finish(SpanStatus status);

		void Finish(Exception exception, SpanStatus status);

		void Finish(Exception exception);
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class SpanExtensions
	{
		public static ISpan StartChild(this ISpan span, string operation, string? description)
		{
			ISpan span2 = span.StartChild(operation);
			span2.Description = description;
			return span2;
		}
	}
	public interface ISpanContext : ITraceContext
	{
	}
	public interface ISpanData : ISpanContext, ITraceContext, IHasTags, IHasExtra
	{
		DateTimeOffset StartTimestamp { get; }

		DateTimeOffset? EndTimestamp { get; }

		bool IsFinished { get; }

		SentryTraceHeader GetTraceHeader();
	}
	public interface ITransaction : ITransactionData, ISpanData, ISpanContext, ITraceContext, IHasTags, IHasExtra, ITransactionContext, IEventLike, IHasBreadcrumbs, ISpan
	{
		new string Name { get; set; }

		new bool? IsParentSampled { get; set; }

		IReadOnlyCollection<ISpan> Spans { get; }

		ISpan? GetLastActiveSpan();
	}
	public interface ITransactionContext : ISpanContext, ITraceContext
	{
		string Name { get; }

		bool? IsParentSampled { get; }
	}
	public interface ITransactionData : ISpanData, ISpanContext, ITraceContext, IHasTags, IHasExtra, ITransactionContext, IEventLike, IHasBreadcrumbs
	{
	}
	public sealed class Package : IJsonSerializable
	{
		public string Name { get; }

		public string Version { get; }

		public Package(string name, string version)
		{
			Name = name;
			Version = version;
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteStringIfNotWhiteSpace("name", Name);
			writer.WriteStringIfNotWhiteSpace("version", Version);
			writer.WriteEndObject();
		}

		public static Package FromJson(JsonElement json)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			string stringOrThrow = ((JsonElement)(ref json)).GetProperty("name").GetStringOrThrow();
			string stringOrThrow2 = ((JsonElement)(ref json)).GetProperty("version").GetStringOrThrow();
			return new Package(stringOrThrow, stringOrThrow2);
		}

		public override int GetHashCode()
		{
			return (Name.GetHashCode() * 397) ^ Version.GetHashCode();
		}

		public override bool Equals(object? obj)
		{
			if (this == obj)
			{
				return true;
			}
			if (obj is Package package)
			{
				if (Name == package.Name)
				{
					return Version == package.Version;
				}
				return false;
			}
			return false;
		}
	}
	internal class PersistedSessionUpdate : IJsonSerializable
	{
		public SessionUpdate Update { get; }

		public DateTimeOffset? PauseTimestamp { get; }

		public PersistedSessionUpdate(SessionUpdate update, DateTimeOffset? pauseTimestamp)
		{
			Update = update;
			PauseTimestamp = pauseTimestamp;
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteSerializable("update", Update, logger);
			DateTimeOffset? pauseTimestamp = PauseTimestamp;
			if (pauseTimestamp.HasValue)
			{
				DateTimeOffset valueOrDefault = pauseTimestamp.GetValueOrDefault();
				writer.WriteString("paused", valueOrDefault);
			}
			writer.WriteEndObject();
		}

		public static PersistedSessionUpdate FromJson(JsonElement json)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			SessionUpdate update = SessionUpdate.FromJson(((JsonElement)(ref json)).GetProperty("update"));
			JsonElement? propertyOrNull = json.GetPropertyOrNull("paused");
			DateTimeOffset? obj;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				JsonElement valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((JsonElement)(ref valueOrDefault)).GetDateTimeOffset();
			}
			DateTimeOffset? pauseTimestamp = obj;
			return new PersistedSessionUpdate(update, pauseTimestamp);
		}
	}
	public sealed class Contexts : ConcurrentDictionary<string, object>, IJsonSerializable
	{
		public App App => this.GetOrCreate<App>("app");

		public Browser Browser => this.GetOrCreate<Browser>("browser");

		public Device Device => this.GetOrCreate<Device>("device");

		public Sentry.Protocol.OperatingSystem OperatingSystem => this.GetOrCreate<Sentry.Protocol.OperatingSystem>("os");

		public Sentry.Protocol.Runtime Runtime => this.GetOrCreate<Sentry.Protocol.Runtime>("runtime");

		public Gpu Gpu => this.GetOrCreate<Gpu>("gpu");

		public Sentry.Protocol.Trace Trace => this.GetOrCreate<Sentry.Protocol.Trace>("trace");

		public Contexts()
			: base((IEqualityComparer<string>?)StringComparer.Ordinal)
		{
		}

		internal Contexts Clone()
		{
			Contexts contexts = new Contexts();
			CopyTo(contexts);
			return contexts;
		}

		internal void CopyTo(Contexts to)
		{
			using IEnumerator<KeyValuePair<string, object>> enumerator = GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<string, object> kv = enumerator.Current;
				to.AddOrUpdate(kv.Key, (string _) => (!(kv.Value is ICloneable<object> cloneable)) ? kv.Value : cloneable.Clone(), delegate(string _, object existing)
				{
					if (existing is IUpdatable updatable)
					{
						updatable.UpdateFrom(kv.Value);
					}
					else if (kv.Value is IDictionary<string, object> dictionary && existing is IDictionary<string, object> dictionary2)
					{
						foreach (KeyValuePair<string, object> item in dictionary)
						{
							if (!dictionary2.TryGetValue(item.Key, out var value))
							{
								dictionary2.Add(item);
							}
							else if (value == null)
							{
								dictionary2[item.Key] = item.Value;
							}
						}
					}
					return existing;
				});
			}
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteDictionaryValue(this, logger);
		}

		public static Contexts FromJson(JsonElement json)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			Contexts contexts = new Contexts();
			ObjectEnumerator val = ((JsonElement)(ref json)).EnumerateObject();
			ObjectEnumerator enumerator = ((ObjectEnumerator)(ref val)).GetEnumerator();
			try
			{
				while (((ObjectEnumerator)(ref enumerator)).MoveNext())
				{
					((ObjectEnumerator)(ref enumerator)).Current.Deconstruct(out string name, out JsonElement value);
					string text = name;
					JsonElement json2 = value;
					JsonElement? propertyOrNull = json2.GetPropertyOrNull("type");
					object obj;
					if (!propertyOrNull.HasValue)
					{
						obj = null;
					}
					else
					{
						value = propertyOrNull.GetValueOrDefault();
						obj = ((JsonElement)(ref value)).GetString();
					}
					if (obj == null)
					{
						obj = text;
					}
					string a = (string)obj;
					if (string.Equals(a, "app", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.App.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "browser", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.Browser.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "device", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.Device.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "os", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.OperatingSystem.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "runtime", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.Runtime.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "gpu", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.Gpu.FromJson(json2);
						continue;
					}
					if (string.Equals(a, "trace", StringComparison.OrdinalIgnoreCase))
					{
						contexts[text] = Sentry.Protocol.Trace.FromJson(json2);
						continue;
					}
					object dynamicOrNull = json2.GetDynamicOrNull();
					if (dynamicOrNull != null)
					{
						contexts[text] = dynamicOrNull;
					}
				}
				return contexts;
			}
			finally
			{
				((IDisposable)(ObjectEnumerator)(ref enumerator)).Dispose();
			}
		}

		internal void ReplaceWith(Contexts? contexts)
		{
			Clear();
			if (contexts == null)
			{
				return;
			}
			foreach (KeyValuePair<string, object> context in contexts)
			{
				base[context.Key] = context.Value;
			}
		}

		internal Contexts? NullIfEmpty()
		{
			if (!base.IsEmpty)
			{
				return this;
			}
			return null;
		}
	}
	public enum ReportAssembliesMode
	{
		None,
		Version,
		InformationalVersion
	}
	public sealed class Request : IJsonSerializable
	{
		internal Dictionary<string, string>? InternalEnv { get; set; }

		internal Dictionary<string, string>? InternalOther { get; set; }

		internal Dictionary<string, string>? InternalHeaders { get; set; }

		public string? Url { get; set; }

		public string? Method { get; set; }

		public object? Data { get; set; }

		public string? QueryString { get; set; }

		public string? Cookies { get; set; }

		public IDictionary<string, string> Headers => InternalHeaders ?? (InternalHeaders = new Dictionary<string, string>());

		public IDictionary<string, string> Env => InternalEnv ?? (InternalEnv = new Dictionary<string, string>());

		public IDictionary<string, string> Other => InternalOther ?? (InternalOther = new Dictionary<string, string>());

		public Request Clone()
		{
			Request request = new Request();
			CopyTo(request);
			return request;
		}

		internal void CopyTo(Request? request)
		{
			if (request != null)
			{
				Request request2 = request;
				if (request2.Url == null)
				{
					string text = (request2.Url = Url);
				}
				request2 = request;
				if (request2.Method == null)
				{
					string text = (request2.Method = Method);
				}
				request2 = request;
				if (request2.Data == null)
				{
					object obj = (request2.Data = Data);
				}
				request2 = request;
				if (request2.QueryString == null)
				{
					string text = (request2.QueryString = QueryString);
				}
				request2 = request;
				if (request2.Cookies == null)
				{
					string text = (request2.Cookies = Cookies);
				}
				InternalEnv?.TryCopyTo(request.Env);
				InternalOther?.TryCopyTo(request.Other);
				InternalHeaders?.TryCopyTo(request.Headers);
			}
		}

		public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
		{
			writer.WriteStartObject();
			writer.WriteStringDictionaryIfNotEmpty("env", InternalEnv);
			writer.WriteStringDictionaryIfNotEmpty("other", InternalOther);
			writer.WriteStringDictionaryIfNotEmpty("headers", InternalHeaders);
			writer.WriteStringIfNotWhiteSpace("url", Url);
			writer.WriteStringIfNotWhiteSpace("method", Method);
			writer.WriteDynamicIfNotNull("data", Data, logger);
			writer.WriteStringIfNotWhiteSpace("query_string", QueryString);
			writer.WriteStringIfNotWhiteSpace("cookies", Cookies);
			writer.WriteEndObject();
		}

		public static Request FromJson(JsonElement json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, string> dictionary = json.GetPropertyOrNull("env")?.GetStringDictionaryOrNull();
			Dictionary<string, string> dictionary2 = json.GetPropertyOrNull("other")?.GetStringDictionaryOrNull();
			Dictionary<string, string> dictionary3 = json.GetPropertyOrNull("headers")?.GetStringDictionaryOrNull();
			JsonElement? propertyOrNull = json.GetPropertyOrNull("url");
			object obj;
			JsonElement valueOrDefault;
			if (!propertyOrNull.HasValue)
			{
				obj = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string url = (string)obj;
			propertyOrNull = json.GetPropertyOrNull("method");
			object obj2;
			if (!propertyOrNull.HasValue)
			{
				obj2 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj2 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string method = (string)obj2;
			object data = json.GetPropertyOrNull("data")?.GetDynamicOrNull();
			propertyOrNull = json.GetPropertyOrNull("query_string");
			object obj3;
			if (!propertyOrNull.HasValue)
			{
				obj3 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj3 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string queryString = (string)obj3;
			propertyOrNull = json.GetPropertyOrNull("cookies");
			object obj4;
			if (!propertyOrNull.HasValue)
			{
				obj4 = null;
			}
			else
			{
				valueOrDefault = propertyOrNull.GetValueOrDefault();
				obj4 = ((JsonElement)(ref valueOrDefault)).GetString();
			}
			string cookies = (string)obj4;
			return new Request
			{
				InternalEnv = dictionary?.WhereNotNullValue()?.ToDictionary(),
				InternalOther = dictionary2?.WhereNotNullValue().ToDictionary(),
				InternalHeaders = dictionary3?.WhereNotNullValue().ToDictionary(),
				Url = url,
				Method = method,
				Data = data,
				QueryString = queryString,
				Cookies = cookies
			};
		}
	}
	public class Scope : IEventLike, IHasBreadcrumbs, IHasTags, IHasExtra, IHasDistribution
	{
		private readonly object _lastEventIdSync = new object();

		private SentryId _lastEventId;

		private readonly object _evaluationSync = new object();

		private volatile bool _hasEvaluated;

		private readonly Lazy<ConcurrentBag<ISentryEventExceptionProcessor>> _lazyExceptionProcessors = new Lazy<ConcurrentBag<ISentryEventExceptionProcessor>>(LazyThreadSafetyMode.PublicationOnly);

		private readonly Lazy<ConcurrentBag<ISentryEventProcessor>> _lazyEventProcessors = new Lazy<ConcurrentBag<ISentryEventProcessor>>(LazyThreadSafetyMode.PublicationOnly);

		private readonly Lazy<ConcurrentBag<ISentryTransactionProcessor>> _lazyTransactionProcessors = new Lazy<ConcurrentBag<ISentryTransactionProcessor>>(LazyThreadSafetyMode.PublicationOnly);

		private Request? _request;

		private readonly Contexts _contexts = new Contexts();

		private User? _user;

		private string? _fallbackTransactionName;

		private ITransaction? _transaction;

		private readonly ConcurrentQueue<Breadcrumb> _breadcrumbs = new ConcurrentQueue<Breadcrumb>();

		private readonly ConcurrentDictionary<string, object?> _extra = new ConcurrentDictionary<string, object>();

		private readonly ConcurrentDictionary<string, string> _tags = new ConcurrentDictionary<string, string>();

		private ConcurrentBag<Attachment> _attachments = new ConcurrentBag<Attachment>();

		internal SentryOptions Options { get; }

		internal bool Locked { get; set; }

		internal SentryId LastEventId
		{
			get
			{
				lock (_lastEventIdSync)
				{
					return _lastEventId;
				}
			}
			set
			{
				lock (_lastEventIdSync)
				{
					_lastEventId = value;
				}
			}
		}

		internal bool HasEvaluated => _hasEvaluated;

		internal ConcurrentBag<ISentryEventExceptionProcessor> ExceptionProcessors => _lazyExceptionProcessors.Value;

		internal ConcurrentBag<ISentryEventProcessor> EventProcessors => _lazyEventProcessors.Value;

		internal ConcurrentBag<ISentryTransactionProcessor> TransactionProcessors => _lazyTransactionProcessors.Value;

		public SentryLevel? Level { get; set; }

		public Request Request
		{
			get
			{
				return _request ?? (_request = new Request());
			}
			set
			{
				_request = value;
			}
		}

		public Contexts Contexts
		{
			get
			{
				return _contexts;
			}
			set
			{
				_contexts.ReplaceWith(value);
			}
		}

		internal Action<User?> UserChanged => delegate(User? user)
		{
			if (Options.EnableScopeSync)
			{
				Options.ScopeObserver?.SetUser(user);
			}
		};

		public User User
		{
			get
			{
				User user = _user;
				if (user == null)
				{
					User obj = new User
					{
						PropertyChanged = UserChanged
					};
					User user2 = obj;
					_user = obj;
					user = user2;
				}
				return user;
			}
			set
			{
				_user = value;
				if (_user != null)
				{
					_user.PropertyChanged = UserChanged;
				}
				UserChanged(_user);
			}
		}

		public string? Platform { get; set; }

		public string? Release { get; set; }

		public string? Distribution { get; set; }

		public string? Environment { get; set; }

		public string? TransactionName
		{
			get
			{
				return Transaction?.Name ?? _fallbackTransactionName;
			}
			set
			{
				_fallbackTransactionName = value;
				ITransaction transaction = Transaction;
				if (transaction != null)
				{
					transaction.Name = ((!string.IsNullOrWhiteSpace(value)) ? value : string.Empty);
				}
			}
		}

		public ITransaction? Transaction
		{
			get
			{
				return _transaction;
			}
			set
			{
				_transaction = value;
			}
		}

		internal SessionUpdate? SessionUpdate { get; set; }

		public SdkVersion Sdk { get; } = new SdkVersion();


		public IReadOnlyList<string> Fingerprint { get; set; } = Array.Empty<string>();


		public IReadOnlyCollection<Breadcrumb> Breadcrumbs => _breadcrumbs;

		public IReadOnlyDictionary<string, object?> Extra => _extra;

		public IReadOnlyDictionary<string, string> Tags => _tags;

		public IReadOnlyCollection<Attachment> Attachments => _attachments;

		internal event EventHandler? OnEvaluating;

		public Scope(SentryOptions? options)
		{
			Options = options ?? new SentryOptions();
		}

		internal Scope()
			: this(new SentryOptions())
		{
		}

		public void AddBreadcrumb(Breadcrumb breadcrumb)
		{
			Func<Breadcrumb, Breadcrumb> beforeBreadcrumb = Options.BeforeBreadcrumb;
			if (beforeBreadcrumb != null)
			{
				Breadcrumb breadcrumb2 = beforeBreadcrumb(breadcrumb);
				if (breadcrumb2 == null)
				{
					return;
				}
				breadcrumb = breadcrumb2;
			}
			if (Options.MaxBreadcrumbs > 0)
			{
				if (Breadcrumbs.Count - Options.MaxBreadcrumbs + 1 > 0)
				{
					_breadcrumbs.TryDequeue(out Breadcrumb _);
				}
				_breadcrumbs.Enqueue(breadcrumb);
				if (Options.EnableScopeSync)
				{
					Options.ScopeObserver?.AddBreadcrumb(breadcrumb);
				}
			}
		}

		public void SetExtra(string key, object? value)
		{
			_extra[key] = value;
			if (Options.EnableScopeSync)
			{
				Options.ScopeObserver?.SetExtra(key, value);
			}
		}

		public void SetTag(string key, string value)
		{
			_tags[key] = value;
			if (Options.EnableScopeSync)
			{
				Options.ScopeObserver?.SetTag(key, value);
			}
		}

		public void UnsetTag(string key)
		{
			_tags.TryRemove(key, out string _);
			if (Options.EnableScopeSync)
			{
				Options.ScopeObserver?.UnsetTag(key);
			}
		}

		public void AddAttachment(Attachment attachment)
		{
			_attachments.Add(attachment);
		}

		public void ClearAttachments()
		{
			Interlocked.Exchange(ref _attachments, new ConcurrentBag<Attachment>());
		}

		public void Apply(IEventLike other)
		{
			if (other.IsNull())
			{
				return;
			}
			if (!other.Fingerprint.Any() && Fingerprint.Any())
			{
				other.Fingerprint = Fingerprint;
			}
			foreach (Breadcrumb breadcrumb in Breadcrumbs)
			{
				other.AddBreadcrumb(breadcrumb);
			}
			string key;
			foreach (KeyValuePair<string, object> item in Extra)
			{
				PolyfillExtensions.Deconstruct(item, out key, out var value);
				string key2 = key;
				object value2 = value;
				if (!other.Extra.ContainsKey(key2))
				{
					other.SetExtra(key2, value2);
				}
			}
			foreach (KeyValuePair<string, string> tag in Tags)
			{
				PolyfillExtensions.Deconstruct(tag, out key, out var value3);
				string key3 = key;
				string value4 = value3;
				if (!other.Tags.ContainsKey(key3))
				{
					other.SetTag(key3, value4);
				}
			}
			Contexts.CopyTo(other.Contexts);
			Request.CopyTo(other.Request);
			User.CopyTo(other.User);
			IEventLike eventLike = other;
			if (eventLike.Platform == null)
			{
				string value3 = (eventLike.Platform = Platform);
			}
			eventLike = other;
			if (eventLike.Release == null)
			{
				string value3 = (eventLike.Release = Release);
			}
			other.WithDistribution(delegate(IHasDistribution _)
			{
				if (_.Distribution == null)
				{
					string text = (_.Distribution = Distribution);
				}
			});
			eventLike = other;
			if (eventLike.Environment == null)
			{
				string value3 = (eventLike.Environment = Environment);
			}
			eventLike = other;
			if (eventLike.TransactionName == null)
			{
				string value3 = (eventLike.TransactionName = TransactionName);
			}
			eventLike = other;
			if (!eventLike.Level.HasValue)
			{
				SentryLevel? sentryLevel = (eventLike.Level = Level);
			}
			if (Sdk.Name != null && Sdk.Version != null)
			{
				other.Sdk.Name = Sdk.Name;
				other.Sdk.Version = Sdk.Version;
			}
			foreach (Package internalPackage in Sdk.InternalPackages)
			{
				other.Sdk.AddPackage(internalPackage);
			}
		}

		public void Apply(Scope other)
		{
			if (other.IsNull())
			{
				return;
			}
			Apply((IEventLike)other);
			Scope scope = other;
			if (scope.Transaction == null)
			{
				ITransaction transaction2 = (scope.Transaction = Transaction);
			}
			scope = other;
			if (scope.SessionUpdate == null)
			{
				SessionUpdate sessionUpdate2 = (scope.SessionUpdate = SessionUpdate);
			}
			foreach (Attachment attachment in Attachments)
			{
				other.AddAttachment(attachment);
			}
		}

		public void Apply(object state)
		{
			Options.SentryScopeStateProcessor.Apply(this, state);
		}

		public Scope Clone()
		{
			Scope scope = new Scope(Options);
			Apply(scope);
			foreach (ISentryEventProcessor eventProcessor in EventProcessors)
			{
				scope.EventProcessors.Add(eventProcessor);
			}
			foreach (ISentryTransactionProcessor transactionProcessor in TransactionProcessors)
			{
				scope.TransactionProcessors.Add(transactionProcessor);
			}
			foreach (ISentryEventExceptionProcessor exceptionProcessor in ExceptionProcessors)
			{
				scope.ExceptionProcessors.Add(exceptionProcessor);
			}
			return scope;
		}

		internal void Evaluate()
		{
			if (_hasEvaluated)
			{
				return;
			}
			lock (_evaluationSync)
			{
				if (_hasEvaluated)
				{
					return;
				}
				try
				{
					this.OnEvaluating?.Invoke(this, EventArgs.Empty);
				}
				catch (Exception exception)
				{
					Options.DiagnosticLogger?.LogError("Failed invoking event handler.", exception);
				}
				finally
				{
					_hasEvaluated = true;
				}
			}
		}

		public ISpan? GetSpan()
		{
			return Transaction?.GetLastActiveSpan() ?? Transaction;
		}

		internal void ResetTransaction(ITransaction? expectedCurrentTransaction)
		{
			Interlocked.CompareExchange(ref _transaction, null, expectedCurrentTransaction);
		}
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class ScopeExtensions
	{
		public static IEnumerable<ISentryEventProcessor> GetAllEventProcessors(this Scope scope)
		{
			foreach (ISentryEventProcessor allEventProcessor in scope.Options.GetAllEventProcessors())
			{
				yield return allEventProcessor;
			}
			foreach (ISentryEventProcessor eventProcessor in scope.EventProcessors)
			{
				yield return eventProcessor;
			}
		}

		public static IEnumerable<ISentryTransactionProcessor> GetAllTransactionProcessors(this Scope scope)
		{
			foreach (ISentryTransactionProcessor allTransactionProcessor in scope.Options.GetAllTransactionProcessors())
			{
				yield return allTransactionProcessor;
			}
			foreach (ISentryTransactionProcessor transactionProcessor in scope.TransactionProcessors)
			{
				yield return transactionProcessor;
			}
		}

		public static IEnumerable<ISentryEventExceptionProcessor> GetAllExceptionProcessors(this Scope scope)
		{
			foreach (ISentryEventExceptionProcessor allExceptionProcessor in scope.Options.GetAllExceptionProcessors())
			{
				yield return allExceptionProcessor;
			}
			foreach (ISentryEventExceptionProcessor exceptionProcessor in scope.ExceptionProcessors)
			{
				yield return exceptionProcessor;
			}
		}

		public static void AddExceptionProcessor(this Scope scope, ISentryEventExceptionProcessor processor)
		{
			scope.ExceptionProcessors.Add(processor);
		}

		public static void AddExceptionProcessors(this Scope scope, IEnumerable<ISentryEventExceptionProcessor> processors)
		{
			foreach (ISentryEventExceptionProcessor processor in processors)
			{
				scope.ExceptionProcessors.Add(processor);
			}
		}

		public static void AddEventProcessor(this Scope scope, ISentryEventProcessor processor)
		{
			scope.EventProcessors.Add(processor);
		}

		public static void AddEventProcessor(this Scope scope, Func<SentryEvent, SentryEvent> processor)
		{
			scope.AddEventProcessor(new DelegateEventProcessor(processor));
		}

		public static void AddEventProcessors(this Scope scope, IEnumerable<ISentryEventProcessor> processors)
		{
			foreach (ISentryEventProcessor processor in processors)
			{
				scope.EventProcessors.Add(processor);
			}
		}

		public static void AddTransactionProcessor(this Scope scope, ISentryTransactionProcessor processor)
		{
			scope.TransactionProcessors.Add(processor);
		}

		public static void AddTransactionProcessor(this Scope scope, Func<Transaction, Transaction?> processor)
		{
			scope.AddTransactionProcessor(new DelegateTransactionProcessor(processor));
		}

		public static void AddTransactionProcessors(this Scope scope, IEnumerable<ISentryTransactionProcessor> processors)
		{
			foreach (ISentryTransactionProcessor processor in processors)
			{
				scope.TransactionProcessors.Add(processor);
			}
		}

		public static void AddAttachment(this Scope scope, Stream stream, string fileName, AttachmentType type = AttachmentType.Default, string? contentType = null)
		{
			if (!stream.TryGetLength().HasValue)
			{
				scope.Options.LogWarning("Cannot evaluate the size of attachment '{0}' because the stream is not seekable.", fileName);
			}
			else
			{
				scope.AddAttachment(new Attachment(type, new StreamAttachmentContent(stream), fileName, contentType));
			}
		}

		public static void AddAttachment(this Scope scope, byte[] data, string fileName, AttachmentType type = AttachmentType.Default, string? contentType = null)
		{
			scope.AddAttachment(new Attachment(type, new ByteAttachmentContent(data), fileName, contentType));
		}

		public static void AddAttachment(this Scope scope, string filePath, AttachmentType type = AttachmentType.Default, string? contentType = null)
		{
			scope.AddAttachment(new Attachment(type, new FileAttachmentContent(filePath, scope.Options.UseAsyncFileIO), Path.GetFileName(filePath), contentType));
		}

		internal static ISpan? LastCreatedSpan(this Scope scope)
		{
			return scope.Transaction?.Spans.LastOrDefault((ISpan s) => !s.IsFinished);
		}
	}
	public sealed class SdkVersion : IJsonSerializable
	{
		private static readonly Lazy<SdkVersion> InstanceLazy = new Lazy<SdkVersion>(() => new SdkVersion
		{
			Name = "sentry.dotnet",
			Version = typeof(ISentryClient).Assembly.GetVersion()
		});

		internal static SdkVersion Instance => InstanceLazy.Value;

		internal ConcurrentBag<Package> InternalPackages { get; set; } = new ConcurrentBag<Package>();


		internal ConcurrentBag<string> Integrations { get; set; } = new ConcurrentBag<string>();


		public IEnumerable<Package> Packages => InternalPackages;

		public string? Name
		{
			get; [EditorBrowsable(EditorBrowsableState.Never)]
			set;
		}

		public string? Version
		{
			get; [EditorBrowsable(EditorBrowsableState.Never)]
			set;
		}

		public void AddPac

Sentry.Microsoft.Bcl.AsyncInterfaces.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDefaultAlias("Microsoft.Bcl.AsyncInterfaces")]
[assembly: AssemblyMetadata(".NETFrameworkAssembly", "")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: AssemblyMetadata("PreferInbox", "True")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Microsoft.Bcl.AsyncInterfaces")]
[assembly: AssemblyFileVersion("5.0.20.51904")]
[assembly: AssemblyInformationalVersion("5.0.0+cf258a14b70ad9069470a108f13765e0e5988f51")]
[assembly: AssemblyProduct("Microsoft® .NET")]
[assembly: AssemblyTitle("Microsoft.Bcl.AsyncInterfaces")]
[assembly: AssemblyMetadata("RepositoryUrl", "git://github.com/dotnet/runtime")]
[assembly: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[assembly: InternalsVisibleTo("Sentry.System.Buffers")]
[assembly: AssemblyVersion("5.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
namespace System
{
	internal interface IAsyncDisposable
	{
		ValueTask DisposeAsync();
	}
}
namespace System.Collections.Generic
{
	internal interface IAsyncEnumerable<out T>
	{
		IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default(CancellationToken));
	}
	internal interface IAsyncEnumerator<out T> : IAsyncDisposable
	{
		T Current { get; }

		ValueTask<bool> MoveNextAsync();
	}
}
namespace System.Runtime.CompilerServices
{
	[StructLayout(LayoutKind.Auto)]
	internal struct AsyncIteratorMethodBuilder
	{
		private AsyncTaskMethodBuilder _methodBuilder;

		private object _id;

		internal object ObjectIdForDebugger => _id ?? Interlocked.CompareExchange(ref _id, new object(), null) ?? _id;

		public static AsyncIteratorMethodBuilder Create()
		{
			AsyncIteratorMethodBuilder result = default(AsyncIteratorMethodBuilder);
			result._methodBuilder = AsyncTaskMethodBuilder.Create();
			return result;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void MoveNext<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
		{
			_methodBuilder.Start(ref stateMachine);
		}

		public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine);
		}

		public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine
		{
			_methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
		}

		public void Complete()
		{
			_methodBuilder.SetResult();
		}
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
	internal sealed class AsyncIteratorStateMachineAttribute : StateMachineAttribute
	{
		public AsyncIteratorStateMachineAttribute(Type stateMachineType)
			: base(stateMachineType)
		{
		}
	}
	[StructLayout(LayoutKind.Auto)]
	internal readonly struct ConfiguredAsyncDisposable
	{
		private readonly IAsyncDisposable _source;

		private readonly bool _continueOnCapturedContext;

		internal ConfiguredAsyncDisposable(IAsyncDisposable source, bool continueOnCapturedContext)
		{
			_source = source;
			_continueOnCapturedContext = continueOnCapturedContext;
		}

		public ConfiguredValueTaskAwaitable DisposeAsync()
		{
			return _source.DisposeAsync().ConfigureAwait(_continueOnCapturedContext);
		}
	}
	[StructLayout(LayoutKind.Auto)]
	internal readonly struct ConfiguredCancelableAsyncEnumerable<T>
	{
		[StructLayout(LayoutKind.Auto)]
		public readonly struct Enumerator
		{
			private readonly IAsyncEnumerator<T> _enumerator;

			private readonly bool _continueOnCapturedContext;

			public T Current => _enumerator.Current;

			internal Enumerator(IAsyncEnumerator<T> enumerator, bool continueOnCapturedContext)
			{
				_enumerator = enumerator;
				_continueOnCapturedContext = continueOnCapturedContext;
			}

			public ConfiguredValueTaskAwaitable<bool> MoveNextAsync()
			{
				return _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext);
			}

			public ConfiguredValueTaskAwaitable DisposeAsync()
			{
				return _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext);
			}
		}

		private readonly IAsyncEnumerable<T> _enumerable;

		private readonly CancellationToken _cancellationToken;

		private readonly bool _continueOnCapturedContext;

		internal ConfiguredCancelableAsyncEnumerable(IAsyncEnumerable<T> enumerable, bool continueOnCapturedContext, CancellationToken cancellationToken)
		{
			_enumerable = enumerable;
			_continueOnCapturedContext = continueOnCapturedContext;
			_cancellationToken = cancellationToken;
		}

		public ConfiguredCancelableAsyncEnumerable<T> ConfigureAwait(bool continueOnCapturedContext)
		{
			return new ConfiguredCancelableAsyncEnumerable<T>(_enumerable, continueOnCapturedContext, _cancellationToken);
		}

		public ConfiguredCancelableAsyncEnumerable<T> WithCancellation(CancellationToken cancellationToken)
		{
			return new ConfiguredCancelableAsyncEnumerable<T>(_enumerable, _continueOnCapturedContext, cancellationToken);
		}

		public Enumerator GetAsyncEnumerator()
		{
			return new Enumerator(_enumerable.GetAsyncEnumerator(_cancellationToken), _continueOnCapturedContext);
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal sealed class EnumeratorCancellationAttribute : Attribute
	{
	}
}
namespace System.Threading.Tasks
{
	internal static class TaskAsyncEnumerableExtensions
	{
		public static ConfiguredAsyncDisposable ConfigureAwait(this IAsyncDisposable source, bool continueOnCapturedContext)
		{
			return new ConfiguredAsyncDisposable(source, continueOnCapturedContext);
		}

		public static ConfiguredCancelableAsyncEnumerable<T> ConfigureAwait<T>(this IAsyncEnumerable<T> source, bool continueOnCapturedContext)
		{
			return new ConfiguredCancelableAsyncEnumerable<T>(source, continueOnCapturedContext, default(CancellationToken));
		}

		public static ConfiguredCancelableAsyncEnumerable<T> WithCancellation<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken)
		{
			return new ConfiguredCancelableAsyncEnumerable<T>(source, continueOnCapturedContext: true, cancellationToken);
		}
	}
}
namespace System.Threading.Tasks.Sources
{
	[StructLayout(LayoutKind.Auto)]
	internal struct ManualResetValueTaskSourceCore<TResult>
	{
		private Action<object> _continuation;

		private object _continuationState;

		private ExecutionContext _executionContext;

		private object _capturedContext;

		private bool _completed;

		private TResult _result;

		private ExceptionDispatchInfo _error;

		private short _version;

		public bool RunContinuationsAsynchronously { get; set; }

		public short Version => _version;

		public void Reset()
		{
			_version++;
			_completed = false;
			_result = default(TResult);
			_error = null;
			_executionContext = null;
			_capturedContext = null;
			_continuation = null;
			_continuationState = null;
		}

		public void SetResult(TResult result)
		{
			_result = result;
			SignalCompletion();
		}

		public void SetException(Exception error)
		{
			_error = ExceptionDispatchInfo.Capture(error);
			SignalCompletion();
		}

		public ValueTaskSourceStatus GetStatus(short token)
		{
			ValidateToken(token);
			if (_continuation != null && _completed)
			{
				if (_error != null)
				{
					if (!(_error.SourceException is OperationCanceledException))
					{
						return ValueTaskSourceStatus.Faulted;
					}
					return ValueTaskSourceStatus.Canceled;
				}
				return ValueTaskSourceStatus.Succeeded;
			}
			return ValueTaskSourceStatus.Pending;
		}

		public TResult GetResult(short token)
		{
			ValidateToken(token);
			if (!_completed)
			{
				throw new InvalidOperationException();
			}
			_error?.Throw();
			return _result;
		}

		public void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags)
		{
			if (continuation == null)
			{
				throw new ArgumentNullException("continuation");
			}
			ValidateToken(token);
			if ((flags & ValueTaskSourceOnCompletedFlags.FlowExecutionContext) != 0)
			{
				_executionContext = ExecutionContext.Capture();
			}
			if ((flags & ValueTaskSourceOnCompletedFlags.UseSchedulingContext) != 0)
			{
				SynchronizationContext current = SynchronizationContext.Current;
				if (current != null && current.GetType() != typeof(SynchronizationContext))
				{
					_capturedContext = current;
				}
				else
				{
					TaskScheduler current2 = TaskScheduler.Current;
					if (current2 != TaskScheduler.Default)
					{
						_capturedContext = current2;
					}
				}
			}
			object obj = _continuation;
			if (obj == null)
			{
				_continuationState = state;
				obj = Interlocked.CompareExchange(ref _continuation, continuation, null);
			}
			if (obj == null)
			{
				return;
			}
			if (obj != System.Threading.Tasks.Sources.ManualResetValueTaskSourceCoreShared.s_sentinel)
			{
				throw new InvalidOperationException();
			}
			object capturedContext = _capturedContext;
			if (capturedContext != null)
			{
				if (!(capturedContext is SynchronizationContext synchronizationContext))
				{
					if (capturedContext is TaskScheduler scheduler)
					{
						Task.Factory.StartNew(continuation, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, scheduler);
					}
				}
				else
				{
					synchronizationContext.Post(delegate(object s)
					{
						Tuple<Action<object>, object> tuple = (Tuple<Action<object>, object>)s;
						tuple.Item1(tuple.Item2);
					}, Tuple.Create(continuation, state));
				}
			}
			else
			{
				Task.Factory.StartNew(continuation, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
			}
		}

		private void ValidateToken(short token)
		{
			if (token != _version)
			{
				throw new InvalidOperationException();
			}
		}

		private void SignalCompletion()
		{
			if (_completed)
			{
				throw new InvalidOperationException();
			}
			_completed = true;
			if (_continuation == null && Interlocked.CompareExchange(ref _continuation, System.Threading.Tasks.Sources.ManualResetValueTaskSourceCoreShared.s_sentinel, null) == null)
			{
				return;
			}
			if (_executionContext != null)
			{
				ExecutionContext.Run(_executionContext, delegate(object s)
				{
					((ManualResetValueTaskSourceCore<TResult>)s).InvokeContinuation();
				}, this);
			}
			else
			{
				InvokeContinuation();
			}
		}

		private void InvokeContinuation()
		{
			object capturedContext = _capturedContext;
			if (capturedContext != null)
			{
				if (!(capturedContext is SynchronizationContext synchronizationContext))
				{
					if (capturedContext is TaskScheduler scheduler)
					{
						Task.Factory.StartNew(_continuation, _continuationState, CancellationToken.None, TaskCreationOptions.DenyChildAttach, scheduler);
					}
				}
				else
				{
					synchronizationContext.Post(delegate(object s)
					{
						Tuple<Action<object>, object> tuple = (Tuple<Action<object>, object>)s;
						tuple.Item1(tuple.Item2);
					}, Tuple.Create(_continuation, _continuationState));
				}
			}
			else if (RunContinuationsAsynchronously)
			{
				Task.Factory.StartNew(_continuation, _continuationState, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
			}
			else
			{
				_continuation(_continuationState);
			}
		}
	}
	internal static class ManualResetValueTaskSourceCoreShared
	{
		internal static readonly Action<object> s_sentinel = CompletionSentinel;

		private static void CompletionSentinel(object _)
		{
			throw new InvalidOperationException();
		}
	}
}

Sentry.System.Buffers.dll

Decompiled 2 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: InternalsVisibleTo("Sentry.Unity.iOS")]
[assembly: InternalsVisibleTo("Sentry.System.Memory")]
[assembly: InternalsVisibleTo("Sentry.System.Reflection.Metadata")]
[assembly: InternalsVisibleTo("Sentry.System.Runtime.CompilerServices.Unsafe")]
[assembly: InternalsVisibleTo("Sentry")]
[assembly: InternalsVisibleTo("Sentry.System.Collections.Immutable")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Json")]
[assembly: InternalsVisibleTo("Sentry.Unity")]
[assembly: InternalsVisibleTo("Sentry.System.Threading.Tasks.Extensions")]
[assembly: InternalsVisibleTo("Sentry.System.Numerics.Vectors")]
[assembly: InternalsVisibleTo("Sentry.System.Text.Encodings.Web")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Microsoft.Bcl.AsyncInterfaces")]
[assembly: InternalsVisibleTo("Sentry.Unity.Android")]
[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
{
	internal 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;
		}
	}
}