Decompiled source of AdventureGuide v2026.1008.0
plugins/AdventureGuide/AdventureGuide.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using AdventureGuide.Config; using AdventureGuide.Core; using AdventureGuide.Data; using AdventureGuide.Diagnostics; using AdventureGuide.Navigation; using AdventureGuide.Patches; using AdventureGuide.Rendering; using AdventureGuide.State; using AdventureGuide.UI; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ErenshorMods.Input; using HarmonyLib; using ImGuiNET; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: InternalsVisibleTo("AdventureGuide.Tests")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AdventureGuide")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1ae4ed0ca70f6324f2e309090088871672eec1aa")] [assembly: AssemblyProduct("AdventureGuide")] [assembly: AssemblyTitle("AdventureGuide")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 ErenshorMods.Input { public interface IKeyboardInput { bool IsHeld(KeyCode key); bool WasPressed(KeyCode key); } public sealed class UnityKeyboardInput : IKeyboardInput { public static UnityKeyboardInput Instance { get; } = new UnityKeyboardInput(); private UnityKeyboardInput() { } public bool IsHeld(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Input.GetKey(key); } public bool WasPressed(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Input.GetKeyDown(key); } } public static class KeyboardShortcuts { public static bool WasPressed(KeyCode key, IKeyboardInput keyboard) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return (int)key != 0 && keyboard.WasPressed(key); } public static bool IsHeld(KeyCode key, IKeyboardInput keyboard) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return (int)key != 0 && keyboard.IsHeld(key); } public static bool IsHeld(IReadOnlyList<KeyCode> keys, IKeyboardInput keyboard) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (keys.Count == 0) { return false; } for (int i = 0; i < keys.Count; i++) { if ((int)keys[i] == 0 || !keyboard.IsHeld(keys[i])) { return false; } } return true; } public static bool IsHeld(KeyCode mainKey, IReadOnlyList<KeyCode> modifiers, IKeyboardInput keyboard) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((int)mainKey == 0 || !keyboard.IsHeld(mainKey)) { return false; } for (int i = 0; i < modifiers.Count; i++) { if ((int)modifiers[i] == 0 || !keyboard.IsHeld(modifiers[i])) { return false; } } return true; } } } namespace AdventureGuide { public sealed class AdventureGuideRuntime : IRuntimeLifecycleEffects { private readonly IModLogger _logger; private readonly IGuideConfigBackend _backend; private readonly string _iniPath; private readonly IKeyboardInput _keyboard; private readonly RuntimeLifecycleCoordinator _lifecycle; private readonly RuntimeResourceOwnership _resources; private Harmony? _harmony; private GuideConfig? _config; private GuideData? _data; private QuestStateTracker? _state; private EntityRegistry? _entities; private NavigationController? _nav; private ArrowRenderer? _arrow; private GroundPathRenderer? _groundPath; private WorldMarkerSystem? _markers; private SpawnTimerTracker? _timers; private MiningNodeTracker? _miningTracker; private LootScanner? _lootScanner; private GuideWindow? _window; private TrackerState? _trackerState; private TrackerWindow? _tracker; private ImGuiRenderer? _imgui; private bool _wasTextInputActive; private bool _gameUIVisible = true; private bool _inGameplay; private bool _discoveryDone; private bool _wasEditUIMode; private bool _wantsMouseCapture; private bool _wantsTextInput; internal static IModLogger Log { get; private set; } = NullModLogger.Instance; public AdventureGuideRuntime(IModLogger logger, IGuideConfigBackend config, string iniPath, IKeyboardInput keyboard) { _logger = logger; _backend = config; _iniPath = iniPath; _keyboard = keyboard; _lifecycle = new RuntimeLifecycleCoordinator(this); _resources = new RuntimeResourceOwnership(config); } public bool Start() { //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Expected O, but got Unknown //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) switch (_lifecycle.BeginStart()) { case RuntimeStartDecision.RejectedAfterStop: return false; case RuntimeStartDecision.AlreadyStarted: return true; default: Log = _logger; AdventureGuideLog.Current = _logger; try { try { _config = new GuideConfig(_backend); _resources.AdoptConfiguration(_config); } catch { _resources.Dispose(); throw; } _data = GuideData.Load(_logger); _entities = new EntityRegistry(); _state = new QuestStateTracker(_data, _entities); _state.LoadFromConfig(_config); _trackerState = new TrackerState(); _trackerState.LoadFromConfig(_config); float num = UiScalePolicy.Resolve(_config.UiScale.Value, Screen.height); _config.ResolvedUiScale = num; _imgui = new ImGuiRenderer(_logger) { UiScale = num, IniPath = _iniPath }; if (!_imgui.Init()) { throw new InvalidOperationException("Adventure Guide ImGui renderer init failed."); } _config.UiScale.SettingChanged += OnUiScaleChanged; _config.ResetWindowLayout.SettingChanged += OnResetWindowLayout; _timers = new SpawnTimerTracker(); _miningTracker = new MiningNodeTracker(); SpawnPointBridge bridge = new SpawnPointBridge(); _lootScanner = new LootScanner(); _nav = new NavigationController(_data, _entities, _state, _timers, _miningTracker, _lootScanner); _state.WorkflowChanged += OnWorkflowChanged; _state.WorkflowCycleReset += OnWorkflowCycleReset; _state.FurnishingsChanged += OnFurnishingsChanged; _state.TreasureHuntChanged += OnTreasureHuntChanged; _arrow = new ArrowRenderer(_nav) { Enabled = _config.ShowArrow.Value }; _config.ShowArrow.SettingChanged += OnShowArrowChanged; _groundPath = new GroundPathRenderer(_nav) { Enabled = _config.ShowGroundPath.Value }; _config.ShowGroundPath.SettingChanged += OnShowGroundPathChanged; _markers = new WorldMarkerSystem(_data, _state, bridge, _lootScanner, _config) { Enabled = _config.ShowWorldMarkers.Value }; _config.ShowWorldMarkers.SettingChanged += OnShowWorldMarkersChanged; _config.TrackerEnabled.SettingChanged += OnTrackerEnabledChanged; _config.ReplaceQuestLog.SettingChanged += OnReplaceQuestLogChanged; NavigationHistory history = new NavigationHistory(_config.HistoryMaxSize.Value); _config.HistoryMaxSize.SettingChanged += delegate { history.MaxSize = _config.HistoryMaxSize.Value; }; _window = new GuideWindow(_data, _state, _nav, history, _trackerState, _config); _state.SetHistory(history); _window.Filter.LoadFrom(_config); _tracker = new TrackerWindow(_data, _state, _nav, _trackerState, _window, _config); Action guideDraw = _window.Draw; Action trackerDraw = delegate { _tracker.Draw(_inGameplay); }; Action arrowDraw = _arrow.Draw; _imgui.OnLayout = delegate { _imgui.DrawIsolated(guideDraw); _imgui.DrawIsolated(trackerDraw); _imgui.DrawIsolated(arrowDraw); }; DebugAPI.Data = _data; DebugAPI.State = _state; DebugAPI.Filter = _window.Filter; DebugAPI.Nav = _nav; DebugAPI.Entities = _entities; DebugAPI.GroundPath = _groundPath; DebugAPI.Markers = _markers; QuestAssignPatch.Tracker = _state; QuestAssignPatch.Nav = _nav; QuestAssignPatch.Loot = _lootScanner; QuestAssignPatch.TrackerPins = _trackerState; QuestFinishPatch.Tracker = _state; QuestFinishPatch.Nav = _nav; QuestFinishPatch.Loot = _lootScanner; QuestFinishPatch.TrackerPins = _trackerState; InventoryPatch.Tracker = _state; InventoryPatch.Nav = _nav; InventoryPatch.Loot = _lootScanner; SpawnPatch.Registry = _entities; SpawnPatch.Timers = _timers; SpawnPatch.Markers = _markers; SpawnPatch.Loot = _lootScanner; SpawnResetPatch.Markers = _markers; NpcStartPatch.Markers = _markers; NpcStartPatch.Entities = _entities; ScriptedEntityStartPatch.Tracker = _state; ScriptedRewardConsumedPatch.Tracker = _state; DeathPatch.Registry = _entities; DeathPatch.Timers = _timers; DeathPatch.Markers = _markers; DeathPatch.Loot = _lootScanner; DeathPatch.Tracker = _state; DeathPatch.Nav = _nav; QuestMarkerPatch.SetSuppression(_config.ShowWorldMarkers.Value); PointerOverUIPatch.WantsMouse = () => _wantsMouseCapture; PlayerTypingPatch.WantsTextInput = () => _gameUIVisible && _wantsTextInput; QuestLogPatch.ReplaceQuestLog = _config.ReplaceQuestLog; CharacterCreatePatch.Config = _config; CharacterDeletePatch.Config = _config; SceneManager.sceneLoaded += OnSceneLoaded; _harmony = new Harmony("wow-much.adventure-guide"); _harmony.PatchAll(); QuestStateTracker? state = _state; Scene activeScene = SceneManager.GetActiveScene(); state.OnSceneChanged(((Scene)(ref activeScene)).name); _entities.SyncFromLiveNPCs(); _miningTracker.Rescan(); _lootScanner.OnSceneLoaded(); activeScene = SceneManager.GetActiveScene(); LoadCharacterState(((Scene)(ref activeScene)).name); activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; _inGameplay = name != "Menu" && name != "LoadScene"; int num2 = 0; foreach (QuestEntry item in _data.All) { if (item.HasSteps) { num2++; } } _logger.LogInfo("Adventure Guide v2026.1008.0\n" + $" Quests: {_data.Count} in guide, {num2} with step data\n" + $" Controls: {_config.ToggleKey.Value} = guide, {_config.TrackerToggleKey.Value} = tracker, {_config.GroundPathToggleKey.Value} = ground path"); return true; } catch (Exception exception) { _logger.LogError("Adventure Guide failed to start; unwinding partial initialization.", exception); Stop(); return false; } } } public void Tick() { _lifecycle.Tick(); } void IRuntimeLifecycleEffects.TickActive() { _tracker?.Update(); bool isVisible = GameUIVisibility.IsVisible; if (isVisible != _gameUIVisible) { _gameUIVisible = isVisible; SyncVisibility(); if (!isVisible) { ClearImGuiCaptureState(); if (_wasTextInputActive) { if (!ChatInputActive()) { GameData.PlayerTyping = false; } _wasTextInputActive = false; } } } bool editUIMode = GameData.EditUIMode; if (_wasEditUIMode && !editUIMode) { GameWindowOverlap.InvalidateRects(); } _wasEditUIMode = editUIMode; if (_gameUIVisible) { CaptureImGuiState(); } if (_gameUIVisible) { bool wantsTextInput = _wantsTextInput; bool? flag = TypingFlagSync.Next(wantsTextInput, _wasTextInputActive, ChatInputActive()); if (flag.HasValue) { GameData.PlayerTyping = flag.Value; } _wasTextInputActive = wantsTextInput; } if (!_discoveryDone) { TryMergeUnknownQuests(); } string currentScene = _state?.CurrentZone ?? ""; _state?.Update(Time.deltaTime); if (_data != null && _state != null) { _lootScanner?.Update(_data, _state); } _nav?.Update(currentScene); _groundPath?.Update(currentScene); _markers?.Update(currentScene); if (_config != null && _window != null && _inGameplay) { HandleKeyboardShortcuts(); if (!_wantsMouseCapture && !GameData.PlayerTyping) { } } } public void Draw() { _lifecycle.Draw(_gameUIVisible); } void IRuntimeLifecycleEffects.DrawActive() { _imgui?.OnGUI(); } public void Stop() { _lifecycle.Stop(); } void IRuntimeLifecycleEffects.StopActive() { SceneManager.sceneLoaded -= OnSceneLoaded; if (_wasTextInputActive && !ChatInputActive()) { GameData.PlayerTyping = false; } ClearImGuiCaptureState(); if (_config != null) { _config.ShowArrow.SettingChanged -= OnShowArrowChanged; _config.ShowGroundPath.SettingChanged -= OnShowGroundPathChanged; _config.ShowWorldMarkers.SettingChanged -= OnShowWorldMarkersChanged; _config.TrackerEnabled.SettingChanged -= OnTrackerEnabledChanged; _config.ReplaceQuestLog.SettingChanged -= OnReplaceQuestLogChanged; _config.UiScale.SettingChanged -= OnUiScaleChanged; _config.ResetWindowLayout.SettingChanged -= OnResetWindowLayout; } if (_state != null) { _state.WorkflowChanged -= OnWorkflowChanged; _state.WorkflowCycleReset -= OnWorkflowCycleReset; _state.FurnishingsChanged -= OnFurnishingsChanged; _state.TreasureHuntChanged -= OnTreasureHuntChanged; } QuestMarkerPatch.SetSuppression(suppressed: false); Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; _tracker?.Dispose(); _state?.SaveToConfig(); _nav?.SavePerCharacter(); _nav?.SuspendForMenu(); _state?.TreasureHunt.Clear(); _imgui?.Dispose(); _imgui = null; _arrow?.Dispose(); _groundPath?.Destroy(); _markers?.Destroy(); _timers?.Clear(); _entities?.Clear(); _miningTracker?.Clear(); MarkerFonts.Destroy(); CameraCache.Invalidate(); GameWindowOverlap.Reset(); _config = null; _resources.Dispose(); ClearPatchStatics(); ClearDebugApi(); AdventureGuideLog.Reset(); Log = NullModLogger.Instance; } private void TryMergeUnknownQuests() { if (!_discoveryDone && _data != null) { int num = _data.MergeUnknownQuests(); if (num >= 0) { _discoveryDone = true; } } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (_config.UiScale.Value < 0f && ((Scene)(ref scene)).name != "Menu" && ((Scene)(ref scene)).name != "LoadScene") { OnUiScaleChanged(this, EventArgs.Empty); } CameraCache.Invalidate(); GameWindowOverlap.Reset(); _inGameplay = ((Scene)(ref scene)).name != "Menu" && ((Scene)(ref scene)).name != "LoadScene"; if (!_inGameplay) { _window?.Hide(); _nav?.SuspendForMenu(); _trackerState?.SuspendForMenu(); _state?.SuspendForMenu(); _config?.SuspendCharacter(); ClearImGuiCaptureState(); } _markers?.OnSceneLoaded(); _entities?.Clear(); _timers?.Clear(); _miningTracker?.Rescan(); _lootScanner?.OnSceneLoaded(); _state?.OnSceneChanged(((Scene)(ref scene)).name); LoadCharacterState(((Scene)(ref scene)).name); _nav?.OnGameStateChanged(((Scene)(ref scene)).name); } private void LoadCharacterState(string scene) { if (scene == "Menu" || scene == "LoadScene") { return; } SaveGameData currentCharacterSlot = GameData.CurrentCharacterSlot; if (currentCharacterSlot != null && !string.IsNullOrEmpty(currentCharacterSlot.CharName)) { _config.PrepareCharacter(currentCharacterSlot.index, currentCharacterSlot.CharName); _trackerState?.OnCharacterLoaded(); _state?.OnCharacterLoaded(); if (_trackerState != null && _state != null && _data != null) { _trackerState.PruneCompleted(_state, _data); } _nav?.LoadPerCharacter(_config, scene); } } private void OnShowArrowChanged(object sender, EventArgs e) { SyncVisibility(); } private void OnShowGroundPathChanged(object sender, EventArgs e) { SyncVisibility(); } private void OnUiScaleChanged(object sender, EventArgs e) { float num = UiScalePolicy.Resolve(_config.UiScale.Value, Screen.height); if (num != _config.ResolvedUiScale) { _config.ResolvedUiScale = num; _config.LayoutResetGeneration++; _imgui?.SetScale(num); } } private void OnResetWindowLayout(object sender, EventArgs e) { if (_config.ResetWindowLayout.Value) { _config.LayoutResetGeneration++; _imgui?.ClearWindowState(); _config.ResetWindowLayout.Value = false; } } private void OnShowWorldMarkersChanged(object sender, EventArgs e) { SyncVisibility(); QuestMarkerPatch.SetSuppression(_config.ShowWorldMarkers.Value); } private void OnTrackerEnabledChanged(object sender, EventArgs e) { _trackerState.Enabled = _config.TrackerEnabled.Value; } private void OnReplaceQuestLogChanged(object sender, EventArgs e) { if (_config.ReplaceQuestLog.Value) { QuestLog questLog = GameData.QuestLog; if ((Object)(object)questLog != (Object)null && (Object)(object)questLog.QuestWindow != (Object)null && questLog.QuestWindow.activeSelf) { questLog.QuestWindow.SetActive(false); _window?.Show(); } } } private void OnWorkflowChanged(QuestEntry quest) { _nav?.OnGameStateChanged(_state?.CurrentZone ?? ""); _lootScanner?.MarkDirty(); } private void OnWorkflowCycleReset(QuestEntry quest) { _trackerState?.OnQuestCompleted(quest.RuntimeKey); } private void OnFurnishingsChanged() { _nav?.OnFurnishingsChanged(_state?.CurrentZone ?? ""); } private void OnTreasureHuntChanged(TreasureHuntChange change) { _nav?.OnTreasureHuntChanged(change); } private void SyncVisibility() { bool gameUIVisible = _gameUIVisible; if (_arrow != null && _config != null) { _arrow.Enabled = gameUIVisible && _config.ShowArrow.Value; } if (_groundPath != null && _config != null) { _groundPath.Enabled = gameUIVisible && _config.ShowGroundPath.Value; } if (_markers != null && _config != null) { _markers.Enabled = gameUIVisible && _config.ShowWorldMarkers.Value; } } private void HandleKeyboardShortcuts() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (_config != null && _window != null) { ShortcutAction shortcutAction = ShortcutCoordinator.Sample(_keyboard, _config.ToggleKey.Value, InputManager.Journal, _config.TrackerToggleKey.Value, _config.GroundPathToggleKey.Value, GameData.PlayerTyping, _wantsTextInput, _config.ReplaceQuestLog.Value, _config.TrackerEnabled.Value); if ((shortcutAction & ShortcutAction.ToggleGuide) != ShortcutAction.None) { _window.Toggle(); } if ((shortcutAction & ShortcutAction.ToggleReplacementJournal) != ShortcutAction.None) { _window.Toggle(); } if ((shortcutAction & ShortcutAction.ToggleTracker) != ShortcutAction.None) { _tracker?.Toggle(); } if ((shortcutAction & ShortcutAction.ToggleGroundPath) != ShortcutAction.None) { _config.ShowGroundPath.Value = !_config.ShowGroundPath.Value; } } } private static bool ChatInputActive() { return (Object)(object)GameData.TextInput != (Object)null && (Object)(object)GameData.TextInput.InputBox != (Object)null && GameData.TextInput.InputBox.activeSelf; } private void CaptureImGuiState() { _wantsMouseCapture = _imgui?.WantCaptureMouse ?? false; _wantsTextInput = _imgui?.WantTextInput ?? false; } private void ClearImGuiCaptureState() { _wantsMouseCapture = false; _wantsTextInput = false; } private static void ClearPatchStatics() { QuestAssignPatch.Tracker = null; QuestAssignPatch.Nav = null; QuestAssignPatch.Loot = null; QuestAssignPatch.TrackerPins = null; QuestFinishPatch.Tracker = null; QuestFinishPatch.Nav = null; QuestFinishPatch.Loot = null; QuestFinishPatch.TrackerPins = null; InventoryPatch.Tracker = null; InventoryPatch.Nav = null; InventoryPatch.Loot = null; SpawnPatch.Registry = null; SpawnPatch.Timers = null; SpawnPatch.Markers = null; SpawnPatch.Loot = null; SpawnResetPatch.Markers = null; NpcStartPatch.Markers = null; NpcStartPatch.Entities = null; ScriptedEntityStartPatch.Tracker = null; ScriptedRewardConsumedPatch.Tracker = null; DeathPatch.Registry = null; DeathPatch.Timers = null; DeathPatch.Markers = null; DeathPatch.Loot = null; DeathPatch.Tracker = null; DeathPatch.Nav = null; QuestMarkerPatch.SuppressGameMarkers = false; PointerOverUIPatch.WantsMouse = null; QuestLogPatch.ReplaceQuestLog = null; PlayerTypingPatch.WantsTextInput = null; CharacterCreatePatch.Config = null; CharacterDeletePatch.Config = null; } private static void ClearDebugApi() { DebugAPI.Data = null; DebugAPI.State = null; DebugAPI.Filter = null; DebugAPI.Nav = null; DebugAPI.Entities = null; DebugAPI.GroundPath = null; DebugAPI.Markers = null; } } internal static class PluginInfo { public const string GUID = "wow-much.adventure-guide"; public const string Name = "Adventure Guide"; public const string Version = "2026.1008.0"; } [BepInPlugin("wow-much.adventure-guide", "Adventure Guide", "2026.1008.0")] public sealed class Plugin : BaseUnityPlugin { private AdventureGuideRuntime? _runtime; private void Awake() { ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ((MonoBehaviour)this).useGUILayout = false; BepInExLogger logger = new BepInExLogger(((BaseUnityPlugin)this).Logger); BepInExConfigBackend config = new BepInExConfigBackend(((BaseUnityPlugin)this).Config); string iniPath = Path.Combine(Paths.ConfigPath, "adventureguide", "imgui.ini"); _runtime = new AdventureGuideRuntime(logger, config, iniPath, UnityKeyboardInput.Instance); _runtime.Start(); } private void Update() { _runtime?.Tick(); } private void OnGUI() { _runtime?.Draw(); } private void OnDestroy() { _runtime?.Stop(); } } internal sealed class BepInExLogger : IModLogger { private readonly ManualLogSource _log; internal BepInExLogger(ManualLogSource log) { _log = log; } public void LogDebug(string message) { _log.LogDebug((object)message); } public void LogInfo(string message) { _log.LogInfo((object)message); } public void LogWarning(string message) { _log.LogWarning((object)message); } public void LogError(string message) { _log.LogError((object)message); } public void LogError(string message, Exception exception) { _log.LogError((object)$"{message}: {exception}"); } } internal sealed class BepInExConfigBackend : IGuideConfigBackend, IDisposable { private sealed class ConfigurationManagerAttributes { public bool? Browsable { get; set; } } private readonly ConfigFile _config; private bool _disposed; internal BepInExConfigBackend(ConfigFile config) { _config = config; } public IConfigValue<T> Bind<T>(string section, string key, T defaultValue, string description, bool hidden = false, float? min = null, float? max = null) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (_disposed) { throw new ObjectDisposedException("BepInExConfigBackend"); } AcceptableValueBase val = CreateRange<T>(min, max); ConfigurationManagerAttributes configurationManagerAttributes = (hidden ? new ConfigurationManagerAttributes { Browsable = false } : null); ConfigEntry<T> entry = _config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, val, new object[1] { configurationManagerAttributes })); return new BepInExConfigValue<T>(entry); } public void Dispose() { _disposed = true; } private static AcceptableValueBase? CreateRange<T>(float? min, float? max) { if (!min.HasValue || !max.HasValue) { return null; } if (typeof(T) == typeof(int)) { return (AcceptableValueBase?)(object)new AcceptableValueRange<int>((int)min.Value, (int)max.Value); } if (typeof(T) == typeof(float)) { return (AcceptableValueBase?)(object)new AcceptableValueRange<float>(min.Value, max.Value); } return null; } } internal sealed class BepInExConfigValue<T> : IConfigValue<T>, IDisposable { private readonly ConfigEntry<T> _entry; private bool _disposed; public T Value { get { return _entry.Value; } set { _entry.Value = value; } } public string Key => ((ConfigEntryBase)_entry).Definition.Section + "." + ((ConfigEntryBase)_entry).Definition.Key; public event EventHandler? SettingChanged; internal BepInExConfigValue(ConfigEntry<T> entry) { _entry = entry; _entry.SettingChanged += OnChanged; } public void SetSerializedValue(string value) { Value = Deserialize(value); } public void Dispose() { if (!_disposed) { _disposed = true; _entry.SettingChanged -= OnChanged; this.SettingChanged = null; } } private void OnChanged(object sender, EventArgs args) { if (!_disposed) { this.SettingChanged?.Invoke(this, args); } } private static T Deserialize(string value) { if (typeof(T).IsEnum) { return (T)Enum.Parse(typeof(T), value); } return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture); } } } namespace AdventureGuide.UI { internal struct DisplayCacheRevision { private bool _valid; private string? _questKey; private int _version; public readonly bool IsCurrent(string? questKey, int version) { return _valid && _questKey == questKey && _version == version; } public void Invalidate() { _valid = false; } public void Commit(string? questKey, int version) { _questKey = questKey; _version = version; _valid = true; } } public enum QuestFilterMode { Active, Available, Completed, All } public enum QuestSortMode { Alphabetical, ByZone, ByLevel } public class FilterState { private GuideConfig? _config; private QuestFilterMode _filterMode = QuestFilterMode.Active; private string _searchText = string.Empty; private string? _zoneFilter; private QuestSortMode _sortMode = QuestSortMode.Alphabetical; public int Version { get; private set; } public QuestFilterMode FilterMode { get { return _filterMode; } set { if (_filterMode != value) { _filterMode = value; Version++; _config?.FilterMode.SetSerializedValue(value.ToString()); } } } public string SearchText { get { return _searchText; } set { if (_searchText != value) { _searchText = value; Version++; } } } public string? ZoneFilter { get { return _zoneFilter; } set { if (_zoneFilter != value) { _zoneFilter = value; Version++; _config?.ZoneFilter.SetSerializedValue(value ?? ""); } } } public QuestSortMode SortMode { get { return _sortMode; } set { if (_sortMode != value) { _sortMode = value; Version++; _config?.SortMode.SetSerializedValue(value.ToString()); } } } public void LoadFrom(GuideConfig config) { _config = config; _filterMode = config.FilterMode.Value; _sortMode = config.SortMode.Value; string value = config.ZoneFilter.Value; _zoneFilter = (string.IsNullOrEmpty(value) ? null : value); Version++; } } public sealed class GuideWindow { private readonly GuideData _data; private readonly QuestStateTracker _state; private readonly FilterState _filter = new FilterState(); private readonly QuestListPanel _listPanel; private readonly QuestDetailPanel _detailPanel; private readonly NavigationHistory _history; private readonly GuideConfig _config; private bool _visible; private LayoutResetState _layoutReset; public bool Visible => _visible; public FilterState Filter => _filter; public GuideWindow(GuideData data, QuestStateTracker state, NavigationController nav, NavigationHistory history, TrackerState tracker, GuideConfig config) { _data = data; _state = state; _history = history; _config = config; _listPanel = new QuestListPanel(data, state, _filter, tracker); _detailPanel = new QuestDetailPanel(data, state, nav, tracker, config); } public void Toggle() { _visible = !_visible; } public void Show() { _visible = true; } public void Hide() { _visible = false; } public void Draw() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return; } long layoutResetGeneration = _config.LayoutResetGeneration; ImGuiCond val = (ImGuiCond)(_layoutReset.IsPending(layoutResetGeneration) ? 1 : 4); float resolvedUiScale = _config.ResolvedUiScale; Vector2 vector = Theme.DisplaySize(); ImGui.SetNextWindowSize(new Vector2(780f * resolvedUiScale, 530f * resolvedUiScale), val); ImGui.SetNextWindowPos(new Vector2(vector.X * 0.5f, vector.Y * 0.5f), val, new Vector2(0.5f, 0.5f)); using (Theme.WindowStyleScope(resolvedUiScale)) { bool flag = false; try { bool flag2 = ImGui.Begin("Adventure Guide", ref _visible, (ImGuiWindowFlags)32); flag = true; _layoutReset.Applied(layoutResetGeneration); if (flag2) { DrawTabBar(); } Theme.ClampWindowPosition(); } finally { if (flag) { ImGui.End(); } } } } private void DrawTabBar() { if (!ImGui.BeginTabBar("##GuideTabs")) { return; } try { if (ImGui.BeginTabItem("Quests")) { try { DrawQuestsTab(); } finally { ImGui.EndTabItem(); } } if (ImGui.TabItemButton("<")) { NavigationHistory.PageRef? pageRef = _history.Back(); if (pageRef.HasValue && pageRef.Value.Type == NavigationHistory.PageType.Quest) { _state.SelectedQuestKey = pageRef.Value.Key; } } if (ImGui.TabItemButton(">")) { NavigationHistory.PageRef? pageRef2 = _history.Forward(); if (pageRef2.HasValue && pageRef2.Value.Type == NavigationHistory.PageType.Quest) { _state.SelectedQuestKey = pageRef2.Value.Key; } } } finally { ImGui.EndTabBar(); } } private void DrawQuestsTab() { float num = ImGui.GetContentRegionAvail().X * 0.32f; ImGui.BeginChild("##LeftPanel", new Vector2(num, 0f), true); try { _listPanel.Draw(num); } finally { ImGui.EndChild(); } ImGui.SameLine(); ImGui.BeginChild("##RightPanel", Vector2.Zero, true); try { _detailPanel.Draw(); } finally { ImGui.EndChild(); } } } internal struct LayoutResetState { private long _appliedGeneration; public readonly bool IsPending(long generation) { return generation != _appliedGeneration; } public void Applied(long generation) { _appliedGeneration = generation; } } public sealed class QuestDetailPanel { private enum StepState { Completed, Current, Future } private sealed class QuestDisplayCache { public int CurrentStepIndex; public readonly Dictionary<QuestStep, StepDisplayCache> Steps = new Dictionary<QuestStep, StepDisplayCache>(); } private sealed class StepDisplayCache { public string Text = ""; public string NavLabel = ""; public string TipsLabel = ""; public string? MoreSourcesLabel; public string? SubQuestLabel; public string? Requirement; public bool HasRequiredQuantity; public bool Navigable; public readonly List<ItemSource> VisibleSources = new List<ItemSource>(); public readonly Dictionary<(ItemSource Source, int Depth), SourceDisplayCache> Sources = new Dictionary<(ItemSource, int), SourceDisplayCache>(); } private sealed class SourceDisplayCache { public string Label = ""; public string ChildrenLabel = ""; public string? SourceId; public string? SelectableLabel; public string? QuestTreeLabel; public string? OpenQuestLabel; public string AddTooltip = ""; public string RemoveTooltip = ""; } private readonly GuideData _data; private readonly QuestStateTracker _state; private readonly NavigationController _nav; private readonly TrackerState _tracker; private readonly GuideConfig _config; private readonly Dictionary<QuestEntry, QuestDisplayCache> _questDisplay = new Dictionary<QuestEntry, QuestDisplayCache>(); private readonly HashSet<string> _visited = new HashSet<string>(); private readonly List<string> _acquisitionLines = new List<string>(); private readonly List<string> _completionLines = new List<string>(); private readonly List<(string Text, bool Secondary)> _rewardLines = new List<(string, bool)>(); private readonly List<(Prerequisite Prerequisite, string Label)> _prerequisites = new List<(Prerequisite, string)>(); private readonly Dictionary<QuestStep, ZoneLineAlternativeLabels> _zoneLineLabels = new Dictionary<QuestStep, ZoneLineAlternativeLabels>(); private HashSet<string>? _stepTreeQuestKeys; private DisplayCacheRevision _displayCacheRevision; private string? _levelZoneLine; private const int MaxSubQuestDepth = 5; private bool IsNavigationEnabled => _config.ShowArrow.Value || _config.ShowGroundPath.Value; public QuestDetailPanel(GuideData data, QuestStateTracker state, NavigationController nav, TrackerState tracker, GuideConfig config) { _data = data; _state = state; _nav = nav; _tracker = tracker; _config = config; } public void Draw() { string selectedQuestKey = _state.SelectedQuestKey; int version = _state.Version; if (!_displayCacheRevision.IsCurrent(selectedQuestKey, version)) { _displayCacheRevision.Invalidate(); RebuildDisplayCache(selectedQuestKey); _displayCacheRevision.Commit(selectedQuestKey, version); } if (_state.SelectedQuestKey == null) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.TextWrapped("Select a quest from the list."); ImGui.PopStyleColor(); return; } QuestEntry byRuntimeKey = _data.GetByRuntimeKey(_state.SelectedQuestKey); if (byRuntimeKey == null) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.TextWrapped("Quest not found in guide data."); ImGui.PopStyleColor(); } else { DrawHeader(byRuntimeKey); DrawObjectives(byRuntimeKey); DrawRewards(byRuntimeKey); DrawPrerequisites(byRuntimeKey); } } private void DrawHeader(QuestEntry quest) { if (_tracker.Enabled) { bool flag = _tracker.IsTracked(quest.RuntimeKey); bool flag2 = _state.IsCompleted(quest); if (!flag2 || flag) { if (flag) { ImGui.PushStyleColor((ImGuiCol)21, Theme.Accent); } if (ImGui.SmallButton(flag ? "[Untrack]" : "[Track]")) { if (flag) { _tracker.Untrack(quest.RuntimeKey); } else { _tracker.Track(quest.RuntimeKey); } } if (flag) { ImGui.PopStyleColor(); } ImGui.SameLine(); } } ImGui.PushStyleColor((ImGuiCol)0, Theme.Header); ImGui.TextWrapped(quest.DisplayName); ImGui.PopStyleColor(); DrawLevelZoneLine(quest); foreach (string acquisitionLine in _acquisitionLines) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.Text(acquisitionLine); ImGui.PopStyleColor(); } foreach (string completionLine in _completionLines) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.Text(completionLine); ImGui.PopStyleColor(); } if (quest.Description != null) { ImGui.Spacing(); ImGui.TextWrapped(quest.Description); } ImGui.Spacing(); ImGui.Separator(); ImGui.Spacing(); } private void DrawLevelZoneLine(QuestEntry quest) { if (_levelZoneLine == null) { return; } ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.Text(_levelZoneLine); if (ImGui.IsItemHovered()) { List<QuestStep> steps = quest.Steps; if (steps != null && steps.Count > 0) { ImGui.BeginTooltip(); ImGui.Text("Quest level: hardest step"); ImGui.Separator(); int? num = quest.LevelEstimate?.Recommended; foreach (QuestStep step in quest.Steps) { int? num2 = step.LevelEstimate?.Recommended; string text = (num2.HasValue ? $"Lv {num2,2}" : " "); bool flag = num.HasValue && num2 == num; string text2 = (flag ? " <" : ""); uint num3 = (flag ? Theme.TextPrimary : Theme.TextSecondary); ImGui.PushStyleColor((ImGuiCol)0, num3); ImGui.Text($" {step.Order}. {step.Description} {text}{text2}"); ImGui.PopStyleColor(); } ImGui.EndTooltip(); } } ImGui.PopStyleColor(); } private void DrawObjectives(QuestEntry quest) { if (!quest.HasSteps) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.TextWrapped("No guide data available for this quest."); ImGui.PopStyleColor(); return; } if (_state.Workflows.IsUnverifiable(quest)) { ImGui.PushStyleColor((ImGuiCol)0, Theme.Warning); ImGui.TextWrapped("Workflow state is ambiguous after reload. Re-enter the trigger area with the required item."); ImGui.PopStyleColor(); } if (ImGui.CollapsingHeader("Objectives", (ImGuiTreeNodeFlags)32)) { _visited.Clear(); _visited.Add(quest.StableKey); ImGui.Indent(); DrawSteps(quest, _visited); ImGui.Unindent(); } } private void DrawSteps(QuestEntry quest, HashSet<string> visited) { if (quest.Steps == null || quest.Steps.Count == 0) { return; } ImGui.PushID(quest.RuntimeKey); int currentStepIndex = _questDisplay[quest].CurrentStepIndex; string text = null; for (int i = 0; i < quest.Steps.Count; i++) { QuestStep questStep = quest.Steps[i]; if (questStep.OrGroup != null && questStep.OrGroup == text) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.Text(" -- OR --"); ImGui.PopStyleColor(); } StepState state = ((i >= currentStepIndex) ? ((i == currentStepIndex) ? StepState.Current : StepState.Future) : StepState.Completed); DrawStep(questStep, state, quest, visited); text = questStep.OrGroup; } ImGui.PopID(); } private void DrawStep(QuestStep step, StepState state, QuestEntry quest, HashSet<string> visited) { if (1 == 0) { } uint num = state switch { StepState.Completed => Theme.QuestCompleted, StepState.Current => Theme.QuestActive, _ => Theme.TextPrimary, }; if (1 == 0) { } uint num2 = num; StepDisplayCache stepDisplayCache = _questDisplay[quest].Steps[step]; string action = step.Action; bool flag = ((action == "collect" || action == "obtain") ? true : false); if (flag && step.TargetKey != null && step.Quantity.HasValue && stepDisplayCache.HasRequiredQuantity) { num2 = Theme.QuestCompleted; } if (step.Action == "complete_quest" && step.TargetKey != null) { QuestEntry byStableKey = _data.GetByStableKey(step.TargetKey); if (byStableKey != null && _state.IsCompleted(byStableKey)) { num2 = Theme.QuestCompleted; } } DrawNavButton(step, quest); ImGui.PushStyleColor((ImGuiCol)0, num2); ImGui.Text(stepDisplayCache.Text); ImGui.PopStyleColor(); if (stepDisplayCache.Requirement != null) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.Text(stepDisplayCache.Requirement); ImGui.PopStyleColor(); } DrawStepSources(step, quest, visited); DrawSubQuestSteps(step, quest, visited); if (_nav.IsNavigating(quest.RuntimeKey, step.Order)) { List<(ZoneLineEntry, float, bool, bool)> alternativeZoneLines = _nav.GetAlternativeZoneLines(_state.CurrentZone); if (alternativeZoneLines.Count > 1) { DrawZoneLineAlternatives(alternativeZoneLines, step); } } } private void DrawNavButton(QuestStep step, QuestEntry quest) { if (!IsNavigationEnabled || step.TargetKey == null) { return; } StepDisplayCache stepDisplayCache = _questDisplay[quest].Steps[step]; bool navigable = stepDisplayCache.Navigable; bool flag = _nav.IsNavigating(quest.RuntimeKey, step.Order); if (!navigable) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); ImGui.PushStyleVar((ImGuiStyleVar)0, 0.4f); ImGui.SmallButton(stepDisplayCache.NavLabel); ImGui.PopStyleVar(); ImGui.PopStyleColor(); if (ImGui.IsItemHovered((ImGuiHoveredFlags)512)) { ImGui.BeginTooltip(); ImGui.Text("No known source"); ImGui.EndTooltip(); } ImGui.SameLine(); return; } if (flag) { ImGui.PushStyleColor((ImGuiCol)21, Theme.QuestActive); } if (ImGui.SmallButton(stepDisplayCache.NavLabel)) { if (flag) { _nav.Clear(); } else { _nav.NavigateTo(step, quest, _state.CurrentZone); } } if (flag) { ImGui.PopStyleColor(); } if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); if (flag) { ImGui.Text("Click to stop navigating"); } else { ImGui.Text("Navigate to " + (step.TargetName ?? step.Description)); } ImGui.EndTooltip(); } ImGui.SameLine(); } private void DrawStepSources(QuestStep step, QuestEntry quest, HashSet<string> visited) { switch (step.Action) { case "collect": case "obtain": case "read": if (step.TargetName != null) { StepDisplayCache stepDisplayCache = _questDisplay[quest].Steps[step]; List<ItemSource> visibleSources = stepDisplayCache.VisibleSources; if (visibleSources.Count == 0) { DrawTips(step, quest); break; } ImGui.Indent(); ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); int num = Math.Min(visibleSources.Count, 4); for (int i = 0; i < num; i++) { DrawSource(visibleSources[i], quest, step, visited); } if (visibleSources.Count > 4 && ImGui.TreeNode(stepDisplayCache.MoreSourcesLabel)) { for (int j = 4; j < visibleSources.Count; j++) { DrawSource(visibleSources[j], quest, step, visited); } ImGui.TreePop(); } ImGui.PopStyleColor(); ImGui.Unindent(); DrawTips(step, quest); break; } goto default; default: DrawTips(step, quest); break; } } private void DrawZoneLineAlternatives(List<(ZoneLineEntry line, float distance, bool isSelected, bool isAccessible)> alternatives, QuestStep step) { ImGui.Indent(); ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); if (!_zoneLineLabels.TryGetValue(step, out ZoneLineAlternativeLabels value)) { value = new ZoneLineAlternativeLabels(step.Order); _zoneLineLabels.Add(step, value); } if (ImGui.TreeNode(value.Header(alternatives.Count))) { for (int i = 0; i < alternatives.Count; i++) { (ZoneLineEntry line, float distance, bool isSelected, bool isAccessible) tuple = alternatives[i]; ZoneLineEntry item = tuple.line; float item2 = tuple.distance; bool item3 = tuple.isSelected; bool item4 = tuple.isAccessible; ZoneLineAlternativeLabels.RowLabels rowLabels = value.Row(i, item.DestinationDisplay, item2); if (!item4) { ImGui.PushStyleVar((ImGuiStyleVar)0, 0.3f); ImGui.TextUnformatted(rowLabels.Text); ImGui.PopStyleVar(); if (item.RequiredQuestGroups == null) { continue; } using List<List<string>>.Enumerator enumerator = item.RequiredQuestGroups.GetEnumerator(); if (!enumerator.MoveNext()) { continue; } List<string> current = enumerator.Current; foreach (string item5 in current) { if (_state.IsGameQuestCompleted(item5)) { continue; } QuestEntry byDBName = _data.GetByDBName(item5); if (byDBName != null) { ImGui.Indent(); if (ImGui.Selectable(rowLabels.Requirement(byDBName.DisplayName, item5))) { _state.SelectQuest(byDBName); } ImGui.Unindent(); } } } else { if (item3) { ImGui.PushStyleColor((ImGuiCol)0, Theme.QuestActive); } if (ImGui.Selectable(rowLabels.Selectable)) { _nav.PinZoneLine(item); } if (item3) { ImGui.PopStyleColor(); } if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.TextUnformatted(rowLabels.Tooltip); ImGui.EndTooltip(); } } } ImGui.TreePop(); } ImGui.PopStyleColor(); ImGui.Unindent(); } private void DrawSource(ItemSource src, QuestEntry quest, QuestStep step, HashSet<string> visited, int depth = 0, bool allowNavigation = true) { if (!IsSourceAvailable(src)) { return; } SourceDisplayCache sourceDisplayCache = _questDisplay[quest].Steps[step].Sources[(src, depth)]; string label = sourceDisplayCache.Label; if (allowNavigation && src.Type == "quest_reward" && src.QuestKey != null) { QuestEntry byStableKey = _data.GetByStableKey(src.QuestKey); List<QuestStep> list = byStableKey?.Steps; if (list != null && list.Count > 0 && visited.Count <= 5 && !visited.Contains(byStableKey.StableKey)) { DrawQuestRewardTree(byStableKey, sourceDisplayCache, visited); return; } } List<ItemSource> children = src.Children; if (children != null && children.Count > 0 && depth < 3) { if (ImGui.TreeNode(sourceDisplayCache.ChildrenLabel)) { if (src.Type == "quest_reward" && src.QuestKey != null) { QuestEntry byStableKey2 = _data.GetByStableKey(src.QuestKey); if (byStableKey2 != null) { ImGui.PushStyleColor((ImGuiCol)0, Theme.QuestActive); if (ImGui.Selectable(sourceDisplayCache.OpenQuestLabel)) { _state.SelectQuest(byStableKey2); } ImGui.PopStyleColor(); } } foreach (ItemSource child in src.Children) { DrawSource(child, quest, step, visited, depth + 1, allowNavigation && ItemSourcePolicy.NeedsUsedItem(src, _state.CountItemDelegate)); } ImGui.TreePop(); } } else { if (allowNavigation) { string sourceId = sourceDisplayCache.SourceId; if (sourceId != null) { bool flag = _nav.IsSourceActive(sourceId); if (flag) { uint num = (_nav.IsManualSourceOverride ? Theme.NavManualOverride : Theme.QuestActive); ImGui.PushStyleColor((ImGuiCol)0, num); } if (ImGui.Selectable(sourceDisplayCache.SelectableLabel)) { if (src.Type == "treasure_chest") { _nav.NavigateToTreasureHunt(quest.RuntimeKey, step.Order); } else { _nav.ToggleSource(sourceId, _state.CurrentZone); } } if (flag) { ImGui.PopStyleColor(); } if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.TextUnformatted(flag ? sourceDisplayCache.RemoveTooltip : sourceDisplayCache.AddTooltip); ImGui.EndTooltip(); } goto IL_030b; } } ImGui.PushStyleColor((ImGuiCol)0, Theme.SourceDimmed); ImGui.TextUnformatted(label); ImGui.PopStyleColor(); } goto IL_030b; IL_030b: if (src.Type != "vendor" && src.Instruction != null) { ImGui.Indent(); ImGui.TextWrapped(src.Instruction); ImGui.Unindent(); } } private void DrawSubQuestSteps(QuestStep step, QuestEntry quest, HashSet<string> visited) { if (step.Action != "complete_quest" || step.TargetKey == null) { return; } QuestEntry byStableKey = _data.GetByStableKey(step.TargetKey); if (byStableKey?.Steps != null && byStableKey.Steps.Count != 0 && visited.Count <= 5 && !visited.Contains(byStableKey.StableKey)) { ImGui.Indent(); ImGui.PushStyleColor((ImGuiCol)0, Theme.QuestActive); if (ImGui.Selectable(_questDisplay[quest].Steps[step].SubQuestLabel)) { _state.SelectQuest(byStableKey); } ImGui.PopStyleColor(); visited.Add(byStableKey.StableKey); DrawSteps(byStableKey, visited); visited.Remove(byStableKey.StableKey); ImGui.Unindent(); } } private void DrawQuestRewardTree(QuestEntry subQuest, SourceDisplayCache display, HashSet<string> visited) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) bool flag = _state.IsCompleted(subQuest); ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)((!flag) ? 32 : 0); if (flag) { ImGui.PushStyleColor((ImGuiCol)0, Theme.QuestCompleted); } bool flag2 = ImGui.TreeNodeEx(display.QuestTreeLabel, val); if (flag) { ImGui.PopStyleColor(); } if (flag2) { ImGui.PushStyleColor((ImGuiCol)0, Theme.QuestActive); if (ImGui.Selectable(display.OpenQuestLabel)) { _state.SelectQuest(subQuest); } ImGui.PopStyleColor(); visited.Add(subQuest.StableKey); DrawSteps(subQuest, visited); visited.Remove(subQuest.StableKey); ImGui.TreePop(); } } private void DrawTips(QuestStep step, QuestEntry quest) { if (step.Tips == null || step.Tips.Count == 0) { return; } ImGui.Indent(); if (ImGui.TreeNode(_questDisplay[quest].Steps[step].TipsLabel)) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); foreach (string tip in step.Tips) { ImGui.TextWrapped(tip); } ImGui.PopStyleColor(); ImGui.TreePop(); } ImGui.Unindent(); } private void DrawRewards(QuestEntry quest) { RewardInfo rewards = quest.Rewards; if (rewards == null || !HasAnyRewards(rewards) || !ImGui.CollapsingHeader("Rewards", (ImGuiTreeNodeFlags)32)) { return; } ImGui.Indent(); foreach (var rewardLine in _rewardLines) { if (rewardLine.Secondary) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); } ImGui.Text(rewardLine.Text); if (rewardLine.Secondary) { ImGui.PopStyleColor(); } } ImGui.Unindent(); } private static bool HasAnyRewards(RewardInfo r) { int result; if (r.XP <= 0 && r.Gold <= 0 && r.ItemName == null && r.VendorUnlock == null) { List<UnlockedZoneLine> unlockedZoneLines = r.UnlockedZoneLines; if (unlockedZoneLines == null || unlockedZoneLines.Count <= 0) { List<UnlockedCharacter> unlockedCharacters = r.UnlockedCharacters; if ((unlockedCharacters == null || unlockedCharacters.Count <= 0) && r.NextQuestName == null) { List<FactionEffect> factionEffects = r.FactionEffects; if (factionEffects == null || factionEffects.Count <= 0) { List<string> alsoCompletes = r.AlsoCompletes; result = ((alsoCompletes != null && alsoCompletes.Count > 0) ? 1 : 0); goto IL_007c; } } } } result = 1; goto IL_007c; IL_007c: return (byte)result != 0; } private void DrawPrerequisites(QuestEntry quest) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) List<(Prerequisite, string)> prerequisites = _prerequisites; if (prerequisites.Count == 0) { return; } bool flag = false; foreach (var item in prerequisites) { if (!IsPrerequisiteCompleted(item.Item1)) { flag = true; break; } } ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)(flag ? 32 : 0); if (!ImGui.CollapsingHeader("Prerequisites", val)) { return; } ImGui.Indent(); foreach (var item2 in prerequisites) { uint num = (IsPrerequisiteCompleted(item2.Item1) ? Theme.QuestCompleted : Theme.TextPrimary); ImGui.PushStyleColor((ImGuiCol)0, num); if (ImGui.Selectable(item2.Item2)) { QuestEntry byStableKey = _data.GetByStableKey(item2.Item1.QuestKey); if (byStableKey != null) { _state.SelectQuest(byStableKey); } } ImGui.PopStyleColor(); } ImGui.Unindent(); } private static HashSet<string> CollectStepTreeQuestKeys(QuestEntry quest) { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if (quest.Steps != null) { foreach (QuestStep step in quest.Steps) { if (step.Action == "complete_quest" && step.TargetKey != null) { hashSet.Add(step.TargetKey); } if (step.Sources != null) { CollectQuestRewardKeys(step.Sources, hashSet); } } } if (quest.RequiredItems != null) { foreach (RequiredItemInfo requiredItem in quest.RequiredItems) { if (requiredItem.Sources != null) { CollectQuestRewardKeys(requiredItem.Sources, hashSet); } } } return hashSet; } private static void CollectQuestRewardKeys(List<ItemSource> sources, HashSet<string> keys) { foreach (ItemSource source in sources) { if (source.Type == "quest_reward" && source.QuestKey != null) { keys.Add(source.QuestKey); } if (source.Children != null) { CollectQuestRewardKeys(source.Children, keys); } } } private bool IsPrerequisiteCompleted(Prerequisite prereq) { QuestEntry byStableKey = _data.GetByStableKey(prereq.QuestKey); return byStableKey != null && _state.IsCompleted(byStableKey); } private void RebuildDisplayCache(string? questKey) { _questDisplay.Clear(); _zoneLineLabels.Clear(); _visited.Clear(); _acquisitionLines.Clear(); _completionLines.Clear(); _rewardLines.Clear(); _prerequisites.Clear(); _stepTreeQuestKeys = null; _levelZoneLine = null; QuestEntry questEntry = ((questKey == null) ? null : _data.GetByRuntimeKey(questKey)); if (questEntry == null) { return; } CacheHeader(questEntry); CacheRewards(questEntry.Rewards); _stepTreeQuestKeys = CollectStepTreeQuestKeys(questEntry); if (questEntry.Prerequisites != null) { foreach (Prerequisite prerequisite in questEntry.Prerequisites) { if (!_stepTreeQuestKeys.Contains(prerequisite.QuestKey)) { string text = ((prerequisite.Item != null) ? (prerequisite.QuestName + " (" + prerequisite.Item + ")") : prerequisite.QuestName); _prerequisites.Add((prerequisite, text + "##prereq_" + prerequisite.QuestKey)); } } } _visited.Add(questEntry.StableKey); CacheStepTree(questEntry, _visited); _visited.Clear(); } private void CacheHeader(QuestEntry quest) { int? num = quest.LevelEstimate?.Recommended; string zoneContext = quest.ZoneContext; bool flag = quest.Flags?.Repeatable ?? false; if (num.HasValue || zoneContext != null || flag) { string text = (num.HasValue ? $"Lv {num}" : ""); if (zoneContext != null) { if (text.Length > 0) { text += " · "; } text += zoneContext; } if (flag) { if (text.Length > 0) { text += " · "; } text += "Repeatable"; } _levelZoneLine = text; } if (quest.Acquisition != null) { foreach (AcquisitionSource item in quest.Acquisition) { string method = item.Method; if (1 == 0) { } string text2; switch (method) { case "dialog": if (item.SourceName == null) { goto default; } text2 = "Given by: " + item.SourceName; break; case "item_read": if (item.SourceName == null) { goto default; } text2 = "Read: " + item.SourceName; break; case "zone_entry": if (item.SourceName == null) { goto default; } text2 = "Enter: " + item.SourceName; break; case "quest_chain": if (item.SourceName == null) { goto default; } text2 = "Chain from: " + item.SourceName; break; default: text2 = ((item.SourceName != null) ? ("From: " + item.SourceName) : null); break; } if (1 == 0) { } string text3 = text2; if (text3 != null) { if (item.ZoneName != null && item.Method == "dialog") { text3 = text3 + " (" + item.ZoneName + ")"; } _acquisitionLines.Add(text3); } } } if (quest.Completion == null) { return; } foreach (CompletionSource item2 in quest.Completion) { string method2 = item2.Method; if (1 == 0) { } string text2; switch (method2) { case "item_turnin": case "dialog": if (item2.SourceName == null) { goto default; } text2 = "Turn in to: " + item2.SourceName; break; case "zone": if (item2.SourceName == null) { goto default; } text2 = "Complete at: " + item2.SourceName; break; default: text2 = ((item2.SourceName == null) ? null : ("Complete: " + item2.SourceName)); break; } if (1 == 0) { } string text4 = text2; if (text4 != null) { bool flag2 = item2.ZoneName != null; bool flag3 = flag2; if (flag3) { text2 = item2.Method; bool flag4 = ((text2 == "item_turnin" || text2 == "dialog") ? true : false); flag3 = flag4; } if (flag3) { text4 = text4 + " (" + item2.ZoneName + ")"; } _completionLines.Add(text4); } } } private void CacheRewards(RewardInfo? r) { if (r == null) { return; } if (r.XP > 0) { _rewardLines.Add(($"{r.XP} XP", false)); } if (r.Gold > 0) { _rewardLines.Add(($"{r.Gold} Gold", false)); } if (r.ItemName != null) { _rewardLines.Add((r.ItemName, false)); } if (r.VendorUnlock != null) { _rewardLines.Add(("Unlocks " + r.VendorUnlock.ItemName + " at " + r.VendorUnlock.VendorName, false)); } List<string> coRequirements; if (r.UnlockedZoneLines != null) { foreach (UnlockedZoneLine unlockedZoneLine in r.UnlockedZoneLines) { string text = "Opens path from " + unlockedZoneLine.FromZone + " to " + unlockedZoneLine.ToZone; coRequirements = unlockedZoneLine.CoRequirements; if (coRequirements != null && coRequirements.Count > 0) { text = text + " (also requires " + string.Join(", ", unlockedZoneLine.CoRequirements) + ")"; } _rewardLines.Add((text, false)); } } if (r.UnlockedCharacters != null) { foreach (UnlockedCharacter unlockedCharacter in r.UnlockedCharacters) { string item = ((unlockedCharacter.Zone != null) ? ("Enables " + unlockedCharacter.Name + " in " + unlockedCharacter.Zone) : ("Enables " + unlockedCharacter.Name)); _rewardLines.Add((item, false)); } } if (r.NextQuestName != null) { _rewardLines.Add(("Next: " + r.NextQuestName, true)); } if (r.FactionEffects != null) { foreach (FactionEffect factionEffect in r.FactionEffects) { string arg = ((factionEffect.Amount >= 0) ? "+" : ""); _rewardLines.Add(($"{factionEffect.FactionName}: {arg}{factionEffect.Amount}", false)); } } coRequirements = r.AlsoCompletes; if (coRequirements != null && coRequirements.Count > 0) { _rewardLines.Add(("Also completes: " + string.Join(", ", r.AlsoCompletes), true)); } } private void CacheStepTree(QuestEntry quest, HashSet<string> visited) { if (!_questDisplay.TryGetValue(quest, out QuestDisplayCache value)) { value = new QuestDisplayCache { CurrentStepIndex = StepProgress.GetCurrentStepIndex(quest, _state, _data) }; _questDisplay.Add(quest, value); if (quest.Steps != null) { foreach (QuestStep step in quest.Steps) { value.Steps.Add(step, CacheStep(quest, step)); } } } if (quest.Steps == null) { return; } foreach (QuestStep step2 in quest.Steps) { foreach (ItemSource visibleSource in value.Steps[step2].VisibleSources) { CacheSourceQuestTree(visibleSource, visited); } if (step2.Action == "complete_quest" && step2.TargetKey != null) { CacheInlineQuest(_data.GetByStableKey(step2.TargetKey), visited); } } } private void CacheInlineQuest(QuestEntry? quest, HashSet<string> visited) { List<QuestStep> list = quest?.Steps; if (list != null && list.Count > 0 && visited.Count <= 5 && !visited.Contains(quest.StableKey)) { visited.Add(quest.StableKey); CacheStepTree(quest, visited); visited.Remove(quest.StableKey); } } private void CacheSourceQuestTree(ItemSource src, HashSet<string> visited, int depth = 0) { if (!IsSourceAvailable(src)) { return; } if (src.Type == "quest_reward" && src.QuestKey != null) { QuestEntry byStableKey = _data.GetByStableKey(src.QuestKey); List<QuestStep> list = byStableKey?.Steps; if (list != null && list.Count > 0 && visited.Count <= 5 && !visited.Contains(byStableKey.StableKey)) { CacheInlineQuest(byStableKey, visited); return; } } if (src.Children == null || depth >= 3) { return; } foreach (ItemSource child in src.Children) { CacheSourceQuestTree(child, visited, depth + 1); } } private StepDisplayCache CacheStep(QuestEntry quest, QuestStep step) { StepDisplayCache stepDisplayCache = new StepDisplayCache { Text = $"{step.Order}. {step.Description}", NavLabel = $"[NAV]##{step.Order}", TipsLabel = $"Tips##{step.Order}" }; if (StepCountPolicy.ShowsInventoryCount(step)) { int num = _state.CountItem(step.TargetKey); stepDisplayCache.Text += $" ({num}/{step.Quantity})"; stepDisplayCache.HasRequiredQuantity = num >= step.Quantity.Value; } int? num2 = step.LevelEstimate?.Recommended; if (num2.HasValue) { int valueOrDefault = num2.GetValueOrDefault(); if (true) { switch (step.Action) { default: { List<LevelFactor> factors = step.LevelEstimate.Factors; if (factors != null && factors.Count > 0) { stepDisplayCache.Text = stepDisplayCache.Text + " · " + step.LevelEstimate.Factors[0].Name; } break; } case "collect": case "obtain": case "read": break; } stepDisplayCache.Text += $" · Lv {valueOrDefault}"; goto IL_023c; } } switch (step.Action) { default: { List<LevelFactor> factors = step.LevelEstimate?.Factors; if (factors != null && factors.Count > 0) { stepDisplayCache.Text = stepDisplayCache.Text + " · " + step.LevelEstimate.Factors[0].Name; } break; } case "collect": case "obtain": case "read": break; } goto IL_023c; IL_023c: List<ItemSource> list = ItemSourcePolicy.SourcesFor(quest, step); if (step.TargetType == "item" && list != null) { foreach (ItemSource item in list) { if (HasNavigableSource(item)) { stepDisplayCache.Navigable = true; break; } } } else if (step.TargetType == "character") { stepDisplayCache.Navigable = step.TargetKey != null && _data.CharacterSpawns.ContainsKey(step.TargetKey); string text = _state.Furnishings.RequirementText(step.TargetKey); if (text != null) { stepDisplayCache.Requirement = " " + text; } } else if (step.TargetType == "zone") { stepDisplayCache.Navigable = step.ZoneName != null || step.TargetKey != null; } bool flag; switch (step.Action) { case "collect": case "obtain": case "read": flag = true; break; default: flag = false; break; } if (flag && step.TargetName != null && list != null) { foreach (ItemSource item2 in list) { if (IsSourceAvailable(item2)) { stepDisplayCache.VisibleSources.Add(item2); CacheSourceLabels(item2, step, stepDisplayCache); } } } if (stepDisplayCache.VisibleSources.Count > 4) { stepDisplayCache.MoreSourcesLabel = SourceListText.MoreSources(stepDisplayCache.VisibleSources, 4) + "##" + step.Order; } if (step.Action == "complete_quest" && step.TargetKey != null) { QuestEntry byStableKey = _data.GetByStableKey(step.TargetKey); if (byStableKey != null) { stepDisplayCache.SubQuestLabel = $"Open quest: {byStableKey.DisplayName}##cq_{step.Order}_{step.TargetKey}"; } } return stepDisplayCache; } private void CacheSourceLabels(ItemSource src, QuestStep step, StepDisplayCache stepDisplay, int depth = 0) { if (stepDisplay.Sources.ContainsKey((src, depth))) { return; } string text = SourceListText.Label(src); SourceDisplayCache sourceDisplayCache = new SourceDisplayCache(); sourceDisplayCache.Label = text; sourceDisplayCache.ChildrenLabel = $"{text}##src_{step.Order}_{depth}_{src.Type}_{src.Name}"; sourceDisplayCache.SourceId = ((src.Type == "treasure_chest" && !_state.TreasureHunt.State.Active) ? null : src.MakeSourceId()); sourceDisplayCache.AddTooltip = ((src.Type == "treasure_chest") ? "Navigate to the active treasure dig site." : ("Add to navigation: " + (src.Name ?? src.Zone ?? src.Scene))); sourceDisplayCache.RemoveTooltip = ((src.Type == "treasure_chest") ? "Navigate to the active treasure dig site." : ("Remove from navigation: " + (src.Name ?? src.Zone ?? src.Scene))); SourceDisplayCache sourceDisplayCache2 = sourceDisplayCache; if (sourceDisplayCache2.SourceId != null) { sourceDisplayCache2.SelectableLabel = $"{text}##src_{step.Order}_{depth}_{sourceDisplayCache2.SourceId}_{src.Level}_{src.LevelMax}"; } if (src.Type == "quest_reward" && src.QuestKey != null) { sourceDisplayCache2.QuestTreeLabel = $"{text}##sqt_{step.Order}_{src.QuestKey}"; QuestEntry byStableKey = _data.GetByStableKey(src.QuestKey); if (byStableKey != null) { sourceDisplayCache2.OpenQuestLabel = $"Open quest: {byStableKey.DisplayName}##goto_{step.Order}_{src.QuestKey}"; } } stepDisplay.Sources.Add((src, depth), sourceDisplayCache2); if (src.Children == null || depth >= 3) { return; } foreach (ItemSource child in src.Children) { CacheSourceLabels(child, step, stepDisplay, depth + 1); } } private bool IsSourceAvailable(ItemSource source) { if (source.RequiredQuestDBNames != null) { foreach (string requiredQuestDBName in source.RequiredQuestDBNames) { if (!_state.IsGameQuestCompleted(requiredQuestDBName)) { return false; } } } return source.SourceKey == null || _state.Furnishings.IsAvailable(source.SourceKey); } private bool HasNavigableSource(ItemSource s) { if (!IsSourceAvailable(s)) { return false; } if (s.Type == "treasure_chest") { return _state.TreasureHunt.State.Active; } if (ItemSourcePolicy.IsRandomSource(s) || !ItemSourcePolicy.NeedsUsedItem(s, _state.CountItemDelegate)) { return false; } if (ItemSourcePolicy.IsStaticCandidate(s) && s.Scene != null) { return true; } if (ItemSourcePolicy.IsStaticCandidate(s) && s.SourceKey != null && _data.CharacterSpawns.TryGetValue(s.SourceKey, out List<SpawnPoint> value) && value.Count > 0) { return true; } if (s.Children != null) { foreach (ItemSource child in s.Children) { if (HasNavigableSource(child)) { return true; } } } return false; } } public sealed class QuestListPanel { private readonly struct RowText { public readonly string Label; public readonly string Id; public RowText(string label, string id) { Label = label; Id = id; } } private readonly GuideData _data; private readonly QuestStateTracker _state; private readonly FilterState _filter; private readonly TrackerState _tracker; private string _searchBuf = string.Empty; private readonly List<QuestEntry> _sorted = new List<QuestEntry>(); private readonly Dictionary<QuestEntry, RowText> _rowText = new Dictionary<QuestEntry, RowText>(); private int _lastFilterVersion = -1; private int _lastStateVersion = -1; private static readonly string[] FilterNames = new string[4] { "Active", "Available", "Completed", "All" }; private const string QuestTrackedMarker = "·"; private int _filterIndex; private const string CurrentZoneSentinel = "\u001current"; private readonly string[] _zoneNames; private int _zoneIndex; private static float QuestListMarkerStartX(float contentStartX) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ImGuiStylePtr style = ImGui.GetStyle(); return contentStartX + ((ImGuiStylePtr)(ref style)).FramePadding.X; } private static float QuestListMarkerColumnWidth() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ImGuiStylePtr style = ImGui.GetStyle(); return ImGui.CalcTextSize("·").X + ((ImGuiStylePtr)(ref style)).ItemInnerSpacing.X; } public QuestListPanel(GuideData data, QuestStateTracker state, FilterState filter, TrackerState tracker) { _data = data; _state = state; _filter = filter; _tracker = tracker; SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.OrdinalIgnoreCase); foreach (QuestEntry item in data.All) { if (item.ZoneContext != null) { sortedSet.Add(item.ZoneContext); } } _zoneNames = new string[sortedSet.Count + 2]; _zoneNames[0] = "All Zones"; _zoneNames[1] = "Current Zone"; int num = 2; foreach (string item2 in sortedSet) { _zoneNames[num++] = item2; } } public void Draw(float width) { DrawFilterRow(width); DrawZoneFilter(); DrawSearchBar(); ImGui.Separator(); ImGui.BeginChild("##QuestScroll"); if (DrawQuestList() == 0) { ImGui.PushStyleColor((ImGuiCol)0, Theme.TextSecondary); if (_data.Count == 0) { ImGui.TextWrapped("No quest data loaded."); } else if (!string.IsNullOrEmpty(_filter.SearchText)) { ImGui.TextWrapped("No quests match your search."); } else { ImGui.TextWrapped("No quests in this category."); } ImGui.PopStyleColor(); } ImGui.EndChild(); } private void DrawFilterRow(float width) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) _filterIndex = (int)_filter.FilterMode; ImGui.SetNextItemWidth(width * 0.55f); if (ImGui.Combo("##Filter", ref _filterIndex, FilterNames, FilterNames.Length)) { _filter.FilterMode = (QuestFilterMode)_filterIndex; } ImGui.SameLine(); DrawSortButton("Az##sort", QuestSortMode.Alphabetical, "Sort alphabetically"); ImGuiStylePtr style = ImGui.GetStyle(); ImGui.SameLine(0f, ((ImGuiStylePtr)(ref style)).ItemSpacing.X * 0.25f); DrawSortButton("Lv##sort", QuestSortMode.ByLevel, "Sort by level"); style = ImGui.GetStyle(); ImGui.SameLine(0f, ((ImGuiStylePtr)(ref style)).ItemSpacing.X * 0.25f); DrawSortButton("Zn##sort", QuestSortMode.ByZone, "Sort by zone"); ImGui.Spacing(); } private void DrawSortButton(string label, QuestSortMode mode, string tooltip) { bool flag = _filter.SortMode == mode; if (flag) { ImGui.PushStyleColor((ImGuiCol)21, Theme.Accent); } if (ImGui.SmallButton(label)) { _filter.SortMode = mode; } if (flag) { ImGui.PopStyleColor(); } if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.TextUnformatted(tooltip); ImGui.EndTooltip(); } } private void DrawZoneFilter() { _zoneIndex = 0; if (_filter.ZoneFilter != null) { if (_filter.ZoneFilter == "\u001current") { _zoneIndex = 1; } else { for (int i = 2; i < _zoneNames.Length; i++) { if (string.Equals(_zoneNames[i], _filter.ZoneFilter, StringComparison.OrdinalIgnoreCase)) { _zoneIndex = i; break; } } } } ImGui.SetNextItemWidth(-1f); if (ImGui.Combo("##Zone", ref _zoneIndex, _zoneNames, _zoneNames.Length)) { FilterState filter = _filter; int zoneIndex = _zoneIndex; if (1 == 0) { } string zoneFilter = zoneIndex switch { 0 => null, 1 => "\u001current", _ => _zoneNames[_zoneIndex], }; if (1 == 0) { } filter.ZoneFilter = zoneFilter; } ImGui.Spacing(); } private void DrawSearchBar() { if (_searchBuf != _filter.SearchText) { _searchBuf = _filter.SearchText; } ImGui.SetNextItemWidth(-1f); if (ImGui.InputTextWithHint("##QuestSearch", "Search quests...", ref _searchBuf, 256u)) { _filter.SearchText = _searchBuf; } ImGui.Spacing(); } private int DrawQuestList() { bool flag = _filter.Version != _lastFilterVersion; bool flag2 = _state.Version != _lastStateVersion; if (flag || flag2) { _lastFilterVersion = _filter.Version; _lastStateVersion = _state.Version; _sorted.Clear(); IReadOnlyList<QuestEntry> all = _data.All; for (int i = 0; i < all.Count; i++) { QuestEntry questEntry = all[i]; if (PassesFilter(questEntry) && PassesSearch(questEntry)) { _sorted.Add(questEntry); } } _sorted.Sort(CompareQuests); } float markerWidth = QuestListMarkerColumnWidth(); foreach (QuestEntry item in _sorted) { DrawQuestEntry(item, markerWidth); } return _sorted.Count; } private int CompareQuests(QuestEntry a, QuestEntry b) { QuestSortMode sortMode = _filter.SortMode; if (1 == 0) { } int result = sortMode switch { QuestSortMode.ByLevel => CompareLevels(a, b), QuestSortMode.ByZone => CompareZones(a, b), _ => string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase), }; if (1 == 0) { } return result; } private static int CompareLevels(QuestEntry a, QuestEntry b) { int? num = a.LevelEstimate?.Recommended; int? num2 = b.LevelEstimate?.Recommended; if (!num.HasValue && !num2.HasValue) { return string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); } if (!num.HasValue) { return 1; } if (!num2.HasValue) { return -1; } int num3 = num.Value.CompareTo(num2.Value); return (num3 != 0) ? num3 : string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); } private static int CompareZones(QuestEntry a, QuestEntry b) { if (a.ZoneContext == null && b.ZoneContext == null) { return string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); } if (a.ZoneContext == null) { return 1; } if (b.ZoneContext == null) { return -1; } int num = string.Compare(a.ZoneContext, b.ZoneContext, StringComparison.OrdinalIgnoreCase); return (num != 0) ? num : string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase); } private bool PassesFilter(QuestEntry quest) { QuestRuntimeStatus status = _state.GetStatus(quest); QuestFilterMode filterMode = _filter.FilterMode; if (1 == 0) { } bool flag; switch (filterMode) { case QuestFilterMode.Active: { bool flag2 = (uint)(status - 1) <= 1u; flag = flag2; break; } case QuestFilterMode.Available: flag = status == QuestRuntimeStatus.Available; break; case QuestFilterMode.Completed: flag = status == QuestRuntimeStatus.Completed; break; case QuestFilterMode.All: flag = true; break; default: flag = true; break; } if (1 == 0) { } if (!flag) { return false; } if (_filter.ZoneFilter != null) { string text = ((_filter.ZoneFilter == "\u001current") ? _data.GetZoneDisplayName(_state.CurrentZone) : _filter.ZoneFilter); if (text == null) { return true; } return string.Equals(quest.ZoneContext, text, StringComparison.OrdinalIgnoreCase); } return true; } private bool PassesSearch(QuestEntry quest) { if (string.IsNullOrEmpty(_filter.SearchText)) { return true; } string searchText = _filter.SearchText; if (quest.DisplayName.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } if (quest.ZoneContext != null && quest.ZoneContext.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } if (quest.Acquisition != null) { foreach (AcquisitionSource item in quest.Acquisition) { if (item.SourceName != null && item.SourceName.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } } } if (quest.RequiredItems != null) { foreach (RequiredItemInfo requiredItem in quest.RequiredItems) { if (requiredItem.ItemName.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } } } if (quest.Steps != null) { foreach (QuestStep step in quest.Steps) { if (step.TargetName != null && step.TargetName.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { return true; } } } return false; } private void DrawQuestEntry(QuestEntry quest, float markerWidth) { bool flag = string.Equals(quest.RuntimeKey, _state.SelectedQuestKey, StringComparison.OrdinalIgnoreCase); uint questColor = GetQuestColor(quest); if (flag) { ImGui.PushStyleColor((ImGuiCol)21, Theme.Accent); } bool flag2 = _tracker.Enabled && _tracker.IsTracked(quest.RuntimeKey); RowText rowText = GetRowText(quest); ImGui.PushStyleColor((ImGuiCol)0, questColor); Vector2 cursorPos = ImGui.GetCursorPos(); Vector2 vector = cursorPos; Vector2 vector2 = new Vector2(ImGui.GetContentRegionAvail().X + cursorPos.X, ImGui.GetTextLineHeight()); ImGui.SetCursorPos(new Vector2(0f, cursorPos.Y)); bool flag3 = ImGui.Selectable(rowText.Id, flag, (ImGuiSelectableFlags)0, vector2); bool flag4 = ImGui.IsItemHovered(); vector = ImGui.GetCursorPos(); if (flag3) { _state.SelectQuest(quest); } float num = QuestListMarkerStartX(cursorPos.X); if (flag2) { ImGui.SetCursorPos(new Vector2(num, cursorPos.Y)); ImGui.TextUnformatted("·"); } ImGui.SetCursorPos(new Vector2(num + markerWidth, cursorPos.Y)); ImGui.TextUnformatted(rowText.Label); ImGui.SetCursorPos(vector); if (flag4) { ImGui.BeginTooltip(); if (quest.ZoneContext != null) { ImGui.Text(quest.ZoneContext); } string text; if (_state.Workflows.IsUnverifiable(quest)) { text = "Workflow state unavailable"; } else { QuestRuntimeStatus status = _state.GetStatus(quest); if (1 == 0) { } string text2 = status switch { QuestRuntimeStatus.Completed => "Completed", QuestRuntimeStatus.ImplicitlyActive => "Completable here", QuestRuntimeStatus.Active => "Active", _ => "Available", }; if (1 == 0) { } text = text2; } string text3 = text; ImGui.Text(text3); int? num2 = quest.LevelEstimate?.Recommended; if (num2.HasValue) { int valueOrDefault = num2.GetValueOrDefault(); if (true) { ImGui.Text($"Level {valueOrDefault}"); } } ImGui.EndTooltip(); } ImGui.PopStyleColor((!flag) ? 1 : 2); } private uint GetQuestColor(QuestEntry quest) { return Theme.GetQuestColor(_state, quest); } private RowText GetRowText(QuestEntry quest) { if (_rowText.TryGetValue(quest, out var value)) { return value; } QuestFlags flags = quest.Flags; string text = ((flags != null && flags.Repeatable) ? " [R]" : ""); int? num = quest.LevelEstimate?.Recommended; string text2; if (num.HasValue) { int valueOrDefault = num.GetValueOrDefault(); text2 = $"{valueOrDefault,2} {quest.DisplayName}{text}"; } else { text2 = " " + quest.DisplayName + text; } string label = text2; value = new RowText(label, "##" + quest.RuntimeKey); _rowText[quest] = value; return value; } } internal static class SourceListText { public static string Label(ItemSource source) { string type = source.Type; if (1 == 0) { } string text; switch (type) { case "world_drop": text = "Drops from: " + source.Name; break; case "fishing_bonus": text = "Fishing: " + source.Name; break; case "treasure_chest": text = $"Treasure map chest (dig at Lv {source.Level}-{source.LevelMax})"; break; case "drop": text = "Drops from: " + source.Name; break; case "vendor": text = (string.IsNullOrWhiteSpace(source.Instruction) ? ("Buy from: " + source.Name) : (source.Instruction + " · " + source.Name)); break; case "dialog_give": text = "Given by: " + source.Name; break; case "fishing": text = "Fishing"; break; case "mining": text = "Mining"; break; case "pickup": text = ((source.Name == null) ? "Found in world" : ("Found in world: " + source.Name)); break; case "crafting": text = "Crafted from: " + source.Name; break; case "quest_reward": text = "Quest reward: " + source.Name; break; case "ingredient": { string? name = source.Name; int? nodeCount = source.NodeCount; object obj; if (nodeCount.HasValue) { int valueOrDefault = nodeCount.GetValueOrDefault(); obj = $" x{valueOrDefault}"; } else { obj = ""; } text = "Ingredient: " + name + (string?)obj; break; } case "item_use": text = "Use: " + source.Name; break; default: text = source.Name ?? source.Type; break; } if (1 == 0) { } string text2 = text; if (source.Zone != null) { text2 = text2 + " · " + source.Zone; } if (!ItemSourcePolicy.IsRandomSource(source)) { int? nodeCount = source.Level; if (nodeCount.HasValue) { int valueOrDefault2 = nodeCount.GetValueOrDefault(); if (true) { text2 += $" · Lv {valueOrDefault2}"; } } } double? chance = source.Chance; if (chance.HasValue) { double valueOrDefault3 = chance.GetValueOrDefault(); if (true) { text2 = text2 + " · " + valueOrDefault3.ToString((source.Type == "treasure_chest") ? "0" : "0.###", CultureInfo.InvariantCulture) + "%"; } } return text2; } public static string MoreSources(IReadOnlyList<ItemSource> sources, int start) { int? num = null; int? num2 = null; int valueOrDefault = default(int); for (int i = start; i < sources.Count; i++) { if (ItemSourcePolicy.IsRandomSource(sources[i])) { continue; } int? level = sources[i].Level; int num3; if (level.HasValue) { valueOrDefault = level.GetValueOrDefault(); num3 = 1; } else { num3 = 0; } if (num3 != 0) { if (!num.HasValue || valueOrDefault < num) { num = valueOrDefault; } if (!num2.HasValue || valueOrDefault > num2) { num2 = valueOrDefault; } } } int num4 = sources.Count - start; if (!num.HasValue) { return $"{num4} more sources"; } return (num == num2) ? $"{num4} more sources (Lv {num})" : $"{num4} more sources (Lv {num}-{num2})"; } } internal static class StepCountPolicy { public static bool ShowsInventoryCount(QuestStep step) { string action = step.Action; bool flag = ((action == "collect" || action == "obtain") ? true : false); return flag && step.TargetKey != null && step.Quantity.HasValue; } } public readonly struct StepDistance { public readonly bool InCurrentZone; public readonly float Meters; public readonly string? Label; public bool HasDistance => Meters < float.MaxValue; public bool HasLabel => Label != null; public StepDistance(bool inCurrentZone, float meters, string? label = null) { InCurrentZone = inCurrentZone; Meters = meters; Label = label; } } public static class Theme { [StructLayout(LayoutKind.Sequential, Size = 1)] internal readonly struct WindowStyleScopeToken : IDisposable { public void Dispose() { PopWindowStyle(); } } public static readonly uint Background = Rgba(0.1f, 0.1f, 0.12f, 0.95f); public static readonly uint Surface = Rgba(0.15f, 0.15f, 0.18f, 1f); public static readonly uint TextPrimary = Rgba(1f, 1f, 1f, 1f); public static readonly uint TextSecondary = Rgba(0.6f, 0.6f, 0.6f, 1f); public static readonly uint Accent = Rgba(0.2f, 0.35f, 0.55f, 1f); public static readonly uint Success = Rgba(0.4f, 0.8f, 0.4f, 1f); public static readonly uint Warning = Rgba(1f, 0.5f, 0.3f, 1f); public static readonly uint Error = Rgba(1f, 0.3f, 0.3f, 1f); public static readonly uint QuestActive = Rgba(1f, 0.9f, 0.3f, 1f); public static readonly uint QuestImplicit = Rgba(0.55f, 0.8f, 0.75f, 1f); public static readonly uint QuestCompleted = Rgba(0.4f, 0.7f, 0.4f, 1f); public static readonly uint QuestAvailable = Rgba(0.5f, 0.7f, 0.9f, 1f); public static readonly uint NavManualOverride = Rgba(0.45f, 0.85f, 0.9f, 1f); public static readonly uint SourceDimmed = Rgba(0.5f, 0.5f, 0.5f, 1f); public static readonly uint Header = Rgba(0.9f, 0.85f, 0.6f, 1f); public static readonly uint LevelSafe = Rgba(0.4f, 0.8f, 0.4f, 1f); public static readonly uint LevelCaution = Rgba(1f, 0.9f, 0.3f, 1f); public static readonly uint LevelDanger = Rgba(1f, 0.3f, 0.3f, 1f); public static readonly uint TrackerFlashGreen = Rgba(0.2f, 0.8f, 0.2f, 0.3f); public static readonly uint TrackerFlashYellow = Rgba(0.8f, 0.7f, 0.1f, 0.2f); public const float WindowPadding = 8f; public const float ItemSpacing = 4f; public const float SectionGap = 8f; public const float IndentWidth = 16f; public const float LeftPanelRatio = 0.32f; private const int WindowStyleColorCount = 15; private const int WindowStyleVarCount = 13; internal static WindowStyleScopeToken WindowStyleScope(float scale) { PushWindowStyle(scale); return default(WindowStyleScopeToken); } public static void PushWindowStyle(float scale) { ThemeMetrics themeMetrics = ThemeMetrics.For(scale); ImGui.PushStyleColor((ImGuiCol)2, Background); ImGui.PushStyleColor((ImGuiCol)3, Surface); ImGui.PushStyleColor((ImGuiCol)21, Rgba(0.26f, 0.59f, 0.98f, 0.4f)); ImGui.PushStyleColor((ImGuiCol)22, Rgba(0.26f, 0.59f, 0.98f, 1f)); ImGui.PushStyleColor((ImGuiCol)23, Rgba(0.06f, 0.53f, 0.98f, 1f)); ImGui.PushStyleColor((ImGuiCol)7, Rgba(0.16f, 0.29f, 0.48f, 0.54f)); ImGui.PushStyleColor((ImGuiCol)8, Rgba(0.26f, 0.59f, 0.98f, 0.4f)); ImGui.PushStyleColor((ImGuiCol)9, Rgba(0.26f, 0.59f, 0.98f, 0.67f)); ImGui.PushStyleColor((ImGuiCol)5, Rgba(0.43f, 0.43f, 0.5f, 0.5f)); ImGui.PushStyleColor((ImGuiCol)10, Rgba(0.04f, 0.04f, 0.04f, 1f)); ImGui.PushStyleColor((ImGuiCol)11, Rgba(0.16f, 0.29f, 0.48f, 1f)); ImGui.PushStyleColor((ImGuiCol)12, Rgba(0f, 0f, 0f, 0.51f)); ImGui.PushStyleColor((ImGuiCol)24, Rgba(0.26f, 0.59f, 0.98f, 0.31f)); ImGui.PushStyleColor((ImGuiCol)25, Rgba(0.26f, 0.59f, 0.98f, 0.8f)); ImGui.PushStyleColor((ImGuiCol)26, Rgba(0.26f, 0.59f, 0.98f, 1f)); ImGui.PushStyleVar((ImGuiStyleVar)3, 0f); ImGui.PushStyleVar((ImGuiStyleVar)7, 0f); ImGui.PushStyleVar((ImGuiStyleVar)12, 0f); ImGui.PushStyleVar((ImGuiStyleVar)9, 0f); ImGui.PushStyleVar((ImGuiStyleVar)19, 0f); ImGui.PushStyleVar((ImGuiStyleVar)21, 0f); ImGui.PushStyleVar((ImGuiStyleVar)22, themeMetrics.TabRounding); ImGui.PushStyleVar((ImGuiStyleVar)8, themeMetrics.ChildBorderSize); ImGui.PushStyleVar((ImGuiStyleVar)13, 0f); ImGui.PushStyleVar((ImGuiStyleVar)11, new Vector2(themeMetrics.FramePaddingX, themeMetrics.FramePaddingY)); ImGui.PushStyleVar((ImGuiStyleVar)14, new Vector2(themeMetrics.ItemSpacingX, themeMetrics.ItemSpacingY)); ImGui.PushStyleVar((ImGuiStyleVar)16, themeMetrics.IndentSpacing); ImGui.PushStyleVar((ImGuiStyleVar)24, new Vector2(0f, 0f)); } public static void PopWindowStyle() { ImGui.PopStyleVar(13); ImGui.PopStyleColor(15); } public static uint Rgba(float r, float g, float b, float a) { byte b2 = (byte)(r * 255f + 0.5f); byte b3 = (byte)(g * 255f + 0.5f); byte b4 = (byte)(b * 255f + 0.5f); byte b5 = (byte)(a * 255f + 0.5f); return (uint)(b2 | (b3 << 8) | (b4 << 16) | (b5 << 24)); } public static Vector2 DisplaySize() { return new Vector2(Screen.width, Screen.height); } public static void ClampWindowPosition() { Vector2 windowPos = ImGui.GetWindowPos(); Vector2 windowSize = ImGui.GetWindowSize(); Vector2 vector = DisplaySize(); float num = windowPos.X; float num2 = windowPos.Y; if (num + windowSize.X < 40f) { num = 40f - windowSize.X; } if (num > vector.X - 40f) { num = vector.X - 40f; } if (num2 > vector.Y - 40f) { num2 = vector.Y - 40f; } if (num2 < 0f) { num2 = 0f; } if (num != windowPos.X || num2 != windowPos.Y) { ImGui.SetWindowPos(new Vector2(num, num2)); } } public static uint GetQuestColor(QuestStateTracker state, QuestEntry quest) { QuestRuntimeStatus status = state.GetStatus(quest); if (1 == 0) { } uint result = status switch { QuestRuntimeStatus.ImplicitlyActive => QuestImplicit, QuestRuntimeStatus.Active => QuestActive, QuestRuntimeStatus.Completed => QuestCompleted, _ => QuestAvailable, }; if (1 == 0) { } return result; } } internal readonly struct ThemeMetrics { private readonly float _scale; public float FramePaddingX => 4f * _scale; public float FramePaddingY => 3f * _scale; public float ItemSpacingX => 8f * _scale; public float ItemSpacingY => 4f * _scale; public float IndentSpacing => 16f * _scale; public float TabRounding => 4f * _scale; public float ChildBorderSize => _scale; private ThemeMetrics(float scale) { _scale = scale; } public static ThemeMetrics For(float scale) { return new ThemeMetrics(scale); } } internal static class TrackerSorter { private readonly struct SourceDistance { public readonly float Meters; public readonly string? Label; public static SourceDistance None => new SourceDistance(float.MaxValue); public SourceDistance(float meters, string? label = null) { Meters = meters; Label = label; } public static SourceDistance Best(SourceDistance a, SourceDistance b) { if (a.Label != null && b.Label == null) { return a; } if (b.Label != null && a.Label == null) { return b; } return (a.Meters <= b.Meters) ? a : b; } } public static void ComputeDistances(IReadOnlyList<string> quests, GuideData data, QuestStateTracker state, NavigationTarget? navigationTarget, float navigationDistance, Vector3 playerPos, Dictionary<string, StepDistance> output) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) output.Clear(); string currentZone = state.CurrentZone; for (int i = 0; i < quests.Count; i++) { string text = quests[i]; QuestEntry byRuntimeKey = data.GetByRuntimeKey(text); if (byRuntimeKey == null) { output[text] = new StepDistance(inCurrentZone: false, float.MaxValue); } else if (navigationTarget != null && string.Equals(navigationTarget.QuestKey, text, StringComparison.OrdinalIgnoreCase)) { bool flag = !navigationTarget.IsCrossZone(currentZone); if (flag && navigationTarget.TargetKind == NavigationTarget.Kind.Zone) { output[text] = new StepDistance(inCurrentZone: true, float.MaxValue); continue; } float meters = (flag ? navigationDistance : float.MaxValue); output[text] = new StepDistance(flag, meters); } else if (!IsCurrentStepInZone(byRuntimeKey, state, data, currentZone)) { output[text] = new StepDistance(inCurrentZone: false, float.MaxValue); } else { SourceDistance sourceDistance = ComputeStepDistance(byRuntimeKey, state, data, currentZone, playerPos); output[text] = new StepDistance(inCurrentZone: true, sourceDistance.Meters, sourceDistance.Label); } } } public static void Sort(List<string> quests, TrackerSortMode mode, GuideData data, IReadOnlyDictionary<string, StepDistance>? distances) { switch (mode) { case TrackerSortMode.Proximity: if (distances == null) { break; } SortByProximity(quests, data, distances); return; case TrackerSortMode.Level: SortByLevel(quests, data); return; } SortAlphabetical(quests, data); } private static void SortByProximity(List<string> quests, GuideData data, IReadOnlyDictionary<string, StepDistance> distances) { quests.Sort(delegate(string a, string b) { StepDistance value; StepDistance stepDistance = (distances.TryGetValue(a, out value) ? value : new StepDistance(inCurrentZone: false, float.MaxValue)); StepDistance value2; StepDistance stepDistance2 = (distances.TryGetValue(b, out value2) ? value2 : new StepDistance(inCurrentZone: false, float.MaxValue)); if (stepDistance.InCurrentZone != stepDistance2.InCurrentZone) { return (!stepDistance.InCurrentZone) ? 1 : (-1); } if (stepDistance.InCurrentZone) { float num = (stepDistance.HasDistance ? stepDistance.Meters : 0f); float value3 = (stepDistance2.HasDistance ? stepDistance2.Meters : 0f); int num2 = num.CompareTo(value3); if (num2 != 0) { return num2; } } QuestEntry byRuntimeKey = data.GetByRuntimeKey(a); QuestEntry byRuntimeKey2 = data.GetByRuntimeKey(b); return string.Compare(byRuntimeKey?.DisplayName, byRuntimeKey2?.DisplayName, StringComparison.OrdinalIgnoreCase); }); } private static void SortByLevel(List<string> quests, GuideData data) { quests.Sort(delegate(string a, string b) { QuestEntry byRuntimeKey = data.GetByRuntimeKey(a); QuestEntry byRuntimeKey2 = data.GetByRuntimeKey(b); int num = byRuntimeKey?.LevelEstimate?.Recommended ?? int.MaxValue; int value = byRuntimeKey2?.LevelEstimate?.Recommended ?? int.MaxValue; int num2 = num.CompareTo(value); return (num2 != 0) ? num2 : string.Compare(byRuntimeKey?.DisplayName, byRuntimeKey2?.DisplayName, StringComparison.OrdinalIgnoreCase); }); } private static void SortAlphabetical(List<string> quests, GuideData data) { quests.Sort(delegate(string a, string b) { QuestEntry byRuntimeKey = data.GetByRuntimeKey(a); QuestEntry byRuntimeKey2 = data.GetByRuntimeKey(b); return string.Compare(byRuntimeKey?.DisplayName ?? a, byRuntimeKey2?.DisplayName ?? b, StringComparison.OrdinalIgnoreCase); }); } public static string? GetStepZoneName(QuestEntry quest, QuestStateTracker state, GuideData data) { QuestStep currentStep = GetCurrentStep(quest, state, data); if (currentStep == null) { return null; } var (questStep, questEntry) = StepProgress.ResolveActiveStep(currentStep, quest, state, data); if (questStep == null) { return null; } string text = StepSceneResolver.ResolveScene(questEntry ?? quest, questStep, data, state.IsGameQuestCompleted, state.Furnishings.IsAvailablePredicate, state.CountItemDelegate); return (text != null) ? data.GetZoneDisplayName(text) : null; } private static bool IsCurrentStepInZone(QuestEntry quest, QuestStateTracker state, GuideData data, string currentScene) { QuestStep currentStep = GetCurrentStep(quest, state, data); if (currentStep == null) { return false; } var (questStep, questEntry) = StepProgress.ResolveActiveStep(currentStep, quest, state, data); if (questStep == null) { return false; } return StepSceneResolver.HasSourceInScene(questEntry ?? quest, questStep, data, currentScene, state.IsGameQuestCompleted, state.Furnishings.IsAvailablePredicate, state.CountItemDelegate); } private static SourceDistance ComputeStepDistance(QuestEntry quest, QuestStateTracker state, GuideData data, string currentScene, Vector3 playerPos) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) QuestStep currentStep = GetCurrentStep(quest, state, data); if (currentStep == null) { return SourceDistance.None; } var (questStep, questEntry) = StepProgress.ResolveActiveStep(currentStep, quest, state, data); if (questStep == null) { return SourceDistance.None; } QuestEntry quest2 = questEntry ?? quest; if (questStep.Location != null) { string text = StepSceneResolver.ResolveScene(quest2, questStep, data, state.IsGameQuestCompleted, state.Furnishings.IsAvailablePredicate, state.CountItemDelegate); if (text != null && string.Equals(text, currentScene, StringComparison.OrdinalIgnoreCase)) { return new SourceDistance(NavigationPolicy.EuclideanDistance(playerPos.x, playerPos.y, playerPos.z, questStep.Location.X, questStep.Location.Y, questStep.Location.Z)); } } string targetKey = ques
plugins/AdventureGuide/ImGui.NET.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: InternalsVisibleTo("ImPlot.NET")] [assembly: InternalsVisibleTo("ImNodes.NET")] [assembly: AssemblyCompany("Eric Mellino")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A .NET wrapper for the Dear ImGui library.")] [assembly: AssemblyFileVersion("1.88.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ImGui.NET")] [assembly: AssemblyTitle("ImGui.NET")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.88.0.0")] [module: UnverifiableCode] namespace ImGuiNET; public struct ImColor { public Vector4 Value; } public struct ImColorPtr { public unsafe ImColor* NativePtr { get; } public unsafe ref Vector4 Value => ref Unsafe.AsRef<Vector4>(&NativePtr->Value); public unsafe ImColorPtr(ImColor* nativePtr) { NativePtr = nativePtr; } public unsafe ImColorPtr(IntPtr nativePtr) { NativePtr = (ImColor*)(void*)nativePtr; } public unsafe static implicit operator ImColorPtr(ImColor* nativePtr) { return new ImColorPtr(nativePtr); } public unsafe static implicit operator ImColor*(ImColorPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImColorPtr(IntPtr nativePtr) { return new ImColorPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImColor_destroy(NativePtr); } public unsafe ImColor HSV(float h, float s, float v) { float a = 1f; ImColor result = default(ImColor); ImGuiNative.ImColor_HSV(&result, h, s, v, a); return result; } public unsafe ImColor HSV(float h, float s, float v, float a) { ImColor result = default(ImColor); ImGuiNative.ImColor_HSV(&result, h, s, v, a); return result; } public unsafe void SetHSV(float h, float s, float v) { float a = 1f; ImGuiNative.ImColor_SetHSV(NativePtr, h, s, v, a); } public unsafe void SetHSV(float h, float s, float v, float a) { ImGuiNative.ImColor_SetHSV(NativePtr, h, s, v, a); } } public struct ImDrawChannel { public ImVector _CmdBuffer; public ImVector _IdxBuffer; } public struct ImDrawChannelPtr { public unsafe ImDrawChannel* NativePtr { get; } public unsafe ImPtrVector<ImDrawCmdPtr> _CmdBuffer => new ImPtrVector<ImDrawCmdPtr>(NativePtr->_CmdBuffer, Unsafe.SizeOf<ImDrawCmd>()); public unsafe ImVector<ushort> _IdxBuffer => new ImVector<ushort>(NativePtr->_IdxBuffer); public unsafe ImDrawChannelPtr(ImDrawChannel* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawChannelPtr(IntPtr nativePtr) { NativePtr = (ImDrawChannel*)(void*)nativePtr; } public unsafe static implicit operator ImDrawChannelPtr(ImDrawChannel* nativePtr) { return new ImDrawChannelPtr(nativePtr); } public unsafe static implicit operator ImDrawChannel*(ImDrawChannelPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawChannelPtr(IntPtr nativePtr) { return new ImDrawChannelPtr(nativePtr); } } public struct ImDrawCmd { public Vector4 ClipRect; public IntPtr TextureId; public uint VtxOffset; public uint IdxOffset; public uint ElemCount; public IntPtr UserCallback; public unsafe void* UserCallbackData; } public struct ImDrawCmdPtr { public unsafe ImDrawCmd* NativePtr { get; } public unsafe ref Vector4 ClipRect => ref Unsafe.AsRef<Vector4>(&NativePtr->ClipRect); public unsafe ref IntPtr TextureId => ref Unsafe.AsRef<IntPtr>(&NativePtr->TextureId); public unsafe ref uint VtxOffset => ref Unsafe.AsRef<uint>(&NativePtr->VtxOffset); public unsafe ref uint IdxOffset => ref Unsafe.AsRef<uint>(&NativePtr->IdxOffset); public unsafe ref uint ElemCount => ref Unsafe.AsRef<uint>(&NativePtr->ElemCount); public unsafe ref IntPtr UserCallback => ref Unsafe.AsRef<IntPtr>(&NativePtr->UserCallback); public unsafe IntPtr UserCallbackData { get { return (IntPtr)NativePtr->UserCallbackData; } set { NativePtr->UserCallbackData = (void*)value; } } public unsafe ImDrawCmdPtr(ImDrawCmd* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawCmdPtr(IntPtr nativePtr) { NativePtr = (ImDrawCmd*)(void*)nativePtr; } public unsafe static implicit operator ImDrawCmdPtr(ImDrawCmd* nativePtr) { return new ImDrawCmdPtr(nativePtr); } public unsafe static implicit operator ImDrawCmd*(ImDrawCmdPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawCmdPtr(IntPtr nativePtr) { return new ImDrawCmdPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawCmd_destroy(NativePtr); } public unsafe IntPtr GetTexID() { return ImGuiNative.ImDrawCmd_GetTexID(NativePtr); } } public struct ImDrawCmdHeader { public Vector4 ClipRect; public IntPtr TextureId; public uint VtxOffset; } public struct ImDrawCmdHeaderPtr { public unsafe ImDrawCmdHeader* NativePtr { get; } public unsafe ref Vector4 ClipRect => ref Unsafe.AsRef<Vector4>(&NativePtr->ClipRect); public unsafe ref IntPtr TextureId => ref Unsafe.AsRef<IntPtr>(&NativePtr->TextureId); public unsafe ref uint VtxOffset => ref Unsafe.AsRef<uint>(&NativePtr->VtxOffset); public unsafe ImDrawCmdHeaderPtr(ImDrawCmdHeader* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawCmdHeaderPtr(IntPtr nativePtr) { NativePtr = (ImDrawCmdHeader*)(void*)nativePtr; } public unsafe static implicit operator ImDrawCmdHeaderPtr(ImDrawCmdHeader* nativePtr) { return new ImDrawCmdHeaderPtr(nativePtr); } public unsafe static implicit operator ImDrawCmdHeader*(ImDrawCmdHeaderPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawCmdHeaderPtr(IntPtr nativePtr) { return new ImDrawCmdHeaderPtr(nativePtr); } } public struct ImDrawData { public byte Valid; public int CmdListsCount; public int TotalIdxCount; public int TotalVtxCount; public unsafe ImDrawList** CmdLists; public Vector2 DisplayPos; public Vector2 DisplaySize; public Vector2 FramebufferScale; public unsafe ImGuiViewport* OwnerViewport; } public struct ImDrawDataPtr { public unsafe ImDrawData* NativePtr { get; } public unsafe ref bool Valid => ref Unsafe.AsRef<bool>(&NativePtr->Valid); public unsafe ref int CmdListsCount => ref Unsafe.AsRef<int>(&NativePtr->CmdListsCount); public unsafe ref int TotalIdxCount => ref Unsafe.AsRef<int>(&NativePtr->TotalIdxCount); public unsafe ref int TotalVtxCount => ref Unsafe.AsRef<int>(&NativePtr->TotalVtxCount); public unsafe IntPtr CmdLists { get { return (IntPtr)NativePtr->CmdLists; } set { NativePtr->CmdLists = (ImDrawList**)(void*)value; } } public unsafe ref Vector2 DisplayPos => ref Unsafe.AsRef<Vector2>(&NativePtr->DisplayPos); public unsafe ref Vector2 DisplaySize => ref Unsafe.AsRef<Vector2>(&NativePtr->DisplaySize); public unsafe ref Vector2 FramebufferScale => ref Unsafe.AsRef<Vector2>(&NativePtr->FramebufferScale); public unsafe ImGuiViewportPtr OwnerViewport => new ImGuiViewportPtr(NativePtr->OwnerViewport); public unsafe RangePtrAccessor<ImDrawListPtr> CmdListsRange => new RangePtrAccessor<ImDrawListPtr>(CmdLists.ToPointer(), CmdListsCount); public unsafe ImDrawDataPtr(ImDrawData* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawDataPtr(IntPtr nativePtr) { NativePtr = (ImDrawData*)(void*)nativePtr; } public unsafe static implicit operator ImDrawDataPtr(ImDrawData* nativePtr) { return new ImDrawDataPtr(nativePtr); } public unsafe static implicit operator ImDrawData*(ImDrawDataPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawDataPtr(IntPtr nativePtr) { return new ImDrawDataPtr(nativePtr); } public unsafe void Clear() { ImGuiNative.ImDrawData_Clear(NativePtr); } public unsafe void DeIndexAllBuffers() { ImGuiNative.ImDrawData_DeIndexAllBuffers(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawData_destroy(NativePtr); } public unsafe void ScaleClipRects(Vector2 fb_scale) { ImGuiNative.ImDrawData_ScaleClipRects(NativePtr, fb_scale); } } [Flags] public enum ImDrawFlags { None = 0, Closed = 1, RoundCornersTopLeft = 0x10, RoundCornersTopRight = 0x20, RoundCornersBottomLeft = 0x40, RoundCornersBottomRight = 0x80, RoundCornersNone = 0x100, RoundCornersTop = 0x30, RoundCornersBottom = 0xC0, RoundCornersLeft = 0x50, RoundCornersRight = 0xA0, RoundCornersAll = 0xF0, RoundCornersDefault = 0xF0, RoundCornersMask = 0x1F0 } public struct ImDrawList { public ImVector CmdBuffer; public ImVector IdxBuffer; public ImVector VtxBuffer; public ImDrawListFlags Flags; public uint _VtxCurrentIdx; public IntPtr _Data; public unsafe byte* _OwnerName; public unsafe ImDrawVert* _VtxWritePtr; public unsafe ushort* _IdxWritePtr; public ImVector _ClipRectStack; public ImVector _TextureIdStack; public ImVector _Path; public ImDrawCmdHeader _CmdHeader; public ImDrawListSplitter _Splitter; public float _FringeScale; } public struct ImDrawListPtr { public unsafe ImDrawList* NativePtr { get; } public unsafe ImPtrVector<ImDrawCmdPtr> CmdBuffer => new ImPtrVector<ImDrawCmdPtr>(NativePtr->CmdBuffer, Unsafe.SizeOf<ImDrawCmd>()); public unsafe ImVector<ushort> IdxBuffer => new ImVector<ushort>(NativePtr->IdxBuffer); public unsafe ImPtrVector<ImDrawVertPtr> VtxBuffer => new ImPtrVector<ImDrawVertPtr>(NativePtr->VtxBuffer, Unsafe.SizeOf<ImDrawVert>()); public unsafe ref ImDrawListFlags Flags => ref Unsafe.AsRef<ImDrawListFlags>(&NativePtr->Flags); public unsafe ref uint _VtxCurrentIdx => ref Unsafe.AsRef<uint>(&NativePtr->_VtxCurrentIdx); public unsafe ref IntPtr _Data => ref Unsafe.AsRef<IntPtr>(&NativePtr->_Data); public unsafe NullTerminatedString _OwnerName => new NullTerminatedString(NativePtr->_OwnerName); public unsafe ImDrawVertPtr _VtxWritePtr => new ImDrawVertPtr(NativePtr->_VtxWritePtr); public unsafe IntPtr _IdxWritePtr { get { return (IntPtr)NativePtr->_IdxWritePtr; } set { NativePtr->_IdxWritePtr = (ushort*)(void*)value; } } public unsafe ImVector<Vector4> _ClipRectStack => new ImVector<Vector4>(NativePtr->_ClipRectStack); public unsafe ImVector<IntPtr> _TextureIdStack => new ImVector<IntPtr>(NativePtr->_TextureIdStack); public unsafe ImVector<Vector2> _Path => new ImVector<Vector2>(NativePtr->_Path); public unsafe ref ImDrawCmdHeader _CmdHeader => ref Unsafe.AsRef<ImDrawCmdHeader>(&NativePtr->_CmdHeader); public unsafe ref ImDrawListSplitter _Splitter => ref Unsafe.AsRef<ImDrawListSplitter>(&NativePtr->_Splitter); public unsafe ref float _FringeScale => ref Unsafe.AsRef<float>(&NativePtr->_FringeScale); public unsafe ImDrawListPtr(ImDrawList* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawListPtr(IntPtr nativePtr) { NativePtr = (ImDrawList*)(void*)nativePtr; } public unsafe static implicit operator ImDrawListPtr(ImDrawList* nativePtr) { return new ImDrawListPtr(nativePtr); } public unsafe static implicit operator ImDrawList*(ImDrawListPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawListPtr(IntPtr nativePtr) { return new ImDrawListPtr(nativePtr); } public unsafe int _CalcCircleAutoSegmentCount(float radius) { return ImGuiNative.ImDrawList__CalcCircleAutoSegmentCount(NativePtr, radius); } public unsafe void _ClearFreeMemory() { ImGuiNative.ImDrawList__ClearFreeMemory(NativePtr); } public unsafe void _OnChangedClipRect() { ImGuiNative.ImDrawList__OnChangedClipRect(NativePtr); } public unsafe void _OnChangedTextureID() { ImGuiNative.ImDrawList__OnChangedTextureID(NativePtr); } public unsafe void _OnChangedVtxOffset() { ImGuiNative.ImDrawList__OnChangedVtxOffset(NativePtr); } public unsafe void _PathArcToFastEx(Vector2 center, float radius, int a_min_sample, int a_max_sample, int a_step) { ImGuiNative.ImDrawList__PathArcToFastEx(NativePtr, center, radius, a_min_sample, a_max_sample, a_step); } public unsafe void _PathArcToN(Vector2 center, float radius, float a_min, float a_max, int num_segments) { ImGuiNative.ImDrawList__PathArcToN(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void _PopUnusedDrawCmd() { ImGuiNative.ImDrawList__PopUnusedDrawCmd(NativePtr); } public unsafe void _ResetForNewFrame() { ImGuiNative.ImDrawList__ResetForNewFrame(NativePtr); } public unsafe void _TryMergeDrawCmds() { ImGuiNative.ImDrawList__TryMergeDrawCmds(NativePtr); } public unsafe void AddBezierCubic(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness) { int num_segments = 0; ImGuiNative.ImDrawList_AddBezierCubic(NativePtr, p1, p2, p3, p4, col, thickness, num_segments); } public unsafe void AddBezierCubic(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness, int num_segments) { ImGuiNative.ImDrawList_AddBezierCubic(NativePtr, p1, p2, p3, p4, col, thickness, num_segments); } public unsafe void AddBezierQuadratic(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness) { int num_segments = 0; ImGuiNative.ImDrawList_AddBezierQuadratic(NativePtr, p1, p2, p3, col, thickness, num_segments); } public unsafe void AddBezierQuadratic(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness, int num_segments) { ImGuiNative.ImDrawList_AddBezierQuadratic(NativePtr, p1, p2, p3, col, thickness, num_segments); } public unsafe void AddCallback(IntPtr callback, IntPtr callback_data) { void* callback_data2 = callback_data.ToPointer(); ImGuiNative.ImDrawList_AddCallback(NativePtr, callback, callback_data2); } public unsafe void AddCircle(Vector2 center, float radius, uint col) { int num_segments = 0; float thickness = 1f; ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircle(Vector2 center, float radius, uint col, int num_segments) { float thickness = 1f; ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircle(Vector2 center, float radius, uint col, int num_segments, float thickness) { ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircleFilled(Vector2 center, float radius, uint col) { int num_segments = 0; ImGuiNative.ImDrawList_AddCircleFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddCircleFilled(Vector2 center, float radius, uint col, int num_segments) { ImGuiNative.ImDrawList_AddCircleFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddConvexPolyFilled(ref Vector2 points, int num_points, uint col) { fixed (Vector2* points2 = &points) { ImGuiNative.ImDrawList_AddConvexPolyFilled(NativePtr, points2, num_points, col); } } public unsafe void AddDrawCmd() { ImGuiNative.ImDrawList_AddDrawCmd(NativePtr); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max) { Vector2 uv_min = default(Vector2); Vector2 uv_max = new Vector2(1f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min) { Vector2 uv_max = new Vector2(1f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max) { uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col) { ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4) { Vector2 uv = default(Vector2); Vector2 uv2 = new Vector2(1f, 0f); Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1) { Vector2 uv2 = new Vector2(1f, 0f); Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2) { Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3) { Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3, Vector2 uv4) { uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3, Vector2 uv4, uint col) { ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageRounded(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddImageRounded(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col, rounding, flags); } public unsafe void AddImageRounded(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_AddImageRounded(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col, rounding, flags); } public unsafe void AddLine(Vector2 p1, Vector2 p2, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddLine(NativePtr, p1, p2, col, thickness); } public unsafe void AddLine(Vector2 p1, Vector2 p2, uint col, float thickness) { ImGuiNative.ImDrawList_AddLine(NativePtr, p1, p2, col, thickness); } public unsafe void AddNgon(Vector2 center, float radius, uint col, int num_segments) { float thickness = 1f; ImGuiNative.ImDrawList_AddNgon(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddNgon(Vector2 center, float radius, uint col, int num_segments, float thickness) { ImGuiNative.ImDrawList_AddNgon(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddNgonFilled(Vector2 center, float radius, uint col, int num_segments) { ImGuiNative.ImDrawList_AddNgonFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddPolyline(ref Vector2 points, int num_points, uint col, ImDrawFlags flags, float thickness) { fixed (Vector2* points2 = &points) { ImGuiNative.ImDrawList_AddPolyline(NativePtr, points2, num_points, col, flags, thickness); } } public unsafe void AddQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddQuad(NativePtr, p1, p2, p3, p4, col, thickness); } public unsafe void AddQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness) { ImGuiNative.ImDrawList_AddQuad(NativePtr, p1, p2, p3, p4, col, thickness); } public unsafe void AddQuadFilled(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col) { ImGuiNative.ImDrawList_AddQuadFilled(NativePtr, p1, p2, p3, p4, col); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags) { float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags, float thickness) { ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilledMultiColor(Vector2 p_min, Vector2 p_max, uint col_upr_left, uint col_upr_right, uint col_bot_right, uint col_bot_left) { ImGuiNative.ImDrawList_AddRectFilledMultiColor(NativePtr, p_min, p_max, col_upr_left, col_upr_right, col_bot_right, col_bot_left); } public unsafe void AddTriangle(Vector2 p1, Vector2 p2, Vector2 p3, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddTriangle(NativePtr, p1, p2, p3, col, thickness); } public unsafe void AddTriangle(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness) { ImGuiNative.ImDrawList_AddTriangle(NativePtr, p1, p2, p3, col, thickness); } public unsafe void AddTriangleFilled(Vector2 p1, Vector2 p2, Vector2 p3, uint col) { ImGuiNative.ImDrawList_AddTriangleFilled(NativePtr, p1, p2, p3, col); } public unsafe void ChannelsMerge() { ImGuiNative.ImDrawList_ChannelsMerge(NativePtr); } public unsafe void ChannelsSetCurrent(int n) { ImGuiNative.ImDrawList_ChannelsSetCurrent(NativePtr, n); } public unsafe void ChannelsSplit(int count) { ImGuiNative.ImDrawList_ChannelsSplit(NativePtr, count); } public unsafe ImDrawListPtr CloneOutput() { return new ImDrawListPtr(ImGuiNative.ImDrawList_CloneOutput(NativePtr)); } public unsafe void Destroy() { ImGuiNative.ImDrawList_destroy(NativePtr); } public unsafe Vector2 GetClipRectMax() { Vector2 result = default(Vector2); ImGuiNative.ImDrawList_GetClipRectMax(&result, NativePtr); return result; } public unsafe Vector2 GetClipRectMin() { Vector2 result = default(Vector2); ImGuiNative.ImDrawList_GetClipRectMin(&result, NativePtr); return result; } public unsafe void PathArcTo(Vector2 center, float radius, float a_min, float a_max) { int num_segments = 0; ImGuiNative.ImDrawList_PathArcTo(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void PathArcTo(Vector2 center, float radius, float a_min, float a_max, int num_segments) { ImGuiNative.ImDrawList_PathArcTo(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void PathArcToFast(Vector2 center, float radius, int a_min_of_12, int a_max_of_12) { ImGuiNative.ImDrawList_PathArcToFast(NativePtr, center, radius, a_min_of_12, a_max_of_12); } public unsafe void PathBezierCubicCurveTo(Vector2 p2, Vector2 p3, Vector2 p4) { int num_segments = 0; ImGuiNative.ImDrawList_PathBezierCubicCurveTo(NativePtr, p2, p3, p4, num_segments); } public unsafe void PathBezierCubicCurveTo(Vector2 p2, Vector2 p3, Vector2 p4, int num_segments) { ImGuiNative.ImDrawList_PathBezierCubicCurveTo(NativePtr, p2, p3, p4, num_segments); } public unsafe void PathBezierQuadraticCurveTo(Vector2 p2, Vector2 p3) { int num_segments = 0; ImGuiNative.ImDrawList_PathBezierQuadraticCurveTo(NativePtr, p2, p3, num_segments); } public unsafe void PathBezierQuadraticCurveTo(Vector2 p2, Vector2 p3, int num_segments) { ImGuiNative.ImDrawList_PathBezierQuadraticCurveTo(NativePtr, p2, p3, num_segments); } public unsafe void PathClear() { ImGuiNative.ImDrawList_PathClear(NativePtr); } public unsafe void PathFillConvex(uint col) { ImGuiNative.ImDrawList_PathFillConvex(NativePtr, col); } public unsafe void PathLineTo(Vector2 pos) { ImGuiNative.ImDrawList_PathLineTo(NativePtr, pos); } public unsafe void PathLineToMergeDuplicate(Vector2 pos) { ImGuiNative.ImDrawList_PathLineToMergeDuplicate(NativePtr, pos); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathStroke(uint col) { ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PathStroke(uint col, ImDrawFlags flags) { float thickness = 1f; ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PathStroke(uint col, ImDrawFlags flags, float thickness) { ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PopClipRect() { ImGuiNative.ImDrawList_PopClipRect(NativePtr); } public unsafe void PopTextureID() { ImGuiNative.ImDrawList_PopTextureID(NativePtr); } public unsafe void PrimQuadUV(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Vector2 uv_a, Vector2 uv_b, Vector2 uv_c, Vector2 uv_d, uint col) { ImGuiNative.ImDrawList_PrimQuadUV(NativePtr, a, b, c, d, uv_a, uv_b, uv_c, uv_d, col); } public unsafe void PrimRect(Vector2 a, Vector2 b, uint col) { ImGuiNative.ImDrawList_PrimRect(NativePtr, a, b, col); } public unsafe void PrimRectUV(Vector2 a, Vector2 b, Vector2 uv_a, Vector2 uv_b, uint col) { ImGuiNative.ImDrawList_PrimRectUV(NativePtr, a, b, uv_a, uv_b, col); } public unsafe void PrimReserve(int idx_count, int vtx_count) { ImGuiNative.ImDrawList_PrimReserve(NativePtr, idx_count, vtx_count); } public unsafe void PrimUnreserve(int idx_count, int vtx_count) { ImGuiNative.ImDrawList_PrimUnreserve(NativePtr, idx_count, vtx_count); } public unsafe void PrimVtx(Vector2 pos, Vector2 uv, uint col) { ImGuiNative.ImDrawList_PrimVtx(NativePtr, pos, uv, col); } public unsafe void PrimWriteIdx(ushort idx) { ImGuiNative.ImDrawList_PrimWriteIdx(NativePtr, idx); } public unsafe void PrimWriteVtx(Vector2 pos, Vector2 uv, uint col) { ImGuiNative.ImDrawList_PrimWriteVtx(NativePtr, pos, uv, col); } public unsafe void PushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max) { byte intersect_with_current_clip_rect = 0; ImGuiNative.ImDrawList_PushClipRect(NativePtr, clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); } public unsafe void PushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max, bool intersect_with_current_clip_rect) { byte intersect_with_current_clip_rect2 = (byte)(intersect_with_current_clip_rect ? 1 : 0); ImGuiNative.ImDrawList_PushClipRect(NativePtr, clip_rect_min, clip_rect_max, intersect_with_current_clip_rect2); } public unsafe void PushClipRectFullScreen() { ImGuiNative.ImDrawList_PushClipRectFullScreen(NativePtr); } public unsafe void PushTextureID(IntPtr texture_id) { ImGuiNative.ImDrawList_PushTextureID(NativePtr, texture_id); } public unsafe void AddText(Vector2 pos, uint col, string text_begin) { int byteCount = Encoding.UTF8.GetByteCount(text_begin); byte* ptr = stackalloc byte[(int)(uint)(byteCount + 1)]; fixed (char* chars = text_begin) { int bytes = Encoding.UTF8.GetBytes(chars, text_begin.Length, ptr, byteCount); ptr[bytes] = 0; } byte* text_end = null; ImGuiNative.ImDrawList_AddText_Vec2(NativePtr, pos, col, ptr, text_end); } public unsafe void AddText(ImFontPtr font, float font_size, Vector2 pos, uint col, string text_begin) { ImFont* nativePtr = font.NativePtr; int byteCount = Encoding.UTF8.GetByteCount(text_begin); byte* ptr = stackalloc byte[(int)(uint)(byteCount + 1)]; fixed (char* chars = text_begin) { int bytes = Encoding.UTF8.GetBytes(chars, text_begin.Length, ptr, byteCount); ptr[bytes] = 0; } byte* text_end = null; float wrap_width = 0f; Vector4* cpu_fine_clip_rect = null; ImGuiNative.ImDrawList_AddText_FontPtr(NativePtr, nativePtr, font_size, pos, col, ptr, text_end, wrap_width, cpu_fine_clip_rect); } } [Flags] public enum ImDrawListFlags { None = 0, AntiAliasedLines = 1, AntiAliasedLinesUseTex = 2, AntiAliasedFill = 4, AllowVtxOffset = 8 } public struct ImDrawListSplitter { public int _Current; public int _Count; public ImVector _Channels; } public struct ImDrawListSplitterPtr { public unsafe ImDrawListSplitter* NativePtr { get; } public unsafe ref int _Current => ref Unsafe.AsRef<int>(&NativePtr->_Current); public unsafe ref int _Count => ref Unsafe.AsRef<int>(&NativePtr->_Count); public unsafe ImPtrVector<ImDrawChannelPtr> _Channels => new ImPtrVector<ImDrawChannelPtr>(NativePtr->_Channels, Unsafe.SizeOf<ImDrawChannel>()); public unsafe ImDrawListSplitterPtr(ImDrawListSplitter* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawListSplitterPtr(IntPtr nativePtr) { NativePtr = (ImDrawListSplitter*)(void*)nativePtr; } public unsafe static implicit operator ImDrawListSplitterPtr(ImDrawListSplitter* nativePtr) { return new ImDrawListSplitterPtr(nativePtr); } public unsafe static implicit operator ImDrawListSplitter*(ImDrawListSplitterPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawListSplitterPtr(IntPtr nativePtr) { return new ImDrawListSplitterPtr(nativePtr); } public unsafe void Clear() { ImGuiNative.ImDrawListSplitter_Clear(NativePtr); } public unsafe void ClearFreeMemory() { ImGuiNative.ImDrawListSplitter_ClearFreeMemory(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawListSplitter_destroy(NativePtr); } public unsafe void Merge(ImDrawListPtr draw_list) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_Merge(NativePtr, nativePtr); } public unsafe void SetCurrentChannel(ImDrawListPtr draw_list, int channel_idx) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_SetCurrentChannel(NativePtr, nativePtr, channel_idx); } public unsafe void Split(ImDrawListPtr draw_list, int count) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_Split(NativePtr, nativePtr, count); } } public struct ImDrawVert { public Vector2 pos; public Vector2 uv; public uint col; } public struct ImDrawVertPtr { public unsafe ImDrawVert* NativePtr { get; } public unsafe ref Vector2 pos => ref Unsafe.AsRef<Vector2>(&NativePtr->pos); public unsafe ref Vector2 uv => ref Unsafe.AsRef<Vector2>(&NativePtr->uv); public unsafe ref uint col => ref Unsafe.AsRef<uint>(&NativePtr->col); public unsafe ImDrawVertPtr(ImDrawVert* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawVertPtr(IntPtr nativePtr) { NativePtr = (ImDrawVert*)(void*)nativePtr; } public unsafe static implicit operator ImDrawVertPtr(ImDrawVert* nativePtr) { return new ImDrawVertPtr(nativePtr); } public unsafe static implicit operator ImDrawVert*(ImDrawVertPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawVertPtr(IntPtr nativePtr) { return new ImDrawVertPtr(nativePtr); } } public struct ImFont { public ImVector IndexAdvanceX; public float FallbackAdvanceX; public float FontSize; public ImVector IndexLookup; public ImVector Glyphs; public unsafe ImFontGlyph* FallbackGlyph; public unsafe ImFontAtlas* ContainerAtlas; public unsafe ImFontConfig* ConfigData; public short ConfigDataCount; public ushort FallbackChar; public ushort EllipsisChar; public ushort DotChar; public byte DirtyLookupTables; public float Scale; public float Ascent; public float Descent; public int MetricsTotalSurface; public unsafe fixed byte Used4kPagesMap[2]; } public struct ImFontPtr { public unsafe ImFont* NativePtr { get; } public unsafe ImVector<float> IndexAdvanceX => new ImVector<float>(NativePtr->IndexAdvanceX); public unsafe ref float FallbackAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->FallbackAdvanceX); public unsafe ref float FontSize => ref Unsafe.AsRef<float>(&NativePtr->FontSize); public unsafe ImVector<ushort> IndexLookup => new ImVector<ushort>(NativePtr->IndexLookup); public unsafe ImPtrVector<ImFontGlyphPtr> Glyphs => new ImPtrVector<ImFontGlyphPtr>(NativePtr->Glyphs, Unsafe.SizeOf<ImFontGlyph>()); public unsafe ImFontGlyphPtr FallbackGlyph => new ImFontGlyphPtr(NativePtr->FallbackGlyph); public unsafe ImFontAtlasPtr ContainerAtlas => new ImFontAtlasPtr(NativePtr->ContainerAtlas); public unsafe ImFontConfigPtr ConfigData => new ImFontConfigPtr(NativePtr->ConfigData); public unsafe ref short ConfigDataCount => ref Unsafe.AsRef<short>(&NativePtr->ConfigDataCount); public unsafe ref ushort FallbackChar => ref Unsafe.AsRef<ushort>(&NativePtr->FallbackChar); public unsafe ref ushort EllipsisChar => ref Unsafe.AsRef<ushort>(&NativePtr->EllipsisChar); public unsafe ref ushort DotChar => ref Unsafe.AsRef<ushort>(&NativePtr->DotChar); public unsafe ref bool DirtyLookupTables => ref Unsafe.AsRef<bool>(&NativePtr->DirtyLookupTables); public unsafe ref float Scale => ref Unsafe.AsRef<float>(&NativePtr->Scale); public unsafe ref float Ascent => ref Unsafe.AsRef<float>(&NativePtr->Ascent); public unsafe ref float Descent => ref Unsafe.AsRef<float>(&NativePtr->Descent); public unsafe ref int MetricsTotalSurface => ref Unsafe.AsRef<int>(&NativePtr->MetricsTotalSurface); public unsafe RangeAccessor<byte> Used4kPagesMap => new RangeAccessor<byte>(NativePtr->Used4kPagesMap, 2); public unsafe ImFontPtr(ImFont* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontPtr(IntPtr nativePtr) { NativePtr = (ImFont*)(void*)nativePtr; } public unsafe static implicit operator ImFontPtr(ImFont* nativePtr) { return new ImFontPtr(nativePtr); } public unsafe static implicit operator ImFont*(ImFontPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontPtr(IntPtr nativePtr) { return new ImFontPtr(nativePtr); } public unsafe void AddGlyph(ImFontConfigPtr src_cfg, ushort c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) { ImFontConfig* nativePtr = src_cfg.NativePtr; ImGuiNative.ImFont_AddGlyph(NativePtr, nativePtr, c, x0, y0, x1, y1, u0, v0, u1, v1, advance_x); } public unsafe void AddRemapChar(ushort dst, ushort src) { byte overwrite_dst = 1; ImGuiNative.ImFont_AddRemapChar(NativePtr, dst, src, overwrite_dst); } public unsafe void AddRemapChar(ushort dst, ushort src, bool overwrite_dst) { byte overwrite_dst2 = (byte)(overwrite_dst ? 1 : 0); ImGuiNative.ImFont_AddRemapChar(NativePtr, dst, src, overwrite_dst2); } public unsafe void BuildLookupTable() { ImGuiNative.ImFont_BuildLookupTable(NativePtr); } public unsafe void ClearOutputData() { ImGuiNative.ImFont_ClearOutputData(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFont_destroy(NativePtr); } public unsafe ImFontGlyphPtr FindGlyph(ushort c) { return new ImFontGlyphPtr(ImGuiNative.ImFont_FindGlyph(NativePtr, c)); } public unsafe ImFontGlyphPtr FindGlyphNoFallback(ushort c) { return new ImFontGlyphPtr(ImGuiNative.ImFont_FindGlyphNoFallback(NativePtr, c)); } public unsafe float GetCharAdvance(ushort c) { return ImGuiNative.ImFont_GetCharAdvance(NativePtr, c); } public unsafe string GetDebugName() { return Util.StringFromPtr(ImGuiNative.ImFont_GetDebugName(NativePtr)); } public unsafe void GrowIndex(int new_size) { ImGuiNative.ImFont_GrowIndex(NativePtr, new_size); } public unsafe bool IsLoaded() { return ImGuiNative.ImFont_IsLoaded(NativePtr) != 0; } public unsafe void RenderChar(ImDrawListPtr draw_list, float size, Vector2 pos, uint col, ushort c) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImFont_RenderChar(NativePtr, nativePtr, size, pos, col, c); } public unsafe void SetGlyphVisible(ushort c, bool visible) { byte visible2 = (byte)(visible ? 1 : 0); ImGuiNative.ImFont_SetGlyphVisible(NativePtr, c, visible2); } } public struct ImFontAtlas { public ImFontAtlasFlags Flags; public IntPtr TexID; public int TexDesiredWidth; public int TexGlyphPadding; public byte Locked; public byte TexReady; public byte TexPixelsUseColors; public unsafe byte* TexPixelsAlpha8; public unsafe uint* TexPixelsRGBA32; public int TexWidth; public int TexHeight; public Vector2 TexUvScale; public Vector2 TexUvWhitePixel; public ImVector Fonts; public ImVector CustomRects; public ImVector ConfigData; public Vector4 TexUvLines_0; public Vector4 TexUvLines_1; public Vector4 TexUvLines_2; public Vector4 TexUvLines_3; public Vector4 TexUvLines_4; public Vector4 TexUvLines_5; public Vector4 TexUvLines_6; public Vector4 TexUvLines_7; public Vector4 TexUvLines_8; public Vector4 TexUvLines_9; public Vector4 TexUvLines_10; public Vector4 TexUvLines_11; public Vector4 TexUvLines_12; public Vector4 TexUvLines_13; public Vector4 TexUvLines_14; public Vector4 TexUvLines_15; public Vector4 TexUvLines_16; public Vector4 TexUvLines_17; public Vector4 TexUvLines_18; public Vector4 TexUvLines_19; public Vector4 TexUvLines_20; public Vector4 TexUvLines_21; public Vector4 TexUvLines_22; public Vector4 TexUvLines_23; public Vector4 TexUvLines_24; public Vector4 TexUvLines_25; public Vector4 TexUvLines_26; public Vector4 TexUvLines_27; public Vector4 TexUvLines_28; public Vector4 TexUvLines_29; public Vector4 TexUvLines_30; public Vector4 TexUvLines_31; public Vector4 TexUvLines_32; public Vector4 TexUvLines_33; public Vector4 TexUvLines_34; public Vector4 TexUvLines_35; public Vector4 TexUvLines_36; public Vector4 TexUvLines_37; public Vector4 TexUvLines_38; public Vector4 TexUvLines_39; public Vector4 TexUvLines_40; public Vector4 TexUvLines_41; public Vector4 TexUvLines_42; public Vector4 TexUvLines_43; public Vector4 TexUvLines_44; public Vector4 TexUvLines_45; public Vector4 TexUvLines_46; public Vector4 TexUvLines_47; public Vector4 TexUvLines_48; public Vector4 TexUvLines_49; public Vector4 TexUvLines_50; public Vector4 TexUvLines_51; public Vector4 TexUvLines_52; public Vector4 TexUvLines_53; public Vector4 TexUvLines_54; public Vector4 TexUvLines_55; public Vector4 TexUvLines_56; public Vector4 TexUvLines_57; public Vector4 TexUvLines_58; public Vector4 TexUvLines_59; public Vector4 TexUvLines_60; public Vector4 TexUvLines_61; public Vector4 TexUvLines_62; public Vector4 TexUvLines_63; public unsafe IntPtr* FontBuilderIO; public uint FontBuilderFlags; public int PackIdMouseCursors; public int PackIdLines; } public struct ImFontAtlasPtr { public unsafe ImFontAtlas* NativePtr { get; } public unsafe ref ImFontAtlasFlags Flags => ref Unsafe.AsRef<ImFontAtlasFlags>(&NativePtr->Flags); public unsafe ref IntPtr TexID => ref Unsafe.AsRef<IntPtr>(&NativePtr->TexID); public unsafe ref int TexDesiredWidth => ref Unsafe.AsRef<int>(&NativePtr->TexDesiredWidth); public unsafe ref int TexGlyphPadding => ref Unsafe.AsRef<int>(&NativePtr->TexGlyphPadding); public unsafe ref bool Locked => ref Unsafe.AsRef<bool>(&NativePtr->Locked); public unsafe ref bool TexReady => ref Unsafe.AsRef<bool>(&NativePtr->TexReady); public unsafe ref bool TexPixelsUseColors => ref Unsafe.AsRef<bool>(&NativePtr->TexPixelsUseColors); public unsafe IntPtr TexPixelsAlpha8 { get { return (IntPtr)NativePtr->TexPixelsAlpha8; } set { NativePtr->TexPixelsAlpha8 = (byte*)(void*)value; } } public unsafe IntPtr TexPixelsRGBA32 { get { return (IntPtr)NativePtr->TexPixelsRGBA32; } set { NativePtr->TexPixelsRGBA32 = (uint*)(void*)value; } } public unsafe ref int TexWidth => ref Unsafe.AsRef<int>(&NativePtr->TexWidth); public unsafe ref int TexHeight => ref Unsafe.AsRef<int>(&NativePtr->TexHeight); public unsafe ref Vector2 TexUvScale => ref Unsafe.AsRef<Vector2>(&NativePtr->TexUvScale); public unsafe ref Vector2 TexUvWhitePixel => ref Unsafe.AsRef<Vector2>(&NativePtr->TexUvWhitePixel); public unsafe ImVector<ImFontPtr> Fonts => new ImVector<ImFontPtr>(NativePtr->Fonts); public unsafe ImPtrVector<ImFontAtlasCustomRectPtr> CustomRects => new ImPtrVector<ImFontAtlasCustomRectPtr>(NativePtr->CustomRects, Unsafe.SizeOf<ImFontAtlasCustomRect>()); public unsafe ImPtrVector<ImFontConfigPtr> ConfigData => new ImPtrVector<ImFontConfigPtr>(NativePtr->ConfigData, Unsafe.SizeOf<ImFontConfig>()); public unsafe RangeAccessor<Vector4> TexUvLines => new RangeAccessor<Vector4>(&NativePtr->TexUvLines_0, 64); public unsafe IntPtr FontBuilderIO { get { return (IntPtr)NativePtr->FontBuilderIO; } set { NativePtr->FontBuilderIO = (IntPtr*)(void*)value; } } public unsafe ref uint FontBuilderFlags => ref Unsafe.AsRef<uint>(&NativePtr->FontBuilderFlags); public unsafe ref int PackIdMouseCursors => ref Unsafe.AsRef<int>(&NativePtr->PackIdMouseCursors); public unsafe ref int PackIdLines => ref Unsafe.AsRef<int>(&NativePtr->PackIdLines); public unsafe ImFontAtlasPtr(ImFontAtlas* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontAtlasPtr(IntPtr nativePtr) { NativePtr = (ImFontAtlas*)(void*)nativePtr; } public unsafe static implicit operator ImFontAtlasPtr(ImFontAtlas* nativePtr) { return new ImFontAtlasPtr(nativePtr); } public unsafe static implicit operator ImFontAtlas*(ImFontAtlasPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontAtlasPtr(IntPtr nativePtr) { return new ImFontAtlasPtr(nativePtr); } public unsafe int AddCustomRectFontGlyph(ImFontPtr font, ushort id, int width, int height, float advance_x) { ImFont* nativePtr = font.NativePtr; return ImGuiNative.ImFontAtlas_AddCustomRectFontGlyph(NativePtr, nativePtr, id, width, height, advance_x, default(Vector2)); } public unsafe int AddCustomRectFontGlyph(ImFontPtr font, ushort id, int width, int height, float advance_x, Vector2 offset) { ImFont* nativePtr = font.NativePtr; return ImGuiNative.ImFontAtlas_AddCustomRectFontGlyph(NativePtr, nativePtr, id, width, height, advance_x, offset); } public unsafe int AddCustomRectRegular(int width, int height) { return ImGuiNative.ImFontAtlas_AddCustomRectRegular(NativePtr, width, height); } public unsafe ImFontPtr AddFont(ImFontConfigPtr font_cfg) { ImFontConfig* nativePtr = font_cfg.NativePtr; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFont(NativePtr, nativePtr)); } public unsafe ImFontPtr AddFontDefault() { ImFontConfig* font_cfg = null; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontDefault(NativePtr, font_cfg)); } public unsafe ImFontPtr AddFontDefault(ImFontConfigPtr font_cfg) { ImFontConfig* nativePtr = font_cfg.NativePtr; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontDefault(NativePtr, nativePtr)); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, font_cfg, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges2); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, font_cfg, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges2); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, font_cfg, glyph_ranges)); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels, ImFontConfigPtr font_cfg) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, nativePtr, glyph_ranges)); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, nativePtr, glyph_ranges2)); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels) { void* font_data2 = font_data.ToPointer(); ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, font_cfg, glyph_ranges)); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels, ImFontConfigPtr font_cfg) { void* font_data2 = font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, nativePtr, glyph_ranges)); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { void* font_data2 = font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); return new ImFontPtr(ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, nativePtr, glyph_ranges2)); } public unsafe bool Build() { return ImGuiNative.ImFontAtlas_Build(NativePtr) != 0; } public unsafe void CalcCustomRectUV(ImFontAtlasCustomRectPtr rect, out Vector2 out_uv_min, out Vector2 out_uv_max) { ImFontAtlasCustomRect* nativePtr = rect.NativePtr; fixed (Vector2* out_uv_min2 = &out_uv_min) { fixed (Vector2* out_uv_max2 = &out_uv_max) { ImGuiNative.ImFontAtlas_CalcCustomRectUV(NativePtr, nativePtr, out_uv_min2, out_uv_max2); } } } public unsafe void Clear() { ImGuiNative.ImFontAtlas_Clear(NativePtr); } public unsafe void ClearFonts() { ImGuiNative.ImFontAtlas_ClearFonts(NativePtr); } public unsafe void ClearInputData() { ImGuiNative.ImFontAtlas_ClearInputData(NativePtr); } public unsafe void ClearTexData() { ImGuiNative.ImFontAtlas_ClearTexData(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontAtlas_destroy(NativePtr); } public unsafe ImFontAtlasCustomRectPtr GetCustomRectByIndex(int index) { return new ImFontAtlasCustomRectPtr(ImGuiNative.ImFontAtlas_GetCustomRectByIndex(NativePtr, index)); } public unsafe IntPtr GetGlyphRangesChineseFull() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesChineseFull(NativePtr); } public unsafe IntPtr GetGlyphRangesChineseSimplifiedCommon() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(NativePtr); } public unsafe IntPtr GetGlyphRangesCyrillic() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesCyrillic(NativePtr); } public unsafe IntPtr GetGlyphRangesDefault() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesDefault(NativePtr); } public unsafe IntPtr GetGlyphRangesJapanese() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesJapanese(NativePtr); } public unsafe IntPtr GetGlyphRangesKorean() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesKorean(NativePtr); } public unsafe IntPtr GetGlyphRangesThai() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesThai(NativePtr); } public unsafe IntPtr GetGlyphRangesVietnamese() { return (IntPtr)ImGuiNative.ImFontAtlas_GetGlyphRangesVietnamese(NativePtr); } public unsafe bool GetMouseCursorTexData(ImGuiMouseCursor cursor, out Vector2 out_offset, out Vector2 out_size, out Vector2 out_uv_border, out Vector2 out_uv_fill) { fixed (Vector2* out_offset2 = &out_offset) { fixed (Vector2* out_size2 = &out_size) { fixed (Vector2* out_uv_border2 = &out_uv_border) { fixed (Vector2* out_uv_fill2 = &out_uv_fill) { return ImGuiNative.ImFontAtlas_GetMouseCursorTexData(NativePtr, cursor, out_offset2, out_size2, out_uv_border2, out_uv_fill2) != 0; } } } } } public unsafe void GetTexDataAsAlpha8(out byte* out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsAlpha8(out byte* out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsAlpha8(out IntPtr out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsAlpha8(out IntPtr out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsRGBA32(out byte* out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsRGBA32(out byte* out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsRGBA32(out IntPtr out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsRGBA32(out IntPtr out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe bool IsBuilt() { return ImGuiNative.ImFontAtlas_IsBuilt(NativePtr) != 0; } public unsafe void SetTexID(IntPtr id) { ImGuiNative.ImFontAtlas_SetTexID(NativePtr, id); } } public struct ImFontAtlasCustomRect { public ushort Width; public ushort Height; public ushort X; public ushort Y; public uint GlyphID; public float GlyphAdvanceX; public Vector2 GlyphOffset; public unsafe ImFont* Font; } public struct ImFontAtlasCustomRectPtr { public unsafe ImFontAtlasCustomRect* NativePtr { get; } public unsafe ref ushort Width => ref Unsafe.AsRef<ushort>(&NativePtr->Width); public unsafe ref ushort Height => ref Unsafe.AsRef<ushort>(&NativePtr->Height); public unsafe ref ushort X => ref Unsafe.AsRef<ushort>(&NativePtr->X); public unsafe ref ushort Y => ref Unsafe.AsRef<ushort>(&NativePtr->Y); public unsafe ref uint GlyphID => ref Unsafe.AsRef<uint>(&NativePtr->GlyphID); public unsafe ref float GlyphAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphAdvanceX); public unsafe ref Vector2 GlyphOffset => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphOffset); public unsafe ImFontPtr Font => new ImFontPtr(NativePtr->Font); public unsafe ImFontAtlasCustomRectPtr(ImFontAtlasCustomRect* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontAtlasCustomRectPtr(IntPtr nativePtr) { NativePtr = (ImFontAtlasCustomRect*)(void*)nativePtr; } public unsafe static implicit operator ImFontAtlasCustomRectPtr(ImFontAtlasCustomRect* nativePtr) { return new ImFontAtlasCustomRectPtr(nativePtr); } public unsafe static implicit operator ImFontAtlasCustomRect*(ImFontAtlasCustomRectPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontAtlasCustomRectPtr(IntPtr nativePtr) { return new ImFontAtlasCustomRectPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontAtlasCustomRect_destroy(NativePtr); } public unsafe bool IsPacked() { return ImGuiNative.ImFontAtlasCustomRect_IsPacked(NativePtr) != 0; } } [Flags] public enum ImFontAtlasFlags { None = 0, NoPowerOfTwoHeight = 1, NoMouseCursors = 2, NoBakedLines = 4 } public struct ImFontConfig { public unsafe void* FontData; public int FontDataSize; public byte FontDataOwnedByAtlas; public int FontNo; public float SizePixels; public int OversampleH; public int OversampleV; public byte PixelSnapH; public Vector2 GlyphExtraSpacing; public Vector2 GlyphOffset; public unsafe ushort* GlyphRanges; public float GlyphMinAdvanceX; public float GlyphMaxAdvanceX; public byte MergeMode; public uint FontBuilderFlags; public float RasterizerMultiply; public ushort EllipsisChar; public unsafe fixed byte Name[40]; public unsafe ImFont* DstFont; } public struct ImFontConfigPtr { public unsafe ImFontConfig* NativePtr { get; } public unsafe IntPtr FontData { get { return (IntPtr)NativePtr->FontData; } set { NativePtr->FontData = (void*)value; } } public unsafe ref int FontDataSize => ref Unsafe.AsRef<int>(&NativePtr->FontDataSize); public unsafe ref bool FontDataOwnedByAtlas => ref Unsafe.AsRef<bool>(&NativePtr->FontDataOwnedByAtlas); public unsafe ref int FontNo => ref Unsafe.AsRef<int>(&NativePtr->FontNo); public unsafe ref float SizePixels => ref Unsafe.AsRef<float>(&NativePtr->SizePixels); public unsafe ref int OversampleH => ref Unsafe.AsRef<int>(&NativePtr->OversampleH); public unsafe ref int OversampleV => ref Unsafe.AsRef<int>(&NativePtr->OversampleV); public unsafe ref bool PixelSnapH => ref Unsafe.AsRef<bool>(&NativePtr->PixelSnapH); public unsafe ref Vector2 GlyphExtraSpacing => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphExtraSpacing); public unsafe ref Vector2 GlyphOffset => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphOffset); public unsafe IntPtr GlyphRanges { get { return (IntPtr)NativePtr->GlyphRanges; } set { NativePtr->GlyphRanges = (ushort*)(void*)value; } } public unsafe ref float GlyphMinAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphMinAdvanceX); public unsafe ref float GlyphMaxAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphMaxAdvanceX); public unsafe ref bool MergeMode => ref Unsafe.AsRef<bool>(&NativePtr->MergeMode); public unsafe ref uint FontBuilderFlags => ref Unsafe.AsRef<uint>(&NativePtr->FontBuilderFlags); public unsafe ref float RasterizerMultiply => ref Unsafe.AsRef<float>(&NativePtr->RasterizerMultiply); public unsafe ref ushort EllipsisChar => ref Unsafe.AsRef<ushort>(&NativePtr->EllipsisChar); public unsafe RangeAccessor<byte> Name => new RangeAccessor<byte>(NativePtr->Name, 40); public unsafe ImFontPtr DstFont => new ImFontPtr(NativePtr->DstFont); public unsafe ImFontConfigPtr(ImFontConfig* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontConfigPtr(IntPtr nativePtr) { NativePtr = (ImFontConfig*)(void*)nativePtr; } public unsafe static implicit operator ImFontConfigPtr(ImFontConfig* nativePtr) { return new ImFontConfigPtr(nativePtr); } public unsafe static implicit operator ImFontConfig*(ImFontConfigPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontConfigPtr(IntPtr nativePtr) { return new ImFontConfigPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontConfig_destroy(NativePtr); } } public struct ImFontGlyph { public uint Colored; public uint Visible; public uint Codepoint; public float AdvanceX; public float X0; public float Y0; public float X1; public float Y1; public float U0; public float V0; public float U1; public float V1; } public struct ImFontGlyphPtr { public unsafe ImFontGlyph* NativePtr { get; } public unsafe ref uint Colored => ref Unsafe.AsRef<uint>(&NativePtr->Colored); public unsafe ref uint Visible => ref Unsafe.AsRef<uint>(&NativePtr->Visible); public unsafe ref uint Codepoint => ref Unsafe.AsRef<uint>(&NativePtr->Codepoint); public unsafe ref float AdvanceX => ref Unsafe.AsRef<float>(&NativePtr->AdvanceX); public unsafe ref float X0 => ref Unsafe.AsRef<float>(&NativePtr->X0); public unsafe ref float Y0 => ref Unsafe.AsRef<float>(&NativePtr->Y0); public unsafe ref float X1 => ref Unsafe.AsRef<float>(&NativePtr->X1); public unsafe ref float Y1 => ref Unsafe.AsRef<float>(&NativePtr->Y1); public unsafe ref float U0 => ref Unsafe.AsRef<float>(&NativePtr->U0); public unsafe ref float V0 => ref Unsafe.AsRef<float>(&NativePtr->V0); public unsafe ref float U1 => ref Unsafe.AsRef<float>(&NativePtr->U1); public unsafe ref float V1 => ref Unsafe.AsRef<float>(&NativePtr->V1); public unsafe ImFontGlyphPtr(ImFontGlyph* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontGlyphPtr(IntPtr nativePtr) { NativePtr = (ImFontGlyph*)(void*)nativePtr; } public unsafe static implicit operator ImFontGlyphPtr(ImFontGlyph* nativePtr) { return new ImFontGlyphPtr(nativePtr); } public unsafe static implicit operator ImFontGlyph*(ImFontGlyphPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontGlyphPtr(IntPtr nativePtr) { return new ImFontGlyphPtr(nativePtr); } } public struct ImFontGlyphRangesBuilder { public ImVector UsedChars; } public struct ImFontGlyphRangesBuilderPtr { public unsafe ImFontGlyphRangesBuilder* NativePtr { get; } public unsafe ImVector<uint> UsedChars => new ImVector<uint>(NativePtr->UsedChars); public unsafe ImFontGlyphRangesBuilderPtr(ImFontGlyphRangesBuilder* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontGlyphRangesBuilderPtr(IntPtr nativePtr) { NativePtr = (ImFontGlyphRangesBuilder*)(void*)nativePtr; } public unsafe static implicit operator ImFontGlyphRangesBuilderPtr(ImFontGlyphRangesBuilder* nativePtr) { return new ImFontGlyphRangesBuilderPtr(nativePtr); } public unsafe static implicit operator ImFontGlyphRangesBuilder*(ImFontGlyphRangesBuilderPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontGlyphRangesBuilderPtr(IntPtr nativePtr) { return new ImFontGlyphRangesBuilderPtr(nativePtr); } public unsafe void AddChar(ushort c) { ImGuiNative.ImFontGlyphRangesBuilder_AddChar(NativePtr, c); } public unsafe void AddRanges(IntPtr ranges) { ushort* ranges2 = (ushort*)ranges.ToPointer(); ImGuiNative.ImFontGlyphRangesBuilder_AddRanges(NativePtr, ranges2); } public unsafe void AddText(string text) { int num = 0; byte* ptr; if (text != null) { num = Encoding.UTF8.GetByteCount(text); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(text, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* text_end = null; ImGuiNative.ImFontGlyphRangesBuilder_AddText(NativePtr, ptr, text_end); if (num > 2048) { Util.Free(ptr); } } public unsafe void BuildRanges(out ImVector out_ranges) { fixed (ImVector* out_ranges2 = &out_ranges) { ImGuiNative.ImFontGlyphRangesBuilder_BuildRanges(NativePtr, out_ranges2); } } public unsafe void Clear() { ImGuiNative.ImFontGlyphRangesBuilder_Clear(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontGlyphRangesBuilder_destroy(NativePtr); } public unsafe bool GetBit(uint n) { return ImGuiNative.ImFontGlyphRangesBuilder_GetBit(NativePtr, n) != 0; } public unsafe void SetBit(uint n) { ImGuiNative.ImFontGlyphRangesBuilder_SetBit(NativePtr, n); } } public static class ImGui { public unsafe static ImGuiPayloadPtr AcceptDragDropPayload(string type) { int num = 0; byte* ptr; if (type != null) { num = Encoding.UTF8.GetByteCount(type); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(type, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiDragDropFlags flags = ImGuiDragDropFlags.None; ImGuiPayload* nativePtr = ImGuiNative.igAcceptDragDropPayload(ptr, flags); if (num > 2048) { Util.Free(ptr); } return new ImGuiPayloadPtr(nativePtr); } public unsafe static ImGuiPayloadPtr AcceptDragDropPayload(string type, ImGuiDragDropFlags flags) { int num = 0; byte* ptr; if (type != null) { num = Encoding.UTF8.GetByteCount(type); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(type, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPayload* nativePtr = ImGuiNative.igAcceptDragDropPayload(ptr, flags); if (num > 2048) { Util.Free(ptr); } return new ImGuiPayloadPtr(nativePtr); } public static void AlignTextToFramePadding() { ImGuiNative.igAlignTextToFramePadding(); } public unsafe static bool ArrowButton(string str_id, ImGuiDir dir) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igArrowButton(ptr, dir); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool Begin(string name) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBegin(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool Begin(string name, ref bool p_open) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBegin(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool Begin(string name, ref bool p_open, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte num2 = ImGuiNative.igBegin(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool BeginChild(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } Vector2 size = default(Vector2); byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginChild_Str(ptr, size, border, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginChild_Str(ptr, size, border, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size, bool border) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border2 = (byte)(border ? 1 : 0); ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginChild_Str(ptr, size, border2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size, bool border, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border2 = (byte)(border ? 1 : 0); byte num2 = ImGuiNative.igBeginChild_Str(ptr, size, border2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static bool BeginChild(uint id) { Vector2 size = default(Vector2); byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; return ImGuiNative.igBeginChild_ID(id, size, border, flags) != 0; } public static bool BeginChild(uint id, Vector2 size) { byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; return ImGuiNative.igBeginChild_ID(id, size, border, flags) != 0; } public static bool BeginChild(uint id, Vector2 size, bool border) { byte border2 = (byte)(border ? 1 : 0); ImGuiWindowFlags flags = ImGuiWindowFlags.None; return ImGuiNative.igBeginChild_ID(id, size, border2, flags) != 0; } public static bool BeginChild(uint id, Vector2 size, bool border, ImGuiWindowFlags flags) { byte border2 = (byte)(border ? 1 : 0); return ImGuiNative.igBeginChild_ID(id, size, border2, flags) != 0; } public static bool BeginChildFrame(uint id, Vector2 size) { ImGuiWindowFlags flags = ImGuiWindowFlags.None; return ImGuiNative.igBeginChildFrame(id, size, flags) != 0; } public static bool BeginChildFrame(uint id, Vector2 size, ImGuiWindowFlags flags) { return ImGuiNative.igBeginChildFrame(id, size, flags) != 0; } public unsafe static bool BeginCombo(string label, string preview_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } int num2 = 0; byte* ptr2; if (preview_value != null) { num2 = Encoding.UTF8.GetByteCount(preview_value); ptr2 = ((num2 <= 2048) ? stackalloc byte[(int)(uint)(num2 + 1)] : Util.Allocate(num2 + 1)); int utf2 = Util.GetUtf8(preview_value, ptr2, num2); ptr2[utf2] = 0; } else { ptr2 = null; } ImGuiComboFlags flags = ImGuiComboFlags.None; byte num3 = ImGuiNative.igBeginCombo(ptr, ptr2, flags); if (num > 2048) { Util.Free(ptr); } if (num2 > 2048) { Util.Free(ptr2); } return num3 != 0; } public unsafe static bool BeginCombo(string label, string preview_value, ImGuiComboFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } int num2 = 0; byte* ptr2; if (preview_value != null) { num2 = Encoding.UTF8.GetByteCount(preview_value); ptr2 = ((num2 <= 2048) ? stackalloc byte[(int)(uint)(num2 + 1)] : Util.Allocate(num2 + 1)); int utf2 = Util.GetUtf8(preview_value, ptr2, num2); ptr2[utf2] = 0; } else { ptr2 = null; } byte num3 = ImGuiNative.igBeginCombo(ptr, ptr2, flags); if (num > 2048) { Util.Free(ptr); } if (num2 > 2048) { Util.Free(ptr2); } return num3 != 0; } public static void BeginDisabled() { ImGuiNative.igBeginDisabled(1); } public static void BeginDisabled(bool disabled) { ImGuiNative.igBeginDisabled((byte)(disabled ? 1 : 0)); } public static bool BeginDragDropSource() { return ImGuiNative.igBeginDragDropSource(ImGuiDragDropFlags.None) != 0; } public static bool BeginDragDropSource(ImGuiDragDropFlags flags) { return ImGuiNative.igBeginDragDropSource(flags) != 0; } public static bool BeginDragDropTarget() { return ImGuiNative.igBeginDragDropTarget() != 0; } public static void BeginGroup() { ImGuiNative.igBeginGroup(); } public unsafe static bool BeginListBox(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginListBox(ptr, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginListBox(string label, Vector2 size) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginListBox(ptr, size); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static bool BeginMainMenuBar() { return ImGuiNative.igBeginMainMenuBar() != 0; } public unsafe static bool BeginMenu(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte enabled = 1; byte num2 = ImGuiNative.igBeginMenu(ptr, enabled); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginMenu(string label, bool enabled) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte enabled2 = (byte)(enabled ? 1 : 0); byte num2 = ImGuiNative.igBeginMenu(ptr, enabled2); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static bool BeginMenuBar() { return ImGuiNative.igBeginMenuBar() != 0; } public unsafe static bool BeginPopup(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginPopup(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopup(string str_id, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginPopup(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextItem() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; return ImGuiNative.igBeginPopupContextItem(str_id, popup_flags) != 0; } public unsafe static bool BeginPopupContextItem(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte num2 = ImGuiNative.igBeginPopupContextItem(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextItem(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginPopupContextItem(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextVoid() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; return ImGuiNative.igBeginPopupContextVoid(str_id, popup_flags) != 0; } public unsafe static bool BeginPopupContextVoid(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte num2 = ImGuiNative.igBeginPopupContextVoid(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextVoid(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginPopupContextVoid(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextWindow() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; return ImGuiNative.igBeginPopupContextWindow(str_id, popup_flags) != 0; } public unsafe static bool BeginPopupContextWindow(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte num2 = ImGuiNative.igBeginPopupContextWindow(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupContextWindow(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginPopupContextWindow(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupModal(string name) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginPopupModal(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginPopupModal(string name, ref bool p_open) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte num2 = ImGuiNative.igBeginPopupModal(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool BeginPopupModal(string name, ref bool p_open, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte num2 = ImGuiNative.igBeginPopupModal(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool BeginTabBar(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTabBarFlags flags = ImGuiTabBarFlags.None; byte num2 = ImGuiNative.igBeginTabBar(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTabBar(string str_id, ImGuiTabBarFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginTabBar(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTabItem(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiTabItemFlags flags = ImGuiTabItemFlags.None; byte num2 = ImGuiNative.igBeginTabItem(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTabItem(string label, ref bool p_open) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiTabItemFlags flags = ImGuiTabItemFlags.None; byte num2 = ImGuiNative.igBeginTabItem(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool BeginTabItem(string label, ref bool p_open, ImGuiTabItemFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte num2 = ImGuiNative.igBeginTabItem(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return num2 != 0; } public unsafe static bool BeginTable(string str_id, int column) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTableFlags flags = ImGuiTableFlags.None; Vector2 outer_size = default(Vector2); float inner_width = 0f; byte num2 = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } Vector2 outer_size = default(Vector2); float inner_width = 0f; byte num2 = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags, Vector2 outer_size) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } float inner_width = 0f; byte num2 = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags, Vector2 outer_size, float inner_width) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static void BeginTooltip() { ImGuiNative.igBeginTooltip(); } public static void Bullet() { ImGuiNative.igBullet(); } public unsafe static void BulletText(string fmt) { int num = 0; byte* ptr; if (fmt != null) { num = Encoding.UTF8.GetByteCount(fmt); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(fmt, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiNative.igBulletText(ptr); if (num > 2048) { Util.Free(ptr); } } public unsafe static bool Button(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igButton(ptr, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool Button(string label, Vector2 size) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igButton(ptr, size); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static float CalcItemWidth() { return ImGuiNative.igCalcItemWidth(); } public unsafe static bool Checkbox(string label, ref bool v) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(v ? 1 : 0); byte* v2 = &b; byte num2 = ImGuiNative.igCheckbox(ptr, v2); if (num > 2048) { Util.Free(ptr); } v = b != 0; return num2 != 0; } public unsafe static bool CheckboxFlags(string label, ref int flags, int flags_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (int* flags2 = &flags) { byte num2 = ImGuiNative.igCheckboxFlags_IntPtr(ptr, flags2, flags_value); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public unsafe static bool CheckboxFlags(string label, ref uint flags, uint flags_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (uint* flags2 = &flags) { byte num2 = ImGuiNative.igCheckboxFlags_UintPtr(ptr, flags2, flags_value); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public static void CloseCurrentPopup() { ImGuiNative.igCloseCurrentPopup(); } public unsafe static bool CollapsingHeader(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None; byte num2 = ImGuiNative.igCollapsingHeader_TreeNodeFlags(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool CollapsingHeader(string label, ImGuiTreeNodeFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igCollapsingHeader_TreeNodeFlags(ptr, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool CollapsingHeader(string label, ref bool p_visible) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_visible ? 1 : 0); byte* p_visible2 = &b; ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None; byte num2 = ImGuiNative.igCollapsingHeader_BoolPtr(ptr, p_visible2, flags); if (num > 2048) { Util.Free(ptr); } p_visible = b != 0; return num2 != 0; } public unsafe static bool CollapsingHeader(string label, ref bool p_visible, ImGuiTreeNodeFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_visible ? 1 : 0); byte* p_visible2 = &b; byte num2 = ImGuiNative.igCollapsingHeader_BoolPtr(ptr, p_visible2, flags); if (num > 2048) { Util.Free(ptr); } p_visible = b != 0; return num2 != 0; } public unsafe static bool ColorButton(string desc_id, Vector4 col) { int num = 0; byte* ptr; if (desc_id != null) { num = Encoding.UTF8.GetByteCount(desc_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(desc_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiColorEditFlags flags = ImGuiColorEditFlags.None; byte num2 = ImGuiNative.igColorButton(ptr, col, flags, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool ColorButton(string desc_id, Vector4 col, ImGuiColorEditFlags flags) { int num = 0; byte* ptr; if (desc_id != null) { num = Encoding.UTF8.GetByteCount(desc_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(desc_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igColorButton(ptr, col, flags, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public unsafe static bool ColorButton(string desc_id, Vector4 col, ImGuiColorEditFlags flags, Vector2 size) { int num = 0; byte* ptr; if (desc_id != null) { num = Encoding.UTF8.GetByteCount(desc_id); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(desc_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte num2 = ImGuiNative.igColorButton(ptr, col, flags, size); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } public static uint ColorConvertFloat4ToU32(Vector4 @in) { return ImGuiNative.igColorConvertFloat4ToU32(@in); } public unsafe static void ColorConvertHSVtoRGB(float h, float s, float v, out float out_r, out float out_g, out float out_b) { fixed (float* out_r2 = &out_r) { fixed (float* out_g2 = &out_g) { fixed (float* out_b2 = &out_b) { ImGuiNative.igColorConvertHSVtoRGB(h, s, v, out_r2, out_g2, out_b2); } } } } public unsafe static void ColorConvertRGBtoHSV(float r, float g, float b, out float out_h, out float out_s, out float out_v) { fixed (float* out_h2 = &out_h) { fixed (float* out_s2 = &out_s) { fixed (float* out_v2 = &out_v) { ImGuiNative.igColorConvertRGBtoHSV(r, g, b, out_h2, out_s2, out_v2); } } } } public unsafe static Vector4 ColorConvertU32ToFloat4(uint @in) { Vector4 result = default(Vector4); ImGuiNative.igColorConvertU32ToFloat4(&result, @in); return result; } public unsafe static bool ColorEdit3(string label, ref Vector3 col) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiColorEditFlags flags = ImGuiColorEditFlags.None; fixed (Vector3* col2 = &col) { byte num2 = ImGuiNative.igColorEdit3(ptr, col2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public unsafe static bool ColorEdit3(string label, ref Vector3 col, ImGuiColorEditFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (Vector3* col2 = &col) { byte num2 = ImGuiNative.igColorEdit3(ptr, col2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public unsafe static bool ColorEdit4(string label, ref Vector4 col) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiColorEditFlags flags = ImGuiColorEditFlags.None; fixed (Vector4* col2 = &col) { byte num2 = ImGuiNative.igColorEdit4(ptr, col2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public unsafe static bool ColorEdit4(string label, ref Vector4 col, ImGuiColorEditFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (Vector4* col2 = &col) { byte num2 = ImGuiNative.igColorEdit4(ptr, col2, flags); if (num > 2048) { Util.Free(ptr); } return num2 != 0; } } public unsafe static bool ColorPicker3(string label, ref Vector3 col) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); ptr = ((num <= 2048) ? stackalloc byte[(int)(uint)(num + 1)] : Util.Allocate(num + 1)); int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiColorEditFlags flags = ImGuiColorEditFlags.None; fixed (Vector3* col2 = &col) { byte num2 = ImGuiNative.igColorPicker3(ptr, col2, flags); if (num > 20
plugins/AdventureGuide/Newtonsoft.Json.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Versioning; using System.Security; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AllowPartiallyTrustedCallers] [assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")] [assembly: CLSCompliant(true)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Newtonsoft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © James Newton-King 2008")] [assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")] [assembly: AssemblyFileVersion("13.0.4.30916")] [assembly: AssemblyInformationalVersion("13.0.4+4e13299d4b0ec96bd4df9954ef646bd2d1b5bf2a")] [assembly: AssemblyProduct("Json.NET")] [assembly: AssemblyTitle("Json.NET .NET Standard 2.0")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/JamesNK/Newtonsoft.Json")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyVersion("13.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)] internal sealed class DynamicallyAccessedMembersAttribute : Attribute { public DynamicallyAccessedMemberTypes MemberTypes { get; } public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes) { MemberTypes = memberTypes; } } [Flags] internal enum DynamicallyAccessedMemberTypes { None = 0, PublicParameterlessConstructor = 1, PublicConstructors = 3, NonPublicConstructors = 4, PublicMethods = 8, NonPublicMethods = 0x10, PublicFields = 0x20, NonPublicFields = 0x40, PublicNestedTypes = 0x80, NonPublicNestedTypes = 0x100, PublicProperties = 0x200, NonPublicProperties = 0x400, PublicEvents = 0x800, NonPublicEvents = 0x1000, Interfaces = 0x2000, All = -1 } [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)] internal sealed class FeatureGuardAttribute : Attribute { public Type FeatureType { get; } public FeatureGuardAttribute(Type featureType) { FeatureType = featureType; } } [AttributeUsage(AttributeTargets.Property, Inherited = false)] internal sealed class FeatureSwitchDefinitionAttribute : Attribute { public string SwitchName { get; } public FeatureSwitchDefinitionAttribute(string switchName) { SwitchName = switchName; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)] internal sealed class RequiresDynamicCodeAttribute : Attribute { public string Message { get; } public string? Url { get; set; } public RequiresDynamicCodeAttribute(string message) { Message = message; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method, Inherited = false)] internal sealed class RequiresUnreferencedCodeAttribute : Attribute { public string Message { get; } public string? Url { get; set; } public RequiresUnreferencedCodeAttribute(string message) { Message = message; } } [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] internal sealed class UnconditionalSuppressMessageAttribute : Attribute { public string Category { get; } public string CheckId { get; } public string? Scope { get; set; } public string? Target { get; set; } public string? MessageId { get; set; } public string? Justification { get; set; } public UnconditionalSuppressMessageAttribute(string category, string checkId) { Category = category; CheckId = checkId; } } } namespace Newtonsoft.Json { public enum ConstructorHandling { Default, AllowNonPublicDefaultConstructor } public enum DateFormatHandling { IsoDateFormat, MicrosoftDateFormat } public enum DateParseHandling { None, DateTime, DateTimeOffset } public enum DateTimeZoneHandling { Local, Utc, Unspecified, RoundtripKind } public class DefaultJsonNameTable : JsonNameTable { private class Entry { internal readonly string Value; internal readonly int HashCode; internal Entry Next; internal Entry(string value, int hashCode, Entry next) { Value = value; HashCode = hashCode; Next = next; } } private static readonly int HashCodeRandomizer; private int _count; private Entry[] _entries; private int _mask = 31; static DefaultJsonNameTable() { HashCodeRandomizer = Environment.TickCount; } public DefaultJsonNameTable() { _entries = new Entry[_mask + 1]; } public override string? Get(char[] key, int start, int length) { if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; num += (num << 7) ^ key[start]; int num2 = start + length; for (int i = start + 1; i < num2; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; int num3 = Volatile.Read(ref _mask); int num4 = num & num3; for (Entry entry = _entries[num4]; entry != null; entry = entry.Next) { if (entry.HashCode == num && TextEquals(entry.Value, key, start, length)) { return entry.Value; } } return null; } public string Add(string key) { if (key == null) { throw new ArgumentNullException("key"); } int length = key.Length; if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; for (int i = 0; i < key.Length; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next) { if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal)) { return entry.Value; } } return AddEntry(key, num); } private string AddEntry(string str, int hashCode) { int num = hashCode & _mask; Entry entry = new Entry(str, hashCode, _entries[num]); _entries[num] = entry; if (_count++ == _mask) { Grow(); } return entry.Value; } private void Grow() { Entry[] entries = _entries; int num = _mask * 2 + 1; Entry[] array = new Entry[num + 1]; for (int i = 0; i < entries.Length; i++) { Entry entry = entries[i]; while (entry != null) { int num2 = entry.HashCode & num; Entry next = entry.Next; entry.Next = array[num2]; array[num2] = entry; entry = next; } } _entries = array; Volatile.Write(ref _mask, num); } private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length) { if (str1.Length != str2Length) { return false; } for (int i = 0; i < str1.Length; i++) { if (str1[i] != str2[str2Start + i]) { return false; } } return true; } } [Flags] public enum DefaultValueHandling { Include = 0, Ignore = 1, Populate = 2, IgnoreAndPopulate = 3 } public enum FloatFormatHandling { String, Symbol, DefaultValue } public enum FloatParseHandling { Double, Decimal } public enum Formatting { None, Indented } public interface IArrayPool<T> { T[] Rent(int minimumLength); void Return(T[]? array); } public interface IJsonLineInfo { int LineNumber { get; } int LinePosition { get; } bool HasLineInfo(); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonArrayAttribute : JsonContainerAttribute { private bool _allowNullItems; public bool AllowNullItems { get { return _allowNullItems; } set { _allowNullItems = value; } } public JsonArrayAttribute() { } public JsonArrayAttribute(bool allowNullItems) { _allowNullItems = allowNullItems; } public JsonArrayAttribute(string id) : base(id) { } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)] public sealed class JsonConstructorAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public abstract class JsonContainerAttribute : Attribute { internal bool? _isReference; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; private Type? _namingStrategyType; private object[]? _namingStrategyParameters; public string? Id { get; set; } public string? Title { get; set; } public string? Description { get; set; } public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get { return _namingStrategyType; } set { _namingStrategyType = value; NamingStrategyInstance = null; } } public object[]? NamingStrategyParameters { get { return _namingStrategyParameters; } set { _namingStrategyParameters = value; NamingStrategyInstance = null; } } internal NamingStrategy? NamingStrategyInstance { get; set; } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } protected JsonContainerAttribute() { } protected JsonContainerAttribute(string id) { Id = id; } } public static class JsonConvert { public static readonly string True = "true"; public static readonly string False = "false"; public static readonly string Null = "null"; public static readonly string Undefined = "undefined"; public static readonly string PositiveInfinity = "Infinity"; public static readonly string NegativeInfinity = "-Infinity"; public static readonly string NaN = "NaN"; public static Func<JsonSerializerSettings>? DefaultSettings { get; set; } public static string ToString(DateTime value) { return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind); } public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling) { DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling); using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(DateTimeOffset value) { return ToString(value, DateFormatHandling.IsoDateFormat); } public static string ToString(DateTimeOffset value, DateFormatHandling format) { using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(bool value) { if (!value) { return False; } return True; } public static string ToString(char value) { return ToString(char.ToString(value)); } public static string ToString(Enum value) { return value.ToString("D"); } public static string ToString(int value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(short value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ushort value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(uint value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(long value) { return value.ToString(null, CultureInfo.InvariantCulture); } private static string ToStringInternal(BigInteger value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ulong value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(float value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value))) { return text; } if (floatFormatHandling == FloatFormatHandling.DefaultValue) { if (nullable) { return Null; } return "0.0"; } return quoteChar + text + quoteChar; } public static string ToString(double value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureDecimalPlace(double value, string text) { if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1) { return text; } return text + ".0"; } private static string EnsureDecimalPlace(string text) { if (StringUtils.IndexOf(text, '.') != -1) { return text; } return text + ".0"; } public static string ToString(byte value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(sbyte value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(decimal value) { return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture)); } public static string ToString(Guid value) { return ToString(value, '"'); } internal static string ToString(Guid value, char quoteChar) { string text = value.ToString("D", CultureInfo.InvariantCulture); string text2 = quoteChar.ToString(CultureInfo.InvariantCulture); return text2 + text + text2; } public static string ToString(TimeSpan value) { return ToString(value, '"'); } internal static string ToString(TimeSpan value, char quoteChar) { return ToString(value.ToString(), quoteChar); } public static string ToString(Uri? value) { if (value == null) { return Null; } return ToString(value, '"'); } internal static string ToString(Uri value, char quoteChar) { return ToString(value.OriginalString, quoteChar); } public static string ToString(string? value) { return ToString(value, '"'); } public static string ToString(string? value, char delimiter) { return ToString(value, delimiter, StringEscapeHandling.Default); } public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling) { if (delimiter != '"' && delimiter != '\'') { throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter"); } return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling); } public static string ToString(object? value) { if (value == null) { return Null; } return ConvertUtils.GetTypeCode(value.GetType()) switch { PrimitiveTypeCode.String => ToString((string)value), PrimitiveTypeCode.Char => ToString((char)value), PrimitiveTypeCode.Boolean => ToString((bool)value), PrimitiveTypeCode.SByte => ToString((sbyte)value), PrimitiveTypeCode.Int16 => ToString((short)value), PrimitiveTypeCode.UInt16 => ToString((ushort)value), PrimitiveTypeCode.Int32 => ToString((int)value), PrimitiveTypeCode.Byte => ToString((byte)value), PrimitiveTypeCode.UInt32 => ToString((uint)value), PrimitiveTypeCode.Int64 => ToString((long)value), PrimitiveTypeCode.UInt64 => ToString((ulong)value), PrimitiveTypeCode.Single => ToString((float)value), PrimitiveTypeCode.Double => ToString((double)value), PrimitiveTypeCode.DateTime => ToString((DateTime)value), PrimitiveTypeCode.Decimal => ToString((decimal)value), PrimitiveTypeCode.DBNull => Null, PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), PrimitiveTypeCode.Guid => ToString((Guid)value), PrimitiveTypeCode.Uri => ToString((Uri)value), PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), _ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), }; } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value) { return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting) { return SerializeObject(value, formatting, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, JsonSerializerSettings? settings) { return SerializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); return SerializeObjectInternal(value, type, jsonSerializer); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings) { return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); jsonSerializer.Formatting = formatting; return SerializeObjectInternal(value, type, jsonSerializer); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer) { StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture); using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) { jsonTextWriter.Formatting = jsonSerializer.Formatting; jsonSerializer.Serialize(jsonTextWriter, value, type); } return stringWriter.ToString(); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value) { return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, JsonSerializerSettings settings) { return DeserializeObject(value, null, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type type) { return DeserializeObject(value, type, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value) { return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject) { return DeserializeObject<T>(value); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings) { return DeserializeObject<T>(value, settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value, params JsonConverter[] converters) { return (T)DeserializeObject(value, typeof(T), converters); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings) { return (T)DeserializeObject(value, typeof(T), settings); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return DeserializeObject(value, type, settings); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings) { ValidationUtils.ArgumentNotNull(value, "value"); JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); if (!jsonSerializer.IsCheckAdditionalContentSet()) { jsonSerializer.CheckAdditionalContent = true; } using JsonTextReader reader = new JsonTextReader(new StringReader(value)); return jsonSerializer.Deserialize(reader, type); } [DebuggerStepThrough] [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static void PopulateObject(string value, object target) { PopulateObject(value, target, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static void PopulateObject(string value, object target, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); using JsonReader jsonReader = new JsonTextReader(new StringReader(value)); jsonSerializer.Populate(jsonReader, target); if (settings == null || !settings.CheckAdditionalContent) { return; } while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.Comment) { throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object."); } } } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node) { return SerializeXmlNode(node, Formatting.None); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node, Formatting formatting) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value) { return DeserializeXmlNode(value, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node) { return SerializeXNode(node, Formatting.None); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node, Formatting formatting) { return SerializeXNode(node, formatting, omitRootObject: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value) { return DeserializeXNode(value, null); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter); } } public abstract class JsonConverter { public virtual bool CanRead => true; public virtual bool CanWrite => true; public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer); public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer); public abstract bool CanConvert(Type objectType); } public abstract class JsonConverter<T> : JsonConverter { public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T)))) { throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } WriteJson(writer, (T)value, serializer); } public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer); public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { bool flag = existingValue == null; if (!flag && !(existingValue is T)) { throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer); } public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer); public sealed override bool CanConvert(Type objectType) { return typeof(T).IsAssignableFrom(objectType); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonConverterAttribute : Attribute { private readonly Type _converterType; public Type ConverterType => _converterType; public object[]? ConverterParameters { get; } public JsonConverterAttribute(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } _converterType = converterType; } public JsonConverterAttribute(Type converterType, params object[] converterParameters) : this(converterType) { ConverterParameters = converterParameters; } } public class JsonConverterCollection : Collection<JsonConverter> { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonDictionaryAttribute : JsonContainerAttribute { public JsonDictionaryAttribute() { } public JsonDictionaryAttribute(string id) : base(id) { } } [Serializable] public class JsonException : Exception { public JsonException() { } public JsonException(string message) : base(message) { } public JsonException(string message, Exception? innerException) : base(message, innerException) { } public JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message) { message = JsonPosition.FormatMessage(lineInfo, path, message); return new JsonException(message); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class JsonExtensionDataAttribute : Attribute { public bool WriteData { get; set; } public bool ReadData { get; set; } public JsonExtensionDataAttribute() { WriteData = true; ReadData = true; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonIgnoreAttribute : Attribute { } public abstract class JsonNameTable { public abstract string? Get(char[] key, int start, int length); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonObjectAttribute : JsonContainerAttribute { private MemberSerialization _memberSerialization; internal MissingMemberHandling? _missingMemberHandling; internal Required? _itemRequired; internal NullValueHandling? _itemNullValueHandling; public MemberSerialization MemberSerialization { get { return _memberSerialization; } set { _memberSerialization = value; } } public MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling.GetValueOrDefault(); } set { _missingMemberHandling = value; } } public NullValueHandling ItemNullValueHandling { get { return _itemNullValueHandling.GetValueOrDefault(); } set { _itemNullValueHandling = value; } } public Required ItemRequired { get { return _itemRequired.GetValueOrDefault(); } set { _itemRequired = value; } } public JsonObjectAttribute() { } public JsonObjectAttribute(MemberSerialization memberSerialization) { MemberSerialization = memberSerialization; } public JsonObjectAttribute(string id) : base(id) { } } internal enum JsonContainerType { None, Object, Array, Constructor } internal struct JsonPosition { private static readonly char[] SpecialCharacters = new char[18] { '.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t', '\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029' }; internal JsonContainerType Type; internal int Position; internal string? PropertyName; internal bool HasIndex; public JsonPosition(JsonContainerType type) { Type = type; HasIndex = TypeHasIndex(type); Position = -1; PropertyName = null; } internal int CalculateLength() { switch (Type) { case JsonContainerType.Object: return PropertyName.Length + 5; case JsonContainerType.Array: case JsonContainerType.Constructor: return MathUtils.IntLength((ulong)Position) + 2; default: throw new ArgumentOutOfRangeException("Type"); } } internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer) { switch (Type) { case JsonContainerType.Object: { string propertyName = PropertyName; if (propertyName.IndexOfAny(SpecialCharacters) != -1) { sb.Append("['"); if (writer == null) { writer = new StringWriter(sb); } JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer); sb.Append("']"); } else { if (sb.Length > 0) { sb.Append('.'); } sb.Append(propertyName); } break; } case JsonContainerType.Array: case JsonContainerType.Constructor: sb.Append('['); sb.Append(Position); sb.Append(']'); break; } } internal static bool TypeHasIndex(JsonContainerType type) { if (type != JsonContainerType.Array) { return type == JsonContainerType.Constructor; } return true; } internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition) { int num = 0; if (positions != null) { for (int i = 0; i < positions.Count; i++) { num += positions[i].CalculateLength(); } } if (currentPosition.HasValue) { num += currentPosition.GetValueOrDefault().CalculateLength(); } StringBuilder stringBuilder = new StringBuilder(num); StringWriter writer = null; char[] buffer = null; if (positions != null) { foreach (JsonPosition position in positions) { position.WriteTo(stringBuilder, ref writer, ref buffer); } } currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer); return stringBuilder.ToString(); } internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message) { if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal)) { message = message.Trim(); if (!StringUtils.EndsWith(message, '.')) { message += "."; } message += " "; } message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path); if (lineInfo != null && lineInfo.HasLineInfo()) { message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition); } message += "."; return message; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonPropertyAttribute : Attribute { internal NullValueHandling? _nullValueHandling; internal DefaultValueHandling? _defaultValueHandling; internal ReferenceLoopHandling? _referenceLoopHandling; internal ObjectCreationHandling? _objectCreationHandling; internal TypeNameHandling? _typeNameHandling; internal bool? _isReference; internal int? _order; internal Required? _required; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get; set; } public object[]? NamingStrategyParameters { get; set; } public NullValueHandling NullValueHandling { get { return _nullValueHandling.GetValueOrDefault(); } set { _nullValueHandling = value; } } public DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling.GetValueOrDefault(); } set { _defaultValueHandling = value; } } public ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling.GetValueOrDefault(); } set { _referenceLoopHandling = value; } } public ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling.GetValueOrDefault(); } set { _objectCreationHandling = value; } } public TypeNameHandling TypeNameHandling { get { return _typeNameHandling.GetValueOrDefault(); } set { _typeNameHandling = value; } } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public int Order { get { return _order.GetValueOrDefault(); } set { _order = value; } } public Required Required { get { return _required.GetValueOrDefault(); } set { _required = value; } } public string? PropertyName { get; set; } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public JsonPropertyAttribute() { } public JsonPropertyAttribute(string propertyName) { PropertyName = propertyName; } } public abstract class JsonReader : IDisposable { protected internal enum State { Start, Complete, Property, ObjectStart, Object, ArrayStart, Array, Closed, PostValue, ConstructorStart, Constructor, Error, Finished } private JsonToken _tokenType; private object? _value; internal char _quoteChar; internal State _currentState; private JsonPosition _currentPosition; private CultureInfo? _culture; private DateTimeZoneHandling _dateTimeZoneHandling; private int? _maxDepth; private bool _hasExceededMaxDepth; internal DateParseHandling _dateParseHandling; internal FloatParseHandling _floatParseHandling; private string? _dateFormatString; private List<JsonPosition>? _stack; protected State CurrentState => _currentState; public bool CloseInput { get; set; } public bool SupportMultipleContent { get; set; } public virtual char QuoteChar { get { return _quoteChar; } protected internal set { _quoteChar = value; } } public DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling; } set { if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind) { throw new ArgumentOutOfRangeException("value"); } _dateTimeZoneHandling = value; } } public DateParseHandling DateParseHandling { get { return _dateParseHandling; } set { if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset) { throw new ArgumentOutOfRangeException("value"); } _dateParseHandling = value; } } public FloatParseHandling FloatParseHandling { get { return _floatParseHandling; } set { if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal) { throw new ArgumentOutOfRangeException("value"); } _floatParseHandling = value; } } public string? DateFormatString { get { return _dateFormatString; } set { _dateFormatString = value; } } public int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; } } public virtual JsonToken TokenType => _tokenType; public virtual object? Value => _value; public virtual Type? ValueType => _value?.GetType(); public virtual int Depth { get { int num = _stack?.Count ?? 0; if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None) { return num; } return num + 1; } } public virtual string Path { get { if (_currentPosition.Type == JsonContainerType.None) { return string.Empty; } JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null); return JsonPosition.BuildPath(_stack, currentPosition); } } public CultureInfo Culture { get { return _culture ?? CultureInfo.InvariantCulture; } set { _culture = value; } } public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync(); } public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (TokenType == JsonToken.PropertyName) { await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth) { } } } internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken) { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { throw CreateUnexpectedEndException(); } } public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean()); } public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes()); } internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken) { List<byte> buffer = new List<byte>(); do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(buffer)); byte[] array = buffer.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime()); } public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset()); } public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal()); } public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(ReadAsDouble()); } public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32()); } public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString()); } internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken) { bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); if (flag) { flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } return flag; } internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken) { JsonToken tokenType = TokenType; if (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { return MoveToContentFromNonContentAsync(cancellationToken); } return AsyncUtils.True; } private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken) { JsonToken tokenType; do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { return false; } tokenType = TokenType; } while (tokenType == JsonToken.None || tokenType == JsonToken.Comment); return true; } internal JsonPosition GetPosition(int depth) { if (_stack != null && depth < _stack.Count) { return _stack[depth]; } return _currentPosition; } protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; _maxDepth = 64; CloseInput = true; } private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); return; } if (_stack == null) { _stack = new List<JsonPosition>(); } _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth) { return; } _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } private JsonContainerType Pop() { JsonPosition currentPosition; if (_stack != null && _stack.Count > 0) { currentPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { currentPosition = _currentPosition; _currentPosition = default(JsonPosition); } if (_maxDepth.HasValue && Depth <= _maxDepth) { _hasExceededMaxDepth = false; } return currentPosition.Type; } private JsonContainerType Peek() { return _currentPosition.Type; } public abstract bool Read(); public virtual int? ReadAsInt32() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is int) { return (int)value; } int num; if (value is BigInteger bigInteger) { num = (int)bigInteger; } else { try { num = Convert.ToInt32(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Integer, num, updateIndex: false); return num; } case JsonToken.String: { string s = (string)Value; return ReadInt32String(s); } default: throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal int? ReadInt32String(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (int.TryParse(s, NumberStyles.Integer, Culture, out var result)) { SetToken(JsonToken.Integer, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual string? ReadAsString() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.String: return (string)Value; default: if (JsonTokenUtils.IsPrimitiveToken(contentToken)) { object value = Value; if (value != null) { string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture)); SetToken(JsonToken.String, text, updateIndex: false); return text; } } throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } public virtual byte[]? ReadAsBytes() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.StartObject: { ReadIntoWrappedTypeObject(); byte[] array2 = ReadAsBytes(); ReaderReadAndAssert(); if (TokenType != JsonToken.EndObject) { throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } SetToken(JsonToken.Bytes, array2, updateIndex: false); return array2; } case JsonToken.String: { string text = (string)Value; Guid g; byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray())); SetToken(JsonToken.Bytes, array3, updateIndex: false); return array3; } case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Bytes: if (Value is Guid guid) { byte[] array = guid.ToByteArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } return (byte[])Value; case JsonToken.StartArray: return ReadArrayIntoByteArray(); default: throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal byte[] ReadArrayIntoByteArray() { List<byte> list = new List<byte>(); do { if (!Read()) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(list)); byte[] array = list.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer) { switch (TokenType) { case JsonToken.None: throw JsonReaderException.Create(this, "Unexpected end when reading bytes."); case JsonToken.Integer: buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture)); return false; case JsonToken.EndArray: return true; case JsonToken.Comment: return false; default: throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } public virtual double? ReadAsDouble() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is double) { return (double)value; } double num = ((!(value is BigInteger bigInteger)) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger)); SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDoubleString((string)Value); default: throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal double? ReadDoubleString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual bool? ReadAsBoolean() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { bool flag = ((!(Value is BigInteger bigInteger)) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L)); SetToken(JsonToken.Boolean, flag, updateIndex: false); return flag; } case JsonToken.String: return ReadBooleanString((string)Value); case JsonToken.Boolean: return (bool)Value; default: throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal bool? ReadBooleanString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (bool.TryParse(s, out var result)) { SetToken(JsonToken.Boolean, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual decimal? ReadAsDecimal() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is decimal) { return (decimal)value; } decimal num; if (value is BigInteger bigInteger) { num = (decimal)bigInteger; } else { try { num = Convert.ToDecimal(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDecimalString((string)Value); default: throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal decimal? ReadDecimalString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTime? ReadAsDateTime() { switch (GetContentToken()) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTimeOffset dateTimeOffset) { SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false); } return (DateTime)Value; case JsonToken.String: return ReadDateTimeString((string)Value); default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } internal DateTime? ReadDateTimeString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTimeOffset? ReadAsDateTimeOffset() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTime dateTime) { SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false); } return (DateTimeOffset)Value; case JsonToken.String: { string s = (string)Value; return ReadDateTimeOffsetString(s); } default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal DateTimeOffset? ReadDateTimeOffsetString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } internal void ReaderReadAndAssert() { if (!Read()) { throw CreateUnexpectedEndException(); } } internal JsonReaderException CreateUnexpectedEndException() { return JsonReaderException.Create(this, "Unexpected end when reading JSON."); } internal void ReadIntoWrappedTypeObject() { ReaderReadAndAssert(); if (Value != null && Value.ToString() == "$type") { ReaderReadAndAssert(); if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal)) { ReaderReadAndAssert(); if (Value.ToString() == "$value") { return; } } } throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject)); } public void Skip() { if (TokenType == JsonToken.PropertyName) { Read(); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (Read() && depth < Depth) { } } } protected void SetToken(JsonToken newToken) { SetToken(newToken, null, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value) { SetToken(newToken, value, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value, bool updateIndex) { _tokenType = newToken; _value = value; switch (newToken) { case JsonToken.StartObject: _currentState = State.ObjectStart; Push(JsonContainerType.Object); break; case JsonToken.StartArray: _currentState = State.ArrayStart; Push(JsonContainerType.Array); break; case JsonToken.StartConstructor: _currentState = State.ConstructorStart; Push(JsonContainerType.Constructor); break; case JsonToken.EndObject: ValidateEnd(JsonToken.EndObject); break; case JsonToken.EndArray: ValidateEnd(JsonToken.EndArray); break; case JsonToken.EndConstructor: ValidateEnd(JsonToken.EndConstructor); break; case JsonToken.PropertyName: _currentState = State.Property; _currentPosition.PropertyName = (string)value; break; case JsonToken.Raw: case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Null: case JsonToken.Undefined: case JsonToken.Date: case JsonToken.Bytes: SetPostValueState(updateIndex); break; case JsonToken.Comment: break; } } internal void SetPostValueState(bool updateIndex) { if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } if (updateIndex) { UpdateScopeWithFinishedValue(); } } private void UpdateScopeWithFinishedValue() { if (_currentPosition.HasIndex) { _currentPosition.Position++; } } private void ValidateEnd(JsonToken endToken) { JsonContainerType jsonContainerType = Pop(); if (GetTypeForCloseToken(endToken) != jsonContainerType) { throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType)); } if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } } protected void SetStateBasedOnCurrent() { JsonContainerType jsonContainerType = Peek(); switch (jsonContainerType) { case JsonContainerType.Object: _currentState = State.Object; break; case JsonContainerType.Array: _currentState = State.Array; break; case JsonContainerType.Constructor: _currentState = State.Constructor; break; case JsonContainerType.None: SetFinished(); break; default: throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType)); } } private void SetFinished() { _currentState = ((!SupportMultipleContent) ? State.Finished : State.Start); } private JsonContainerType GetTypeForCloseToken(JsonToken token) { return token switch { JsonToken.EndObject => JsonContainerType.Object, JsonToken.EndArray => JsonContainerType.Array, JsonToken.EndConstructor => JsonContainerType.Constructor, _ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), }; } void IDisposable.Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (_currentState != State.Closed && disposing) { Close(); } } public virtual void Close() { _currentState = State.Closed; _tokenType = JsonToken.None; _value = null; } internal void ReadAndAssert() { if (!Read()) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter) { if (!ReadForType(contract, hasConverter)) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal bool ReadForType(JsonContract? contract, bool hasConverter) { if (hasConverter) { return Read(); } switch (contract?.InternalReadType ?? ReadType.Read) { case ReadType.Read: return ReadAndMoveToContent(); case ReadType.ReadAsInt32: ReadAsInt32(); break; case ReadType.ReadAsInt64: { bool result = ReadAndMoveToContent(); if (TokenType == JsonToken.Undefined) { throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long))); } return result; } case ReadType.ReadAsDecimal: ReadAsDecimal(); break; case ReadType.ReadAsDouble: ReadAsDouble(); break; case ReadType.ReadAsBytes: ReadAsBytes(); break; case ReadType.ReadAsBoolean: ReadAsBoolean(); break; case ReadType.ReadAsString: ReadAsString(); break; case ReadType.ReadAsDateTime: ReadAsDateTime(); break; case ReadType.ReadAsDateTimeOffset: ReadAsDateTimeOffset(); break; default: throw new ArgumentOutOfRangeException(); } return TokenType != JsonToken.None; } internal bool ReadAndMoveToContent() { if (Read()) { return MoveToContent(); } return false; } internal bool MoveToContent() { JsonToken tokenType = TokenType; while (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { if (!Read()) { return false; } tokenType = TokenType; } return true; } private JsonToken GetContentToken() { JsonToken tokenType; do { if (!Read()) { SetToken(JsonToken.None); return JsonToken.None; } tokenType = TokenType; } while (tokenType == JsonToken.Comment); return tokenType; } } [Serializable] public class JsonReaderException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonReaderException() { } public JsonReaderException(string message) : base(message) { } public JsonReaderException(string message, Exception innerException) : base(message, innerException) { } public JsonReaderException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonReaderException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonReaderException(message, path, lineNumber, linePosition, ex); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonRequiredAttribute : Attribute { } [Serializable] public class JsonSerializationException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonSerializationException() { } public JsonSerializationException(string message) : base(message) { } public JsonSerializationException(string message, Exception innerException) : base(message, innerException) { } public JsonSerializationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonSerializationException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonSerializationException(message, path, lineNumber, linePosition, ex); } } [RequiresUnreferencedCode("Newtonsoft.Json relies on reflection over types that may be removed when trimming.")] [RequiresDynamicCode("Newtonsoft.Json relies on dynamically creating types that may not be available with Ahead of Time compilation.")] public class JsonSerializer { internal TypeNameHandling _typeNameHandling; internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling; internal PreserveReferencesHandling _preserveReferencesHandling; internal ReferenceLoopHandling _referenceLoopHandling; internal MissingMemberHandling _missingMemberHandling; internal ObjectCreationHandling _objectCreationHandling; internal NullValueHandling _nullValueHandling; internal DefaultValueHandling _defaultValueHandling; internal ConstructorHandling _constructorHandling; internal MetadataPropertyHandling _metadataPropertyHandling; internal JsonConverterCollection? _converters; internal IContractResolver _contractResolver; internal ITraceWriter? _traceWriter; internal IEqualityComparer? _equalityComparer; internal ISerializationBinder _serializationBinder; internal StreamingContext _context; private IReferenceResolver? _referenceResolver; private Formatting? _formatting; private DateFormatHandling? _dateFormatHandling; private DateTimeZoneHandling? _dateTimeZoneHandling; private DateParseHandling? _dateParseHandling; private FloatFormatHandling? _floatFormatHandling; private FloatParseHandling? _floatParseHandling; private StringEscapeHandling? _stringEscapeHandling; private CultureInfo _culture; private int? _maxDepth; private bool _maxDepthSet; private bool? _checkAdditionalContent; private string? _dateFormatString; private bool _dateFormatStringSet; public virtual IReferenceResolver? ReferenceResolver { get { return GetReferenceResolver(); } set { if (value == null) { throw new ArgumentNullException("value", "Reference resolver cannot be null."); } _referenceResolver = value; } } [Obsolete("Binder is obsolete. Use SerializationBinder instead.")] public virtual SerializationBinder Binder { get { if (_serializationBinder is SerializationBinder result) { return result; } if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter) { return serializationBinderAdapter.SerializationBinder; } throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set."); } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value); } } public virtual ISerializationBinder SerializationBinder { get { return _serializationBinder; } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = value; } } public virtual ITraceWriter? TraceWriter { get { return _traceWriter; } set { _traceWriter = value; } } public virtual IEqualityComparer? EqualityComparer { get { return _equalityComparer; } set { _equalityComparer = value; } } public virtual TypeNameHandling TypeNameHandling { get { return _typeNameHandling; } set { if (value < TypeNameHandling.None || value > TypeNameHandling.Auto) { throw new ArgumentOutOfRangeException("value"); } _typeNameHandling = value; } } [Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")] public virtual FormatterAssemblyStyle TypeNameAssemblyFormat { get { return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling; } set { if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value; } } public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling { get { return _typeNameAssemblyFormatHandling; } set { if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = value; } } public virtual PreserveReferencesHandling PreserveReferencesHandling { get { return _preserveReferencesHandling; } set { if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All) { throw new ArgumentOutOfRangeException("value"); } _preserveReferencesHandling = value; } } public virtual ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling; } set { if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize) { throw new ArgumentOutOfRangeException("value"); } _referenceLoopHandling = value; } } public virtual MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling; } set { if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error) { throw new ArgumentOutOfRangeException("value"); } _missingMemberHandling = value; } } public virtual NullValueHandling NullValueHandling { get { return _nullValueHandling; } set { if (value < NullValueHandling.Include || value > NullValueHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _nullValueHandling = value; } } public virtual DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling; } set { if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate) { throw new ArgumentOutOfRangeException("value"); } _defaultValueHandling = value; } } public virtual ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling; } set { if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace) { throw new ArgumentOutOfRangeException("value"); } _objectCreationHandling = value; } } public virtual ConstructorHandling ConstructorHandling { get { return _constructorHandling; } set { if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor) { throw new ArgumentOutOfRangeException("value"); } _constructorHandling = value; } } public virtual MetadataPropertyHandling MetadataPropertyHandling { get { return _metadataPropertyHandling; } set { if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _metadataPropertyHandling = value; } } public virtual JsonConverterCollection Converters { get { if (_converters == null) { _converters = new JsonConverterCollection(); } return _converters; } } public virtual IContractResolver ContractResolver { get { return _contractResolver; } set { _contractResolver = value ?? DefaultContractResolver.Instance; } } public virtual StreamingContext Context { get { return _context; } set { _context = value; } } public virtual Formatting Formatting { get { return _formatting.GetValueOrDefault(); } set { _formatting = value; } } public virtual DateFormatHandling DateFormatHandling { get { return _dateFormatHandling.GetValueOrDefault(); } set { _dateFormatHandling = value; } } public virtual DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling.GetValueOrDefault(DateTimeZoneHandling.RoundtripKind); } set { _dateTimeZoneHandling = value; } } public virtual DateParseHandling DateParseHandling { get { return _dateParseHandling.GetValueOrDefault(DateParseHandling.DateTime); } set { _dateParseHandling = value; } } public virtual FloatParseHandling FloatParseHandling { get { return _floatParseHandling.GetValueOrDefault(); } set { _floatParseHandling = value; } } public virtual FloatFormatHandling FloatFormatHandling { get { return _floatFormatHandling.GetValueOrDefault(); } set { _floatFormatHandling = value; } } public virtual StringEscapeHandling StringEscapeHandling { get { return _stringEscapeHandling.GetValueOrDefault(); } set { _stringEscapeHandling = value; } } public virtual string DateFormatString { get { return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"; } set { _dateFormatString = value; _dateFormatStringSet = true; } } public virtual CultureInfo Culture { get { return _culture ?? JsonSerializerSettings.DefaultCulture; } set { _culture = value; } } public virtual int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; _maxDepthSet = true; } } public virtual bool CheckAdditionalContent { get { return _checkAdditionalContent.GetValueOrDefault(); } set { _checkAdditionalContent = value; } } public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error; internal bool IsCheckAdditionalContentSet() { return _checkAdditionalContent.HasValue; } public JsonSerializer() { _referenceLoopHandling = ReferenceLoopHandling.Error; _missingMemberHandling = MissingMemberHandling.Ignore; _nullValueHandling = NullValueHandling.Include; _defaultValueHandling = DefaultValueHandling.Include; _objectCreationHandling = ObjectCreationHandling.Auto; _preserveReferencesHandling = PreserveReferencesHandling.None; _constructorHandling = ConstructorHandling.Default; _typeNameHandling = TypeNameHandling.None; _metadataPropertyHandling = MetadataPropertyHandling.Default; _context = JsonSerializerSettings.DefaultContext; _serializationBinder = DefaultSerializationBinder.Instance; _culture = JsonSerializerSettings.DefaultCulture; _contractResolver = DefaultContractResolver.Instance; } public static JsonSerializer Create() { return new JsonSerializer(); } public static JsonSerializer Create(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = Create(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } public static JsonSerializer CreateDefault() { return Create(JsonConvert.DefaultSettings?.Invoke()); } public static JsonSerializer CreateDefault(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = CreateDefault(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings) { if (!CollectionUtils.IsNullOrEmpty(settings.Converters)) { for (int i = 0; i < settings.Converters.Count; i++) { serializer.Converters.Insert(i, settings.Converters[i]); } } if (settings._typeNameHandling.HasValue) { serializer.TypeNameHandling = settings.TypeNameHandling; } if (settings._metadataPropertyHandling.HasValue) { serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling; } if (settings._typeNameAssemblyFormatHandling.HasValue) { serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling; } if (settings._preserveReferencesHandling.HasValue) { serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling; } if (settings._referenceLoopHandling.HasValue) { serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling; } if (settings._missingMemberHandling.HasValue) { serializer.MissingMemberHandling = settings.MissingMemberHandling; } if (settings._objectCreationHandling.HasValue) { serializer.ObjectCreationHandling = settings.ObjectCreationHandling; } if (settings._nullValueHandling.HasValue) { serializer.NullValueHandling = settings.NullValueHandling; } if (settings._defaultValueHandling.HasValue) { serializer.DefaultValueHandling = settings.DefaultValueHandling; } if (settings._constructorHandling.HasValue) { serializer.ConstructorHandling = settings.ConstructorHandling; } if (settings._context.HasValue) { serializer.Context = settings.Context; } if (settings._checkAdditionalContent.HasValue) { serializer._checkAdditionalContent = settings._checkAdditionalContent; } if (settings.Error != null) { serializer.Error += settings.Error; } if (settings.ContractResolver != null) { serializer.ContractResolver = settings.ContractResolver; } if (settings.ReferenceResolverProvider != null) { serializer.ReferenceResolver = settings.ReferenceResolverProvider(); } if (settings.TraceWriter != null) { serializer.TraceWriter = settings.TraceWriter; } if (settings.EqualityComparer != null) { serializer.EqualityComparer = settings.EqualityComparer; } if (settings.SerializationBinder != null) { serializer.SerializationBinder = settings.SerializationBinder; } if (settings._formatting.HasValue) { serializer._formatting = settings._formatting; } if (settings._dateFormatHandling.HasValue) { serializer._dateFormatHandling = settings._dateFormatHandling; } if (settings._dateTimeZoneHandling.HasValue) { serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling; } if (settings._dateParseHandling.HasValue) { serializer._dateParseHandling = settings._dateParseHandling; } if (settings._dateFormatStringSet) { serializer._dateFormatString = settings._dateFormatString; serializer._dateFormatStringSet = settings._dateFormatStringSet; } if (settings._floatFormatHandling.HasValue) { serializer._floatFormatHandling = settings._floatFormatHandling; } if (settings._floatParseHandling.HasValue) { serializer._floatParseHandling = settings._floatParseHandling; } if (settings._stringEscapeHandling.HasValue) { serializer._stringEscapeHandling = settings._stringEscapeHandling; } if (settings._culture != null) { serializer._culture = settings._culture; } if (settings._maxDepthSet) { serializer._maxDepth = settings._maxDepth; serializer._maxDepthSet = settings._maxDepthSet; } } [DebuggerStepThrough] public void Populate(TextReader reader, object target) { Populate(new JsonTextReader(reader), target); } [DebuggerStepThrough] public void Populate(JsonReader reader, object target) { PopulateInternal(reader, target); } internal virtual void PopulateInternal(JsonReader reader, object target) { ValidationUtils.ArgumentNotNull(reader, "reader"); ValidationUtils.ArgumentNotNull(target, "target"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); new JsonSerializerInternalReader(this).Populate(traceJsonReader ?? reader, target); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader) { return Deserialize(reader, null); } [DebuggerStepThrough] public object? Deserialize(TextReader reader, Type objectType) { return Deserialize(new JsonTextReader(reader), objectType); } [DebuggerStepThrough] public T? Deserialize<T>(JsonReader reader) { return (T)Deserialize(reader, typeof(T)); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader, Type? objectType) { return DeserializeInternal(reader, objectType); } internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType) { ValidationUtils.ArgumentNotNull(reader, "reader"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); object? result = new JsonSerializerInternalReader(this).Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); return result; } internal void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString) { if (_culture != null && !_culture.Equals(reader.Culture)) { previousCulture = reader.Culture; reader.Culture = _culture; } else { previousCulture = null; } if (_dateTimeZoneHandling.HasValue && reader.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling
plugins/AdventureGuide/System.Numerics.Vectors.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Globalization; using System.Numerics; using System.Numerics.Hashing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using FxResources.System.Numerics.Vectors; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Numerics.Vectors")] [assembly: AssemblyDescription("System.Numerics.Vectors")] [assembly: AssemblyDefaultAlias("System.Numerics.Vectors")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.25519.03")] [assembly: AssemblyInformationalVersion("4.6.25519.03 built by: dlab-DDVSOWINAGE013. Commit Hash: 8321c729934c0f8be754953439b88e6e1c120c24")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.1.3.0")] [assembly: TypeForwardedTo(typeof(Matrix3x2))] [assembly: TypeForwardedTo(typeof(Matrix4x4))] [assembly: TypeForwardedTo(typeof(Plane))] [assembly: TypeForwardedTo(typeof(Quaternion))] [assembly: TypeForwardedTo(typeof(Vector2))] [assembly: TypeForwardedTo(typeof(Vector3))] [assembly: TypeForwardedTo(typeof(Vector4))] [module: UnverifiableCode] namespace FxResources.System.Numerics.Vectors { internal static class SR { } } namespace System { internal static class MathF { public const float PI = 3.1415927f; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Abs(float x) { return Math.Abs(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Acos(float x) { return (float)Math.Acos(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Cos(float x) { return (float)Math.Cos(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float IEEERemainder(float x, float y) { return (float)Math.IEEERemainder(x, y); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Sin(float x) { return (float)Math.Sin(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Sqrt(float x) { return (float)Math.Sqrt(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Tan(float x) { return (float)Math.Tan(x); } } internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Numerics.Vectors.SR"; private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType)); internal static string Arg_ArgumentOutOfRangeException => GetResourceString("Arg_ArgumentOutOfRangeException", null); internal static string Arg_ElementsInSourceIsGreaterThanDestination => GetResourceString("Arg_ElementsInSourceIsGreaterThanDestination", null); internal static string Arg_NullArgumentNullRef => GetResourceString("Arg_NullArgumentNullRef", null); internal static string Arg_TypeNotSupported => GetResourceString("Arg_TypeNotSupported", null); internal static Type ResourceType => typeof(SR); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Numerics { internal class ConstantHelper { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte GetByteWithAllBitsSet() { byte result = 0; result = byte.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static sbyte GetSByteWithAllBitsSet() { sbyte result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort GetUInt16WithAllBitsSet() { ushort result = 0; result = ushort.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static short GetInt16WithAllBitsSet() { short result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint GetUInt32WithAllBitsSet() { uint result = 0u; result = uint.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetInt32WithAllBitsSet() { int result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong GetUInt64WithAllBitsSet() { ulong result = 0uL; result = ulong.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long GetInt64WithAllBitsSet() { long result = 0L; result = -1L; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static float GetSingleWithAllBitsSet() { float result = 0f; *(int*)(&result) = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static double GetDoubleWithAllBitsSet() { double result = 0.0; *(long*)(&result) = -1L; return result; } } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property)] internal class JitIntrinsicAttribute : Attribute { } [StructLayout(LayoutKind.Explicit)] internal struct Register { [FieldOffset(0)] internal byte byte_0; [FieldOffset(1)] internal byte byte_1; [FieldOffset(2)] internal byte byte_2; [FieldOffset(3)] internal byte byte_3; [FieldOffset(4)] internal byte byte_4; [FieldOffset(5)] internal byte byte_5; [FieldOffset(6)] internal byte byte_6; [FieldOffset(7)] internal byte byte_7; [FieldOffset(8)] internal byte byte_8; [FieldOffset(9)] internal byte byte_9; [FieldOffset(10)] internal byte byte_10; [FieldOffset(11)] internal byte byte_11; [FieldOffset(12)] internal byte byte_12; [FieldOffset(13)] internal byte byte_13; [FieldOffset(14)] internal byte byte_14; [FieldOffset(15)] internal byte byte_15; [FieldOffset(0)] internal sbyte sbyte_0; [FieldOffset(1)] internal sbyte sbyte_1; [FieldOffset(2)] internal sbyte sbyte_2; [FieldOffset(3)] internal sbyte sbyte_3; [FieldOffset(4)] internal sbyte sbyte_4; [FieldOffset(5)] internal sbyte sbyte_5; [FieldOffset(6)] internal sbyte sbyte_6; [FieldOffset(7)] internal sbyte sbyte_7; [FieldOffset(8)] internal sbyte sbyte_8; [FieldOffset(9)] internal sbyte sbyte_9; [FieldOffset(10)] internal sbyte sbyte_10; [FieldOffset(11)] internal sbyte sbyte_11; [FieldOffset(12)] internal sbyte sbyte_12; [FieldOffset(13)] internal sbyte sbyte_13; [FieldOffset(14)] internal sbyte sbyte_14; [FieldOffset(15)] internal sbyte sbyte_15; [FieldOffset(0)] internal ushort uint16_0; [FieldOffset(2)] internal ushort uint16_1; [FieldOffset(4)] internal ushort uint16_2; [FieldOffset(6)] internal ushort uint16_3; [FieldOffset(8)] internal ushort uint16_4; [FieldOffset(10)] internal ushort uint16_5; [FieldOffset(12)] internal ushort uint16_6; [FieldOffset(14)] internal ushort uint16_7; [FieldOffset(0)] internal short int16_0; [FieldOffset(2)] internal short int16_1; [FieldOffset(4)] internal short int16_2; [FieldOffset(6)] internal short int16_3; [FieldOffset(8)] internal short int16_4; [FieldOffset(10)] internal short int16_5; [FieldOffset(12)] internal short int16_6; [FieldOffset(14)] internal short int16_7; [FieldOffset(0)] internal uint uint32_0; [FieldOffset(4)] internal uint uint32_1; [FieldOffset(8)] internal uint uint32_2; [FieldOffset(12)] internal uint uint32_3; [FieldOffset(0)] internal int int32_0; [FieldOffset(4)] internal int int32_1; [FieldOffset(8)] internal int int32_2; [FieldOffset(12)] internal int int32_3; [FieldOffset(0)] internal ulong uint64_0; [FieldOffset(8)] internal ulong uint64_1; [FieldOffset(0)] internal long int64_0; [FieldOffset(8)] internal long int64_1; [FieldOffset(0)] internal float single_0; [FieldOffset(4)] internal float single_1; [FieldOffset(8)] internal float single_2; [FieldOffset(12)] internal float single_3; [FieldOffset(0)] internal double double_0; [FieldOffset(8)] internal double double_1; } public struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct { private struct VectorSizeHelper { internal Vector<T> _placeholder; internal byte _byte; } private System.Numerics.Register register; private static readonly int s_count = InitializeCount(); private static readonly Vector<T> zero = new Vector<T>(GetZeroValue()); private static readonly Vector<T> one = new Vector<T>(GetOneValue()); private static readonly Vector<T> allOnes = new Vector<T>(GetAllBitsSetValue()); [JitIntrinsic] public static int Count => s_count; [JitIntrinsic] public static Vector<T> Zero => zero; [JitIntrinsic] public static Vector<T> One => one; internal static Vector<T> AllOnes => allOnes; [JitIntrinsic] public unsafe T this[int index] { get { if (index >= Count || index < 0) { throw new IndexOutOfRangeException(System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, index)); } if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { return (T)(object)ptr[index]; } } if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { return (T)(object)ptr2[index]; } } if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { return (T)(object)ptr3[index]; } } if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { return (T)(object)ptr4[index]; } } if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { return (T)(object)ptr5[index]; } } if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { return (T)(object)ptr6[index]; } } if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { return (T)(object)ptr7[index]; } } if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { return (T)(object)ptr8[index]; } } if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { return (T)(object)ptr9[index]; } } if (typeof(T) == typeof(double)) { fixed (double* ptr10 = ®ister.double_0) { return (T)(object)ptr10[index]; } } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } } private unsafe static int InitializeCount() { VectorSizeHelper vectorSizeHelper = default(VectorSizeHelper); byte* ptr = &vectorSizeHelper._placeholder.register.byte_0; byte* ptr2 = &vectorSizeHelper._byte; int num = (int)(ptr2 - ptr); int num2 = -1; if (typeof(T) == typeof(byte)) { num2 = 1; } else if (typeof(T) == typeof(sbyte)) { num2 = 1; } else if (typeof(T) == typeof(ushort)) { num2 = 2; } else if (typeof(T) == typeof(short)) { num2 = 2; } else if (typeof(T) == typeof(uint)) { num2 = 4; } else if (typeof(T) == typeof(int)) { num2 = 4; } else if (typeof(T) == typeof(ulong)) { num2 = 8; } else if (typeof(T) == typeof(long)) { num2 = 8; } else if (typeof(T) == typeof(float)) { num2 = 4; } else { if (!(typeof(T) == typeof(double))) { throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } num2 = 8; } return num / num2; } [JitIntrinsic] public unsafe Vector(T value) { this = default(Vector<T>); if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)value; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)value; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)value; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)value; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)value; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)value; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)value; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)value; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)value; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)value; } } } } else if (typeof(T) == typeof(byte)) { register.byte_0 = (byte)(object)value; register.byte_1 = (byte)(object)value; register.byte_2 = (byte)(object)value; register.byte_3 = (byte)(object)value; register.byte_4 = (byte)(object)value; register.byte_5 = (byte)(object)value; register.byte_6 = (byte)(object)value; register.byte_7 = (byte)(object)value; register.byte_8 = (byte)(object)value; register.byte_9 = (byte)(object)value; register.byte_10 = (byte)(object)value; register.byte_11 = (byte)(object)value; register.byte_12 = (byte)(object)value; register.byte_13 = (byte)(object)value; register.byte_14 = (byte)(object)value; register.byte_15 = (byte)(object)value; } else if (typeof(T) == typeof(sbyte)) { register.sbyte_0 = (sbyte)(object)value; register.sbyte_1 = (sbyte)(object)value; register.sbyte_2 = (sbyte)(object)value; register.sbyte_3 = (sbyte)(object)value; register.sbyte_4 = (sbyte)(object)value; register.sbyte_5 = (sbyte)(object)value; register.sbyte_6 = (sbyte)(object)value; register.sbyte_7 = (sbyte)(object)value; register.sbyte_8 = (sbyte)(object)value; register.sbyte_9 = (sbyte)(object)value; register.sbyte_10 = (sbyte)(object)value; register.sbyte_11 = (sbyte)(object)value; register.sbyte_12 = (sbyte)(object)value; register.sbyte_13 = (sbyte)(object)value; register.sbyte_14 = (sbyte)(object)value; register.sbyte_15 = (sbyte)(object)value; } else if (typeof(T) == typeof(ushort)) { register.uint16_0 = (ushort)(object)value; register.uint16_1 = (ushort)(object)value; register.uint16_2 = (ushort)(object)value; register.uint16_3 = (ushort)(object)value; register.uint16_4 = (ushort)(object)value; register.uint16_5 = (ushort)(object)value; register.uint16_6 = (ushort)(object)value; register.uint16_7 = (ushort)(object)value; } else if (typeof(T) == typeof(short)) { register.int16_0 = (short)(object)value; register.int16_1 = (short)(object)value; register.int16_2 = (short)(object)value; register.int16_3 = (short)(object)value; register.int16_4 = (short)(object)value; register.int16_5 = (short)(object)value; register.int16_6 = (short)(object)value; register.int16_7 = (short)(object)value; } else if (typeof(T) == typeof(uint)) { register.uint32_0 = (uint)(object)value; register.uint32_1 = (uint)(object)value; register.uint32_2 = (uint)(object)value; register.uint32_3 = (uint)(object)value; } else if (typeof(T) == typeof(int)) { register.int32_0 = (int)(object)value; register.int32_1 = (int)(object)value; register.int32_2 = (int)(object)value; register.int32_3 = (int)(object)value; } else if (typeof(T) == typeof(ulong)) { register.uint64_0 = (ulong)(object)value; register.uint64_1 = (ulong)(object)value; } else if (typeof(T) == typeof(long)) { register.int64_0 = (long)(object)value; register.int64_1 = (long)(object)value; } else if (typeof(T) == typeof(float)) { register.single_0 = (float)(object)value; register.single_1 = (float)(object)value; register.single_2 = (float)(object)value; register.single_3 = (float)(object)value; } else if (typeof(T) == typeof(double)) { register.double_0 = (double)(object)value; register.double_1 = (double)(object)value; } } [JitIntrinsic] public Vector(T[] values) : this(values, 0) { } public unsafe Vector(T[] values, int index) { this = default(Vector<T>); if (values == null) { throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef); } if (index < 0 || values.Length - index < Count) { throw new IndexOutOfRangeException(); } if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)values[i + index]; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)values[j + index]; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)values[k + index]; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)values[l + index]; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)values[m + index]; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)values[n + index]; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)values[num + index]; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)values[num2 + index]; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)values[num3 + index]; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)values[num4 + index]; } } } } else if (typeof(T) == typeof(byte)) { fixed (byte* ptr11 = ®ister.byte_0) { *ptr11 = (byte)(object)values[index]; ptr11[1] = (byte)(object)values[1 + index]; ptr11[2] = (byte)(object)values[2 + index]; ptr11[3] = (byte)(object)values[3 + index]; ptr11[4] = (byte)(object)values[4 + index]; ptr11[5] = (byte)(object)values[5 + index]; ptr11[6] = (byte)(object)values[6 + index]; ptr11[7] = (byte)(object)values[7 + index]; ptr11[8] = (byte)(object)values[8 + index]; ptr11[9] = (byte)(object)values[9 + index]; ptr11[10] = (byte)(object)values[10 + index]; ptr11[11] = (byte)(object)values[11 + index]; ptr11[12] = (byte)(object)values[12 + index]; ptr11[13] = (byte)(object)values[13 + index]; ptr11[14] = (byte)(object)values[14 + index]; ptr11[15] = (byte)(object)values[15 + index]; } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr12 = ®ister.sbyte_0) { *ptr12 = (sbyte)(object)values[index]; ptr12[1] = (sbyte)(object)values[1 + index]; ptr12[2] = (sbyte)(object)values[2 + index]; ptr12[3] = (sbyte)(object)values[3 + index]; ptr12[4] = (sbyte)(object)values[4 + index]; ptr12[5] = (sbyte)(object)values[5 + index]; ptr12[6] = (sbyte)(object)values[6 + index]; ptr12[7] = (sbyte)(object)values[7 + index]; ptr12[8] = (sbyte)(object)values[8 + index]; ptr12[9] = (sbyte)(object)values[9 + index]; ptr12[10] = (sbyte)(object)values[10 + index]; ptr12[11] = (sbyte)(object)values[11 + index]; ptr12[12] = (sbyte)(object)values[12 + index]; ptr12[13] = (sbyte)(object)values[13 + index]; ptr12[14] = (sbyte)(object)values[14 + index]; ptr12[15] = (sbyte)(object)values[15 + index]; } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr13 = ®ister.uint16_0) { *ptr13 = (ushort)(object)values[index]; ptr13[1] = (ushort)(object)values[1 + index]; ptr13[2] = (ushort)(object)values[2 + index]; ptr13[3] = (ushort)(object)values[3 + index]; ptr13[4] = (ushort)(object)values[4 + index]; ptr13[5] = (ushort)(object)values[5 + index]; ptr13[6] = (ushort)(object)values[6 + index]; ptr13[7] = (ushort)(object)values[7 + index]; } } else if (typeof(T) == typeof(short)) { fixed (short* ptr14 = ®ister.int16_0) { *ptr14 = (short)(object)values[index]; ptr14[1] = (short)(object)values[1 + index]; ptr14[2] = (short)(object)values[2 + index]; ptr14[3] = (short)(object)values[3 + index]; ptr14[4] = (short)(object)values[4 + index]; ptr14[5] = (short)(object)values[5 + index]; ptr14[6] = (short)(object)values[6 + index]; ptr14[7] = (short)(object)values[7 + index]; } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr15 = ®ister.uint32_0) { *ptr15 = (uint)(object)values[index]; ptr15[1] = (uint)(object)values[1 + index]; ptr15[2] = (uint)(object)values[2 + index]; ptr15[3] = (uint)(object)values[3 + index]; } } else if (typeof(T) == typeof(int)) { fixed (int* ptr16 = ®ister.int32_0) { *ptr16 = (int)(object)values[index]; ptr16[1] = (int)(object)values[1 + index]; ptr16[2] = (int)(object)values[2 + index]; ptr16[3] = (int)(object)values[3 + index]; } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr17 = ®ister.uint64_0) { *ptr17 = (ulong)(object)values[index]; ptr17[1] = (ulong)(object)values[1 + index]; } } else if (typeof(T) == typeof(long)) { fixed (long* ptr18 = ®ister.int64_0) { *ptr18 = (long)(object)values[index]; ptr18[1] = (long)(object)values[1 + index]; } } else if (typeof(T) == typeof(float)) { fixed (float* ptr19 = ®ister.single_0) { *ptr19 = (float)(object)values[index]; ptr19[1] = (float)(object)values[1 + index]; ptr19[2] = (float)(object)values[2 + index]; ptr19[3] = (float)(object)values[3 + index]; } } else if (typeof(T) == typeof(double)) { fixed (double* ptr20 = ®ister.double_0) { *ptr20 = (double)(object)values[index]; ptr20[1] = (double)(object)values[1 + index]; } } } internal unsafe Vector(void* dataPointer) : this(dataPointer, 0) { } internal unsafe Vector(void* dataPointer, int offset) { this = default(Vector<T>); if (typeof(T) == typeof(byte)) { byte* ptr = (byte*)dataPointer; ptr += offset; fixed (byte* ptr2 = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr2[i] = ptr[i]; } } return; } if (typeof(T) == typeof(sbyte)) { sbyte* ptr3 = (sbyte*)dataPointer; ptr3 += offset; fixed (sbyte* ptr4 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr4[j] = ptr3[j]; } } return; } if (typeof(T) == typeof(ushort)) { ushort* ptr5 = (ushort*)dataPointer; ptr5 += offset; fixed (ushort* ptr6 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr6[k] = ptr5[k]; } } return; } if (typeof(T) == typeof(short)) { short* ptr7 = (short*)dataPointer; ptr7 += offset; fixed (short* ptr8 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr8[l] = ptr7[l]; } } return; } if (typeof(T) == typeof(uint)) { uint* ptr9 = (uint*)dataPointer; ptr9 += offset; fixed (uint* ptr10 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr10[m] = ptr9[m]; } } return; } if (typeof(T) == typeof(int)) { int* ptr11 = (int*)dataPointer; ptr11 += offset; fixed (int* ptr12 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr12[n] = ptr11[n]; } } return; } if (typeof(T) == typeof(ulong)) { ulong* ptr13 = (ulong*)dataPointer; ptr13 += offset; fixed (ulong* ptr14 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr14[num] = ptr13[num]; } } return; } if (typeof(T) == typeof(long)) { long* ptr15 = (long*)dataPointer; ptr15 += offset; fixed (long* ptr16 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr16[num2] = ptr15[num2]; } } return; } if (typeof(T) == typeof(float)) { float* ptr17 = (float*)dataPointer; ptr17 += offset; fixed (float* ptr18 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr18[num3] = ptr17[num3]; } } return; } if (typeof(T) == typeof(double)) { double* ptr19 = (double*)dataPointer; ptr19 += offset; fixed (double* ptr20 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr20[num4] = ptr19[num4]; } } return; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } private Vector(ref System.Numerics.Register existingRegister) { register = existingRegister; } [JitIntrinsic] public void CopyTo(T[] destination) { CopyTo(destination, 0); } [JitIntrinsic] public unsafe void CopyTo(T[] destination, int startIndex) { if (destination == null) { throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef); } if (startIndex < 0 || startIndex >= destination.Length) { throw new ArgumentOutOfRangeException("startIndex", System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, startIndex)); } if (destination.Length - startIndex < Count) { throw new ArgumentException(System.SR.Format(System.SR.Arg_ElementsInSourceIsGreaterThanDestination, startIndex)); } if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = (byte[])(object)destination) { for (int i = 0; i < Count; i++) { ptr[startIndex + i] = (byte)(object)this[i]; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = (sbyte[])(object)destination) { for (int j = 0; j < Count; j++) { ptr2[startIndex + j] = (sbyte)(object)this[j]; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = (ushort[])(object)destination) { for (int k = 0; k < Count; k++) { ptr3[startIndex + k] = (ushort)(object)this[k]; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = (short[])(object)destination) { for (int l = 0; l < Count; l++) { ptr4[startIndex + l] = (short)(object)this[l]; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = (uint[])(object)destination) { for (int m = 0; m < Count; m++) { ptr5[startIndex + m] = (uint)(object)this[m]; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = (int[])(object)destination) { for (int n = 0; n < Count; n++) { ptr6[startIndex + n] = (int)(object)this[n]; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = (ulong[])(object)destination) { for (int num = 0; num < Count; num++) { ptr7[startIndex + num] = (ulong)(object)this[num]; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = (long[])(object)destination) { for (int num2 = 0; num2 < Count; num2++) { ptr8[startIndex + num2] = (long)(object)this[num2]; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = (float[])(object)destination) { for (int num3 = 0; num3 < Count; num3++) { ptr9[startIndex + num3] = (float)(object)this[num3]; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = (double[])(object)destination) { for (int num4 = 0; num4 < Count; num4++) { ptr10[startIndex + num4] = (double)(object)this[num4]; } } } } else if (typeof(T) == typeof(byte)) { fixed (byte* ptr11 = (byte[])(object)destination) { ptr11[startIndex] = register.byte_0; ptr11[startIndex + 1] = register.byte_1; ptr11[startIndex + 2] = register.byte_2; ptr11[startIndex + 3] = register.byte_3; ptr11[startIndex + 4] = register.byte_4; ptr11[startIndex + 5] = register.byte_5; ptr11[startIndex + 6] = register.byte_6; ptr11[startIndex + 7] = register.byte_7; ptr11[startIndex + 8] = register.byte_8; ptr11[startIndex + 9] = register.byte_9; ptr11[startIndex + 10] = register.byte_10; ptr11[startIndex + 11] = register.byte_11; ptr11[startIndex + 12] = register.byte_12; ptr11[startIndex + 13] = register.byte_13; ptr11[startIndex + 14] = register.byte_14; ptr11[startIndex + 15] = register.byte_15; } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr12 = (sbyte[])(object)destination) { ptr12[startIndex] = register.sbyte_0; ptr12[startIndex + 1] = register.sbyte_1; ptr12[startIndex + 2] = register.sbyte_2; ptr12[startIndex + 3] = register.sbyte_3; ptr12[startIndex + 4] = register.sbyte_4; ptr12[startIndex + 5] = register.sbyte_5; ptr12[startIndex + 6] = register.sbyte_6; ptr12[startIndex + 7] = register.sbyte_7; ptr12[startIndex + 8] = register.sbyte_8; ptr12[startIndex + 9] = register.sbyte_9; ptr12[startIndex + 10] = register.sbyte_10; ptr12[startIndex + 11] = register.sbyte_11; ptr12[startIndex + 12] = register.sbyte_12; ptr12[startIndex + 13] = register.sbyte_13; ptr12[startIndex + 14] = register.sbyte_14; ptr12[startIndex + 15] = register.sbyte_15; } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr13 = (ushort[])(object)destination) { ptr13[startIndex] = register.uint16_0; ptr13[startIndex + 1] = register.uint16_1; ptr13[startIndex + 2] = register.uint16_2; ptr13[startIndex + 3] = register.uint16_3; ptr13[startIndex + 4] = register.uint16_4; ptr13[startIndex + 5] = register.uint16_5; ptr13[startIndex + 6] = register.uint16_6; ptr13[startIndex + 7] = register.uint16_7; } } else if (typeof(T) == typeof(short)) { fixed (short* ptr14 = (short[])(object)destination) { ptr14[startIndex] = register.int16_0; ptr14[startIndex + 1] = register.int16_1; ptr14[startIndex + 2] = register.int16_2; ptr14[startIndex + 3] = register.int16_3; ptr14[startIndex + 4] = register.int16_4; ptr14[startIndex + 5] = register.int16_5; ptr14[startIndex + 6] = register.int16_6; ptr14[startIndex + 7] = register.int16_7; } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr15 = (uint[])(object)destination) { ptr15[startIndex] = register.uint32_0; ptr15[startIndex + 1] = register.uint32_1; ptr15[startIndex + 2] = register.uint32_2; ptr15[startIndex + 3] = register.uint32_3; } } else if (typeof(T) == typeof(int)) { fixed (int* ptr16 = (int[])(object)destination) { ptr16[startIndex] = register.int32_0; ptr16[startIndex + 1] = register.int32_1; ptr16[startIndex + 2] = register.int32_2; ptr16[startIndex + 3] = register.int32_3; } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr17 = (ulong[])(object)destination) { ptr17[startIndex] = register.uint64_0; ptr17[startIndex + 1] = register.uint64_1; } } else if (typeof(T) == typeof(long)) { fixed (long* ptr18 = (long[])(object)destination) { ptr18[startIndex] = register.int64_0; ptr18[startIndex + 1] = register.int64_1; } } else if (typeof(T) == typeof(float)) { fixed (float* ptr19 = (float[])(object)destination) { ptr19[startIndex] = register.single_0; ptr19[startIndex + 1] = register.single_1; ptr19[startIndex + 2] = register.single_2; ptr19[startIndex + 3] = register.single_3; } } else if (typeof(T) == typeof(double)) { fixed (double* ptr20 = (double[])(object)destination) { ptr20[startIndex] = register.double_0; ptr20[startIndex + 1] = register.double_1; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override bool Equals(object obj) { if (!(obj is Vector<T>)) { return false; } return Equals((Vector<T>)obj); } [JitIntrinsic] public bool Equals(Vector<T> other) { if (Vector.IsHardwareAccelerated) { for (int i = 0; i < Count; i++) { if (!ScalarEquals(this[i], other[i])) { return false; } } return true; } if (typeof(T) == typeof(byte)) { if (register.byte_0 == other.register.byte_0 && register.byte_1 == other.register.byte_1 && register.byte_2 == other.register.byte_2 && register.byte_3 == other.register.byte_3 && register.byte_4 == other.register.byte_4 && register.byte_5 == other.register.byte_5 && register.byte_6 == other.register.byte_6 && register.byte_7 == other.register.byte_7 && register.byte_8 == other.register.byte_8 && register.byte_9 == other.register.byte_9 && register.byte_10 == other.register.byte_10 && register.byte_11 == other.register.byte_11 && register.byte_12 == other.register.byte_12 && register.byte_13 == other.register.byte_13 && register.byte_14 == other.register.byte_14) { return register.byte_15 == other.register.byte_15; } return false; } if (typeof(T) == typeof(sbyte)) { if (register.sbyte_0 == other.register.sbyte_0 && register.sbyte_1 == other.register.sbyte_1 && register.sbyte_2 == other.register.sbyte_2 && register.sbyte_3 == other.register.sbyte_3 && register.sbyte_4 == other.register.sbyte_4 && register.sbyte_5 == other.register.sbyte_5 && register.sbyte_6 == other.register.sbyte_6 && register.sbyte_7 == other.register.sbyte_7 && register.sbyte_8 == other.register.sbyte_8 && register.sbyte_9 == other.register.sbyte_9 && register.sbyte_10 == other.register.sbyte_10 && register.sbyte_11 == other.register.sbyte_11 && register.sbyte_12 == other.register.sbyte_12 && register.sbyte_13 == other.register.sbyte_13 && register.sbyte_14 == other.register.sbyte_14) { return register.sbyte_15 == other.register.sbyte_15; } return false; } if (typeof(T) == typeof(ushort)) { if (register.uint16_0 == other.register.uint16_0 && register.uint16_1 == other.register.uint16_1 && register.uint16_2 == other.register.uint16_2 && register.uint16_3 == other.register.uint16_3 && register.uint16_4 == other.register.uint16_4 && register.uint16_5 == other.register.uint16_5 && register.uint16_6 == other.register.uint16_6) { return register.uint16_7 == other.register.uint16_7; } return false; } if (typeof(T) == typeof(short)) { if (register.int16_0 == other.register.int16_0 && register.int16_1 == other.register.int16_1 && register.int16_2 == other.register.int16_2 && register.int16_3 == other.register.int16_3 && register.int16_4 == other.register.int16_4 && register.int16_5 == other.register.int16_5 && register.int16_6 == other.register.int16_6) { return register.int16_7 == other.register.int16_7; } return false; } if (typeof(T) == typeof(uint)) { if (register.uint32_0 == other.register.uint32_0 && register.uint32_1 == other.register.uint32_1 && register.uint32_2 == other.register.uint32_2) { return register.uint32_3 == other.register.uint32_3; } return false; } if (typeof(T) == typeof(int)) { if (register.int32_0 == other.register.int32_0 && register.int32_1 == other.register.int32_1 && register.int32_2 == other.register.int32_2) { return register.int32_3 == other.register.int32_3; } return false; } if (typeof(T) == typeof(ulong)) { if (register.uint64_0 == other.register.uint64_0) { return register.uint64_1 == other.register.uint64_1; } return false; } if (typeof(T) == typeof(long)) { if (register.int64_0 == other.register.int64_0) { return register.int64_1 == other.register.int64_1; } return false; } if (typeof(T) == typeof(float)) { if (register.single_0 == other.register.single_0 && register.single_1 == other.register.single_1 && register.single_2 == other.register.single_2) { return register.single_3 == other.register.single_3; } return false; } if (typeof(T) == typeof(double)) { if (register.double_0 == other.register.double_0) { return register.double_1 == other.register.double_1; } return false; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } public override int GetHashCode() { int num = 0; if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { for (int i = 0; i < Count; i++) { num = HashHelpers.Combine(num, ((byte)(object)this[i]).GetHashCode()); } return num; } if (typeof(T) == typeof(sbyte)) { for (int j = 0; j < Count; j++) { num = HashHelpers.Combine(num, ((sbyte)(object)this[j]).GetHashCode()); } return num; } if (typeof(T) == typeof(ushort)) { for (int k = 0; k < Count; k++) { num = HashHelpers.Combine(num, ((ushort)(object)this[k]).GetHashCode()); } return num; } if (typeof(T) == typeof(short)) { for (int l = 0; l < Count; l++) { num = HashHelpers.Combine(num, ((short)(object)this[l]).GetHashCode()); } return num; } if (typeof(T) == typeof(uint)) { for (int m = 0; m < Count; m++) { num = HashHelpers.Combine(num, ((uint)(object)this[m]).GetHashCode()); } return num; } if (typeof(T) == typeof(int)) { for (int n = 0; n < Count; n++) { num = HashHelpers.Combine(num, ((int)(object)this[n]).GetHashCode()); } return num; } if (typeof(T) == typeof(ulong)) { for (int num2 = 0; num2 < Count; num2++) { num = HashHelpers.Combine(num, ((ulong)(object)this[num2]).GetHashCode()); } return num; } if (typeof(T) == typeof(long)) { for (int num3 = 0; num3 < Count; num3++) { num = HashHelpers.Combine(num, ((long)(object)this[num3]).GetHashCode()); } return num; } if (typeof(T) == typeof(float)) { for (int num4 = 0; num4 < Count; num4++) { num = HashHelpers.Combine(num, ((float)(object)this[num4]).GetHashCode()); } return num; } if (typeof(T) == typeof(double)) { for (int num5 = 0; num5 < Count; num5++) { num = HashHelpers.Combine(num, ((double)(object)this[num5]).GetHashCode()); } return num; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } if (typeof(T) == typeof(byte)) { num = HashHelpers.Combine(num, register.byte_0.GetHashCode()); num = HashHelpers.Combine(num, register.byte_1.GetHashCode()); num = HashHelpers.Combine(num, register.byte_2.GetHashCode()); num = HashHelpers.Combine(num, register.byte_3.GetHashCode()); num = HashHelpers.Combine(num, register.byte_4.GetHashCode()); num = HashHelpers.Combine(num, register.byte_5.GetHashCode()); num = HashHelpers.Combine(num, register.byte_6.GetHashCode()); num = HashHelpers.Combine(num, register.byte_7.GetHashCode()); num = HashHelpers.Combine(num, register.byte_8.GetHashCode()); num = HashHelpers.Combine(num, register.byte_9.GetHashCode()); num = HashHelpers.Combine(num, register.byte_10.GetHashCode()); num = HashHelpers.Combine(num, register.byte_11.GetHashCode()); num = HashHelpers.Combine(num, register.byte_12.GetHashCode()); num = HashHelpers.Combine(num, register.byte_13.GetHashCode()); num = HashHelpers.Combine(num, register.byte_14.GetHashCode()); return HashHelpers.Combine(num, register.byte_15.GetHashCode()); } if (typeof(T) == typeof(sbyte)) { num = HashHelpers.Combine(num, register.sbyte_0.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_1.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_2.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_3.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_4.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_5.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_6.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_7.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_8.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_9.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_10.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_11.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_12.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_13.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_14.GetHashCode()); return HashHelpers.Combine(num, register.sbyte_15.GetHashCode()); } if (typeof(T) == typeof(ushort)) { num = HashHelpers.Combine(num, register.uint16_0.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_1.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_2.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_3.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_4.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_5.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_6.GetHashCode()); return HashHelpers.Combine(num, register.uint16_7.GetHashCode()); } if (typeof(T) == typeof(short)) { num = HashHelpers.Combine(num, register.int16_0.GetHashCode()); num = HashHelpers.Combine(num, register.int16_1.GetHashCode()); num = HashHelpers.Combine(num, register.int16_2.GetHashCode()); num = HashHelpers.Combine(num, register.int16_3.GetHashCode()); num = HashHelpers.Combine(num, register.int16_4.GetHashCode()); num = HashHelpers.Combine(num, register.int16_5.GetHashCode()); num = HashHelpers.Combine(num, register.int16_6.GetHashCode()); return HashHelpers.Combine(num, register.int16_7.GetHashCode()); } if (typeof(T) == typeof(uint)) { num = HashHelpers.Combine(num, register.uint32_0.GetHashCode()); num = HashHelpers.Combine(num, register.uint32_1.GetHashCode()); num = HashHelpers.Combine(num, register.uint32_2.GetHashCode()); return HashHelpers.Combine(num, register.uint32_3.GetHashCode()); } if (typeof(T) == typeof(int)) { num = HashHelpers.Combine(num, register.int32_0.GetHashCode()); num = HashHelpers.Combine(num, register.int32_1.GetHashCode()); num = HashHelpers.Combine(num, register.int32_2.GetHashCode()); return HashHelpers.Combine(num, register.int32_3.GetHashCode()); } if (typeof(T) == typeof(ulong)) { num = HashHelpers.Combine(num, register.uint64_0.GetHashCode()); return HashHelpers.Combine(num, register.uint64_1.GetHashCode()); } if (typeof(T) == typeof(long)) { num = HashHelpers.Combine(num, register.int64_0.GetHashCode()); return HashHelpers.Combine(num, register.int64_1.GetHashCode()); } if (typeof(T) == typeof(float)) { num = HashHelpers.Combine(num, register.single_0.GetHashCode()); num = HashHelpers.Combine(num, register.single_1.GetHashCode()); num = HashHelpers.Combine(num, register.single_2.GetHashCode()); return HashHelpers.Combine(num, register.single_3.GetHashCode()); } if (typeof(T) == typeof(double)) { num = HashHelpers.Combine(num, register.double_0.GetHashCode()); return HashHelpers.Combine(num, register.double_1.GetHashCode()); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } public override string ToString() { return ToString("G", CultureInfo.CurrentCulture); } public string ToString(string format) { return ToString(format, CultureInfo.CurrentCulture); } public string ToString(string format, IFormatProvider formatProvider) { StringBuilder stringBuilder = new StringBuilder(); string numberGroupSeparator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; stringBuilder.Append('<'); for (int i = 0; i < Count - 1; i++) { stringBuilder.Append(((IFormattable)(object)this[i]).ToString(format, formatProvider)); stringBuilder.Append(numberGroupSeparator); stringBuilder.Append(' '); } stringBuilder.Append(((IFormattable)(object)this[Count - 1]).ToString(format, formatProvider)); stringBuilder.Append('>'); return stringBuilder.ToString(); } public unsafe static Vector<T>operator +(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarAdd(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarAdd(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarAdd(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarAdd(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarAdd(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarAdd(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarAdd(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarAdd(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarAdd(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarAdd(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 + right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 + right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 + right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 + right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 + right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 + right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 + right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 + right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 + right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 + right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 + right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 + right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 + right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 + right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 + right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 + right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 + right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 + right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 + right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 + right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 + right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 + right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 + right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 + right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 + right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 + right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 + right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 + right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 + right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 + right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 + right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 + right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 + right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 + right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 + right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 + right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 + right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 + right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 + right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 + right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 + right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 + right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 + right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 + right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 + right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 + right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 + right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 + right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 + right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 + right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 + right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 + right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 + right.register.int32_0; result.register.int32_1 = left.register.int32_1 + right.register.int32_1; result.register.int32_2 = left.register.int32_2 + right.register.int32_2; result.register.int32_3 = left.register.int32_3 + right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 + right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 + right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 + right.register.int64_0; result.register.int64_1 = left.register.int64_1 + right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 + right.register.single_0; result.register.single_1 = left.register.single_1 + right.register.single_1; result.register.single_2 = left.register.single_2 + right.register.single_2; result.register.single_3 = left.register.single_3 + right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 + right.register.double_0; result.register.double_1 = left.register.double_1 + right.register.double_1; } return result; } public unsafe static Vector<T>operator -(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarSubtract(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarSubtract(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarSubtract(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarSubtract(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarSubtract(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarSubtract(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarSubtract(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarSubtract(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarSubtract(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarSubtract(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 - right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 - right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 - right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 - right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 - right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 - right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 - right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 - right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 - right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 - right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 - right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 - right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 - right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 - right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 - right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 - right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 - right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 - right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 - right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 - right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 - right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 - right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 - right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 - right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 - right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 - right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 - right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 - right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 - right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 - right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 - right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 - right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 - right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 - right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 - right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 - right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 - right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 - right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 - right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 - right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 - right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 - right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 - right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 - right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 - right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 - right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 - right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 - right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 - right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 - right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 - right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 - right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 - right.register.int32_0; result.register.int32_1 = left.register.int32_1 - right.register.int32_1; result.register.int32_2 = left.register.int32_2 - right.register.int32_2; result.register.int32_3 = left.register.int32_3 - right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 - right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 - right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 - right.register.int64_0; result.register.int64_1 = left.register.int64_1 - right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 - right.register.single_0; result.register.single_1 = left.register.single_1 - right.register.single_1; result.register.single_2 = left.register.single_2 - right.register.single_2; result.register.single_3 = left.register.single_3 - right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 - right.register.double_0; result.register.double_1 = left.register.double_1 - right.register.double_1; } return result; } public unsafe static Vector<T>operator *(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarMultiply(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarMultiply(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarMultiply(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarMultiply(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarMultiply(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarMultiply(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarMultiply(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarMultiply(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarMultiply(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarMultiply(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 * right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 * right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 * right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 * right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 * right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 * right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 * right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 * right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 * right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 * right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 * right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 * right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 * right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 * right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 * right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 * right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 * right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 * right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 * right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 * right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 * right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 * right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 * right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 * right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 * right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 * right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 * right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 * right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 * right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 * right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 * right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 * right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 * right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 * right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 * right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 * right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 * right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 * right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 * right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 * right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 * right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 * right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 * right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 * right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 * right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 * right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 * right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 * right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 * right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 * right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 * right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 * right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 * right.register.int32_0; result.register.int32_1 = left.register.int32_1 * right.register.int32_1; result.register.int32_2 = left.register.int32_2 * right.register.int32_2; result.register.int32_3 = left.register.int32_3 * right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 * right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 * right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 * right.register.int64_0; result.register.int64_1 = left.register.int64_1 * right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 * right.register.single_0; result.register.single_1 = left.register.single_1 * right.register.single_1; result.register.single_2 = left.register.single_2 * right.register.single_2; result.register.single_3 = left.register.single_3 * right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 * right.register.double_0; result.register.double_1 = left.register.double_1 * right.register.double_1; } return result; } public static Vector<T>operator *(Vector<T> value, T factor) { if (Vector.IsHardwareAccelerated) { return new Vector<T>(factor) * value; } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor; result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor; result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor; result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = value.register.int32_0 * (int)(object)factor; result.register.int32_1 = value.register.int32_1 * (int)(object)factor; result.register.int32_2 = value.register.int32_2 * (int)(object)factor; result.register.int32_3 = value.register.int32_3 * (int)(object)factor; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor; result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = value.register.int64_0 * (long)(object)factor; result.register.int64_1 = value.register.int64_1 * (long)(object)factor; } else if (typeof(T) == typeof(float)) { result.register.single_0 = value.register.single_0 * (float)(object)factor; result.register.single_1 = value.register.single_1 * (float)(object)factor; result.register.single_2 = value.register.single_2 * (float)(object)factor; result.register.single_3 = value.register.single_3 * (float)(object)factor; } else if (typeof(T) == typeof(double)) { result.register.double_0 = value.register.double_0 * (double)(object)factor; result.register.double_1 = value.register.double_1 * (double)(object)factor; } return result; } public static Vector<T>operator *(T factor, Vector<T> value) { if (Vector.IsHardwareAccelerated) { return new Vector<T>(factor) * value; } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor; result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor; result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor; result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = value.register.int32_0 * (int)(object)factor; result.register.int32_1 = value.register.int32_1 * (int)(object)factor; result.register.int32_2 = value.register.int32_2 * (int)(object)factor; result.register.int32_3 = value.register.int32_3 * (int)(object)factor; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor; result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = value.register.int64_0 * (long)(object)factor; result.register.int64_1 = value.register.int64_1 * (long)(object)factor; } else if (typeof(T) == typeof(float)) { result.register.single_0 = value.register.single_0 * (float)(object)factor; result.register.single_1 = value.register.single_1 * (float)(object)factor; result.register.single_2 = value.register.single_2 * (float)(object)factor; result.register.single_3 = value.register.single_3 * (float)(object)factor; } else if (typeof(T) == typeof(double)) { result.register.double_0 = value.register.double_0 * (double)(object)factor; result.register.double_1 = value.register.double_1 * (double)(object)factor; } return result; } public unsafe static Vector<T>operator /(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarDivide(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarDivide(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarDivide(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarDivide(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarDivide(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarDivide(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarDivide(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarDivide(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarDivide(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarDivide(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 / right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 / right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 / right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 / right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 / right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 / right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 / right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 / right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 / right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 / right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 / right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 / right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 / right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 / right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 / right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 / right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 / right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 / right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 / right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 / right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 / right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 / right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 / right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 / right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 / right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 / right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 / right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 / right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 / right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 / right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 / right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 / right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 / right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 / right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 / right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 / right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 / right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 / right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 / right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 / right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 / right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 / right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 / right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 / right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 / right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 / right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 / right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 / right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 / right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 / right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 / right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 / right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 / right.register.int32_0; result.register.int32_1 = left.register.int32_1 / right.register.int32_1; result.register.int32_2 = left.register.int32_2 / right.register.int32_2; result.register.int32_3 = left.register.int32_3 / right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 / right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 / right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 / right.register.int64_0; result.register.int64_1 = left.register.int64_1 / right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 / right.register.single_0; result.register.single_1 = left.register.single_1 / right.register.single_1; result.register.single_2 = left.register.single_2 / right.register.single_2; result.register.single_3 = left.register.single_3 / right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 / right.register.double_0; result.register.double_1 = left.register.double_1 / right.register.double_1; } return result; } public static Vector<T>operator -(Vector<T> value) { return Zero - value; } [JitIntrinsic] public unsafe static Vector<T>operator &(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] & ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 & right.register.int64_0; result.register.int64_1 = left.register.int64_1 & right.register.int64_1; } return result; } [JitIntrinsic] public unsafe static Vector<T>operator |(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] | ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 | right.register.int64_0; result.register.int64_1 = left.register.int64_1 | right.register.int64_1; } return result; } [JitIntrinsic] public unsafe static Vector<T>operator ^(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] ^ ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 ^ right.register.int64_0; result.register.int64_1 = left.register.int64_1 ^ right.register.int64_1; } return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector<T>operator ~(Vector<T> value) { return allOnes ^ value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(Vector<T> left, Vector<T> right) { return left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Vector<T> left, Vector<T> right) { return !(left == right); } [JitIntrinsic] public static explicit operator Vector<byte>(Vector<T> value) { return new Vector<byte>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<sbyte>(Vector<T> value) { return new Vector<sbyte>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<ushort>(Vector<T> value) { return new Vector<ushort>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<short>(Vector<T> value) { return new Vector<short>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<uint>(Vector<T> value) { return new Vector<uint>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<int>(Vector<T> value) { return new Vector<int>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<ulong>(Vector<T> value) { return new Vector<ulong>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<long>(Vector<T> value) { return new Vector<long>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<float>(Vector<T> value) { return new Vector<float>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<double>(Vector<T> value) { return new Vector<double>(ref value.register); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [JitIntrinsic] internal unsafe static Vector<T> Equals(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(ScalarEquals(left[i], right[i]) ? ConstantHelper.GetByteWithAllBitsSet() : 0); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(ScalarEquals(left[j], right[j]) ? ConstantHelper.GetSByteWithAllBitsSet() : 0); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] =
plugins/AdventureGuide/System.Runtime.CompilerServices.Unsafe.dll
Decompiled 3 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyFileVersion("4.0.0.0")] [assembly: AssemblyInformationalVersion("4.0.0.0")] [assembly: AssemblyTitle("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: CompilationRelaxations(8)] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: CLSCompliant(false)] [assembly: AssemblyVersion("4.0.3.0")] namespace System.Runtime.CompilerServices { public static class Unsafe : Object { [MethodImpl(256)] [NonVersionable] public unsafe static T Read<T>(void* source) { return Unsafe.Read<T>(source); } [MethodImpl(256)] [NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return Unsafe.ReadUnaligned<T>(source); } [MethodImpl(256)] [NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(256)] [NonVersionable] public unsafe static void Write<T>(void* destination, T value) { Unsafe.Write(destination, value); } [MethodImpl(256)] [NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { Unsafe.WriteUnaligned(destination, value); } [MethodImpl(256)] [NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(256)] [NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { Unsafe.Write(destination, source); } [MethodImpl(256)] [NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { destination = Unsafe.Read<T>(source); } [MethodImpl(256)] [NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return Unsafe.AsPointer(ref value); } [MethodImpl(256)] [NonVersionable] public static int SizeOf<T>() { return Unsafe.SizeOf<T>(); } [MethodImpl(256)] [NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(256)] [NonVersionable] public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(ref destination, ref source, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(256)] [NonVersionable] public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static T As<T>(object o) where T : class { return (T)o; } [MethodImpl(256)] [NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref *(T*)source; } [MethodImpl(256)] [NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(256)] [NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T Add<T>(ref T source, System.IntPtr elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T AddByteOffset<T>(ref T source, System.IntPtr byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(256)] [NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T Subtract<T>(ref T source, System.IntPtr elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, System.IntPtr byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(256)] [NonVersionable] public static System.IntPtr ByteOffset<T>(ref T origin, ref T target) { return Unsafe.ByteOffset(target: ref target, origin: ref origin); } [MethodImpl(256)] [NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return Unsafe.AreSame(ref left, ref right); } } } namespace System.Runtime.Versioning { [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class NonVersionableAttribute : Attribute { } }