-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DynamicMessage support for C# #658
Comments
It would be nice to have specific requirements around this - scenarios we're trying to make simple.
|
@jskeet @anandolee Is this DynamicMessage implemented in C#? |
Not that I'm aware of. |
The simpler, still very useful, support would be removing the need to compile .proto files to DLLs at build time, so that a .NET application could generate the serializer/deserializer at runtime (caching it in memory) from .proto files provided by users for example. see for example https://stackoverflow.com/a/27505474/2793555 |
@dluc: That's far from simple - the C# code has no facility for parsing .proto files at all. That's all in protoc. If any dynamic message support is introduced, it would almost certainly work with the descriptors, not the original .proto files. (And generating the code at execution time is far from trivial too - again, all the code generation is in protoc, not in the Google.Protobuf library.) |
I'm actively working on this now. The initial support is likely to be relatively bare, but it'll be there. The main reason for me doing this is for the sake of writing protoc plugins in C#. |
@jskeet Is this something you're still working on? I'm happy to contribute if you consider this a parallelisable task. |
I'm not working on it at the moment, no. Basically I don't have time to work on protobuf other than for features I need for other work, e.g. being able to load the descriptors dynamically. I'm afraid I wouldn't have time to review significant chunks of code either, but hopefully @anandolee will be able to help. |
Thanks Jon - I'm getting the feeling that adding |
@jskeet Thanks for adding
If not, is there a way to generate a |
It's not quite that simple, unfortunately. From memory, you can create your own message that has a message FileDescriptorSet {
repeated bytes file = 1;
} ... and parse the descriptor set with that, then pass the resulting |
Thanks, Jon! That works just like you said:
|
Is there any progress on this? currently forced to have to use the old java port https://github.com/jskeet/protobuf-csharp-port/blob/master/src/ProtocolBuffers/DynamicMessage.cs real blocker for being able to handle dynamic streams of protobuf records on kafka with .net clients (java clients work fine as they have dynamic message). use cases is similar to using GenericRecord in avro, where consumers just need to resolve the filedescriptorset which is being held in a central repo akin to schema registries in avro. |
@michaelpearce-gain this is not actively being worked on and we don't have bandwidth to work on this. If this is something you believe lot of users need, consider contributing. |
Btw, we just merged proto2 support a few days ago, that might help when working with the descriptors (descriptors are defined as proto2, so until recently they've been implemented in a restricted fashion). |
I think that will help, whats the expected sort of time, that would be until its released? +100 having that |
I think in the next 12 weeks. We might not have made it on time for the upcoming 3.10 release, but it will be in 3.11 (Google.Protobuf now has a release approx. once every 6 weeks). |
No plans to work on DynamicMessage support at the moment. |
Hi, Is there any progress on this? |
FYI, I wrote a .NET library grpc-curl that provides an API to access dynamically a gRPC service by using reflection. It's available in the NuGet package DynamicGrpc You can access a gRPC service like this: var channel = GrpcChannel.ForAddress("http://192.168.100.1:9200");
// Fetch reflection data from server
var client = await DynamicGrpcClient.FromServerReflection(channel);
// Call the method `Handle` on the service `SpaceX.API.Device.Device`
var result = await client.AsyncUnaryCall("SpaceX.API.Device.Device", "Handle", new Dictionary<string, object>()
{
{ "get_status", new Dictionary<string, object>() }
}); The underlying |
Just to update this, we have more resources for C# support in protobuf now, but they're still limited. I would definitely like to do this (as a significant piece of missing functionality present in other languages) but it's definitely non-trivial. I'll attempt to carve out some time to prototype this in the next few weeks, so that we've got a better idea of just how difficult it's likely to be. |
@jskeet a quick question: is this required to build / parse messages when only the descpriptor of those messages is available?
Unfortunately, the It would be great if you could confirm if deserializing a Message where only the |
@KerstinKeller: No, it isn't possible at the moment I'm afraid. |
…c.; Fixed: Make sure to check optional inner messages for null when encoding, see protocolbuffers#658
…from source (for webpack), see protocolbuffers#658
PiperOrigin-RevId: 457738277
@jskeet , do you happen to have an execution plan written down somewhere in case someone may have enough bandwidth to work on this feature? Will this be a large undertaking or maybe medium sized and will need couple weeks to implement? |
No, I don't have anything like that I'm afraid. I'd expect it to take someone who is very familiar with protobuf and the .NET library at least a couple of weeks of full time work - and for someone less familiar, significantly more, I'm afraid. |
Oh bummer, this is unfortunate. Thanks for getting back to me. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
This is something that I am interested in. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
I am still interested in this. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We would still very much like to see this feature! |
Not a requirement as of now, but it would be nice to have one day in not too distant future.
The text was updated successfully, but these errors were encountered: