Skip to content

chore: update protobuf to latest#23

Open
sgammon wants to merge 1 commit intoDogacel:mainfrom
sgammon:chore/proto-v28
Open

chore: update protobuf to latest#23
sgammon wants to merge 1 commit intoDogacel:mainfrom
sgammon:chore/proto-v28

Conversation

@sgammon
Copy link

@sgammon sgammon commented Sep 13, 2024

Hey! Cool project. I'd like to contribute and potentially use it in some of my work. Can I help contribute? 😄

First up, here is a PR which updates Protobuf to the latest version (4.28.1 at the time of this writing). It includes some transition internally to Protocol Buffer Editions, which happen to provide a nicer API for some of the stuff needed by this plugin.

I've updated in the places I think need it, and done a little clean up along the way. Please make sure, though, that I've done this right according to the codebase's styles and so on. The tests pass and we intend to use the lib downstream. Cheers!

Signed-off-by: Sam Gammon <sam@elide.ventures>
@sgammon
Copy link
Author

sgammon commented Sep 13, 2024

cc / @Dogacel

Copy link
Owner

@Dogacel Dogacel left a comment

Choose a reason for hiding this comment

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

Hi 👋 First of all, thank you for contributing!

It seems like some of the changes you made caused field signatures to change. I see issues especially with nullability. Even though we use a newer version of protobuf compiler, the existing generated code shouldn't change because it's syntax is proto3.

Also, it would be nice to include some proto2 and edition 2023 test files.

According to https://protobuf.dev/editions/implementation/ we still have a lot to support.

Comment on lines -34 to -42
) {
init {
require(
listOfNotNull(
someValue,
).size <= 1
) { "Should only contain one of some_oneof." }
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, I wonder whether isSyntheticCompat works as intended in this situation or not. I don't see a reason why this block would be removed. It is not possible to set more than 1 one ofs.

Comment on lines +9 to +12
// Indicate whether the field unconditionally has a value; true if the field is PROTO2 and marked `required`, or if
// the field has a default value when unset.
private val FieldDescriptor.unconditionallyHasValue: Boolean get() =
!isOptional || !options.features.hasFieldPresence()
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure if this works as intended.

In proto 3, having field presence = being marked as optional.

The method name was a little confusing, maybe we should name that something like hasFieldPresence()?

Copy link
Owner

Choose a reason for hiding this comment

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

Also I wonder whether optional int32 a = 1 in proto3 and int32 a = 1 in edition 2023 both have hasFieldPresence set to true. Can you cross-check, write a test and confirm?


if (
fieldDescriptor.hasOptionalKeyword() ||
fieldDescriptor.isOptional ||
Copy link
Owner

Choose a reason for hiding this comment

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

I think this causes a bug, we should update this to be unconditionallyHasValue as well.

Copy link
Owner

Choose a reason for hiding this comment

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

Or maybe hasFieldPresence() is enough. Let's give it a try.

@Dogacel
Copy link
Owner

Dogacel commented Oct 13, 2024

@sgammon hi, just checking in as this PR has became stale.

@sgammon
Copy link
Author

sgammon commented Oct 14, 2024

@Dogacel Sorry, got busy with work... we don't need this component quite yet, but we will soon. Thank you for your review comments. Why don't I re-file this week after some cleanup? 😄

@Dogacel
Copy link
Owner

Dogacel commented Oct 14, 2024

@Dogacel Sorry, got busy with work... we don't need this component quite yet, but we will soon. Thank you for your review comments. Why don't I re-file this week after some cleanup? 😄

Sure! Waiting for it 🙂

@Dogacel
Copy link
Owner

Dogacel commented Mar 9, 2025

@sgammon I have released a version 0.1.0 that supports editions. Can you try to upgrade your library and try to see if the generated code looks right? According to my tests, proto3 compatability should be still fine.

I don't have time to write code to cover proto2, proto2_editions, proto3_editions and editions2023. However I have added some conformance test classes and fixed a couple-bugs on the go. I am thinking about using https://github.com/dogacel/kotest-property-protobuf to test the serialization feature as well.

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.

2 participants