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

Prevent conflicts from same name options of different types #3005

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

oldergod
Copy link
Member

No description provided.

@oldergod oldergod force-pushed the bquenaudon.2024-06-24.optionconflict branch 2 times, most recently from 6142266 to 3cf6efb Compare June 25, 2024 10:47
ClassName annotationName =
annotationName(protoFile, field, new ClassNameFactory(), "Option");
if (memberToJavaName.containsValue(annotationName)) {
// To avoid conflicts for same named options on different types, we generate a more
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
// To avoid conflicts for same named options on different types, we generate a more
// To avoid conflicts for same named options of different types, we generate a more

memberToKotlinName[protoMember] = annotationName(protoFile, field, ClassNameFactory())
val annotationName = annotationName(protoFile, field, ClassNameFactory())
if (memberToKotlinName.containsValue(annotationName)) {
// To avoid conflicts for same named options on different types, we generate a more
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
// To avoid conflicts for same named options on different types, we generate a more
// To avoid conflicts for same named options of different types, we generate a more

ClassName annotationName =
annotationName(protoFile, field, new ClassNameFactory(), "Option");
if (memberToJavaName.containsValue(annotationName)) {
// To avoid conflicts for same named options on different types, we generate a more
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible for us to always pick suffix based on the option type, so that all message options will be named XxxMessageOption and all field names - XxxFieldOption?

Copy link
Member Author

Choose a reason for hiding this comment

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

That'd be the ideal solution but the feature has already shipped and we'll be breaking all clients with this change 😢
So we decided to do that only when conflicts arise.

protoFile,
field,
new ClassNameFactory(),
extendSimpleName.substring(0, extendSimpleName.length() - 1)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will extendSimpleName here always have the value FieldOptions, or it can also have the value MessageOptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can be any option type, FieldOption, MessageOption, EnumValueOption, etc. This is how we avoid the conflict

@oldergod oldergod force-pushed the bquenaudon.2024-06-24.optionconflict branch from 3cf6efb to 046a14e Compare June 27, 2024 12:04
@oldergod oldergod merged commit 31d0e07 into master Jun 28, 2024
11 checks passed
@oldergod oldergod deleted the bquenaudon.2024-06-24.optionconflict branch June 28, 2024 09:18
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.

None yet

2 participants