question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support shared .NET contracts

See original GitHub issue

Right now, gRPC seems to rely on Protobuf contracts to be shared between server and client. But for a .NET context, .proto files are somewhat strange.

I would like having a way to define services as interfaces and data contracts as POCOs in a separate .NET assembly that would then be referenced by both the server and the client. That way, one wouldn’t need to exchange .proto files but could rely on .NET mechanisms to share .NET-native types.

In a way, this would be a bit like WCF’s ChannelFactory<T> which also allowed you to connect to a hosted service when you already had the contracts around.


@JamesNK - Oct 2019 update:

protobuf-net.Grpc supports code-first gRPC without .proto code generation. It builds on top of grpc-dotnet, replacing the code generation serializer with protobuf-net.

protobuf-net.Grpc is available on NuGet today. There are currently no plans to support code-first in grpc-dotnet.

For more information about protobuf-net.Grpc, see https://protobuf-net.github.io/protobuf-net.Grpc/gettingstarted

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:33
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
AlgorithmsAreCoolcommented, Feb 10, 2019

@Kadajski

The point of making this request here is that we want to use GRPC and not a REST based API. GRPC has great features such as bi-directional streaming that are valuable to us.

Libraries like ProtoBuf-Net and even WCF have showed us that versioning POCO definitions is very possible and not overly cumbersome.

Besides, it is not like Protobuf has some magic that allows versioning to always work, you still have to follow rules when you update your definitions.

Lastly we don’t want today really have to write a reflection based shim.

We would just like a path forward that allows us to annotate an existing POCO model so that it can be serialized across the wire.

As an aside, magic onion might be that solution but first party support for this scenario would be nice and that is the key ask of this issue.

7reactions
neuecccommented, Feb 7, 2019

gRPC itself does not depend protocol buffers and there method definition. We can register handler manually, it completely works. I’ve already tried, and created a framework that built on gRPC. https://github.com/Cysharp/MagicOnion Maybe it is not a concern of gRPC Core. However, if grpc-dotnet is also open to extensibility, such a framework can continue to be developed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code-first gRPC services and clients with .NET
.NET service and data contract types can be shared between the .NET server and clients. Avoids the need to define contracts in .proto...
Read more >
Sharing message contracts • NServiceBus • Particular Docs
Sharing contracts ​​ A sender and receiver of a given message must use the same message contract. Message contracts may be shared in...
Read more >
Shared Services Agreement: Everything You Need to Know
A shared services agreement is a model for delivering corporate support. It works by consolidating and combining services between business units and ...
Read more >
Sharing Pacts with the Pact Broker | Pact Docs
solves the problem of how to share contracts and verification results between consumer and provider projects; tells you which versions of your ...
Read more >
.NET Microservices: API Contracts | by Liviu Costea ...
In our case we started to create NuGet packages from our shared library. All clients and the service are using those packages. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found