-
Notifications
You must be signed in to change notification settings - Fork 101
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
Namespace extension fields #303
Namespace extension fields #303
Conversation
2a18b2b
to
d230acd
Compare
d230acd
to
48fb343
Compare
@@ -20,7 +20,7 @@ class FieldGenerator < Base | |||
attr_reader :field_options | |||
|
|||
def applicable_options | |||
@applicable_options ||= field_options.map { |k, v| ":#{k} => #{v}" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by what this is for, same with the one below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's for extension names with a dot in the middle -- wouldn't be valid ruby syntax with :foo.bar
so it has to be :"foo.bar"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't do :.string
without ruby complaining, you have to do :".string"
. Now that we are namespacing options and extensions in general, the names will include .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang it @zachmargolis beat me while I had typed out my answer but failed to press send for 20 minutes :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be to explicitly use double quotes rather than relying on inspect since it's not totally obvious. Or maybe a comment to clarify?
Sent from my iPhone
On Feb 25, 2016, at 12:44, Zach Margolis notifications@github.com wrote:
In lib/protobuf/generators/field_generator.rb:
@@ -20,7 +20,7 @@ class FieldGenerator < Base
attr_reader :field_optionsdef applicable_options
it's for extension names with a dot in the middle -- wouldn't be valid ruby syntax with :foo.bar so it has to be :"foo.bar"@applicable_options ||= field_options.map { |k, v| ":#{k} => #{v}" }
—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So:
@applicable_options ||= field_options.map { |k, v| ":\"#{k}\" => #{v}" }
?
Examples:
[1] pry(main)> sym = ".boom.foo".to_sym
=> :".boom.foo"
[2] pry(main)> puts sym.inspect
:".boom.foo"
=> nil
[3] pry(main)> puts %[:"#{sym}"]
:".boom.foo"
=> nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed with a comment.
(Not applicable to proto field names, but inspect is nice: :'boom"'.inspect #=> ":\"boom\\\"\""
)
Seems fine, confused by |
So excited for this! Should we do a bigger version bump than a patch since it may be not bavvkwards compat? |
Agreed that it is not currently backwards compatible in this case: Before:
After:
|
@embark True. It is not backward compatible. To make it backward compatible, we can store the unnamespaced extension name in the message field store (as both a string and a symbol), but it is getting a little crazy in there. The
No judgements, but, hmmmm.... yes judgements. |
@zachmargolis or @film42 thoughts on keeping it backwards compatible now with deprecated accessors, or just doing a bigger version bump? It will be so nice to support extensions with the same name in for the same message. |
@embark I think that as good software practices, it would be good make a small bump with a deprecation warning and then a big bump with the breaking change? That is sort of what was outlined in in #196: #196 (comment) |
It might be ugly, but a clean upgrade path is how we typically try to roll. We might be approaching time for a major version bump where we can cleanup a lot of the "cruft" that we've accumulated. |
e431530
to
b4e6709
Compare
b4e6709
to
5ab6bbb
Compare
5ab6bbb
to
f52b276
Compare
Hey guys so we updated the branch to be backwards compatible. The specs of the new commit show the new accessors that we allow, basically: |
yayyyyyy LGTM 👍 😎 🎉 |
🎉 🎉 🎉 🎉 🎉 |
This PR is branched off #302, so the first commit can be ignored.
cc @embark