Skip to content
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

Stop generating has and clear for repeated extension fields #944

Closed
thomasvl opened this issue Jan 29, 2020 · 0 comments
Closed

Stop generating has and clear for repeated extension fields #944

thomasvl opened this issue Jan 29, 2020 · 0 comments

Comments

@thomasvl
Copy link
Collaborator

Currently a has and clear method is generated for each property we create for extension fields. But for repeated fields, that's sorta pointless. It makes more sense to treat them like normal message fields, and just let folks use isEmpty and assignment to the empty list for these.

While they should strip away if not used, the problem is the file is generated with visibility public then the code likely comes along and lives in the final framework or binary (SR-521, SR-1021).

To transition to this, we could generated the current ones, but tag them with Swift's @available to tag the current ones as deprecated and then eventually drop them.

thomasvl added a commit to thomasvl/swift-protobuf that referenced this issue Feb 28, 2020
Setting a repeated extension field to an empty array would result it that value
being stored, so has* came back at true even though there was nothing to include
in binary serialization.

In addition to fixing that bug be behavior, this clears the way for eventually
deprecating/removing the generation of has*/clear* for repeated extension
properties.

Progress on apple#944
thomasvl added a commit that referenced this issue Feb 28, 2020
Setting a repeated extension field to an empty array would result it that value
being stored, so has* came back at true even though there was nothing to include
in binary serialization.

In addition to fixing that bug be behavior, this clears the way for eventually
deprecating/removing the generation of has*/clear* for repeated extension
properties.

Progress on #944
thomasvl added a commit to thomasvl/swift-protobuf that referenced this issue Mar 7, 2022
thomasvl added a commit to thomasvl/swift-protobuf that referenced this issue Mar 7, 2022
The presence can be checked with `isEmpty`on the Array, and they can be cleared
by assigning to `[]`.

Fixes apple#944
Helps with apple#1204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant