Ruby deprecated descriptors should throw ruby warnings
#2.275 aberto em 20 de out. de 2016
Métricas do repositório
- Stars
- (71.223 stars)
- Métricas de merge de PR
- (Mesclagem média 2d 11h) (185 fundiu PRs em 30d)
Description
To keep things backwards compatible and follow semver.org when working with our protobufs, we would like to be able to use the deprecated option: int32 old_field = 3 [deprecated=true];
This would be great if it notified the downstream consumer that the field had been deprecated. As is standard practice in ruby, this is typically done with a warning.
https://ruby-doc.org/core-2.2.0/Kernel.html#method-i-warn
This could be done simply by outputing:
warn("DEPRECATION WARNING: Field #{field_name} for message #{message_name} is deprecated, consider removing references to it")
If this is output then when one of our downstream clients upgrades to a new minor version, their code will work but will include warnings that warn about the now deprecated fields in use. If they don't reference (get or set) the field or other descriptor type, then they will get no warnings. Providing descriptor name and as much detail as possible will help the user debug their code and remove the deprecated fields.
Currently the approach is to either reserve or rename the field. This works until they update their schema, then it will start failing. This keeps the data message backwards compatible but not the generated code. Adding the deprecation warning will assist in this manner.