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

Correctly handle groups in FieldDescriptor.TextName #297

Merged
merged 1 commit into from
May 2, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented May 2, 2024

No description provided.

@jhump jhump requested a review from emcfarlane May 2, 2024 14:16
@jhump jhump force-pushed the jh/fix-group-text-name branch from f6814f9 to 62290ce Compare May 2, 2024 14:23
// and the message type is a sibling whose name is a mixed-case version of the field name.
return f.Kind() == protoreflect.GroupKind &&
f.Message().FullName().Parent() == f.FullName().Parent() &&
string(f.Name()) == strings.ToLower(string(f.Message().Name()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could f.Name() not be mixed case for a group? Assuming it's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be all upper-case. But the compiler requires the group name to start with a capital letter, so it is almost always mixed-case due use of PascalCase naming convention. The corresponding field name is never identical to the type name, because the type contains at least one capital letter whereas the field name is always lower-case.

@jhump jhump merged commit 3ded041 into main May 2, 2024
8 checks passed
@jhump jhump deleted the jh/fix-group-text-name branch May 2, 2024 18:02
kralicky pushed a commit to kralicky/protocompile that referenced this pull request May 19, 2024
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Jun 8, 2024
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