提交 70a06781 编写于 作者: S Sam Harwell

Pass arguments to StreamJsonRpc as arrays

Works around microsoft/vs-streamjsonrpc#272
上级 0b8e89e9
......@@ -244,6 +244,9 @@ public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> source)
return source.Where((Func<T, bool>)s_notNullTest);
}
public static T[] AsArray<T>(this IEnumerable<T> source)
=> source as T[] ?? source.ToArray();
public static ImmutableArray<TResult> SelectAsArray<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
{
if (source == null)
......
......@@ -59,7 +59,7 @@ public async Task InvokeAsync(string targetName, IReadOnlyList<object> arguments
try
{
await _rpc.InvokeWithCancellationAsync(targetName, arguments, cancellationToken).ConfigureAwait(false);
await _rpc.InvokeWithCancellationAsync(targetName, arguments?.AsArray(), cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ReportUnlessCanceled(ex, cancellationToken))
{
......@@ -73,7 +73,7 @@ public async Task<T> InvokeAsync<T>(string targetName, IReadOnlyList<object> arg
try
{
return await _rpc.InvokeWithCancellationAsync<T>(targetName, arguments, cancellationToken).ConfigureAwait(false);
return await _rpc.InvokeWithCancellationAsync<T>(targetName, arguments?.AsArray(), cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ReportUnlessCanceled(ex, cancellationToken))
{
......
......@@ -227,7 +227,7 @@ private async Task RpcInvokeAsync(string targetName, params object[] arguments)
// after shutdown.
try
{
await _rpc.InvokeWithCancellationAsync(targetName, arguments, _shutdownCancellationTokenSource.Token).ConfigureAwait(false);
await _rpc.InvokeWithCancellationAsync(targetName, arguments?.AsArray(), _shutdownCancellationTokenSource.Token).ConfigureAwait(false);
}
catch (Exception ex) when (ReportUnlessCanceled(ex))
{
......
......@@ -103,7 +103,7 @@ protected void StartService()
protected Task<TResult> InvokeAsync<TResult>(
string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
{
return _rpc.InvokeWithCancellationAsync<TResult>(targetName, arguments, cancellationToken);
return _rpc.InvokeWithCancellationAsync<TResult>(targetName, arguments?.AsArray(), cancellationToken);
}
protected Task<TResult> InvokeAsync<TResult>(
......@@ -121,7 +121,7 @@ protected Task InvokeAsync(string targetName, CancellationToken cancellationToke
protected Task InvokeAsync(
string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken)
{
return _rpc.InvokeWithCancellationAsync(targetName, arguments, cancellationToken);
return _rpc.InvokeWithCancellationAsync(targetName, arguments?.AsArray(), cancellationToken);
}
protected Task<Solution> GetSolutionAsync(CancellationToken cancellationToken)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册