Skip to content

Commit 9cd97ce

Browse files
WeihanLiJamesNK
andauthored
support ReadAllAsync for netstandard2.0 (#2411)
Co-authored-by: James Newton-King <[email protected]>
1 parent c04d01a commit 9cd97ce

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<PackageVersion Include="Google.Api.CommonProtos" Version="2.13.0" />
6161
<PackageVersion Include="Google.Apis.Auth" Version="1.46.0" />
6262
<PackageVersion Include="Google.Protobuf" Version="3.24.0" />
63+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
6364
<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.5" />
6465
<PackageVersion Include="Microsoft.Build" Version="16.9.0" />
6566
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview.23472.1" />

src/Grpc.Net.Common/AsyncStreamReaderExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#endregion
1818

19-
#if !NETSTANDARD2_0 && !NET462
20-
2119
using System.Runtime.CompilerServices;
2220
using Grpc.Shared;
2321

@@ -50,5 +48,3 @@ private static async IAsyncEnumerable<T> ReadAllAsyncCore<T>(IAsyncStreamReader<
5048
}
5149
}
5250
}
53-
54-
#endif

src/Grpc.Net.Common/Grpc.Net.Common.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616
<ProjectReference Include="..\Grpc.Core.Api\Grpc.Core.Api.csproj" />
1717
</ItemGroup>
1818

19+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
20+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
21+
</ItemGroup>
22+
1923
</Project>

test/Grpc.Net.Client.Tests/Grpc.Net.Client.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
4848
<Reference Include="System.Net.Http" />
49+
50+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
4951
</ItemGroup>
5052

5153
</Project>

test/Grpc.Net.Client.Tests/ReadAllAsyncTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
using Grpc.Tests.Shared;
2424
using NUnit.Framework;
2525

26-
#if !NET462
27-
2826
namespace Grpc.Net.Client.Tests;
2927

3028
[TestFixture]
@@ -275,5 +273,3 @@ public async Task MoveNextAsync_CancelCall_ThrowOperationCanceledOnCancellation_
275273
Assert.AreEqual(StatusCode.Cancelled, call.GetStatus().StatusCode);
276274
}
277275
}
278-
279-
#endif

test/Grpc.Net.Client.Web.Tests/Grpc.Net.Client.Web.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
2323
<Reference Include="System.Net.Http" />
24+
25+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
2426
</ItemGroup>
2527

2628
</Project>

test/Shared/TaskExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#region Copyright notice and license
1+
#region Copyright notice and license
22

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

105-
#if !NET462
106105
public static IAsyncEnumerable<T> DefaultTimeout<T>(this IAsyncEnumerable<T> enumerable,
107106
[CallerFilePath] string? filePath = null,
108107
[CallerLineNumber] int lineNumber = default)
@@ -169,5 +168,4 @@ public ValueTask<bool> MoveNextAsync()
169168
return new ValueTask<bool>(_enumerator.MoveNextAsync().AsTask().TimeoutAfter(_timeout, _filePath, _lineNumber));
170169
}
171170
}
172-
#endif
173171
}

0 commit comments

Comments
 (0)