The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of PEAKLib Core v1.6.0
plugins/com.github.PEAKModding.PEAKLib.Core.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using Microsoft.CodeAnalysis; using MonoDetour; using MonoDetour.Cil; using MonoDetour.DetourTypes; using MonoDetour.HookGen; using MonoDetour.Reflection.Unspeakable; using MonoMod.Utils; using On.GameHandler; using On.LoadingScreenHandler; using PEAKLib.Core.Extensions; using PEAKLib.Core.UnityEditor; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PEAKModding, Hamunii, Boxofbiscuits97")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Core module of the PEAKLib community API for the game PEAK.")] [assembly: AssemblyFileVersion("1.6.0.0")] [assembly: AssemblyInformationalVersion("1.6.0+c821198a0bb2464382d499877b96abee63793387")] [assembly: AssemblyProduct("com.github.PEAKModding.PEAKLib.Core")] [assembly: AssemblyTitle("PEAKLib.Core")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace On.LoadingScreenHandler { internal static class Awake { public delegate void PrefixSignature(LoadingScreenHandler self); public delegate ReturnFlow ControlFlowPrefixSignature(LoadingScreenHandler self); public delegate void PostfixSignature(LoadingScreenHandler self); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ControlFlowPrefix(ControlFlowPrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { Type typeFromHandle = typeof(LoadingScreenHandler); MethodInfo method = typeFromHandle.GetMethod("Awake", (BindingFlags)(-1), null, Array.Empty<Type>(), null); if ((object)method == null) { throw new MissingMethodException("LoadingScreenHandler", "Awake"); } return method; } } internal static class LoadSceneProcess { public delegate void PrefixSignature(LoadingScreenHandler self, ref string sceneName, ref bool networked, ref bool yieldForCharacterSpawn, ref float extraYieldTimeOnEnd); public delegate ReturnFlow ControlFlowPrefixSignature(LoadingScreenHandler self, ref string sceneName, ref bool networked, ref bool yieldForCharacterSpawn, ref float extraYieldTimeOnEnd, ref IEnumerator returnValue); public delegate void PostfixSignature(LoadingScreenHandler self, ref string sceneName, ref bool networked, ref bool yieldForCharacterSpawn, ref float extraYieldTimeOnEnd, ref IEnumerator returnValue); public delegate void PrefixMoveNextSignature(SpeakableEnumerator<object, LoadingScreenHandler> self); public delegate ReturnFlow ControlFlowPrefixMoveNextSignature(SpeakableEnumerator<object, LoadingScreenHandler> self, ref bool continueEnumeration); public delegate void PostfixMoveNextSignature(SpeakableEnumerator<object, LoadingScreenHandler> self, ref bool continueEnumeration); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ControlFlowPrefix(ControlFlowPrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MonoDetourHook PrefixMoveNext(PrefixMoveNextSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>((MethodBase)StateMachineTarget(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ControlFlowPrefixMoveNext(ControlFlowPrefixMoveNextSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>((MethodBase)StateMachineTarget(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook PostfixMoveNext(PostfixMoveNextSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>((MethodBase)StateMachineTarget(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHookMoveNext(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook((MethodBase)StateMachineTarget(), manipulator, config, applyByDefault); } public static MethodBase Target() { Type typeFromHandle = typeof(LoadingScreenHandler); MethodInfo method = typeFromHandle.GetMethod("LoadSceneProcess", (BindingFlags)(-1), null, new Type[4] { typeof(string), typeof(bool), typeof(bool), typeof(float) }, null); if ((object)method == null) { throw new MissingMethodException("LoadingScreenHandler", "LoadSceneProcess"); } return method; } public static MethodInfo StateMachineTarget() { return Extensions.GetStateMachineTarget((MethodInfo)Target()); } } internal static class get_loading { } internal static class set_loading { } internal static class GetLoadingScreenPrefab { } internal static class Load { } internal static class LoadingRoutine { } internal static class LoadSceneProcessNetworked { } internal static class LoadSceneProcessOffline { } internal static class _ctor { } internal static class _LoadSceneProcess_d__11 { internal static class _ctor { } internal static class System_IDisposable_Dispose { } internal static class MoveNext { } internal static class System_Collections_Generic_IEnumerator_System_Object__get_Current { } internal static class System_Collections_IEnumerator_Reset { } internal static class System_Collections_IEnumerator_get_Current { } } internal static class _LoadSceneProcessNetworked_d__12 { internal static class _ctor { } internal static class System_IDisposable_Dispose { } internal static class MoveNext { } internal static class System_Collections_Generic_IEnumerator_System_Object__get_Current { } internal static class System_Collections_IEnumerator_Reset { } internal static class System_Collections_IEnumerator_get_Current { } } internal static class _LoadSceneProcessOffline_d__13 { internal static class _ctor { } internal static class System_IDisposable_Dispose { } internal static class MoveNext { } internal static class System_Collections_Generic_IEnumerator_System_Object__get_Current { } internal static class System_Collections_IEnumerator_Reset { } internal static class System_Collections_IEnumerator_get_Current { } } internal static class _LoadingRoutine_d__10 { internal static class _ctor { } internal static class System_IDisposable_Dispose { } internal static class MoveNext { } internal static class System_Collections_Generic_IEnumerator_System_Object__get_Current { } internal static class System_Collections_IEnumerator_Reset { } internal static class System_Collections_IEnumerator_get_Current { } } } namespace On.GameHandler { internal static class Awake { public delegate void PrefixSignature(GameHandler self); public delegate void PostfixSignature(GameHandler self); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { Type typeFromHandle = typeof(GameHandler); MethodInfo method = typeFromHandle.GetMethod("Awake", (BindingFlags)(-1), null, Array.Empty<Type>(), null); if ((object)method == null) { throw new MissingMethodException("GameHandler", "Awake"); } return method; } } internal static class Initialize { public delegate void PrefixSignature(GameHandler self); public delegate void PostfixSignature(GameHandler self); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { Type typeFromHandle = typeof(GameHandler); MethodInfo method = typeFromHandle.GetMethod("Initialize", (BindingFlags)(-1), null, Array.Empty<Type>(), null); if ((object)method == null) { throw new MissingMethodException("GameHandler", "Initialize"); } return method; } } internal static class get_Instance { } internal static class get_SettingsHandler { } internal static class set_SettingsHandler { } internal static class get_Initialized { } internal static class OnDestroy { } internal static class WaitForInitialization { } internal static class ClearAllStatuses { } internal static class Update { } internal static class _ctor { } internal static class __c { internal static class _ctor { } } internal static class __c__DisplayClass14_0 { internal static class _ctor { } } internal static class _Awake_d__14 { internal static class _ctor { } internal static class MoveNext { } internal static class SetStateMachine { } } internal static class _WaitForInitialization_d__17 { internal static class _ctor { } internal static class MoveNext { } internal static class SetStateMachine { } } } namespace MonoDetour.HookGen { internal static class DefaultMonoDetourManager { internal static MonoDetourManager Instance { get; } = New(); internal static MonoDetourManager New() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name); } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)] internal class MonoDetourTargetsAttribute : Attribute, IMonoDetourTargets { public Type? TargetType { get; } public bool IncludeNestedTypes { get; set; } public bool DistinguishOverloadsByName { get; set; } public string[]? Members { get; set; } public string[]? MemberNamePrefixes { get; set; } public string[]? MemberNameSuffixes { get; set; } public bool GenerateControlFlowVariants { get; set; } public MonoDetourTargetsAttribute(Type? targetType = null) { TargetType = targetType; IncludeNestedTypes = true; base..ctor(); } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PEAKLib.Core { public static class BundleLoader { private class LoadOperation { public enum State { LoadingBundle, LoadingContent } public string Path { get; } public DateTime StartTime { get; } = DateTime.Now; public State CurrentState { get; set; } public bool LoadContents { get; } public ModDefinition? ModDefinition { get; } public Action<PeakBundle>? OnBundleLoaded { get; } public AssetBundleCreateRequest BundleRequest { get; } public TimeSpan ElapsedTime => DateTime.Now - StartTime; public string FileName { get; } internal LoadOperation(string path, Action<PeakBundle>? onBundleLoaded = null, bool loadContents = true, ModDefinition? modDefinition = null) { Path = path; OnBundleLoaded = onBundleLoaded; LoadContents = loadContents; ModDefinition = modDefinition; FileName = System.IO.Path.GetFileName(Path); BundleRequest = AssetBundle.LoadFromFileAsync(path); ((AsyncOperation)BundleRequest).completed += OnLoaded; } private void OnLoaded(AsyncOperation operation) { ((MonoBehaviour)CorePlugin.Instance).StartCoroutine(FinishLoadOperation(this)); } private static IEnumerator FinishLoadOperation(LoadOperation operation) { LoadOperation operation2 = operation; AssetBundle bundle = operation2.BundleRequest.assetBundle; if ((Object)(object)bundle == (Object)null) { CorePlugin.Log.LogError((object)("Failed to load bundle " + operation2.FileName + "!")); Finish(); yield break; } operation2.CurrentState = State.LoadingContent; AssetBundleRequest assetRequest = bundle.LoadAllAssetsAsync<ScriptableObject>(); yield return assetRequest; Object[] allAssets = assetRequest.allAssets; List<ModDefinition> list; try { list = (from x in allAssets.OfType<UnityModDefinition>() select x.Resolve()).ToList(); } catch (Exception arg) { CorePlugin.Log.LogError((object)$"Failed to Resolve ModDefinition: {arg}"); Finish(); yield break; } ModDefinition modDefinition = operation2.ModDefinition; if (modDefinition != null) { list.Add(modDefinition); } int count = list.Count; if (count <= 1) { if (count == 0) { CorePlugin.Log.LogError((object)("Bundle " + operation2.FileName + " contains no mods!")); Finish(); yield break; } ModDefinition modDefinition2 = list[0]; IEnumerable<IContent> enumerable = allAssets.OfType<IContent>(); foreach (IContent item in enumerable) { modDefinition2.Content.Add(item); } PeakBundle t = new PeakBundle(bundle, modDefinition2); operation2.OnBundleLoaded?.SafeInvoke(t); if (operation2.LoadContents) { foreach (IContent item2 in enumerable) { try { modDefinition2.Register(item2); } catch (Exception ex) { try { CorePlugin.Log.LogError((object)$"Failed to register '{item2.Name}' ({item2.GetType().Name}) from bundle '{operation2.FileName}' ({modDefinition2.Id}): {ex}"); } catch (Exception arg2) { CorePlugin.Log.LogError((object)$"Failed to print error message. This should NOT throw. {arg2}"); } } } } BundleLoader.OnBundleLoaded?.SafeInvoke(t); CorePlugin.Log.LogInfo((object)$"Loaded bundle {operation2.FileName} in {operation2.ElapsedTime.TotalSeconds:N1}s"); Finish(); } else { CorePlugin.Log.LogError((object)("Bundle " + operation2.FileName + " contains more than one mod!")); Finish(); } void Finish() { _operations.Remove(operation2); InvokeOnAllBundlesLoadedIfShould(); } } } private static bool calledOnBundleLoaded; private static bool bundleLoadingWindowClosed; private static readonly List<LoadOperation> _operations = new List<LoadOperation>(); public static event Action? OnAllBundlesLoaded; public static event Action<PeakBundle>? OnBundleLoaded; private static void InvokeOnAllBundlesLoadedIfShould() { if (_operations.Count == 0 && bundleLoadingWindowClosed && !calledOnBundleLoaded) { calledOnBundleLoaded = true; BundleLoader.OnAllBundlesLoaded?.SafeInvoke(); } } internal static void CloseBundleLoadingWindow() { bundleLoadingWindowClosed = true; InvokeOnAllBundlesLoadedIfShould(); } private static void AddOperation(LoadOperation operation) { CorePlugin.Log.LogInfo((object)("Loading bundle at '" + operation.Path + "'...")); if (bundleLoadingWindowClosed) { CorePlugin.Log.LogWarning((object)("The bundle loading window has passed. Set your asset bundle to load in your plugin's Awake method " + $"for the best chances of everything working properly.\n{new StackTrace()}")); } _operations.Add(operation); } internal static void LoadAllBundles(string root, string withExtension) { CorePlugin.Log.LogInfo((object)("Loading all bundles with extension " + withExtension + " from root " + root)); string[] files = Directory.GetFiles(root, "*" + withExtension, SearchOption.AllDirectories); string[] array = files; foreach (string path in array) { LoadBundleAndContentsFromPath(path); } } public static void LoadBundleWithName(this BaseUnityPlugin baseUnityPlugin, string fileName, Action<PeakBundle> onLoaded) { ThrowHelper.ThrowIfArgumentNull(onLoaded, "onLoaded"); baseUnityPlugin.LoadBundleWithNameInternal(fileName, onLoaded, loadContents: false); } public static void LoadBundleAndContentsWithName(this BaseUnityPlugin baseUnityPlugin, string fileName, Action<PeakBundle>? onLoaded = null) { baseUnityPlugin.LoadBundleWithNameInternal(fileName, onLoaded, loadContents: true); } private static void LoadBundleWithNameInternal(this BaseUnityPlugin baseUnityPlugin, string fileName, Action<PeakBundle>? onLoaded, bool loadContents) { ThrowHelper.ThrowIfArgumentNull<BaseUnityPlugin>(baseUnityPlugin, "baseUnityPlugin"); ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(fileName, "fileName"); string directoryName = Path.GetDirectoryName(baseUnityPlugin.Info.Location); string[] files = Directory.GetFiles(directoryName, fileName, SearchOption.AllDirectories); ModDefinition orCreate = ModDefinition.GetOrCreate(baseUnityPlugin.Info); string[] array = files; foreach (string path in array) { AddOperation(new LoadOperation(path, onLoaded, loadContents, orCreate)); } } public static void LoadBundleFromPath(string path, Action<PeakBundle> onLoaded, ModDefinition? mod = null) { ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(path, "path"); ThrowHelper.ThrowIfArgumentNull(onLoaded, "onLoaded"); AddOperation(new LoadOperation(path, onLoaded, loadContents: false, mod)); } public static void LoadBundleAndContentsFromPath(string path, Action<PeakBundle>? onLoaded = null, ModDefinition? mod = null) { ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(path, "path"); AddOperation(new LoadOperation(path, onLoaded, loadContents: true, mod)); } internal static IEnumerator LoadOperationsDeadlineWait(MonoBehaviour behaviour) { (TMP_Text, Action)? tuple = SetupLoadingUI(); if (tuple.HasValue) { (TMP_Text, Action) valueOrDefault = tuple.GetValueOrDefault(); (TMP_Text, Action) tuple2 = valueOrDefault; TMP_Text text = tuple2.Item1; Action disableLoadingUI = tuple2.Item2; float startTime = Time.time; float lastUpdate = Time.time; while (_operations.Count > 0) { if (Time.time - lastUpdate <= 1f) { yield return null; } if (Time.time - startTime > 3f) { ((Component)text).gameObject.SetActive(true); } lastUpdate = Time.time; string arg = ((_operations.Count == 1) ? "bundle" : "bundles"); text.text = $"PEAKLib: Waiting for {_operations.Count} {arg} to load..."; foreach (LoadOperation operation in _operations) { string text2 = $"Loading {operation.FileName}: {operation.CurrentState}"; float? num = ((operation.CurrentState != 0) ? null : new float?(((AsyncOperation)operation.BundleRequest).progress)); float? num2 = num; if (num2.HasValue) { text2 += $" {num2.Value:P0}"; } CorePlugin.Log.LogDebug((object)text2); } yield return null; } disableLoadingUI(); CorePlugin.Log.LogInfo((object)"Bundle loading screen finished."); } else { CorePlugin.Log.LogError((object)"Loading UI failed!"); while (_operations.Count > 0) { yield return null; } } } private static (TMP_Text, Action)? SetupLoadingUI() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.Find("LoadingScreenSimple(Clone)"); Canvas val = ((obj != null) ? obj.GetComponent<Canvas>() : null); if ((Object)(object)val == (Object)null) { CorePlugin.Log.LogError((object)"Loading UI Canvas not found!"); return null; } Transform val2 = TransformExtensions.FindChildRecursive(((Component)val).transform, "LoadingText"); if ((Object)(object)val2 == (Object)null) { CorePlugin.Log.LogError((object)"Loading UI 'LoadingText' transform not found!"); return null; } GameObject gameObject = ((Component)val2).gameObject; GameObject textObj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, true); ((Object)textObj).name = "PEAKLib Loading Text"; TextMeshProUGUI text = textObj.GetComponent<TextMeshProUGUI>(); ((TMP_Text)text).text = ""; RectTransform component = textObj.GetComponent<RectTransform>(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, 300f); textObj.SetActive(false); (TextMeshProUGUI, Action) tuple = (text, delegate { ((TMP_Text)text).text = "PEAKLib: All bundles loaded!"; ((MonoBehaviour)CorePlugin.Instance).StartCoroutine(WaitAndDisableText(textObj)); }); return ((TMP_Text)(object)tuple.Item1, tuple.Item2); } private static IEnumerator WaitAndDisableText(GameObject textObj) { yield return (object)new WaitForSeconds(1f); if (!((Object)(object)textObj == (Object)null)) { textObj.SetActive(false); } } } public static class ContentRegistry { internal static readonly Dictionary<IContent, IRegisteredContent> s_RegisteredContent = new Dictionary<IContent, IRegisteredContent>(); public static RegisteredContent<T> Register<T>(T modContent, ModDefinition owner) where T : IContent<T> { return new RegisteredContent<T>(modContent, owner); } public static bool IsRegistered(this IContent modContent) { return s_RegisteredContent.ContainsKey(modContent.Resolve()); } public static bool TryGetRegisteredContent<T>(this T modContent, [NotNullWhen(true)] out RegisteredContent<T>? registeredContent) where T : IContent<T> { registeredContent = null; if (!s_RegisteredContent.TryGetValue(modContent, out IRegisteredContent value)) { return false; } registeredContent = (RegisteredContent<T>)value; return true; } public static bool TryResolveAndGetRegisteredContent<T>(this T modContent, [NotNullWhen(true)] out IRegisteredContent? registeredContent) where T : IContent { registeredContent = null; if (!s_RegisteredContent.TryGetValue(modContent.Resolve(), out IRegisteredContent value)) { return false; } registeredContent = value; return true; } } internal class CustomPrefabPool : IPunPrefabPool { internal readonly Dictionary<string, GameObject> idToGameObject = new Dictionary<string, GameObject>(); internal readonly Dictionary<GameObject, string> gameObjectToId = new Dictionary<GameObject, string>(); private DefaultPool? _defaultPool; public DefaultPool DefaultPool { get { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (_defaultPool == null) { _defaultPool = new DefaultPool(); } return _defaultPool; } set { if (value != null) { _defaultPool = value; } } } internal CustomPrefabPool() { } public bool TryRegisterPrefab(string prefabId, GameObject prefab) { prefabId = ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(prefabId, "prefabId"); prefab = ThrowHelper.ThrowIfArgumentNull<GameObject>(prefab, "prefab"); if (HasPrefab(prefabId)) { CorePlugin.Log.LogError((object)("CustomPrefabPool: failed to register network prefab \"" + prefabId + "\". Prefab already exists in Resources with the same prefab id.")); return false; } if (idToGameObject.ContainsKey(prefabId)) { CorePlugin.Log.LogError((object)("CustomPrefabPool: failed to register network prefab \"" + prefabId + "\". There is already a prefab registered with the same prefab id.")); return false; } idToGameObject.Add(prefabId, prefab); gameObjectToId.Add(prefab, prefabId); CorePlugin.Log.LogDebug((object)("CustomPrefabPool: registered network prefab \"" + prefabId + "\"")); return true; } public bool HasPrefab(GameObject prefab) { return idToGameObject.ContainsValue(prefab); } public bool HasPrefab(string prefabId) { GameObject prefab; return TryGetPrefab(prefabId, out prefab); } public bool TryGetPrefabId(GameObject prefab, [NotNullWhen(true)] out string? id) { return gameObjectToId.TryGetValue(prefab, out id); } public bool TryGetPrefab(string prefabId, [NotNullWhen(true)] out GameObject? prefab) { prefabId = ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(prefabId, "prefabId"); if (idToGameObject.TryGetValue(prefabId, out prefab)) { return true; } prefab = Resources.Load<GameObject>(prefabId); return (Object)(object)prefab != (Object)null; } public GameObject? Instantiate(string prefabId, Vector3 position, Quaternion rotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) prefabId = ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(prefabId, "prefabId"); GameObject val; if (!idToGameObject.TryGetValue(prefabId, out GameObject value)) { val = DefaultPool.Instantiate(prefabId, position, rotation); if ((Object)(object)val == (Object)null) { CorePlugin.Log.LogError((object)("CustomPrefabPool: failed to spawn network prefab \"" + prefabId + "\". GameObject is null.")); } return val; } bool activeSelf = value.activeSelf; if (activeSelf) { value.SetActive(false); } val = Object.Instantiate<GameObject>(value, position, rotation); if (activeSelf) { value.SetActive(true); } CorePlugin.Log.LogInfo((object)$"CustomPrefabPool: spawned network prefab \"{prefabId}\" at position {position}, rotation {((Quaternion)(ref rotation)).eulerAngles}"); return val; } public void Destroy(GameObject gameObject) { Object.Destroy((Object)(object)gameObject); } } public interface IContent<T> : IContent where T : IContent<T> { new RegisteredContent<T> Register(ModDefinition owner); } public interface IContent { string Name { get; } IRegisteredContent Register(ModDefinition owner); IContent Resolve(); } public interface IModDefinitionResolvable { ModDefinition Resolve(); } public class ModDefinition : IModDefinitionResolvable { internal HashSet<IRegisteredContent> registeredContent = new HashSet<IRegisteredContent>(); private static readonly Dictionary<string, ModDefinition> s_guidToMod = new Dictionary<string, ModDefinition>(); public string Id { get; } public string Name { get; } public Version Version { get; } public HashSet<IContent> Content { get; } = new HashSet<IContent>(); public IEnumerable<IRegisteredContent> RegisteredContent => registeredContent; private ModDefinition(string id, string name, Version version) { Id = ThrowHelper.ThrowIfArgumentNull(id, "id"); Name = ThrowHelper.ThrowIfArgumentNull(name, "name"); Version = ThrowHelper.ThrowIfArgumentNull(version, "version"); } public static ModDefinition GetOrCreate(PluginInfo pluginInfo) { return GetOrCreate(pluginInfo.Metadata); } public static ModDefinition GetOrCreate(BepInPlugin bepInPlugin) { return GetOrCreate(bepInPlugin.GUID, bepInPlugin.Name, bepInPlugin.Version); } public static ModDefinition GetOrCreate(string id, string name, Version version) { if (s_guidToMod.TryGetValue(id, out ModDefinition value)) { return value; } value = new ModDefinition(id, name, version); s_guidToMod.Add(id, value); return value; } public static bool TryGetMod(string id, [NotNullWhen(true)] out ModDefinition? modDefinition) { return s_guidToMod.TryGetValue(id, out modDefinition); } public void RegisterContent() { foreach (IContent item in Content) { if (!item.IsRegistered()) { try { item.Register(this); } catch (Exception ex) { CorePlugin.Log.LogError((object)ex); } } } } public RegisteredContent<T> Register<T>(T content) where T : IContent<T> { return content.Register(this); } public IRegisteredContent Register(IContent content) { return content.Register(this); } public ModDefinition Resolve() { return this; } public override int GetHashCode() { return Id.GetHashCode(); } } public static class Networking { internal static readonly HashSet<string> hostPluginGuids = new HashSet<string>(); private static readonly Dictionary<string, (Action HasPlugin, Action NoPlugin)> s_OnHasPluginCallbacks = new Dictionary<string, (Action, Action)>(); internal static NetworkManager? s_NetworkManager; public static IReadOnlyCollection<string> HostPluginGuids => hostPluginGuids; public static void AddHostHasPluginListeners(string pluginGuid, Action onHasPlugin, Action onNoPlugin) { ThrowHelper.ThrowIfArgumentNull(pluginGuid, "pluginGuid"); ThrowHelper.ThrowIfArgumentNull(onHasPlugin, "onHasPlugin"); ThrowHelper.ThrowIfArgumentNull(onNoPlugin, "onNoPlugin"); if (s_OnHasPluginCallbacks.TryGetValue(pluginGuid, out (Action, Action) value)) { ref Action item = ref value.Item1; item = (Action)Delegate.Combine(item, onHasPlugin); ref Action item2 = ref value.Item2; item2 = (Action)Delegate.Combine(item2, onNoPlugin); } else { s_OnHasPluginCallbacks.Add(pluginGuid, (onHasPlugin, onNoPlugin)); } } internal static void InvokeGuidCallbacks() { foreach (KeyValuePair<string, (Action, Action)> s_OnHasPluginCallback in s_OnHasPluginCallbacks) { if (hostPluginGuids.Contains(s_OnHasPluginCallback.Key)) { CorePlugin.Log.LogDebug((object)$"Host has plugin with guid: {s_OnHasPluginCallback}"); s_OnHasPluginCallback.Value.Item1.SafeInvoke(); } else { CorePlugin.Log.LogDebug((object)$"Host does not have plugin with guid: {s_OnHasPluginCallback}"); s_OnHasPluginCallback.Value.Item2.SafeInvoke(); } } } } internal class NetworkManager : MonoBehaviourPunCallbacks { private Character? character; private void Awake() { CorePlugin.Log.LogDebug((object)"Loaded Network Component"); character = ((Component)this).GetComponent<Character>(); if ((Object)(object)character == (Object)null) { CorePlugin.Log.LogError((object)"Could not find reference to local character!"); } else { CallRPC("GetHostPluginsRPC", (RpcTarget)2); } } [PunRPC] private void GetHostPluginsRPC() { if (PhotonNetwork.IsMasterClient) { List<string> list = new List<string>(); list.AddRange(Chainloader.PluginInfos.Select((KeyValuePair<string, PluginInfo> x) => x.Value.Metadata.GUID)); string[] array = list.ToArray(); object[] parameters = array; CallRPC("ReceivePluginsFromHostRPC", (RpcTarget)0, parameters); } } [PunRPC] private void ReceivePluginsFromHostRPC(string[] guids) { CorePlugin.Log.LogDebug((object)"Received new Plugin guid list from host"); Networking.hostPluginGuids.Clear(); foreach (string text in guids) { CorePlugin.Log.LogDebug((object)("Received Plugin guid from host: " + text)); Networking.hostPluginGuids.Add(text); } Networking.InvokeGuidCallbacks(); } private void CallRPC(string methodName, RpcTarget target, params object[] parameters) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { CorePlugin.Log.LogError((object)"Could not find reference to local character!"); } else { character.view.RPC(methodName, target, parameters); } } public override void OnMasterClientSwitched(Player newMasterClient) { CorePlugin.Log.LogDebug((object)("Master Client Switched to player: " + newMasterClient.NickName)); if (PhotonNetwork.IsMasterClient) { CallRPC("ReceivePluginsFromHostRPC", (RpcTarget)2); } } } public static class NetworkPrefabManager { private static CustomPrefabPool? _customPrefabPool; internal static CustomPrefabPool PEAKLibPrefabPool { get { if (_customPrefabPool == null) { _customPrefabPool = new CustomPrefabPool(); } return _customPrefabPool; } private set { _customPrefabPool = value; } } internal static void Initialize() { if (PhotonNetwork.PrefabPool is CustomPrefabPool) { CorePlugin.Log.LogWarning((object)"NetworkPrefabs failed to initialize. PhotonNetwork.PrefabPool is already a CustomPrefabPool."); return; } CorePlugin.Log.LogInfo((object)"Initializing NetworkPrefabs."); CorePlugin.Log.LogDebug((object)$"PhotonNetwork.PrefabPool = {((object)PhotonNetwork.PrefabPool).GetType()}"); IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool; DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null); if (val != null) { PEAKLibPrefabPool.DefaultPool = val; } else if (!(PhotonNetwork.PrefabPool is CustomPrefabPool)) { CorePlugin.Log.LogWarning((object)$"PhotonNetwork has an unknown prefab pool assigned. PhotonNetwork.PrefabPool = {((object)PhotonNetwork.PrefabPool).GetType()}"); } PhotonNetwork.PrefabPool = (IPunPrefabPool)(object)PEAKLibPrefabPool; CorePlugin.Log.LogInfo((object)"Replaced PhotonNetwork.PrefabPool with CustomPrefabPool."); CorePlugin.Log.LogDebug((object)$"PhotonNetwork.PrefabPool = {((object)PhotonNetwork.PrefabPool).GetType()}"); CorePlugin.Log.LogInfo((object)"Finished initializing NetworkPrefabs."); } public static void RegisterNetworkPrefab(ModDefinition mod, GameObject prefab) { RegisterNetworkPrefab(mod, "", prefab); } public static void RegisterNetworkPrefab(ModDefinition mod, string folder, GameObject prefab) { ThrowHelper.ThrowIfArgumentNull(mod, "mod"); ((Object)prefab).name = mod.Id + ":" + ((Object)prefab).name; RegisterNetworkPrefab(folder + ((Object)prefab).name, prefab); } public static void RegisterNetworkPrefab(string prefabId, GameObject prefab) { if (PEAKLibPrefabPool.TryRegisterPrefab(prefabId, prefab)) { return; } throw new Exception("Failed to register network prefab!"); } public static bool TryRegisterNetworkPrefab(string prefabId, GameObject prefab) { return PEAKLibPrefabPool.TryRegisterPrefab(prefabId, prefab); } public static bool HasNetworkPrefab(string prefabId) { return PEAKLibPrefabPool.HasPrefab(prefabId); } public static bool TryGetNetworkPrefab(string prefabId, [NotNullWhen(true)] out GameObject? prefab) { return PEAKLibPrefabPool.TryGetPrefab(prefabId, out prefab); } public static GameObject SpawnNetworkPrefab(string prefabId, Vector3 position, Quaternion rotation, byte group = 0, object[]? data = null) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) ThrowHelper.ThrowIfArgumentNullOrWhiteSpace(prefabId, "prefabId"); if (!HasNetworkPrefab(prefabId)) { throw new Exception("Failed to spawn network prefab \"" + prefabId + "\". PrefabId is not registered as a network prefab."); } if (!PhotonNetwork.IsMasterClient) { throw new Exception("Failed to spawn network prefab \"" + prefabId + "\". You are not the host."); } return PhotonNetwork.InstantiateRoomObject(prefabId, position, rotation, group, data); } } public sealed class PeakBundle { private readonly AssetBundle bundle; public ModDefinition Mod { get; } internal PeakBundle(AssetBundle assetBundle, ModDefinition modDefinition) { bundle = ThrowHelper.ThrowIfArgumentNull<AssetBundle>(assetBundle, "assetBundle"); Mod = ThrowHelper.ThrowIfArgumentNull(modDefinition, "modDefinition"); } public bool Contains(string name) { return bundle.Contains(name); } public Object LoadAsset(string name) { return bundle.LoadAsset(name); } public T LoadAsset<T>(string name) where T : Object { return bundle.LoadAsset<T>(name); } public AssetBundleRequest LoadAssetAsync(string name) { return bundle.LoadAssetAsync(name); } public AssetBundleRequest LoadAssetAsync<T>(string name) { return bundle.LoadAssetAsync<T>(name); } public Object[] LoadAssetWithSubAssets(string name) { return bundle.LoadAssetWithSubAssets(name); } public T[] LoadAssetWithSubAssets<T>(string name) where T : Object { return bundle.LoadAssetWithSubAssets<T>(name); } public AssetBundleRequest LoadAssetWithSubAssetsAsync(string name) { return bundle.LoadAssetWithSubAssetsAsync(name); } public AssetBundleRequest LoadAssetWithSubAssetsAsync<T>(string name) { return bundle.LoadAssetWithSubAssetsAsync<T>(name); } public Object[] LoadAllAssets() { return bundle.LoadAllAssets(); } public T[] LoadAllAssets<T>() where T : Object { return bundle.LoadAllAssets<T>(); } public AssetBundleRequest LoadAllAssetsAsync() { return bundle.LoadAllAssetsAsync(); } public AssetBundleRequest LoadAllAssetsAsync<T>() { return bundle.LoadAllAssetsAsync<T>(); } public string[] GetAllAssetNames() { return bundle.GetAllAssetNames(); } public string[] GetAllScenePaths() { return bundle.GetAllScenePaths(); } } [BepInPlugin("com.github.PEAKModding.PEAKLib.Core", "PEAKLib.Core", "1.6.0")] public class CorePlugin : BaseUnityPlugin { private static CorePlugin? _instance = null; public const string Id = "com.github.PEAKModding.PEAKLib.Core"; internal static ManualLogSource Log { get; } = Logger.CreateLogSource(Name); internal static CorePlugin Instance => _instance ?? throw new NullReferenceException("PEAKLib.Core hasn't been initialized yet! Please depend on it with [BepInDependency(CorePlugin.Id)]"); public static string Name => "PEAKLib.Core"; public static string Version => "1.6.0"; private void Awake() { _instance = this; MonoDetourManager.InvokeHookInitializers(typeof(CorePlugin).Assembly); PlayerHandler.OnCharacterRegistered = (Action<Character>)Delegate.Combine(PlayerHandler.OnCharacterRegistered, (Action<Character>)delegate(Character character) { Networking.s_NetworkManager = ((Component)character).gameObject.AddComponent<NetworkManager>(); }); BundleLoader.LoadAllBundles(Paths.PluginPath, ".autoload.peakbundle"); BundleLoader.LoadAllBundles(Paths.PluginPath, ".autoload_peakbundle"); Log.LogInfo((object)("Plugin " + Name + " is loaded!")); } private void Start() { BundleLoader.CloseBundleLoadingWindow(); } } public class RegisteredContent<T> : IRegisteredContent where T : IContent { public T Content { get; } IContent IRegisteredContent.Content => Content; public ModDefinition Mod { get; } internal RegisteredContent(T content, ModDefinition mod) { Content = ThrowHelper.ThrowIfArgumentNull(content, "content"); Mod = ThrowHelper.ThrowIfArgumentNull(mod, "mod"); if (!ContentRegistry.s_RegisteredContent.TryAdd(content, this)) { throw new Exception($"This Content has been registered already: '{content}'"); } mod.registeredContent.Add(this); } } public interface IRegisteredContent { IContent Content { get; } ModDefinition Mod { get; } } public static class ThrowHelper { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ThrowIfFieldNullOrWhiteSpace([NotNull] string? field, [CallerArgumentExpression("field")] string name = "") { if (string.IsNullOrWhiteSpace(field)) { throw new NullReferenceException("Field or property '" + name + "' must not be null or whitespace."); } return field; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T ThrowIfFieldNull<T>([NotNull] T? field, [CallerArgumentExpression("field")] string name = "") { if (field == null) { throw new NullReferenceException("Field or property '" + name + "' must not be null."); } return field; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ThrowIfArgumentNullOrWhiteSpace([NotNull] string? argument, [CallerArgumentExpression("argument")] string name = "") { if (string.IsNullOrWhiteSpace(argument)) { throw new ArgumentException("'" + name + "' must not be null or whitespace."); } return argument; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T ThrowIfArgumentNull<T>([NotNull] T? argument, [CallerArgumentExpression("argument")] string name = "") { if (argument == null) { ThrowArgumentNull(name); } return argument; } [DoesNotReturn] private static void ThrowArgumentNull(string argName) { throw new ArgumentNullException(argName); } } } namespace PEAKLib.Core.UnityEditor { [CreateAssetMenu(fileName = "ModDefinition", menuName = "PEAKLib/ModDefinition", order = 0)] public class UnityModDefinition : ScriptableObject, IModDefinitionResolvable { [SerializeField] private string modId = ""; [SerializeField] private string modName = ""; [SerializeField] private string modVersion = ""; public ModDefinition Resolve() { ThrowHelper.ThrowIfFieldNullOrWhiteSpace(modId, "modId"); ThrowHelper.ThrowIfFieldNullOrWhiteSpace(modName, "modName"); ThrowHelper.ThrowIfFieldNullOrWhiteSpace(modVersion, "modVersion"); Version version; try { version = new Version(modVersion); } catch (FormatException ex) { throw new FormatException("Version of the mod is not in a valid format!\n" + ex.Message, ex); } return ModDefinition.GetOrCreate(modId, modName, version); } } } namespace PEAKLib.Core.Hooks { [MonoDetourTargets(typeof(GameHandler))] internal static class GameHandlerHooks { private static bool patchedAwake; [MonoDetourHookInitialize] private static void Init() { On.GameHandler.Awake.Postfix(Postfix_Awake); } private static void Postfix_Awake(GameHandler self) { if (!patchedAwake) { patchedAwake = true; NetworkPrefabManager.Initialize(); } } } [MonoDetourTargets(typeof(LoadingScreenHandler), GenerateControlFlowVariants = true)] internal static class LoadingScreenHandlerHooks { private static bool loadBundlesStepInjected; private static readonly EnumeratorFieldReferenceGetter<string> sceneName = EnumeratorReflection.EnumeratorFastFieldReference<string>(LoadSceneProcess.StateMachineTarget(), "sceneName"); [MonoDetourHookInitialize] private static void Init() { LoadSceneProcess.ControlFlowPrefixMoveNext(Prefix_LoadSceneProcess_MoveNext); } private static ReturnFlow Prefix_LoadSceneProcess_MoveNext(SpeakableEnumerator<object, LoadingScreenHandler> self, ref bool continueEnumeration) { if (self.State == 0) { if (!loadBundlesStepInjected) { if (sceneName.Invoke((IEnumerator)self.Enumerator) == "Airport") { self.Current = BundleLoader.LoadOperationsDeadlineWait((MonoBehaviour)(object)self.This); loadBundlesStepInjected = true; continueEnumeration = true; return (ReturnFlow)2; } return (ReturnFlow)0; } return (ReturnFlow)0; } return (ReturnFlow)0; } } } namespace PEAKLib.Core.Extensions { internal static class ActionExtensions { public static void SafeInvoke(this Action @delegate) { foreach (Action item in @delegate.GetInvocationList().Cast<Action>()) { try { item(); } catch (Exception arg) { CorePlugin.Log.LogError((object)$"Unhandled exception in callback: {arg}"); } } } public static void SafeInvoke<T1>(this Action<T1> @delegate, T1 t1) { foreach (Action<T1> item in @delegate.GetInvocationList().Cast<Action<T1>>()) { try { item(t1); } catch (Exception arg) { CorePlugin.Log.LogError((object)$"Unhandled exception in callback: {arg}"); } } } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ConstantExpectedAttribute : Attribute { public object? Min { get; set; } public object? Max { get; set; } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ExperimentalAttribute : Attribute { public string DiagnosticId { get; } public string? UrlFormat { get; set; } public ExperimentalAttribute(string diagnosticId) { DiagnosticId = diagnosticId; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SetsRequiredMembersAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class StringSyntaxAttribute : Attribute { public const string CompositeFormat = "CompositeFormat"; public const string DateOnlyFormat = "DateOnlyFormat"; public const string DateTimeFormat = "DateTimeFormat"; public const string EnumFormat = "EnumFormat"; public const string GuidFormat = "GuidFormat"; public const string Json = "Json"; public const string NumericFormat = "NumericFormat"; public const string Regex = "Regex"; public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; public const string Xml = "Xml"; public string Syntax { get; } public object?[] Arguments { get; } public StringSyntaxAttribute(string syntax) { Syntax = syntax; Arguments = new object[0]; } public StringSyntaxAttribute(string syntax, params object?[] arguments) { Syntax = syntax; Arguments = arguments; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class UnscopedRefAttribute : Attribute { } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiresPreviewFeaturesAttribute : Attribute { public string? Message { get; } public string? Url { get; set; } public RequiresPreviewFeaturesAttribute() { } public RequiresPreviewFeaturesAttribute(string? message) { Message = message; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CallerArgumentExpressionAttribute : Attribute { public string ParameterName { get; } public CallerArgumentExpressionAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CollectionBuilderAttribute : Attribute { public Type BuilderType { get; } public string MethodName { get; } public CollectionBuilderAttribute(Type builderType, string methodName) { BuilderType = builderType; MethodName = methodName; } } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CompilerFeatureRequiredAttribute : Attribute { public const string RefStructs = "RefStructs"; public const string RequiredMembers = "RequiredMembers"; public string FeatureName { get; } public bool IsOptional { get; set; } public CompilerFeatureRequiredAttribute(string featureName) { FeatureName = featureName; } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute { public string[] Arguments { get; } public InterpolatedStringHandlerArgumentAttribute(string argument) { Arguments = new string[1] { argument }; } public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) { Arguments = arguments; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerAttribute : Attribute { } [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal static class IsExternalInit { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ModuleInitializerAttribute : Attribute { } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class OverloadResolutionPriorityAttribute : Attribute { public int Priority { get; } public OverloadResolutionPriorityAttribute(int priority) { Priority = priority; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] [ExcludeFromCodeCoverage] internal sealed class ParamCollectionAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal sealed class RequiresLocationAttribute : Attribute { } [AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SkipLocalsInitAttribute : Attribute { } }