Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove System.Interactive.Async dependency #19059

Merged
merged 4 commits into from Jul 29, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/csharp/Grpc.Core.Api/AsyncStreamReaderExtensions.cs
@@ -0,0 +1,50 @@
#region Copyright notice and license

// Copyright 2015 gRPC authors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/2015/2019

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#endregion

using System;
using System.Threading;
using System.Threading.Tasks;

namespace Grpc.Core
{
/// <summary>
/// Extension methods for <see cref="IAsyncStreamReader{T}"/>.
/// </summary>
public static class AsyncStreamReaderExtensions
{
/// <summary>
/// Advances the stream reader to the next element in the sequence, returning the result asynchronously.
/// </summary>
/// <typeparam name="T">The message type.</typeparam>
/// <param name="streamReader">The stream reader.</param>
/// <returns>
/// Task containing the result of the operation: true if the reader was successfully advanced
/// to the next element; false if the reader has passed the end of the sequence.
/// </returns>
public static Task<bool> MoveNext<T>(this IAsyncStreamReader<T> streamReader)
where T : class
{
if (streamReader == null)
{
throw new ArgumentNullException(nameof(streamReader));
}

return streamReader.MoveNext(CancellationToken.None);
}
}
}
1 change: 0 additions & 1 deletion src/csharp/Grpc.Core.Api/Grpc.Core.Api.csproj
Expand Up @@ -23,7 +23,6 @@
<Import Project="..\Grpc.Core\SourceLink.csproj.include" />

<ItemGroup>
<PackageReference Include="System.Interactive.Async" Version="3.2.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>

Expand Down
22 changes: 16 additions & 6 deletions src/csharp/Grpc.Core.Api/IAsyncStreamReader.cs
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2015 gRPC authors.
//
Expand All @@ -16,10 +16,7 @@

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Grpc.Core
Expand Down Expand Up @@ -50,7 +47,20 @@ namespace Grpc.Core
/// </para>
/// </summary>
/// <typeparam name="T">The message type.</typeparam>
public interface IAsyncStreamReader<T> : IAsyncEnumerator<T>
public interface IAsyncStreamReader<T>
{
/// <summary>
/// Gets the current element in the iteration.
/// </summary>
T Current { get; }

/// <summary>
/// Advances the reader to the next element in the sequence, returning the result asynchronously.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to cancel the operation.</param>
/// <returns>
/// Task containing the result of the operation: true if the reader was successfully advanced
/// to the next element; false if the reader has passed the end of the sequence.</returns>
Task<bool> MoveNext(CancellationToken cancellationToken);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the goal to make this non-source breaking?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my source got broken here, would it make sence to do something like
CancellationToken cancellationToken = CancellationToken.None ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there's an extension method that provides the parameterless MoveNext():
https://github.com/grpc/grpc/pull/19059/files#diff-fa87174ba85fa18aefdd2f6f0c173750R39

you need to make sure that extension is visible from your code and you should be fine. (using Grpc.Core; should be enough?)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtattermusch thanks for your answer, i'm using v 2.23.
have using Grpc.Core;,
changed to while (await responseStream.MoveNext(CancellationToken.None)) to make it work

}
}
3 changes: 1 addition & 2 deletions src/csharp/Grpc.Core/Grpc.Core.csproj
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="Common.csproj.include" />

Expand Down Expand Up @@ -98,7 +98,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Interactive.Async" Version="3.2.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>

Expand Down
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down