-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Problem with reflection for methods with many enums #323
Comments
I think this comes down to name collisions; we should add a mode that optionally includes the enum name as a prefix in all enum names (including zero), so we generate TokenType_Zero, TokenType_Temporary, etc unrelated: you might want to look at https://protobuf-net.github.io/protobuf-net/compatibilitylevel re the data and guid |
Thank you for your answer. Currently, I'll try to change ordering of elements starting from 0. Is it possible in future releases to change enum members generation style? Because the same collision can be in cases when 2 enums contain elements with same names. |
Yes, that is what I was proposing - sorry if that was unclear. |
Thank you! I'll wait for new release))) |
Why is this closed? |
Sorry, my bad. |
I encountered this issue as well. To work around it globally for now I am using: // model can be any or the default ProtoBuf.Meta.RuntimeTypeModel.Default;
model.AfterApplyDefaultBehaviour += ( obj, evt ) => {
if ( evt.Type.IsEnum
&& evt.MetaType.GetEnumValues().None( static v => v.Value is 0 )
&& evt.MetaType.GetEnumValues().FirstOrDefault().Value switch {
long => false,
ulong => false,
uint => false,
_ => true
} ) {
evt.MetaType.SetEnumValues( [ new EnumMember( ( byte )0, $"{evt.MetaType.GetSchemaTypeName()}__ZERO__DOES_NOT_EXIST" ), ..evt.MetaType.GetEnumValues() ] );
}
}; |
Hello, Marc.
I try to use reflection in my project, but got problem with enums.
I have service with request record:
The proto file was generated:
So, when I try to use command docker run fullstorydev/grpcurl -plaintext -use-reflection 172.23.17.107:50029 describe SharedInterfaces.TokenService.SecurityInterfaces.Token.TokenGeneration
I got a message
Failed to resolve symbol "SharedInterfaces.TokenService.SecurityInterfaces.Token.TokenGeneration": proto: descriptor "SharedInterfaces.TokenService.SecurityInterfaces.Token.ZERO" already declared
I've tried to find solution in the internet/SO/tg chats, but without any success. Could you help me to fix this problem? Or is there no way just only change enum elements order starting not from 1, but from 0?
The text was updated successfully, but these errors were encountered: