-
Notifications
You must be signed in to change notification settings - Fork 229
Alternative solution for: Fix double nested naming #21
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
Conversation
Trying to add a test for this in proto file as above (filename: syntax = "proto3";
message Test {
message Parent {
message RootParentChild {
string a = 1;
}
enum EnumChild{
A = 0;
B = 1;
}
message Child {
string foo = 1;
}
reserved 1;
repeated Child child = 2;
repeated EnumChild enumChild=3;
repeated RootParentChild rootParentChild=4;
bool bar = 5;
}
string name = 1;
Parent parent = 2;
} json file (filename: {
"name": "double-nested",
"parent": {
"child": [{"foo": "hello"}],
"enumChild": ["A"],
"rootParentChild": [{"a": "hello"}],
"bar": true
}
} Can you add this to your branch? |
Yes I will, thank you very much for picking this up. Is it okay if I rename RootParentChild to TestParentChild? I added it originally because I wanted to test the case where the parent names were already a prefix of the child name. |
Might not be a good idea; if it results in a class being generated under the tests directory with a name that starts or ends with |
@nat-n Should we then not name the enclosing message Test at all? As the concatenation of nested message names will mean that all messages will be prefixed with Test? |
@adament indeed. Seems kinda redundant to name test fixtures "Test*" coming to think of it. Root seems to be like a good name. |
Looking a bit closer at the test framework, the test generator in generate.py assumes that the test message is named Test. If this should be changed, I think it should be a separate changeset. |
@adament ah, so it does. I agree it's beyond the scope of this change to fix. I guess it's not really a problem so long as none of the generated classes happen to include an |
I think I may have caused some confusion, I apologize folks. I did not intend to replace Root with Test, I actually should have put everything including Root inside the Test message, because the Test message is just a container that the test framework recognizes as a target |
This is an alternative solution to #17 than #18. This fixes the double naming issue, even if the prefix is already a prefix of the child name. All credit should go to @cetanu for identifying and tracking down the problem.
Test case: