Skip to content

Commit db6cf1f

Browse files
committed
investigate SO62732593; add some error detail to TryGetClientHelper
1 parent 37d4a59 commit db6cf1f

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/protobuf-net.Grpc/Internal/ContractOperation.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,17 @@ public static List<ContractOperation> FindOperations(BinderConfiguration binderC
286286

287287
internal MethodInfo? TryGetClientHelper()
288288
{
289+
289290
var name = GetClientHelperName();
290-
if (name == null || !s_reshaper.TryGetValue(name, out var method)) return null;
291-
return method.MakeGenericMethod(From, To);
291+
try
292+
{
293+
if (name == null || !s_reshaper.TryGetValue(name, out var method)) return null;
294+
return method.MakeGenericMethod(From, To);
295+
}
296+
catch (Exception ex)
297+
{
298+
throw new InvalidOperationException($"Error obtaining client-helper '{name}' (from: '{From?.FullName}', to: '{To?.FullName}'): {ex.Message}", ex);
299+
}
292300
}
293301
#pragma warning disable CS0618 // Reshape
294302
static readonly Dictionary<string, MethodInfo> s_reshaper =
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Grpc.Core;
2+
using ProtoBuf.Grpc.Client;
3+
using System.Collections.Generic;
4+
using System.Runtime.Serialization;
5+
using System.ServiceModel;
6+
using System.Threading.Tasks;
7+
using Xunit;
8+
9+
namespace protobuf_net.Grpc.Test.Integration.Issues
10+
{
11+
public class SO62732593
12+
{
13+
[Fact]
14+
public void CanCreateProxy()
15+
{
16+
Channel channel = new Channel("none", ChannelCredentials.Insecure);
17+
var svc = channel.CreateGrpcService<ICustomerService>();
18+
Assert.NotNull(svc);
19+
}
20+
21+
[DataContract]
22+
public class CustomerResultSet
23+
{
24+
[DataMember(Order = 1)]
25+
public IEnumerable<Customer> Customers { get; set; }
26+
}
27+
[DataContract]
28+
public partial class Customer
29+
{
30+
[DataMember(Order = 1)]
31+
public int CustomerId { get; set; }
32+
[DataMember(Order = 2)]
33+
public string CustomerName { get; set; }
34+
}
35+
36+
[ServiceContract(Name = "Services.Customer")]
37+
public interface ICustomerService
38+
{
39+
ValueTask<Customer> CreateCustomer(Customer customerDTO);
40+
41+
ValueTask<CustomerResultSet> GetCustomers();
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)