summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-06-03 18:58:04 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-06-03 18:58:04 -0400
commit80f882baf3f1854e32df3546fc4d4485c2aab68f (patch)
treec0968a6305cd650956bcdfb10f5ac607a9b123a9 /src
parent8c4edc27656b7b60b4036a158c30f4fc1caccdd7 (diff)
downloadSMAPI-80f882baf3f1854e32df3546fc4d4485c2aab68f.tar.gz
SMAPI-80f882baf3f1854e32df3546fc4d4485c2aab68f.tar.bz2
SMAPI-80f882baf3f1854e32df3546fc4d4485c2aab68f.zip
stop rewriting module at first error
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
index c4e6013e..898d7fad 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
@@ -59,6 +60,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
{
// rewrite each type in the assembly, tracking whether any type was rewritten (Item1)
// and any exception that occurred during rewriting (Item2).
+ var cancellationToken = new CancellationTokenSource();
Tuple<bool, Exception> result = this.Module
.GetTypes()
.Where(type => type.BaseType != null) // skip special types like <Module>
@@ -66,6 +68,9 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
.WithExecutionMode(ParallelExecutionMode.ForceParallelism)
.Select(type =>
{
+ if (cancellationToken.IsCancellationRequested)
+ return Tuple.Create(false, null as Exception);
+
bool anyRewritten = false;
try
{
@@ -118,6 +123,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
}
catch (Exception e)
{
+ cancellationToken.Cancel();
return Tuple.Create(anyRewritten, e);
}
})