Decompiled source of JusticeForF7 v2026.213.0
plugins/JusticeForF7/JusticeForF7.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; 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.Diagnostics.Tracing; using System.Globalization; using System.IO; using System.Numerics; using System.Numerics.Hashing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Text; using System.Text.Encodings.Web; using System.Text.Internal; using System.Text.Json.Serialization; using System.Text.Json.Serialization.Converters; using System.Text.Unicode; using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Sources; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FxResources.System.Buffers; using FxResources.System.Memory; using FxResources.System.Numerics.Vectors; using FxResources.System.Text.Encodings.Web; using FxResources.System.Text.Json; using HarmonyLib; using JusticeForF7.Patches; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JusticeForF7")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ab4f131f3195bad3d9fa97807ec4b3a2482bfa1d")] [assembly: AssemblyProduct("JusticeForF7")] [assembly: AssemblyTitle("JusticeForF7")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace JusticeForF7 { [BepInPlugin("wow-much.justice-for-f7", "Justice for F7", "2026.213.0")] public sealed class Plugin : BaseUnityPlugin { private Harmony? _harmony; private WorldUIHider? _hider; private void Awake() { //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch. When false, F7 behaves as vanilla."); if (!val.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Justice for F7 v2026.213.0 loaded (disabled via config)"); return; } ConfigEntry<bool> val2 = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableLogging", true, "Enable debug logging. Set to false to silence all mod log output."); ConfigEntry<int> rescanInterval = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RescanInterval", 30, "Frames between re-scans while UI is hidden (0 = disable re-scan)."); ConfigEntry<bool> hideNameplates = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideNameplates", true, "Hide NPC, SimPlayer, and player nameplates."); ConfigEntry<bool> hideDamageNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideDamageNumbers", true, "Hide floating damage and heal numbers."); ConfigEntry<bool> hideTargetRings = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideTargetRings", true, "Hide the selection ring under targeted characters."); ConfigEntry<bool> hideXPOrbs = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideXPOrbs", true, "Hide XP orb particles."); ConfigEntry<bool> hideCastBars = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideCastBars", true, "Hide NPC and SimPlayer cast bars above nameplates."); ConfigEntry<bool> hideOtherWorldText = ((BaseUnityPlugin)this).Config.Bind<bool>("Elements", "HideOtherWorldText", true, "Hide remaining world-space text (loot prompts, etc.)."); _hider = new WorldUIHider(((BaseUnityPlugin)this).Logger, val2, hideNameplates, hideDamageNumbers, hideTargetRings, hideXPOrbs, hideCastBars, hideOtherWorldText, rescanInterval); TypeTextPatch.Hider = _hider; DmgPopPatch.Hider = _hider; XPBubPatch.Hider = _hider; _harmony = new Harmony("wow-much.justice-for-f7"); _harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; if (val2.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Justice for F7 v2026.213.0 loaded"); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { _hider?.OnSceneLoaded(); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class PluginInfo { public const string GUID = "wow-much.justice-for-f7"; public const string Name = "Justice for F7"; public const string Version = "2026.213.0"; } internal sealed class WorldUIHider { private readonly ManualLogSource _log; private readonly ConfigEntry<bool> _enableLogging; private readonly ConfigEntry<bool> _hideNameplates; private readonly ConfigEntry<bool> _hideDamageNumbers; private readonly ConfigEntry<bool> _hideTargetRings; private readonly ConfigEntry<bool> _hideXPOrbs; private readonly ConfigEntry<bool> _hideCastBars; private readonly ConfigEntry<bool> _hideOtherWorldText; private readonly ConfigEntry<int> _rescanInterval; private readonly HashSet<Renderer> _disabledRenderers = new HashSet<Renderer>(); private readonly HashSet<GameObject> _disabledGameObjects = new HashSet<GameObject>(); private int _framesSinceLastScan; public bool IsHidden { get; private set; } public bool SuppressDamageNumbers => IsHidden && _hideDamageNumbers.Value; public bool SuppressXPOrbs => IsHidden && _hideXPOrbs.Value; public WorldUIHider(ManualLogSource log, ConfigEntry<bool> enableLogging, ConfigEntry<bool> hideNameplates, ConfigEntry<bool> hideDamageNumbers, ConfigEntry<bool> hideTargetRings, ConfigEntry<bool> hideXPOrbs, ConfigEntry<bool> hideCastBars, ConfigEntry<bool> hideOtherWorldText, ConfigEntry<int> rescanInterval) { _log = log; _enableLogging = enableLogging; _hideNameplates = hideNameplates; _hideDamageNumbers = hideDamageNumbers; _hideTargetRings = hideTargetRings; _hideXPOrbs = hideXPOrbs; _hideCastBars = hideCastBars; _hideOtherWorldText = hideOtherWorldText; _rescanInterval = rescanInterval; } public void OnUIHidden() { IsHidden = true; _framesSinceLastScan = 0; ScanAndHide(); } public void OnUIShown() { IsHidden = false; RestoreAll(); } public void Tick() { if (!IsHidden) { return; } int value = _rescanInterval.Value; if (value > 0) { _framesSinceLastScan++; if (_framesSinceLastScan >= value) { _framesSinceLastScan = 0; ScanAndHide(); } } } public void OnSceneLoaded() { _disabledRenderers.Clear(); _disabledGameObjects.Clear(); if (IsHidden) { _framesSinceLastScan = 0; ScanAndHide(); } } private void ScanAndHide() { int num = 0; if (_hideNameplates.Value) { num += HideNameplates(); } if (_hideDamageNumbers.Value) { num += HideDamageNumbers(); } if (_hideTargetRings.Value) { num += HideTargetRings(); } if (_hideXPOrbs.Value) { num += HideXPOrbs(); } if (_hideCastBars.Value) { num += HideCastBars(); } if (_hideOtherWorldText.Value) { num += HideOtherWorldText(); } if (_enableLogging.Value) { _log.LogDebug((object)$"Scan complete: {num} elements hidden"); } } private int HideNameplates() { int num = 0; NamePlate[] array = Object.FindObjectsOfType<NamePlate>(); foreach (NamePlate val in array) { Renderer component = ((Component)val).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null && component.enabled) { component.enabled = false; _disabledRenderers.Add(component); num++; } } return num; } private int HideDamageNumbers() { int num = 0; DmgPop[] array = Object.FindObjectsOfType<DmgPop>(); foreach (DmgPop val in array) { Renderer val2 = (((Object)(object)val.Num != (Object)null) ? ((Component)val.Num).GetComponent<Renderer>() : null); if ((Object)(object)val2 != (Object)null && val2.enabled) { val2.enabled = false; _disabledRenderers.Add(val2); num++; } } return num; } private int HideTargetRings() { int num = 0; Character[] array = Object.FindObjectsOfType<Character>(); foreach (Character val in array) { GameObject targetRing = val.TargetRing; if ((Object)(object)targetRing != (Object)null && targetRing.activeSelf) { targetRing.SetActive(false); _disabledGameObjects.Add(targetRing); num++; } } return num; } private int HideXPOrbs() { int num = 0; XPBub[] array = Object.FindObjectsOfType<XPBub>(); foreach (XPBub val in array) { Renderer component = ((Component)val).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null && component.enabled) { component.enabled = false; _disabledRenderers.Add(component); num++; } } return num; } private int HideCastBars() { int num = 0; FlashUIColors[] array = Object.FindObjectsOfType<FlashUIColors>(); foreach (FlashUIColors val in array) { if (!((Object)(object)val.CastBar == (Object)null)) { Renderer component = ((Component)val.CastBar).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null && component.enabled) { component.enabled = false; _disabledRenderers.Add(component); num++; } } } return num; } private int HideOtherWorldText() { int num = 0; TextMeshPro[] array = Object.FindObjectsOfType<TextMeshPro>(); foreach (TextMeshPro val in array) { if (!((Object)(object)((Component)val).GetComponent<NamePlate>() != (Object)null) && !((Object)(object)((Component)val).GetComponent<DmgPop>() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<DmgPop>() != (Object)null)) { Renderer component = ((Component)val).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null && component.enabled) { component.enabled = false; _disabledRenderers.Add(component); num++; } } } return num; } private void RestoreAll() { int num = 0; int num2 = 0; _disabledRenderers.RemoveWhere((Renderer r) => (Object)(object)r == (Object)null); _disabledGameObjects.RemoveWhere((GameObject go) => (Object)(object)go == (Object)null); foreach (Renderer disabledRenderer in _disabledRenderers) { disabledRenderer.enabled = true; num++; } foreach (GameObject disabledGameObject in _disabledGameObjects) { disabledGameObject.SetActive(true); num2++; } _disabledRenderers.Clear(); _disabledGameObjects.Clear(); if (_enableLogging.Value) { _log.LogDebug((object)$"Restored {num} renderers, {num2} game objects"); } } } } namespace JusticeForF7.Patches { internal static class DmgPopPatch { public static WorldUIHider? Hider { get; set; } [HarmonyPatch(typeof(Misc), "GenPopup")] [HarmonyPrefix] public static bool GenPopupPrefix(int _dmg, bool _crit, DamageType _type, Transform _tar) { return Hider == null || !Hider.SuppressDamageNumbers; } [HarmonyPatch(typeof(Misc), "GenPopupString")] [HarmonyPrefix] public static bool GenPopupStringPrefix(string _msg, Transform _tar) { return Hider == null || !Hider.SuppressDamageNumbers; } } [HarmonyPatch(typeof(TypeText), "Update")] internal static class TypeTextPatch { private static bool _lastCanvasEnabled = true; public static WorldUIHider? Hider { get; set; } [HarmonyPostfix] public static void Postfix() { if (Hider == null) { return; } Canvas mainCanvas = GameData.MainCanvas; if ((Object)(object)mainCanvas == (Object)null) { return; } bool enabled = ((Behaviour)mainCanvas).enabled; if (enabled == _lastCanvasEnabled) { Hider.Tick(); return; } _lastCanvasEnabled = enabled; if (!enabled) { Hider.OnUIHidden(); } else { Hider.OnUIShown(); } } } [HarmonyPatch(typeof(Misc), "GetXPBalls")] internal static class XPBubPatch { public static WorldUIHider? Hider { get; set; } [HarmonyPrefix] public static bool Prefix(int amt, Vector3 callPos, Transform _tar) { return Hider == null || !Hider.SuppressXPOrbs; } } } 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 NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } internal static class AssemblyInfo { public const string AssemblyName = "MonoMod.Backports"; public const string AssemblyVersion = "1.1.2"; } namespace MonoMod.SourceGen.Attributes { [AttributeUsage(AttributeTargets.Class)] internal sealed class EmitILOverloadsAttribute : Attribute { public EmitILOverloadsAttribute(string filename, string kind) { } } internal static class ILOverloadKind { public const string Cursor = "ILCursor"; public const string Matcher = "ILMatcher"; } } namespace MonoMod.Backports { internal static class MethodImplOptionsEx { public const MethodImplOptions Unmanaged = MethodImplOptions.Unmanaged; public const MethodImplOptions NoInlining = MethodImplOptions.NoInlining; public const MethodImplOptions ForwardRef = MethodImplOptions.ForwardRef; public const MethodImplOptions Synchronized = MethodImplOptions.Synchronized; public const MethodImplOptions NoOptimization = MethodImplOptions.NoOptimization; public const MethodImplOptions PreserveSig = MethodImplOptions.PreserveSig; public const MethodImplOptions AggressiveInlining = MethodImplOptions.AggressiveInlining; public const MethodImplOptions AggressiveOptimization = MethodImplOptions.AggressiveOptimization; public const MethodImplOptions InternalCall = MethodImplOptions.InternalCall; } } namespace MonoMod.Backports.ILHelpers { [CLSCompliant(false)] internal static class UnsafeRaw { [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static T Read<T>(void* source) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.ReadUnaligned<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void Write<T>(void* destination, T value) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Write(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.WriteUnaligned(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Copy(destination, ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Copy(ref destination, source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AsPointer(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void SkipInit<T>(out T value) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.SkipInit<T>(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.CopyBlock(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static T As<T>(object o) where T : class { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<T>(o); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AsRef<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T AsRef<T>(in T source) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AsRef(in source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Unbox<T>(object box) where T : struct { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Unbox<T>(box); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T AddByteOffset<T>(ref T source, nint byteOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T AddByteOffset<T>(ref T source, nuint byteOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, nint byteOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, nuint byteOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static nint ByteOffset<T>(ref T origin, ref T target) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.ByteOffset(ref origin, ref target); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AreSame(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.IsAddressGreaterThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static bool IsAddressLessThan<T>(ref T left, ref T right) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.IsAddressLessThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static bool IsNullRef<T>(ref T source) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.IsNullRef(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T NullRef<T>() { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.NullRef<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static int SizeOf<T>() { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void* Add<T>(void* source, int elementOffset) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Add<T>(source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Add<T>(ref T source, nint elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Add<T>(ref T source, nuint elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public unsafe static void* Subtract<T>(void* source, int elementOffset) { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Subtract<T>(source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Subtract<T>(ref T source, nint elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] public static ref T Subtract<T>(ref T source, nuint elementOffset) { return ref <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.Subtract(ref source, elementOffset); } } } namespace System { internal static class ArrayEx { public static int MaxLength => 1879048191; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T[] Empty<T>() { return Array.Empty<T>(); } } internal static class EnvironmentEx { public static int CurrentManagedThreadId => Environment.CurrentManagedThreadId; } internal sealed class Gen2GcCallback : CriticalFinalizerObject { private readonly Func<bool>? _callback0; private readonly Func<object, bool>? _callback1; private GCHandle _weakTargetObj; private Gen2GcCallback(Func<bool> callback) { _callback0 = callback; } private Gen2GcCallback(Func<object, bool> callback, object targetObj) { _callback1 = callback; _weakTargetObj = GCHandle.Alloc(targetObj, GCHandleType.Weak); } public static void Register(Func<bool> callback) { new System.Gen2GcCallback(callback); } public static void Register(Func<object, bool> callback, object targetObj) { new System.Gen2GcCallback(callback, targetObj); } ~Gen2GcCallback() { if (_weakTargetObj.IsAllocated) { object target = _weakTargetObj.Target; if (target == null) { _weakTargetObj.Free(); return; } try { if (!_callback1(target)) { _weakTargetObj.Free(); return; } } catch { } } else { try { if (!_callback0()) { return; } } catch { } } GC.ReRegisterForFinalize(this); } } internal static class MathEx { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte Clamp(byte value, byte min, byte max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static decimal Clamp(decimal value, decimal min, decimal max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Clamp(double value, double min, double max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static short Clamp(short value, short min, short max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Clamp(int value, int min, int max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Clamp(long value, long min, long max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static nint Clamp(nint value, nint min, nint max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static sbyte Clamp(sbyte value, sbyte min, sbyte max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Clamp(float value, float min, float max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ushort Clamp(ushort value, ushort min, ushort max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint Clamp(uint value, uint min, uint max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong Clamp(ulong value, ulong min, ulong max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static nuint Clamp(nuint value, nuint min, nuint max) { if (min > max) { ThrowMinMaxException(min, max); } if (value < min) { return min; } if (value > max) { return max; } return value; } [DoesNotReturn] private static void ThrowMinMaxException<T>(T min, T max) { throw new ArgumentException($"Minimum {min} is less than maximum {max}"); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] internal sealed class NonVersionableAttribute : Attribute { } internal static class StringComparerEx { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static StringComparer FromComparison(StringComparison comparisonType) { return StringComparer.FromComparison(comparisonType); } } internal static class StringExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Replace(this string self, string oldValue, string newValue, StringComparison comparison) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.self); <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(oldValue, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.oldValue); <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(newValue, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.newValue); return self.Replace(oldValue, newValue, comparison); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Contains(this string self, string value, StringComparison comparison) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.self); <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(value, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.value); return self.Contains(value, comparison); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Contains(this string self, char value, StringComparison comparison) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.self); return self.Contains(value, comparison); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetHashCode(this string self, StringComparison comparison) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.self); return self.GetHashCode(comparison); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf(this string self, char value, StringComparison comparison) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.self); return self.IndexOf(value, comparison); } } internal static class <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper { [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void ThrowIfArgumentNull([NotNull] object? obj, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument argument) { if (obj == null) { ThrowArgumentNullException(argument); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void ThrowIfArgumentNull([NotNull] object? obj, string argument, string? message = null) { if (obj == null) { ThrowArgumentNullException(argument, message); } } [DoesNotReturn] internal static void ThrowArgumentNullException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument argument) { throw CreateArgumentNullException(argument); } [DoesNotReturn] internal static void ThrowArgumentNullException(string argument, string? message = null) { throw CreateArgumentNullException(argument, message); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentNullException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument argument) { return CreateArgumentNullException(argument.ToString()); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentNullException(string argument, string? message = null) { return new ArgumentNullException(argument, message); } [DoesNotReturn] internal static void ThrowArrayTypeMismatchException() { throw CreateArrayTypeMismatchException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArrayTypeMismatchException() { return new ArrayTypeMismatchException(); } [DoesNotReturn] internal static void ThrowArgumentException_InvalidTypeWithPointersNotSupported(Type type) { throw CreateArgumentException_InvalidTypeWithPointersNotSupported(type); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_InvalidTypeWithPointersNotSupported(Type type) { return new ArgumentException($"Type {type} with managed pointers cannot be used in a Span"); } [DoesNotReturn] internal static void ThrowArgumentException_DestinationTooShort() { throw CreateArgumentException_DestinationTooShort(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_DestinationTooShort() { return new ArgumentException("Destination too short"); } [DoesNotReturn] internal static void ThrowArgumentException(string message, string? argument = null) { throw CreateArgumentException(message, argument); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException(string message, string? argument) { return new ArgumentException(message, argument ?? ""); } [DoesNotReturn] internal static void ThrowIndexOutOfRangeException() { throw CreateIndexOutOfRangeException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateIndexOutOfRangeException() { return new IndexOutOfRangeException(); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException() { throw CreateArgumentOutOfRangeException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException() { return new ArgumentOutOfRangeException(); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument argument) { throw CreateArgumentOutOfRangeException(argument); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument argument) { return new ArgumentOutOfRangeException(argument.ToString()); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException_PrecisionTooLarge() { throw CreateArgumentOutOfRangeException_PrecisionTooLarge(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_PrecisionTooLarge() { return new ArgumentOutOfRangeException("precision", $"Precision too large (max: {99})"); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException_SymbolDoesNotFit() { throw CreateArgumentOutOfRangeException_SymbolDoesNotFit(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_SymbolDoesNotFit() { return new ArgumentOutOfRangeException("symbol", "Bad format specifier"); } [DoesNotReturn] internal static void ThrowInvalidOperationException() { throw CreateInvalidOperationException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException() { return new InvalidOperationException(); } [DoesNotReturn] internal static void ThrowInvalidOperationException_OutstandingReferences() { throw CreateInvalidOperationException_OutstandingReferences(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_OutstandingReferences() { return new InvalidOperationException("Outstanding references"); } [DoesNotReturn] internal static void ThrowInvalidOperationException_UnexpectedSegmentType() { throw CreateInvalidOperationException_UnexpectedSegmentType(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_UnexpectedSegmentType() { return new InvalidOperationException("Unexpected segment type"); } [DoesNotReturn] internal static void ThrowInvalidOperationException_EndPositionNotReached() { throw CreateInvalidOperationException_EndPositionNotReached(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_EndPositionNotReached() { return new InvalidOperationException("End position not reached"); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException_PositionOutOfRange() { throw CreateArgumentOutOfRangeException_PositionOutOfRange(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_PositionOutOfRange() { return new ArgumentOutOfRangeException("position"); } [DoesNotReturn] internal static void ThrowArgumentOutOfRangeException_OffsetOutOfRange() { throw CreateArgumentOutOfRangeException_OffsetOutOfRange(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_OffsetOutOfRange() { return new ArgumentOutOfRangeException("offset"); } [DoesNotReturn] internal static void ThrowObjectDisposedException_ArrayMemoryPoolBuffer() { throw CreateObjectDisposedException_ArrayMemoryPoolBuffer(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateObjectDisposedException_ArrayMemoryPoolBuffer() { return new ObjectDisposedException("ArrayMemoryPoolBuffer"); } [DoesNotReturn] internal static void ThrowFormatException_BadFormatSpecifier() { throw CreateFormatException_BadFormatSpecifier(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateFormatException_BadFormatSpecifier() { return new FormatException("Bad format specifier"); } [DoesNotReturn] internal static void ThrowArgumentException_OverlapAlignmentMismatch() { throw CreateArgumentException_OverlapAlignmentMismatch(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_OverlapAlignmentMismatch() { return new ArgumentException("Overlap alignment mismatch"); } [DoesNotReturn] internal static void ThrowNotSupportedException(string? msg = null) { throw CreateThrowNotSupportedException(msg); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateThrowNotSupportedException(string? msg) { return new NotSupportedException(); } [DoesNotReturn] internal static void ThrowKeyNullException() { ThrowArgumentNullException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.key); } [DoesNotReturn] internal static void ThrowValueNullException() { throw CreateThrowValueNullException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateThrowValueNullException() { return new ArgumentException("Value is null"); } [DoesNotReturn] internal static void ThrowOutOfMemoryException() { throw CreateOutOfMemoryException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateOutOfMemoryException() { return new OutOfMemoryException(); } 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; } [DoesNotReturn] 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(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.startSegment); } if (endSegment == null) { return CreateArgumentNullException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.endSegment); } if (startSegment != endSegment && startSegment.RunningIndex > endSegment.RunningIndex) { return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.endSegment); } if ((uint)startSegment.Memory.Length < (uint)startIndex) { return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.startIndex); } return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.endIndex); } [DoesNotReturn] 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(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.array); } if ((uint)start > (uint)array.Length) { return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.start); } return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.length); } [DoesNotReturn] internal static void ThrowArgumentException_TupleIncorrectType(object other) { throw new ArgumentException($"Value tuple of incorrect type (found {other.GetType()})", "other"); } [DoesNotReturn] public static void ThrowStartOrEndArgumentValidationException(long start) { throw CreateStartOrEndArgumentValidationException(start); } private static Exception CreateStartOrEndArgumentValidationException(long start) { if (start < 0) { return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.start); } return CreateArgumentOutOfRangeException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.length); } } internal enum <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument { length, start, bufferSize, minimumBufferSize, elementIndex, comparable, comparer, destination, offset, startSegment, endSegment, startIndex, endIndex, array, culture, manager, key, collection, index, type, self, value, oldValue, newValue } internal static class TypeExtensions { public static bool IsByRefLike(this Type type) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(type, <23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.type); if ((object)type == null) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowArgumentNullException(<23e83c09-da64-4f5d-8118-db579398253b>ExceptionArgument.type); } return type.IsByRefLike; } } } namespace System.Threading { internal static class MonitorEx { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Enter(object obj, ref bool lockTaken) { Monitor.Enter(obj, ref lockTaken); } } } namespace System.Text { internal static class StringBuilderExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static StringBuilder Clear(this StringBuilder builder) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(builder, "builder"); return builder.Clear(); } } } namespace System.Numerics { internal static class BitOperations { private static ReadOnlySpan<byte> TrailingZeroCountDeBruijn => new byte[32] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; private static ReadOnlySpan<byte> Log2DeBruijn => new byte[32] { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int LeadingZeroCount(uint value) { if (value == 0) { return 32; } return 0x1F ^ Log2SoftwareFallback(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int LeadingZeroCount(ulong value) { uint num = (uint)(value >> 32); if (num == 0) { return 32 + LeadingZeroCount((uint)value); } return LeadingZeroCount(num); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int Log2(uint value) { value |= 1u; return Log2SoftwareFallback(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int Log2(ulong value) { value |= 1; uint num = (uint)(value >> 32); if (num == 0) { return Log2((uint)value); } return 32 + Log2(num); } private static int Log2SoftwareFallback(uint value) { value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(Log2DeBruijn), (IntPtr)(int)(value * 130329821 >> 27)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int Log2Ceiling(uint value) { int num = Log2(value); if (PopCount(value) != 1) { num++; } return num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int Log2Ceiling(ulong value) { int num = Log2(value); if (PopCount(value) != 1) { num++; } return num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int PopCount(uint value) { return SoftwareFallback(value); static int SoftwareFallback(uint value) { value -= (value >> 1) & 0x55555555; value = (value & 0x33333333) + ((value >> 2) & 0x33333333); value = ((value + (value >> 4)) & 0xF0F0F0F) * 16843009 >> 24; return (int)value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int PopCount(ulong value) { if (IntPtr.Size == 8) { return PopCount((uint)value) + PopCount((uint)(value >> 32)); } return SoftwareFallback(value); static int SoftwareFallback(ulong value) { value -= (value >> 1) & 0x5555555555555555L; value = (value & 0x3333333333333333L) + ((value >> 2) & 0x3333333333333333L); value = ((value + (value >> 4)) & 0xF0F0F0F0F0F0F0FL) * 72340172838076673L >> 56; return (int)value; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int TrailingZeroCount(int value) { return TrailingZeroCount((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int TrailingZeroCount(uint value) { if (value == 0) { return 32; } return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(TrailingZeroCountDeBruijn), (IntPtr)(int)((value & (0 - value)) * 125613361 >> 27)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int TrailingZeroCount(long value) { return TrailingZeroCount((ulong)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int TrailingZeroCount(ulong value) { uint num = (uint)value; if (num == 0) { return 32 + TrailingZeroCount((uint)(value >> 32)); } return TrailingZeroCount(num); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint RotateLeft(uint value, int offset) { return (value << offset) | (value >> 32 - offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong RotateLeft(ulong value, int offset) { return (value << offset) | (value >> 64 - offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint RotateRight(uint value, int offset) { return (value >> offset) | (value << 32 - offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong RotateRight(ulong value, int offset) { return (value >> offset) | (value << 64 - offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static uint ResetLowestSetBit(uint value) { return value & (value - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static uint ResetBit(uint value, int bitPos) { return value & (uint)(~(1 << bitPos)); } } internal static class BitOperationsEx { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPow2(int value) { if ((value & (value - 1)) == 0) { return value > 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static bool IsPow2(uint value) { if ((value & (value - 1)) == 0) { return value != 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPow2(long value) { if ((value & (value - 1)) == 0L) { return value > 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static bool IsPow2(ulong value) { if ((value & (value - 1)) == 0L) { return value != 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPow2(nint value) { if ((value & (value - 1)) == 0) { return value > 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static bool IsPow2(nuint value) { if ((value & (value - 1)) == 0) { return value != 0; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint RoundUpToPowerOf2(uint value) { value--; value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; return value + 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong RoundUpToPowerOf2(ulong value) { value--; value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; value |= value >> 32; return value + 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static nuint RoundUpToPowerOf2(nuint value) { if (IntPtr.Size == 8) { return (nuint)RoundUpToPowerOf2((ulong)value); } return RoundUpToPowerOf2((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int LeadingZeroCount(uint value) { return BitOperations.LeadingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int LeadingZeroCount(ulong value) { return BitOperations.LeadingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int LeadingZeroCount(nuint value) { if (IntPtr.Size == 8) { return LeadingZeroCount((ulong)value); } return LeadingZeroCount((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int Log2(uint value) { return BitOperations.Log2(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int Log2(ulong value) { return BitOperations.Log2(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int Log2(nuint value) { if (IntPtr.Size == 8) { return Log2((ulong)value); } return Log2((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int PopCount(uint value) { return BitOperations.PopCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int PopCount(ulong value) { return BitOperations.PopCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int PopCount(nuint value) { if (IntPtr.Size == 8) { return PopCount((ulong)value); } return PopCount((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int TrailingZeroCount(int value) { return BitOperations.TrailingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int TrailingZeroCount(uint value) { return BitOperations.TrailingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int TrailingZeroCount(long value) { return BitOperations.TrailingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int TrailingZeroCount(ulong value) { return BitOperations.TrailingZeroCount(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int TrailingZeroCount(nint value) { if (IntPtr.Size == 8) { return TrailingZeroCount((long)value); } return TrailingZeroCount((int)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static int TrailingZeroCount(nuint value) { if (IntPtr.Size == 8) { return TrailingZeroCount((ulong)value); } return TrailingZeroCount((uint)value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint RotateLeft(uint value, int offset) { return BitOperations.RotateLeft(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong RotateLeft(ulong value, int offset) { return BitOperations.RotateLeft(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static nuint RotateLeft(nuint value, int offset) { if (IntPtr.Size == 8) { return (nuint)RotateLeft((ulong)value, offset); } return RotateLeft((uint)value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static uint RotateRight(uint value, int offset) { return BitOperations.RotateRight(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static ulong RotateRight(ulong value, int offset) { return BitOperations.RotateRight(value, offset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public static nuint RotateRight(nuint value, int offset) { if (IntPtr.Size == 8) { return (nuint)RotateRight((ulong)value, offset); } return RotateRight((uint)value, offset); } } } namespace System.IO { internal static class StreamExtensions { public static void CopyTo(this Stream src, Stream destination) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(src, "src"); src.CopyTo(destination); } public static void CopyTo(this Stream src, Stream destination, int bufferSize) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(src, "src"); src.CopyTo(destination, bufferSize); } } } namespace System.Collections { internal static class HashHelpers { public const uint HashCollisionThreshold = 100u; public const int MaxPrimeArrayLength = 2147483587; public const int HashPrime = 101; private static readonly int[] s_primes = new int[72] { 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369 }; public static bool IsPrime(int candidate) { if (((uint)candidate & (true ? 1u : 0u)) != 0) { int num = (int)Math.Sqrt(candidate); for (int i = 3; i <= num; i += 2) { if (candidate % i == 0) { return false; } } return true; } return candidate == 2; } public static int GetPrime(int min) { if (min < 0) { throw new ArgumentException("Prime minimum cannot be less than zero"); } int[] array = s_primes; foreach (int num in array) { if (num >= min) { return num; } } for (int j = min | 1; j < int.MaxValue; j += 2) { if (IsPrime(j) && (j - 1) % 101 != 0) { return j; } } return min; } public static int ExpandPrime(int oldSize) { int num = 2 * oldSize; if ((uint)num > 2147483587u && 2147483587 > oldSize) { return 2147483587; } return GetPrime(num); } public static ulong GetFastModMultiplier(uint divisor) { return ulong.MaxValue / (ulong)divisor + 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint FastMod(uint value, uint divisor, ulong multiplier) { return (uint)(((multiplier * value >> 32) + 1) * divisor >> 32); } } } namespace System.Collections.Concurrent { internal static class ConcurrentExtensions { public static void Clear<T>(this ConcurrentBag<T> bag) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(bag, "bag"); bag.Clear(); } public static void Clear<T>(this ConcurrentQueue<T> queue) { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(queue, "queue"); queue.Clear(); } public static TValue AddOrUpdate<TKey, TValue, TArg>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TKey, TArg, TValue> addValueFactory, Func<TKey, TValue, TArg, TValue> updateValueFactory, TArg factoryArgument) where TKey : notnull { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(dict, "dict"); return dict.AddOrUpdate(key, addValueFactory, updateValueFactory, factoryArgument); } public static TValue GetOrAdd<TKey, TValue, TArg>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument) where TKey : notnull { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(dict, "dict"); return dict.GetOrAdd(key, valueFactory, factoryArgument); } public static bool TryRemove<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, KeyValuePair<TKey, TValue> item) where TKey : notnull { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(dict, "dict"); if (dict.TryRemove(item.Key, out TValue value)) { if (EqualityComparer<TValue>.Default.Equals(item.Value, value)) { return true; } dict.AddOrUpdate(item.Key, (TKey _) => value, (TKey _, TValue _) => value); return false; } return false; } } } namespace System.Runtime { internal struct DependentHandle : IDisposable { private sealed class DependentHolder : CriticalFinalizerObject { public GCHandle TargetHandle; private IntPtr dependent; public object? Dependent { get { return GCHandle.FromIntPtr(dependent).Target; } set { IntPtr value2 = GCHandle.ToIntPtr(GCHandle.Alloc(value, GCHandleType.Normal)); IntPtr intPtr; do { intPtr = dependent; } while (Interlocked.CompareExchange(ref dependent, value2, intPtr) == intPtr); GCHandle.FromIntPtr(intPtr).Free(); } } public DependentHolder(GCHandle targetHandle, object dependent) { TargetHandle = targetHandle; this.dependent = GCHandle.ToIntPtr(GCHandle.Alloc(dependent, GCHandleType.Normal)); } ~DependentHolder() { if (!AppDomain.CurrentDomain.IsFinalizingForUnload() && (!Environment.HasShutdownStarted && (TargetHandle.IsAllocated && TargetHandle.Target != null))) { GC.ReRegisterForFinalize(this); } else { GCHandle.FromIntPtr(dependent).Free(); } } } private GCHandle dependentHandle; private volatile bool allocated; public bool IsAllocated => allocated; public object? Target { get { if (!allocated) { throw new InvalidOperationException(); } return UnsafeGetTarget(); } set { if (!allocated || value != null) { throw new InvalidOperationException(); } UnsafeSetTargetToNull(); } } public object? Dependent { get { if (!allocated) { throw new InvalidOperationException(); } return UnsafeGetHolder()?.Dependent; } set { if (!allocated) { throw new InvalidOperationException(); } UnsafeSetDependent(value); } } public (object? Target, object? Dependent) TargetAndDependent { get { if (!allocated) { throw new InvalidOperationException(); } return (UnsafeGetTarget(), Dependent); } } public DependentHandle(object? target, object? dependent) { GCHandle targetHandle = GCHandle.Alloc(target, GCHandleType.WeakTrackResurrection); dependentHandle = AllocDepHolder(targetHandle, dependent); GC.KeepAlive(target); allocated = true; } private static GCHandle AllocDepHolder(GCHandle targetHandle, object? dependent) { return GCHandle.Alloc((dependent != null) ? new DependentHolder(targetHandle, dependent) : null, GCHandleType.WeakTrackResurrection); } private DependentHolder? UnsafeGetHolder() { return <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<DependentHolder>(dependentHandle.Target); } internal object? UnsafeGetTarget() { return UnsafeGetHolder()?.TargetHandle.Target; } internal object? UnsafeGetTargetAndDependent(out object? dependent) { dependent = null; DependentHolder dependentHolder = UnsafeGetHolder(); if (dependentHolder == null) { return null; } object target = dependentHolder.TargetHandle.Target; if (target == null) { return null; } dependent = dependentHolder.Dependent; return target; } internal void UnsafeSetTargetToNull() { Free(); } internal void UnsafeSetDependent(object? value) { DependentHolder dependentHolder = UnsafeGetHolder(); if (dependentHolder != null) { if (!dependentHolder.TargetHandle.IsAllocated) { Free(); } else { dependentHolder.Dependent = value; } } } private void FreeDependentHandle() { if (allocated) { UnsafeGetHolder()?.TargetHandle.Free(); dependentHandle.Free(); } allocated = false; } private void Free() { FreeDependentHandle(); } public void Dispose() { Free(); allocated = false; } } } namespace System.Runtime.InteropServices { internal static class MarshalEx { private static readonly MethodInfo? Marshal_SetLastWin32Error_Meth = typeof(Marshal).GetMethod("SetLastPInvokeError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); private static readonly Action<int>? Marshal_SetLastWin32Error = (((object)Marshal_SetLastWin32Error_Meth == null) ? null : ((Action<int>)Delegate.CreateDelegate(typeof(Action<int>), Marshal_SetLastWin32Error_Meth))); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetLastPInvokeError() { return Marshal.GetLastWin32Error(); } public static void SetLastPInvokeError(int error) { (Marshal_SetLastWin32Error ?? throw new PlatformNotSupportedException("Cannot set last P/Invoke error (no method Marshal.SetLastWin32Error or Marshal.SetLastPInvokeError)"))(error); } } } namespace System.Runtime.CompilerServices { [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal static class IsExternalInit { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] internal sealed class CallerArgumentExpressionAttribute : Attribute { public string ParameterName { get; } public CallerArgumentExpressionAttribute(string parameterName) { ParameterName = parameterName; } } internal interface ICWTEnumerable<T> { IEnumerable<T> SelfEnumerable { get; } IEnumerator<T> GetEnumerator(); } internal sealed class CWTEnumerable<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : class where TValue : class? { private readonly ConditionalWeakTable<TKey, TValue> cwt; public CWTEnumerable(ConditionalWeakTable<TKey, TValue> table) { cwt = table; } public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() { return cwt.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } internal static class ConditionalWeakTableExtensions { public static IEnumerable<KeyValuePair<TKey, TValue>> AsEnumerable<TKey, TValue>(this ConditionalWeakTable<TKey, TValue> self) where TKey : class where TValue : class? { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, "self"); if (self != null) { return self; } if (self is ICWTEnumerable<KeyValuePair<TKey, TValue>> iCWTEnumerable) { return iCWTEnumerable.SelfEnumerable; } return new CWTEnumerable<TKey, TValue>(self); } public static IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator<TKey, TValue>(this ConditionalWeakTable<TKey, TValue> self) where TKey : class where TValue : class? { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, "self"); if (self != null) { return ((IEnumerable<KeyValuePair<TKey, TValue>>)self).GetEnumerator(); } if (self is ICWTEnumerable<KeyValuePair<TKey, TValue>> iCWTEnumerable) { return iCWTEnumerable.GetEnumerator(); } throw new PlatformNotSupportedException("This version of MonoMod.Backports was built targeting a version of the framework where ConditionalWeakTable is enumerable, but it isn't!"); } public static void Clear<TKey, TValue>(this ConditionalWeakTable<TKey, TValue> self) where TKey : class where TValue : class? { <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, "self"); self.Clear(); } public static bool TryAdd<TKey, TValue>(this ConditionalWeakTable<TKey, TValue> self, TKey key, TValue value) where TKey : class where TValue : class? { TValue value2 = value; <23e83c09-da64-4f5d-8118-db579398253b>ThrowHelper.ThrowIfArgumentNull(self, "self"); bool didAdd = false; self.GetValue(key, delegate { didAdd = true; return value2; }); return didAdd; } } [InterpolatedStringHandler] internal ref struct DefaultInterpolatedStringHandler { private const int GuessedLengthPerHole = 11; private const int MinimumArrayPoolLength = 256; private readonly IFormatProvider? _provider; private char[]? _arrayToReturnToPool; private Span<char> _chars; private int _pos; private readonly bool _hasCustomFormatter; internal ReadOnlySpan<char> Text => _chars.Slice(0, _pos); public DefaultInterpolatedStringHandler(int literalLength, int formattedCount) { _provider = null; _chars = (_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount))); _pos = 0; _hasCustomFormatter = false; } public DefaultInterpolatedStringHandler(int literalLength, int formattedCount, IFormatProvider? provider) { _provider = provider; _chars = (_arrayToReturnToPool = ArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount))); _pos = 0; _hasCustomFormatter = provider != null && HasCustomFormatter(provider); } public DefaultInterpolatedStringHandler(int literalLength, int formattedCount, IFormatProvider? provider, Span<char> initialBuffer) { _provider = provider; _chars = initialBuffer; _arrayToReturnToPool = null; _pos = 0; _hasCustomFormatter = provider != null && HasCustomFormatter(provider); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int GetDefaultLength(int literalLength, int formattedCount) { return Math.Max(256, literalLength + formattedCount * 11); } public override string ToString() { return Text.ToString(); } public string ToStringAndClear() { string result = Text.ToString(); Clear(); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal void Clear() { char[] arrayToReturnToPool = _arrayToReturnToPool; this = default(DefaultInterpolatedStringHandler); if (arrayToReturnToPool != null) { ArrayPool<char>.Shared.Return(arrayToReturnToPool); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AppendLiteral(string value) { if (value.Length == 1) { Span<char> chars = _chars; int pos = _pos; if ((uint)pos < (uint)chars.Length) { chars[pos] = value[0]; _pos = pos + 1; } else { GrowThenCopyString(value); } } else if (value.Length == 2) { Span<char> chars2 = _chars; int pos2 = _pos; if ((uint)pos2 < chars2.Length - 1) { MemoryExtensions.AsSpan(value).CopyTo(chars2.Slice(pos2)); _pos = pos2 + 2; } else { GrowThenCopyString(value); } } else { AppendStringDirect(value); } } private void AppendStringDirect(string value) { if (MemoryExtensions.AsSpan(value).TryCopyTo(_chars.Slice(_pos))) { _pos += value.Length; } else { GrowThenCopyString(value); } } public void AppendFormatted<T>(T value) { if (_hasCustomFormatter) { AppendCustomFormatter(value, null); return; } if (typeof(T) == typeof(IntPtr)) { AppendFormatted(<157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<T, IntPtr>(ref value)); return; } if (typeof(T) == typeof(UIntPtr)) { AppendFormatted(<157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<T, UIntPtr>(ref value)); return; } string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(null, _provider)); if (text != null) { AppendStringDirect(text); } } public void AppendFormatted<T>(T value, string? format) { if (_hasCustomFormatter) { AppendCustomFormatter(value, format); return; } if (typeof(T) == typeof(IntPtr)) { AppendFormatted(<157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<T, IntPtr>(ref value), format); return; } if (typeof(T) == typeof(UIntPtr)) { AppendFormatted(<157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe.As<T, UIntPtr>(ref value), format); return; } string text = ((!(value is IFormattable)) ? value?.ToString() : ((IFormattable)(object)value).ToString(format, _provider)); if (text != null) { AppendStringDirect(text); } } public void AppendFormatted<T>(T value, int alignment) { int pos = _pos; AppendFormatted(value); if (alignment != 0) { AppendOrInsertAlignmentIfNeeded(pos, alignment); } } public void AppendFormatted<T>(T value, int alignment, string? format) { int pos = _pos; AppendFormatted(value, format); if (alignment != 0) { AppendOrInsertAlignmentIfNeeded(pos, alignment); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void AppendFormatted(IntPtr value) { if (IntPtr.Size == 4) { AppendFormatted((int)value); } else { AppendFormatted((long)value); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void AppendFormatted(IntPtr value, string? format) { if (IntPtr.Size == 4) { AppendFormatted((int)value, format); } else { AppendFormatted((long)value, format); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void AppendFormatted(UIntPtr value) { if (UIntPtr.Size == 4) { AppendFormatted((uint)value); } else { AppendFormatted((ulong)value); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void AppendFormatted(UIntPtr value, string? format) { if (UIntPtr.Size == 4) { AppendFormatted((uint)value, format); } else { AppendFormatted((ulong)value, format); } } public void AppendFormatted(ReadOnlySpan<char> value) { if (value.TryCopyTo(_chars.Slice(_pos))) { _pos += value.Length; } else { GrowThenCopySpan(value); } } public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null) { bool flag = false; if (alignment < 0) { flag = true; alignment = -alignment; } int num = alignment - value.Length; if (num <= 0) { AppendFormatted(value); return; } EnsureCapacityForAdditionalChars(value.Length + num); if (flag) { value.CopyTo(_chars.Slice(_pos)); _pos += value.Length; _chars.Slice(_pos, num).Fill(' '); _pos += num; } else { _chars.Slice(_pos, num).Fill(' '); _pos += num; value.CopyTo(_chars.Slice(_pos)); _pos += value.Length; } } public void AppendFormatted(string? value) { if (!_hasCustomFormatter && value != null && MemoryExtensions.AsSpan(value).TryCopyTo(_chars.Slice(_pos))) { _pos += value.Length; } else { AppendFormattedSlow(value); } } [MethodImpl(MethodImplOptions.NoInlining)] private void AppendFormattedSlow(string? value) { if (_hasCustomFormatter) { AppendCustomFormatter(value, null); } else if (value != null) { EnsureCapacityForAdditionalChars(value.Length); MemoryExtensions.AsSpan(value).CopyTo(_chars.Slice(_pos)); _pos += value.Length; } } public void AppendFormatted(string? value, int alignment = 0, string? format = null) { this.AppendFormatted<string>(value, alignment, format); } public void AppendFormatted(object? value, int alignment = 0, string? format = null) { this.AppendFormatted<object>(value, alignment, format); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool HasCustomFormatter(IFormatProvider provider) { if (provider.GetType() != typeof(CultureInfo)) { return provider.GetFormat(typeof(ICustomFormatter)) != null; } return false; } [MethodImpl(MethodImplOptions.NoInlining)] private void AppendCustomFormatter<T>(T value, string? format) { ICustomFormatter customFormatter = (ICustomFormatter)_provider.GetFormat(typeof(ICustomFormatter)); if (customFormatter != null) { string text = customFormatter.Format(format, value, _provider); if (text != null) { AppendStringDirect(text); } } } private void AppendOrInsertAlignmentIfNeeded(int startingPos, int alignment) { int num = _pos - startingPos; bool flag = false; if (alignment < 0) { flag = true; alignment = -alignment; } int num2 = alignment - num; if (num2 > 0) { EnsureCapacityForAdditionalChars(num2); if (flag) { _chars.Slice(_pos, num2).Fill(' '); } else { _chars.Slice(startingPos, num).CopyTo(_chars.Slice(startingPos + num2)); _chars.Slice(startingPos, num2).Fill(' '); } _pos += num2; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void EnsureCapacityForAdditionalChars(int additionalChars) { if (_chars.Length - _pos < additionalChars) { Grow(additionalChars); } } [MethodImpl(MethodImplOptions.NoInlining)] private void GrowThenCopyString(string value) { Grow(value.Length); MemoryExtensions.AsSpan(value).CopyTo(_chars.Slice(_pos)); _pos += value.Length; } [MethodImpl(MethodImplOptions.NoInlining)] private void GrowThenCopySpan(ReadOnlySpan<char> value) { Grow(value.Length); value.CopyTo(_chars.Slice(_pos)); _pos += value.Length; } [MethodImpl(MethodImplOptions.NoInlining)] private void Grow(int additionalChars) { GrowCore((uint)(_pos + additionalChars)); } [MethodImpl(MethodImplOptions.NoInlining)] private void Grow() { GrowCore((uint)(_chars.Length + 1)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void GrowCore(uint requiredMinCapacity) { int minimumLength = (int)MathEx.Clamp(Math.Max(requiredMinCapacity, Math.Min((uint)(_chars.Length * 2), uint.MaxValue)), 256u, 2147483647u); char[] array = ArrayPool<char>.Shared.Rent(minimumLength); _chars.Slice(0, _pos).CopyTo(array); char[] arrayToReturnToPool = _arrayToReturnToPool; _chars = (_arrayToReturnToPool = array); if (arrayToReturnToPool != null) { ArrayPool<char>.Shared.Return(arrayToReturnToPool); } } } [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] internal sealed class DisableRuntimeMarshallingAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] internal sealed class InterpolatedStringHandlerAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute { public string[] Arguments { get; } public InterpolatedStringHandlerArgumentAttribute(string argument) { Arguments = new string[1] { argument }; } public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) { Arguments = arguments; } } internal interface ITuple { int Length { get; } object? this[int index] { get; } } [AttributeUsage(AttributeTargets.Method, Inherited = false)] internal sealed class ModuleInitializerAttribute : Attribute { } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullAttribute : Attribute { public string[] Members { get; } public <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public <23e83c09-da64-4f5d-8118-db579398253b>MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } internal static class ExtraDynamicallyAccessedMemberTypes { public const <23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMemberTypes Interfaces = (<23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMemberTypes)8192; } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)] internal sealed class <23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMembersAttribute : Attribute { public <23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMemberTypes MemberTypes { get; } public <23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMembersAttribute(<23e83c09-da64-4f5d-8118-db579398253b>DynamicallyAccessedMemberTypes memberTypes) { MemberTypes = memberTypes; } } [Flags] internal enum <23e83c09-da64-4f5d-8118-db579398253b>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.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] internal sealed class UnscopedRefAttribute : Attribute { } } [CompilerGenerated] internal sealed class <23e83c09-da64-4f5d-8118-db579398253b><PrivateImplementationDetails> { [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 32)] private struct __StaticArrayInitTypeSize=32 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 288)] private struct __StaticArrayInitTypeSize=288 { } internal static readonly __StaticArrayInitTypeSize=32 3BF63951626584EB1653F9B8DBB590A5EE1EAE1135A904B9317C3773896DF076/* Not supported: data(00 01 1C 02 1D 0E 18 03 1E 16 14 0F 19 11 04 08 1F 1B 0D 17 15 13 10 07 1A 0C 12 06 0B 05 0A 09) */; internal static readonly __StaticArrayInitTypeSize=32 4BCD43D478B9229AB7A13406353712C7944B60348C36B4D0E6B789D10F697652/* Not supported: data(00 09 01 0A 0D 15 02 1D 0B 0E 10 12 16 19 03 1E 08 0C 14 1C 0F 11 18 07 13 1B 17 06 1A 05 04 1F) */; internal static readonly __StaticArrayInitTypeSize=288 74BCD6ED20AF2231F2BB1CDE814C5F4FF48E54BAC46029EEF90DDF4A208E2B20/* Not supported: data(03 00 00 00 07 00 00 00 0B 00 00 00 11 00 00 00 17 00 00 00 1D 00 00 00 25 00 00 00 2F 00 00 00 3B 00 00 00 47 00 00 00 59 00 00 00 6B 00 00 00 83 00 00 00 A3 00 00 00 C5 00 00 00 EF 00 00 00 25 01 00 00 61 01 00 00 AF 01 00 00 09 02 00 00 77 02 00 00 F9 02 00 00 97 03 00 00 4F 04 00 00 2F 05 00 00 3D 06 00 00 8B 07 00 00 1D 09 00 00 F1 0A 00 00 2B 0D 00 00 D1 0F 00 00 FD 12 00 00 CF 16 00 00 65 1B 00 00 E3 20 00 00 77 27 00 00 6F 2F 00 00 FF 38 00 00 6F 44 00 00 1F 52 00 00 8D 62 00 00 55 76 00 00 01 8E 00 00 6B AA 00 00 89 CC 00 00 83 F5 00 00 A7 26 01 00 9B 61 01 00 57 A8 01 00 3B FD 01 00 15 63 02 00 67 DD 02 00 1B 70 03 00 23 20 04 00 61 F3 04 00 ED F0 05 00 25 21 07 00 31 8E 08 00 3B 44 0A 00 EB 51 0C 00 C1 C8 0E 00 BF BD 11 00 3F 4A 15 00 4F 8C 19 00 67 A8 1E 00 19 CA 24 00 C1 25 2C 00 1B FA 34 00 8F 92 3F 00 87 49 4C 00 6F 8B 5B 00 89 DA 6D 00) */; } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] internal sealed class <157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionableAttribute : Attribute { } } namespace System.Runtime.CompilerServices { internal sealed class IsReadOnlyAttribute : Attribute { } } namespace MonoMod { internal static class ILHelpers { [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static T TailCallDelegatePtr<T>(IntPtr source) { return ((delegate*<T>)source)(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T TailCallFunc<T>(Func<T> func) { return func(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static ref T ObjectAsRef<T>(object obj) { fixed (object obj2 = obj) { T** ptr = (T**)(&obj2); return ref *(*ptr); } } } } namespace System.Runtime.CompilerServices { internal static class <157889e7-97fa-408c-a5f2-46fc03c50572>Unsafe { [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static T Read<T>(void* source) { return Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return Unsafe.ReadUnaligned<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void Write<T>(void* destination, T value) { Unsafe.Write(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { Unsafe.WriteUnaligned(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { Unsafe.Write(destination, source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { destination = Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return Unsafe.AsPointer(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static void SkipInit<T>(out T value) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static int SizeOf<T>() { return Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>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)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>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)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static T As<T>(object o) where T : class { return (T)o; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref *(T*)source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T AsRef<T>(in T source) { return ref source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Unbox<T>(object box) where T : struct { return ref (T)box; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void* Add<T>(void* source, int elementOffset) { return (byte*)source + (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Add<T>(ref T source, nint elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Add<T>(ref T source, nuint elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T AddByteOffset<T>(ref T source, nint byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T AddByteOffset<T>(ref T source, nuint byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static void* Subtract<T>(void* source, int elementOffset) { return (byte*)source - (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Subtract<T>(ref T source, nint elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T Subtract<T>(ref T source, nuint elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, nint byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, nuint byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static nint ByteOffset<T>(ref T origin, ref T target) { return Unsafe.ByteOffset(target: ref target, origin: ref origin); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return Unsafe.AreSame(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { return Unsafe.IsAddressGreaterThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public static bool IsAddressLessThan<T>(ref T left, ref T right) { return Unsafe.IsAddressLessThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static bool IsNullRef<T>(ref T source) { return Unsafe.AsPointer(ref source) == null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [<157889e7-97fa-408c-a5f2-46fc03c50572>NonVersionable] public unsafe static ref T NullRef<T>() { return ref *(T*)null; } } } namespace FxResources.System.Buffers { internal static class SR { } } namespace System { internal static class <081c3ecc-60b8-44f9-a6aa-b9d202311a05>SR { private static ResourceManager s_resourceManager; private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType)); internal static Type ResourceType { get; } = typeof(FxResources.System.Buffers.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 <081c3ecc-60b8-44f9-a6aa-b9d202311a05>__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) };