-
Notifications
You must be signed in to change notification settings - Fork 570
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
Allow edition parsing #2998
base: master
Are you sure you want to change the base?
Allow edition parsing #2998
Conversation
d7c397b
to
7da5c16
Compare
defaulting to proto2 behavior
fd94792
to
a305de2
Compare
PROTO_2("proto2"), | ||
PROTO_3("proto3"), | ||
; | ||
/** Syntax and edition version. */ |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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>)`. |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love these tests
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...