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

chore: update protobuf to latest #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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!

@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?

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 🙂

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