Skip to content

Commit

Permalink
fix fldDescriptor.TextName
Browse files Browse the repository at this point in the history
  • Loading branch information
jhump committed May 2, 2024
1 parent 5ff9915 commit f6814f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions linker/descriptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,10 @@ func (f *fldDescriptor) TextName() string {
if f.IsExtension() {
return fmt.Sprintf("[%s]", f.FullName())
}
if f.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP {
// proto2 groups (that aren't extensions) use the type name
return string(protoreflect.FullName(f.proto.GetTypeName()).Name())
}
return string(f.Name())
}

Expand Down
1 change: 1 addition & 0 deletions linker/descriptors_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func checkAttributesInFields(t *testing.T, exp, actual protoreflect.ExtensionDes
assert.Equal(t, expFld.IsList(), actFld.IsList(), "%s: field is list at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.IsMap(), actFld.IsMap(), "%s: field is map at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.JSONName(), actFld.JSONName(), "%s: field json name at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.TextName(), actFld.TextName(), "%s: field text name at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.HasJSONName(), actFld.HasJSONName(), "%s: field has json name at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.IsExtension(), actFld.IsExtension(), "%s: field is extension at index %d (%s)", where, i, expFld.Name())
assert.Equal(t, expFld.IsPacked(), actFld.IsPacked(), "%s: field is packed at index %d (%s)", where, i, expFld.Name())
Expand Down

0 comments on commit f6814f9

Please sign in to comment.