Skip to content

Commit 1665750

Browse files
author
Meir Kriheli
committed
revert server binding changes
1 parent 60de0f0 commit 1665750

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,16 @@ public int Bind(object state, Type serviceType, BinderConfiguration? binderConfi
3636
int totalCount = 0;
3737
object?[]? argsBuffer = null;
3838
Type[] typesBuffer = Array.Empty<Type>();
39-
40-
binderConfiguration ??= BinderConfiguration.Default;
41-
42-
if (binderConfiguration.Binder.IsServiceContract(serviceType, out var serviceName) == false)
43-
{
44-
// TODO: shall we assert the following? (currently it will fail some tests)
45-
//throw new ArgumentException($"Type {serviceType.Name} is not defined as contract service", nameof(serviceType));
46-
}
47-
48-
var serviceContracts = ContractOperation.ExpandInterfaces(serviceType);
39+
string? serviceName;
40+
if (binderConfiguration == null) binderConfiguration = BinderConfiguration.Default;
41+
var serviceContracts = typeof(IGrpcService).IsAssignableFrom(serviceType)
42+
? new HashSet<Type> { serviceType }
43+
: ContractOperation.ExpandInterfaces(serviceType);
4944

5045
bool serviceImplSimplifiedExceptions = serviceType.IsDefined(typeof(SimpleRpcExceptionsAttribute));
5146
foreach (var serviceContract in serviceContracts)
5247
{
53-
// Do not take inherited interfaces names!
54-
// The main serviceName will be used as routing identifier to all inherited methods!
55-
if (!binderConfiguration.Binder.IsServiceContract(serviceContract, out _)) continue;
48+
if (!binderConfiguration.Binder.IsServiceContract(serviceContract, out serviceName)) continue;
5649

5750
var serviceContractSimplifiedExceptions = serviceImplSimplifiedExceptions || serviceContract.IsDefined(typeof(SimpleRpcExceptionsAttribute));
5851
int svcOpCount = 0;

0 commit comments

Comments
 (0)