Skip to content

Commit

Permalink
Do not deregister from Application.ThreadException between tests (git…
Browse files Browse the repository at this point in the history
…extensions#7686)

between tests in order to catch all exceptions during tests
fixes gitextensions#7684
  • Loading branch information
mstv authored and RussKie committed Jan 26, 2020
1 parent 45e742a commit 548ce20
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ public sealed class ConfigureJoinableTaskFactoryAttribute : Attribute, ITestActi

public ActionTargets Targets => ActionTargets.Test;

public ConfigureJoinableTaskFactoryAttribute()
{
Application.ThreadException += HandleApplicationThreadException;
}

public void BeforeTest(ITest test)
{
Assert.IsNull(ThreadHelper.JoinableTaskContext, "Tests with joinable tasks must not be run in parallel!");

Application.ThreadException += HandleApplicationThreadException;

IList apartmentState = null;
for (var scope = test; scope != null; scope = scope.Parent)
{
Expand Down Expand Up @@ -81,8 +84,6 @@ public void AfterTest(ITest test)
}
finally
{
Application.ThreadException -= HandleApplicationThreadException;

// Reset _threadException to null, and throw if it was set during the current test.
Interlocked.Exchange(ref _threadException, null)?.Throw();
}
Expand Down

0 comments on commit 548ce20

Please sign in to comment.