-
Notifications
You must be signed in to change notification settings - Fork 150
feat: add full_name callback to proto messages #409
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
base: main
Are you sure you want to change the base?
Conversation
It seems that syntax = "proto3";
package demo.v1;
import "google/protobuf/any.proto";
message Example {
message NestedFirstLevel {
message NestedSecondLevel {}
NestedSecondLevel nested_second = 1;
}
enum NestedTypes {
TYPE_UNSPECIFIED = 0;
TYPE_ONE = 1;
TYPE_TWO = 2;
}
NestedFirstLevel nested_first = 1;
NestedTypes type = 2;
}
enum TopLevelEnum {
TOP_LEVEL_UNSPECIFIED = 0;
TOP_LEVEL_ONE = 1;
TOP_LEVEL_TWO = 2;
}
message Integration {
google.protobuf.Any data = 1;
}
package demo__test
import (
"fmt"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/reflect/protoreflect"
"testing"
demov1 "demo/gen/pb/demo/v1"
)
func TestName(t *testing.T) {
nestedFirstNestedSecond := &demov1.Example_NestedFirstLevel_NestedSecondLevel{}
nestedFirst := &demov1.Example_NestedFirstLevel{NestedSecond: nestedFirstNestedSecond}
example := demov1.Example{NestedFirst: nestedFirst}
exampleName := fullName(&example)
fmt.Printf("%v", exampleName)
nestedFirstName := fullName(example.GetNestedFirst())
nestedFirstNameTop := fullName(nestedFirst)
fmt.Printf("%v --- %v", nestedFirstName, nestedFirstNameTop)
assert.Equal(t, nestedFirstName, nestedFirstNameTop)
nestedFirstNestedSecondName := fullName(example.GetNestedFirst().GetNestedSecond())
nestedFirstNestedSecondNameTop := fullName(nestedFirstNestedSecond)
fmt.Printf("%v --- %v", nestedFirstNestedSecondName, nestedFirstNestedSecondNameTop)
assert.Equal(t, nestedFirstNestedSecondName, nestedFirstNestedSecondNameTop)
}
func fullName(msg protoreflect.ProtoMessage) protoreflect.FullName {
return msg.ProtoReflect().Descriptor().FullName()
} |
c828171
to
9c3504b
Compare
@whatyouhide @v0idpwn I think it is ready to code review, at least adding the fallback to follow up on |
5acfd35
to
ffe23ba
Compare
As far as I can tell |
What in the world is that 🤔 |
Mh yeah, I have very vague memories of this but no notes on it, sorry 😭 I don't really have cycles to look into this now :( |
closes #408