-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
csharp generate identifiers for extensions #5246
csharp generate identifiers for extensions #5246
Conversation
- added support for type safe identifiers to be written to c# generated file so that an object can be passed in to CustomOptions.TryGet* that is safe to the type of option being passed, so mistakes like passing the wrong extension to the function will be detected at compile time - updated c# generator to write type safe extension identifiers to an extensions namespace under the package
changed back to simple integer constant so compatibility isn't broken with the custom options api
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
Not quit understand how this change will be used as no test has been added for the usage. It looks a temp solution which should indeed work in descriptors not generated APIs. We are very serious on generated APIs because once it is published, it will be very hard to change/delete for compatibility reason. @ObsidianMinor is working on C# proto2 support and extension is one of the major work. I'd prefer a fully extension support instead of a temp solution. |
This change basically brings the c# generator up to parity with the c++ generator in terms of using your named extension identifiers to create field constants so that you can fetch them with a named variable rather than a literal integer. That make sense? |
I would think that whatever extension work that is being performed, fetching them by a readable identifier that maps to the field id would be part of it. |
It is a part of it. Making it type safe is a bigger part of it. This PR would be completely replaced by full support, so what's the point? |
My first check in was also a type safe variation but I ultimately changed it to be simpler like c++ so as not to totally break the api for existing users. I didn't know about your work or I wouldn't have bothered. Feel free to close it. |
the goal of these changes is to allow the csharp code generator to emit named constants for the extensions defined in the proto file so that fetching them in csharp code doesn't need to use literal number constants, which are error prone and not very readable