Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Dependencies/Threading/TestHooks/IAsyncToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ namespace Microsoft.CodeAnalysis.Shared.TestHooks;

internal interface IAsyncToken : IDisposable
{
bool IsNull { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public AsyncToken(AsynchronousOperationListener listener)

public AsynchronousOperationListener Listener { get; }

public bool IsNull
=> false;

public void Dispose()
{
using (Listener._gate.DisposableWait(CancellationToken.None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ internal sealed class EmptyAsyncToken : IAsyncToken
{
public static IAsyncToken Instance { get; } = new EmptyAsyncToken();

public bool IsNull => true;

private EmptyAsyncToken()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static Task CompletesAsyncOperation(this Task task, IAsyncToken asyncToke
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "This is a Task wrapper, not an asynchronous method.")]
public static Task CompletesTrackingOperation(this Task task, IDisposable token)
{
if (token == null || token == EmptyAsyncToken.Instance)
if (token is IAsyncToken { IsNull: true })
{
return task;
}
Expand Down