Skip to content
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 ability to get FileDescriptorSet serialization in C# #5441

Closed
mcon-gr opened this issue Dec 10, 2018 · 8 comments
Closed

Add ability to get FileDescriptorSet serialization in C# #5441

mcon-gr opened this issue Dec 10, 2018 · 8 comments
Assignees
Labels

Comments

@mcon-gr
Copy link

mcon-gr commented Dec 10, 2018

What language does this apply to?
This issue relates to the C# Google.Protobuf package.

Describe the problem you are trying to solve.
Currently there is no way to obtain a ByteString from generated code, which represents either a message/proto-file with its dependencies which can be used with protoc. The appropriate data structure for this is FileDescriptorSet.

In particular I'd like to be able to generate protobuf code for another language given the generated C# protobuf code. We can already get an IList<FileDescriptor> of dependencies through the Dependencies property on FileDescriptor, all that needs to be done is bundling that with the instance of the FileDescrpitor and putting that into a FileDescriptorSet data structure and serializing.

Describe the solution you'd like
I'd like to add facility to get the serialized representation of FileDescriptorSet, containing all dependencies from either a FileDescriptor or a MessageDescriptor. This is code I'd be happy to write/test myself.

Describe alternatives you've considered
Ultimately the 2 formats for specifying protobuf messages are:

  • .proto files
  • FileDescriptorSets
    Given the necessary information is already stored in generated code to obtain the FileDescriptorSet, and this mechanism allows for easy bundling of dependencies, that seemed like the best way forward.

Additional context
The reason I'm looking to generate code for other languages, given the generated code for one (in this case C#), is to facilitate adding Protobuf support to the Pact contract testing framework. I can provide additional context if required.

@acozzette acozzette self-assigned this Dec 10, 2018
@acozzette
Copy link
Member

You can call protoc and pass --descriptor_set_out to have it write the FileDescriptorSet out to a file. Does that help with what you're trying to do?

@mcon-gr
Copy link
Author

mcon-gr commented Dec 10, 2018

Hi @acozzette, sure so I completely get that if I have the appropriate .proto files, then I'm able to get the FileDescriptorSet, however that's something I need to be able to do from the generated files.
Java and other languages implement the SelfDescribingMessage which includes the FileDescriptorSet, so there's precedent for adding functionality of this kind.

The reason that doing things from the .proto is not sufficient is that I'm trying to add functionality to the Pact testing framework: we're trying to test against the functionality of the application, as opposed to the .proto, which in general may live in another repository to the application.

@acozzette acozzette assigned anandolee and unassigned acozzette Dec 11, 2018
@ghost
Copy link

ghost commented Oct 25, 2019

@mcon-gr

If I understand your issue correctly, it should be resolved by 69cb61c which exists now in master. However, this change does not appear to have been applied to any release. I'm in the middle of creating a PR to help get this into 3.10.x and will link it when done.

@ObsidianMinor
Copy link
Contributor

this change does not appear to have been applied to any release

That's because it's meant to go with the rest of the changes from #5936 in the 3.11 release which should be in the next month if this comment is still accurate. So I'd just wait a little bit.

@ghost
Copy link

ghost commented Oct 25, 2019 via email

@jtattermusch
Copy link
Contributor

jtattermusch commented Nov 4, 2019

@nagytech it this a regression with respect to some of the older releases (= e.g. something we broke in let's say the last release) or this never worked, so you're basically filing a feature request?

@ghost
Copy link

ghost commented Nov 4, 2019

@jtattermusch

I'm not the author of this issue. However, from what I can tell they are requesting a new feature.

However, I would argue that it's some level of debt to the C# implementation of Protobuf given that these same fields are not internal to the other frameworks.

@elharo
Copy link
Contributor

elharo commented Sep 20, 2021

resolved

@elharo elharo closed this as completed Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants