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

support ReadAllAsync for netstandard2.0 #2411

Merged
merged 2 commits into from
Apr 17, 2024
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 Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<PackageVersion Include="Google.Api.CommonProtos" Version="2.13.0" />
<PackageVersion Include="Google.Apis.Auth" Version="1.46.0" />
<PackageVersion Include="Google.Protobuf" Version="3.24.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.5" />
<PackageVersion Include="Microsoft.Build" Version="16.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23472.1" />
Expand Down
4 changes: 0 additions & 4 deletions src/Grpc.Net.Common/AsyncStreamReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#endregion

#if !NETSTANDARD2_0 && !NET462

using System.Runtime.CompilerServices;
using Grpc.Shared;

Expand Down Expand Up @@ -50,5 +48,3 @@ private static async IAsyncEnumerable<T> ReadAllAsyncCore<T>(IAsyncStreamReader<
}
}
}

#endif
4 changes: 4 additions & 0 deletions src/Grpc.Net.Common/Grpc.Net.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<ProjectReference Include="..\Grpc.Core.Api\Grpc.Core.Api.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions test/Grpc.Net.Client.Tests/Grpc.Net.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<Reference Include="System.Net.Http" />

<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
</ItemGroup>

</Project>
4 changes: 0 additions & 4 deletions test/Grpc.Net.Client.Tests/ReadAllAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
using Grpc.Tests.Shared;
using NUnit.Framework;

#if !NET462

namespace Grpc.Net.Client.Tests;

[TestFixture]
Expand Down Expand Up @@ -275,5 +273,3 @@ public async Task MoveNextAsync_CancelCall_ThrowOperationCanceledOnCancellation_
Assert.AreEqual(StatusCode.Cancelled, call.GetStatus().StatusCode);
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<Reference Include="System.Net.Http" />

<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions test/Shared/TaskExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Copyright notice and license
#region Copyright notice and license

// Copyright 2019 The gRPC Authors
//
Expand Down Expand Up @@ -102,7 +102,6 @@ private static string CreateMessage(TimeSpan timeout, string? filePath, int line
? $"The operation timed out after reaching the limit of {timeout.TotalMilliseconds}ms."
: $"The operation at {filePath}:{lineNumber} timed out after reaching the limit of {timeout.TotalMilliseconds}ms.";

#if !NET462
public static IAsyncEnumerable<T> DefaultTimeout<T>(this IAsyncEnumerable<T> enumerable,
[CallerFilePath] string? filePath = null,
[CallerLineNumber] int lineNumber = default)
Expand Down Expand Up @@ -169,5 +168,4 @@ public ValueTask<bool> MoveNextAsync()
return new ValueTask<bool>(_enumerator.MoveNextAsync().AsTask().TimeoutAfter(_timeout, _filePath, _lineNumber));
}
}
#endif
}
Loading