-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from AArnott/fix41
Execute theory data-generating methods on UI thread
- Loading branch information
Showing
23 changed files
with
449 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
|
||
public class NonSerializableObject | ||
{ | ||
public static object[][] Data => new object[][] { new object[] { new NonSerializableObject() } }; | ||
|
||
public int ProcessId { get; } = Process.GetCurrentProcess().Id; | ||
|
||
public int ThreadId { get; } = Environment.CurrentManagedThreadId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE.txt file in the project root for full license information. | ||
|
||
#nullable enable | ||
|
||
namespace Xunit.Sdk | ||
{ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
|
||
/// <summary> | ||
/// An asynchronous implementation of an AutoResetEvent. | ||
/// </summary> | ||
[DebuggerDisplay("Signaled: {signaled}")] | ||
internal class AsyncAutoResetEvent | ||
{ | ||
/// <summary> | ||
/// A queue of folks awaiting signals. | ||
/// </summary> | ||
private readonly Queue<TaskCompletionSource<object?>> signalAwaiters = new Queue<TaskCompletionSource<object?>>(); | ||
|
||
/// <summary> | ||
/// A value indicating whether this event is already in a signaled state. | ||
/// </summary> | ||
/// <devremarks> | ||
/// This should not need the volatile modifier because it is | ||
/// always accessed within a lock. | ||
/// </devremarks> | ||
private bool signaled; | ||
|
||
/// <summary> | ||
/// Returns an awaitable that may be used to asynchronously acquire the next signal. | ||
/// </summary> | ||
/// <returns>An awaitable.</returns> | ||
public Task WaitAsync() | ||
{ | ||
lock (this.signalAwaiters) | ||
{ | ||
if (this.signaled) | ||
{ | ||
this.signaled = false; | ||
return Task.CompletedTask; | ||
} | ||
else | ||
{ | ||
var waiter = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously); | ||
this.signalAwaiters.Enqueue(waiter); | ||
return waiter.Task; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Sets the signal if it has not already been set, allowing one awaiter to handle the signal if one is already waiting. | ||
/// </summary> | ||
public void Set() | ||
{ | ||
TaskCompletionSource<object?>? toRelease = null; | ||
lock (this.signalAwaiters) | ||
{ | ||
if (this.signalAwaiters.Count > 0) | ||
{ | ||
toRelease = this.signalAwaiters.Dequeue(); | ||
} | ||
else if (!this.signaled) | ||
{ | ||
this.signaled = true; | ||
} | ||
} | ||
|
||
toRelease?.TrySetResult(null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.