From 63557ce9da5a814a9e5693cf2dfd2e09f471f209 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 15 Jan 2020 21:13:49 -0600 Subject: [PATCH] Fixed disable tasks for .NET 3 --- IPA.Loader/Loader/PluginManager.cs | 3 ++- Net3-Proxy/Net3-Proxy.csproj | 1 + Net3-Proxy/TaskEx6.cs | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Net3-Proxy/TaskEx6.cs diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 98dc9afc..ae5f8fd3 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -15,6 +15,7 @@ using Logger = IPA.Logging.Logger; using System.Threading.Tasks; #if NET4 using TaskEx = System.Threading.Tasks.Task; +using TaskEx6 = System.Threading.Tasks.Task; using Task = System.Threading.Tasks.Task; #endif #if NET3 @@ -177,7 +178,7 @@ namespace IPA.Loader else { if (exec.Executor.Metadata.RuntimeOptions != RuntimeOptions.DynamicInit) - return TaskEx.FromException(new CannotRuntimeDisableException(exec.Executor.Metadata)); + return TaskEx6.FromException(new CannotRuntimeDisableException(exec.Executor.Metadata)); var res = TaskEx.WhenAll(exec.Dependents.Select(d => Disable(d, alreadyDisabled))) .ContinueWith(t => TaskEx.WhenAll(t, exec.Executor.Disable())).Unwrap(); diff --git a/Net3-Proxy/Net3-Proxy.csproj b/Net3-Proxy/Net3-Proxy.csproj index 67f6e4c5..21a7bccd 100644 --- a/Net3-Proxy/Net3-Proxy.csproj +++ b/Net3-Proxy/Net3-Proxy.csproj @@ -48,6 +48,7 @@ + diff --git a/Net3-Proxy/TaskEx6.cs b/Net3-Proxy/TaskEx6.cs new file mode 100644 index 00000000..8ad0ec39 --- /dev/null +++ b/Net3-Proxy/TaskEx6.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Net3_Proxy +{ + public static class TaskEx6 + { + public static Task FromException(Exception exception) + { + if (exception == null) throw new ArgumentNullException(nameof(exception)); + var tcs = new TaskCompletionSource(); + tcs.TrySetException(exception); + return tcs.Task; + } + public static Task FromException(Exception exception) => FromException(exception); + + private struct VoidTaskResult { } + } +}