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 support for Protobuf TextFormat #125

Open
kriswuollett opened this issue Sep 17, 2018 · 9 comments
Open

Add support for Protobuf TextFormat #125

kriswuollett opened this issue Sep 17, 2018 · 9 comments

Comments

@kriswuollett
Copy link

https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.text_format

sigurdm added a commit to sigurdm/protobuf that referenced this issue Dec 10, 2018
@sigurdm sigurdm added the refactoring Non-user-facing changes label Jan 24, 2019
@sigurdm
Copy link
Collaborator

sigurdm commented Jan 24, 2019

Does this include support for parsing the TextFormat?

If it is mainly for debugging purposes, the toString is relatively close to the textFormat.

@kriswuollett
Copy link
Author

Yes, parsing and writing TextFormat. Not for debugging purposes. System I work on uses proto text for runtime configuration and human-readable data for creating test cases.

@osa1 osa1 self-assigned this Apr 14, 2022
@osa1 osa1 added feature request and removed refactoring Non-user-facing changes labels May 11, 2022
@osa1
Copy link
Member

osa1 commented Aug 4, 2022

We can't and don't want to support every alternative serialization format for protos.

Ideally we should make it possible for users to implement (de)serializers as libraries.

IIRC currently the only blocker for this is that we don't have a public protobuf field type. We expose field types as an int, and the constants to interpret those ints (constants in field_type.dart) are not public.

Even if they were public, that API is painful to use and very error prone.

#605 attempts to fix this, but it comes with runtime cost, because we currently don't have a way in Dart to implement zero-cost wrappers around existing types.

Maybe something to revisit after view types.

@osa1 osa1 removed their assignment Aug 4, 2022
@kriswuollett
Copy link
Author

Feature request was generically for any type of support. Did not specifically request to be implemented on a message class.

Implementation in a library should be fine as the package could have nearly identical methods as C++'s text_format.h.

@sigurdm
Copy link
Collaborator

sigurdm commented Aug 5, 2022

#605 attempts to fix this, but it comes with runtime cost, because we currently don't have a way in Dart to implement zero-cost wrappers around existing types.

Even without zero-cost wrappers we could make a public interface for querying the field-type (it can stay an int at be queried through getters)

@osa1
Copy link
Member

osa1 commented Aug 5, 2022

it can stay an int at be queried through getters

Which class do you add the getters to?

@sigurdm
Copy link
Collaborator

sigurdm commented Aug 5, 2022

it can stay an int at be queried through getters

Which class do you add the getters to?

I guess from the FieldInfo where we currently expose int-type currently (ok, it will probably not be getters, but functions of the tag-number).

We could also consider wrapping the type only for external use, and keep the int internally for performance...

@osa1
Copy link
Member

osa1 commented Aug 5, 2022

We could also consider wrapping the type only for external use, and keep the int internally for performance...

I considered this in #605, but I want to use this new class (actually enum with all the proto field types) internally too, for example, in #592. Also in other (de)serialization code that check field types.

I wonder if there's an implementation strategy where we introduce a type for external users only and then transparently start using it internally (maybe with view types when it's ready) without loss of performance and breaking downstream.

@osa1
Copy link
Member

osa1 commented Oct 27, 2022

In case we want to go ahead with this, the text format spec was made public a few weeks ago: https://developers.google.com/protocol-buffers/docs/text-format-spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants