From d1e00010e79e74f84b024b8d7d9ba88a99dcaef9 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Fri, 17 Jan 2020 22:47:15 -0600 Subject: [PATCH] More docs Custom CWT now does more null checks --- IPA.Loader/Loader/StateTransitionTransaction.cs | 5 +++++ Net3-Proxy/CompilerServices.cs | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/IPA.Loader/Loader/StateTransitionTransaction.cs b/IPA.Loader/Loader/StateTransitionTransaction.cs index 16263863..7d0a6a4c 100644 --- a/IPA.Loader/Loader/StateTransitionTransaction.cs +++ b/IPA.Loader/Loader/StateTransitionTransaction.cs @@ -216,6 +216,11 @@ namespace IPA.Loader /// /// If you are running in a coroutine, you can use instead of . /// + /// + /// If you are running on the Unity main thread, this will block until all enabling is done, and will return a task representing the disables. + /// Otherwise, the task returned represents both, and will not complete until Unity has done (possibly) several updates, depending on + /// the number of plugins being disabled, and the time they take. + /// /// /// a which completes whenever all disables complete /// if this object has been disposed diff --git a/Net3-Proxy/CompilerServices.cs b/Net3-Proxy/CompilerServices.cs index f37a0787..a827fd37 100644 --- a/Net3-Proxy/CompilerServices.cs +++ b/Net3-Proxy/CompilerServices.cs @@ -35,7 +35,9 @@ namespace System.Runtime.CompilerServices } public void Add(TKey key, TValue value) - { + { + if (key == null) + throw new ArgumentException("Null key", nameof(key)); lock (_lock) items.Add(WeakRef(key), value); } @@ -73,8 +75,13 @@ namespace System.Runtime.CompilerServices public TValue GetOrCreateValue(TKey key) => GetValue(key, k => Activator.CreateInstance()); - public bool Remove(TKey key) - => items.Remove(WeakRef(key)); + public bool Remove(TKey key) + { + if (key == null) + throw new ArgumentException("Null key", nameof(key)); + + items.Remove(WeakRef(key)); + } public ConditionalWeakTable() => GCTracker.OnGC += OnGC;