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
14 changes: 7 additions & 7 deletions src/Client/LanguageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static Task<LanguageClient> From(Action<LanguageClientOptions> optionsAct
public static async Task<LanguageClient> From(LanguageClientOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken);
await server.Initialize(cancellationToken).ConfigureAwait(false);
return server;
}

Expand Down Expand Up @@ -261,10 +261,10 @@ await LanguageProtocolEventingHelper.Run(
(handler, ct) => handler.OnInitialize(this, @params, ct),
_concurrency,
token
);
).ConfigureAwait(false);

_connection.Open();
var serverParams = await SendRequest(ClientSettings, token);
var serverParams = await SendRequest(ClientSettings, token).ConfigureAwait(false);
_receiver.Initialized();

ServerSettings = serverParams;
Expand All @@ -276,7 +276,7 @@ await LanguageProtocolEventingHelper.Run(
(handler, ct) => handler.OnInitialized(this, @params, serverParams, ct),
_concurrency,
token
);
).ConfigureAwait(false);

// post init

Expand All @@ -290,7 +290,7 @@ await LanguageProtocolEventingHelper.Run(
(handler, ct) => handler.OnStarted(this, ct),
_concurrency,
token
);
).ConfigureAwait(false);

_instanceHasStarted.Started = true;

Expand Down Expand Up @@ -361,11 +361,11 @@ public async Task Shutdown()
{
if (_connection.IsOpen)
{
await this.RequestShutdown();
await this.RequestShutdown().ConfigureAwait(false);
this.SendExit();
}

await _connection.StopAsync();
await _connection.StopAsync().ConfigureAwait(false);
_connection.Dispose();
}

Expand Down
19 changes: 5 additions & 14 deletions src/Dap.Client/DebugAdapterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static Task<DebugAdapterClient> From(Action<DebugAdapterClientOptions> op
public static async Task<DebugAdapterClient> From(DebugAdapterClientOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken);
await server.Initialize(cancellationToken).ConfigureAwait(false);
return server;
}

Expand Down Expand Up @@ -127,12 +127,12 @@ await DebugAdapterEventingHelper.Run(
(handler, ct) => handler.OnInitialize(this, ClientSettings, ct),
_concurrency,
token
);
).ConfigureAwait(false);

RegisterCapabilities(ClientSettings);

_connection.Open();
var serverParams = await this.RequestDebugAdapterInitialize(ClientSettings, token);
var serverParams = await this.RequestDebugAdapterInitialize(ClientSettings, token).ConfigureAwait(false);

ServerSettings = serverParams;
_receiver.Initialized();
Expand All @@ -144,7 +144,7 @@ await DebugAdapterEventingHelper.Run(
(handler, ct) => handler.OnInitialized(this, ClientSettings, ServerSettings, ct),
_concurrency,
token
);
).ConfigureAwait(false);

await _initializedComplete.ToTask(token);

Expand All @@ -155,22 +155,13 @@ await DebugAdapterEventingHelper.Run(
(handler, ct) => handler.OnStarted(this, ct),
_concurrency,
token
);
).ConfigureAwait(false);

_instanceHasStarted.Started = true;
}

async Task<Unit> IRequestHandler<InitializedEvent, Unit>.Handle(InitializedEvent request, CancellationToken cancellationToken)
{
await DebugAdapterEventingHelper.Run(
_initializedDelegates,
(handler, ct) => handler(this, ClientSettings, ServerSettings, ct),
_initializedHandlers.Union(_collection.Select(z => z.Handler).OfType<IOnDebugAdapterClientInitialized>()),
(handler, ct) => handler.OnInitialized(this, ClientSettings, ServerSettings, ct),
_concurrency,
cancellationToken
);

_initializedComplete.OnNext(request);
_initializedComplete.OnCompleted();
return Unit.Value;
Expand Down
12 changes: 6 additions & 6 deletions src/Dap.Server/DebugAdapterServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static Task<DebugAdapterServer> From(Action<DebugAdapterServerOptions> op
public static async Task<DebugAdapterServer> From(DebugAdapterServerOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken);
await server.Initialize(cancellationToken).ConfigureAwait(false);
return server;
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public async Task Initialize(CancellationToken token)
{
try
{
await _initializingTask;
await _initializingTask.ConfigureAwait(false);
}
catch
{
Expand All @@ -139,15 +139,15 @@ public async Task Initialize(CancellationToken token)
try
{
_initializingTask = _initializeComplete.ToTask(token);
await _initializingTask;
await _initializingTask.ConfigureAwait(false);
await DebugAdapterEventingHelper.Run(
_startedDelegates,
(handler, ct) => handler(this, ct),
_startedHandlers.Union(_collection.Select(z => z.Handler).OfType<IOnDebugAdapterServerStarted>()),
(handler, ct) => handler.OnStarted(this, ct),
_concurrency,
token
);
).ConfigureAwait(false);
_instanceHasStarted.Started = true;

this.SendDebugAdapterInitialized(new InitializedEvent());
Expand Down Expand Up @@ -178,7 +178,7 @@ await DebugAdapterEventingHelper.Run(
(handler, ct) => handler.OnInitialize(this, request, ct),
_concurrency,
cancellationToken
);
).ConfigureAwait(false);

_receiver.Initialized();

Expand Down Expand Up @@ -230,7 +230,7 @@ await DebugAdapterEventingHelper.Run(
(handler, ct) => handler.OnInitialized(this, request, response, ct),
_concurrency,
cancellationToken
);
).ConfigureAwait(false);

_initializeComplete.OnNext(response);
_initializeComplete.OnCompleted();
Expand Down
4 changes: 2 additions & 2 deletions src/Dap.Shared/DapResponseRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task<TResponse> Returning<TResponse>(CancellationToken cancellation

try
{
var result = await tcs.Task;
var result = await tcs.Task.ConfigureAwait(false);
if (typeof(TResponse) == typeof(Unit))
{
return (TResponse) (object) Unit.Value;
Expand All @@ -131,7 +131,7 @@ public async Task<TResponse> Returning<TResponse>(CancellationToken cancellation
}
}

public async Task ReturningVoid(CancellationToken cancellationToken) => await Returning<Unit>(cancellationToken);
public async Task ReturningVoid(CancellationToken cancellationToken) => await Returning<Unit>(cancellationToken).ConfigureAwait(false);
}
}
}
2 changes: 1 addition & 1 deletion src/Dap.Testing/DebugAdapterProtocolTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Action<DebugAdapterServerOptions> serverOptionsAction
return await Observable.FromAsync(_client.Initialize).ForkJoin(
Observable.FromAsync(_server.Initialize),
(a, b) => ( _client, _server )
).ToTask(CancellationToken);
).ToTask(CancellationToken).ConfigureAwait(false);
}
}
}
2 changes: 1 addition & 1 deletion src/Dap.Testing/DebugAdapterServerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected virtual async Task<IDebugAdapterClient> InitializeClient(Action<DebugA

Disposable.Add(_client);

await _client.Initialize(CancellationToken);
await _client.Initialize(CancellationToken).ConfigureAwait(false);

return _client;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc.Testing/JsonRpcServerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Action<JsonRpcServerOptions> serverOptionsAction
}, CancellationToken
);

await Task.WhenAll(clientTask, serverTask);
await Task.WhenAll(clientTask, serverTask).ConfigureAwait(false);
_client = clientTask.Result;
_server = serverTask.Result;

Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc.Testing/SettlePipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async Task<R> IPipelineBehavior<T, R>.Handle(T request, CancellationToken cancel
_settler.OnStartRequest();
try
{
return await next();
return await next().ConfigureAwait(false);
}
finally
{
Expand Down
4 changes: 2 additions & 2 deletions src/JsonRpc/DelegatingHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Request(Func<TParams, Task> handler) : this((a, ct) => handler(a))
async Task<Unit> IRequestHandler<TParams, Unit>.
Handle(TParams request, CancellationToken cancellationToken)
{
await _handler(request, cancellationToken);
await _handler(request, cancellationToken).ConfigureAwait(false);
return Unit.Value;
}
}
Expand All @@ -62,7 +62,7 @@ public Notification(Action<TParams, CancellationToken> handler) : this(

async Task<Unit> IRequestHandler<TParams, Unit>.Handle(TParams request, CancellationToken cancellationToken)
{
await _handler(request, cancellationToken);
await _handler(request, cancellationToken).ConfigureAwait(false);
return Unit.Value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/DelegatingJsonNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DelegatingJsonNotificationHandler : IJsonRpcNotificationHandler<Del

public async Task<Unit> Handle(DelegatingNotification<JToken> request, CancellationToken cancellationToken)
{
await _handler.Invoke(request.Value, cancellationToken);
await _handler.Invoke(request.Value, cancellationToken).ConfigureAwait(false);
return Unit.Value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/DelegatingJsonRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DelegatingJsonRequestHandler : IJsonRpcRequestHandler<DelegatingReq

public async Task<JToken> Handle(DelegatingRequest<JToken> request, CancellationToken cancellationToken)
{
var response = await _handler.Invoke(request.Value, cancellationToken);
var response = await _handler.Invoke(request.Value, cancellationToken).ConfigureAwait(false);
return response;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/DelegatingNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DelegatingNotificationHandler(ISerializer serializer, Func<T, Cancellatio

public async Task<Unit> Handle(DelegatingNotification<T> request, CancellationToken cancellationToken)
{
await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken);
await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken).ConfigureAwait(false);
return Unit.Value;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/JsonRpc/DelegatingRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DelegatingRequestHandler(ISerializer serializer, Func<T, CancellationToke

public async Task<JToken> Handle(DelegatingRequest<T> request, CancellationToken cancellationToken)
{
var response = await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken);
var response = await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken).ConfigureAwait(false);
return JToken.FromObject(response, _serializer.JsonSerializer);
}
}
Expand All @@ -36,7 +36,7 @@ public DelegatingRequestHandler(ISerializer serializer, Func<T, CancellationToke

public async Task<JToken> Handle(DelegatingRequest<T> request, CancellationToken cancellationToken)
{
await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken);
await _handler.Invoke(request.Value.ToObject<T>(_serializer.JsonSerializer), cancellationToken).ConfigureAwait(false);
return JValue.CreateNull();
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/JsonRpc/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void Start()

public async Task StopAsync()
{
await _outputHandler.StopAsync();
await _pipeReader.CompleteAsync();
await _outputHandler.StopAsync().ConfigureAwait(false);
await _pipeReader.CompleteAsync().ConfigureAwait(false);
}

public void Dispose()
Expand Down Expand Up @@ -284,7 +284,7 @@ internal async Task ProcessInputStream(CancellationToken cancellationToken)
long length = 0;
do
{
var result = await _pipeReader.ReadAsync(cancellationToken);
var result = await _pipeReader.ReadAsync(cancellationToken).ConfigureAwait(false);
buffer = result.Buffer;

var dataParsed = true;
Expand Down Expand Up @@ -337,8 +337,8 @@ internal async Task ProcessInputStream(CancellationToken cancellationToken)
}
finally
{
await _outputHandler.StopAsync();
await _pipeReader.CompleteAsync();
await _outputHandler.StopAsync().ConfigureAwait(false);
await _pipeReader.CompleteAsync().ConfigureAwait(false);
}
}

Expand Down Expand Up @@ -504,7 +504,7 @@ private SchedulerDelegate RouteRequest(IRequestDescriptor<IHandlerDescriptor> de
{
return await _requestRouter.RouteRequest(
descriptors, request, cts.Token
);
).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
Expand Down Expand Up @@ -571,7 +571,7 @@ private SchedulerDelegate RouteNotification(IRequestDescriptor<IHandlerDescripto
using var timer = _logger.TimeDebug("Processing notification {Method}", notification.Method);
try
{
await _requestRouter.RouteNotification(descriptors, notification, ct);
await _requestRouter.RouteNotification(descriptors, notification, ct).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc/JsonRpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Task<JsonRpcServer> From(Action<JsonRpcServerOptions> optionsActio
public static async Task<JsonRpcServer> From(JsonRpcServerOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)
{
var server = Create(options, outerServiceProvider);
await server.Initialize(cancellationToken);
await server.Initialize(cancellationToken).ConfigureAwait(false);
return server;
}

Expand Down
12 changes: 6 additions & 6 deletions src/JsonRpc/OutputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Send(object value)

public async Task StopAsync()
{
await _pipeWriter.CompleteAsync();
await _pipeWriter.CompleteAsync().ConfigureAwait(false);
_disposable.Dispose();
}

Expand All @@ -81,8 +81,8 @@ public async Task StopAsync()
[EditorBrowsable(EditorBrowsableState.Never)]
internal async Task WriteAndFlush()
{
await _pipeWriter.FlushAsync();
await _pipeWriter.CompleteAsync();
await _pipeWriter.FlushAsync().ConfigureAwait(false);
await _pipeWriter.CompleteAsync().ConfigureAwait(false);
}

private async Task ProcessOutputStream(object value, CancellationToken cancellationToken)
Expand All @@ -92,9 +92,9 @@ private async Task ProcessOutputStream(object value, CancellationToken cancellat
// TODO: this will be part of the serialization refactor to make streaming first class
var content = _serializer.SerializeObject(value);
var contentBytes = Encoding.UTF8.GetBytes(content).AsMemory();
await _pipeWriter.WriteAsync(Encoding.UTF8.GetBytes($"Content-Length: {contentBytes.Length}\r\n\r\n"), cancellationToken);
await _pipeWriter.WriteAsync(contentBytes, cancellationToken);
await _pipeWriter.FlushAsync(cancellationToken);
await _pipeWriter.WriteAsync(Encoding.UTF8.GetBytes($"Content-Length: {contentBytes.Length}\r\n\r\n"), cancellationToken).ConfigureAwait(false);
await _pipeWriter.WriteAsync(contentBytes, cancellationToken).ConfigureAwait(false);
await _pipeWriter.FlushAsync(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException ex) when (ex.CancellationToken != cancellationToken)
{
Expand Down
Loading