protobuf
protobuf copied to clipboard
Only rename size fields if sizer is enabled.
The Size method is only created if the sizer plugin is enabled, and other parts of the codebase seem to handle this case. The helpers here were assuming that either Size or ProtoSize exists, which is not true, especially if the base message was generated with the google golang plugin.
Could you add a test that shows how it broke before this change? So that we don't regress in future.
hello?
I would like to volunteer my help in getting this merged. This is a necessary change for our continued use of the library. What sort of test are you looking for? Is there an existing example exercising another feature that might work as a basis? Essentially what the test(s) would do is ensure there is no Size
and GetSize()
created when sizer
is not used.
Hi, Thanks for volunteering.
I didn't look at this issue initially, but correct me if I am wrong. I think the issue is we assume we are generating a Size() method, even without enabling the gogo-option.
This means we will always substitute fields Size -> Size_
.
Is there an existing example exercising another feature that might work as a basis? What sort of test are you looking for?
Here an example of tests involving Size
and ProtoSize
.
You could create a similar tests and assert the resulting structure has the expected methods/fields with the combination of the sizer_all
,protosizer_all
, no size options?
That would assert that the generation of the structs are as expected with the relevant size options?
Essentially what the test(s) would do is ensure there is no Size and GetSize() created when sizer is not used. Yeh
does it possible to not modify struct member Size to Size_ ?i need to expose this member as-is with name Size.
Anyone can fix it? I need this too.
option (gogoproto.protosizer_all) = true;
option (gogoproto.sizer_all) = false;
No matter, enable protosizer and disable sizer works for me.