Skip to content

Commit 96d8e67

Browse files
committed
- fix #110 (implicit operator NRE)
- rev pb-net ref and fix schema test - add example for #111 - add repro for #109
1 parent 4e3cb4e commit 96d8e67

File tree

6 files changed

+83
-9
lines changed

6 files changed

+83
-9
lines changed

src/protobuf-net.Grpc.Reflection/protobuf-net.Grpc.Reflection.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
<ItemGroup>
1010
<!-- note this uses v3 features that are not back-ported to v2 -->
11-
<PackageReference Include="protobuf-net.Reflection" Version="3.0.21" />
12-
<PackageReference Include="protobuf-net" Version="3.0.21" />
13-
<PackageReference Include="protobuf-net.Core" Version="3.0.21" />
11+
<PackageReference Include="protobuf-net.Reflection" Version="3.0.24" />
12+
<PackageReference Include="protobuf-net" Version="3.0.24" />
13+
<PackageReference Include="protobuf-net.Core" Version="3.0.24" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/protobuf-net.Grpc/Configuration/ClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static ClientFactory Create(BinderConfiguration? binderConfiguration = nu
3131
/// <summary>
3232
/// Get the binder configuration associated with this instance
3333
/// </summary>
34-
public static implicit operator BinderConfiguration(ClientFactory value) => value.BinderConfiguration;
34+
public static implicit operator BinderConfiguration(ClientFactory? value) => value?.BinderConfiguration ?? BinderConfiguration.Default;
3535

3636
/// <summary>
3737
/// Create a service-client backed by a CallInvoker

tests/protobuf-net.Grpc.Reflection.Test/SchemaGeneration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ message MyResponse {
4545
}
4646
service MyService {
4747
rpc AsyncEmpty (.google.protobuf.Empty) returns (.google.protobuf.Empty);
48-
rpc ClientStreaming (MyResponse) returns (stream MyRequest);
49-
rpc FullDuplex (stream MyResponse) returns (stream MyRequest);
50-
rpc ServerStreaming (stream MyResponse) returns (MyRequest);
48+
rpc ClientStreaming (stream MyRequest) returns (MyResponse);
49+
rpc FullDuplex (stream MyRequest) returns (stream MyResponse);
50+
rpc ServerStreaming (MyRequest) returns (stream MyResponse);
5151
rpc SyncEmpty (.google.protobuf.Empty) returns (.google.protobuf.Empty);
52-
rpc Unary (MyResponse) returns (MyRequest);
52+
rpc Unary (MyRequest) returns (MyResponse);
5353
}
5454
", schema, ignoreLineEndingDifferences: true);
5555
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Grpc.Core;
2+
using System.Threading.Tasks;
3+
using ProtoBuf.Grpc.Server;
4+
using Xunit;
5+
6+
namespace protobuf_net.Grpc.Test.Integration.Issues
7+
{
8+
public class Issue109 // Server refuses to die!
9+
{
10+
[Fact(Skip = "definitely fails, but needs Grpc.Core input")]
11+
public async Task Issue_109()
12+
{
13+
var port = 10050;
14+
15+
var server = new Server()
16+
{
17+
Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
18+
};
19+
// it seems that the port is already in use at this point
20+
21+
// try all kinds of ways to release the port
22+
await server.ShutdownAsync();
23+
// await server.KillAsync(); // kill also doesn't release, but can't Shutdown *and* Kill
24+
await server.ShutdownTask;
25+
26+
27+
var server2 = new Server()
28+
{
29+
Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
30+
};
31+
32+
// server2.Services.Add(...) // note: repros even without any services
33+
server2.Start(); // <--- crash, socket is still in use.
34+
}
35+
36+
public interface IVoid
37+
{
38+
ValueTask Void();
39+
}
40+
public class FooService : IVoid {
41+
ValueTask IVoid.Void() => default;
42+
}
43+
}
44+
}

tests/protobuf-net.Grpc.Test.IntegrationUpLevel/protobuf-net.Grpc.Test.IntegrationUpLevel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
14-
<PackageReference Include="protobuf-net" Version="3.0.21" />
14+
<PackageReference Include="protobuf-net" Version="3.0.24" />
1515
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
1616
<PackageReference Include="xunit" Version="2.4.1" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Grpc.Core;
2+
using ProtoBuf.Grpc;
3+
using Xunit;
4+
5+
namespace protobuf_net.Grpc.Test.Issues
6+
{
7+
public class Issue111
8+
{
9+
[Fact]
10+
public void DirectOptions()
11+
{
12+
var options = new CallOptions(new Metadata
13+
{
14+
{ "Authorization", $"Bearer abc" }
15+
});
16+
Assert.Equal("Bearer abc", options.Headers.GetString("Authorization"));
17+
}
18+
19+
[Fact]
20+
public void TwoStepOptions()
21+
{
22+
var headers = new Metadata
23+
{
24+
{ "Authorization", $"Bearer abc" }
25+
};
26+
var options = new CallOptions(headers);
27+
Assert.Equal("Bearer abc", options.Headers.GetString("Authorization"));
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)