Skip to content

Conversation

@oldergod
Copy link
Member

@oldergod oldergod commented Jun 20, 2024

defaulting to proto2 behavior, which is kinda wrong.

The way we break the world for Java callers is very sad...
Maybe we could just manually increate the enum values one bye one each year...

@oldergod oldergod force-pushed the bquenaudon.2024-06-20.editionparsing branch from d7c397b to 7da5c16 Compare June 20, 2024 11:59
oldergod added 2 commits June 21, 2024 13:15
defaulting to proto2 behavior
@oldergod oldergod force-pushed the bquenaudon.2024-06-20.editionparsing branch from fd94792 to a305de2 Compare June 21, 2024 12:22
PROTO_2("proto2"),
PROTO_3("proto3"),
;
/** Syntax and edition version. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has nothing to do with your PR, but I just completely hate this design decision in protobuf. What a disaster for authors and readers of protobuf.

PROTO_3("proto3"),
;
/** Syntax and edition version. */
sealed class Syntax(internal val string: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m tempted to say we create a new thing, Syntax2 or something, that offers these things, and keep Syntax as-is? Making a big binary-incompatible change to wire-runtime has a potentially large user impact?

(Why is Syntax in the runtime API?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's passed as a parameter to adapters

expect abstract class ProtoAdapter<E>(
  fieldEncoding: FieldEncoding,
  type: KClass<*>?,
  typeUrl: String?,
  syntax: Syntax,
  identity: E? = null,
  sourceFile: String? = null,
) {

// Created for backward capability with when Syntax used to be an enum.
fun name(): String {
return when (this) {
// TODO(Benoit) Edition needs to return something like `Edition(<value>)`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, yuck. Anything calling this might not be able to parse it later

}

@Test
fun rejectUnknownEditions() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love these tests

@oldergod oldergod mentioned this pull request Aug 11, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants