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

Support looking up enum values by string #948

Closed
bruwozniak opened this issue Feb 6, 2020 · 1 comment
Closed

Support looking up enum values by string #948

bruwozniak opened this issue Feb 6, 2020 · 1 comment

Comments

@bruwozniak
Copy link

bruwozniak commented Feb 6, 2020

It would be handy in some cases to be able to assign enum fields with values matching some string. In fact, this functionality already exists, but it is internal to the package and so can't be accessed when using the generated code.
See: https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/NameMap.swift#L271

There's already a TODO comment about this, see:
https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/NameMap.swift#L11

Right now the only way I've found to do it, is MyMessage(textFormatString: "category: \(categoryString)").category which is clearly sub-optimal.

@thomasvl
Copy link
Collaborator

thomasvl commented Feb 6, 2020

I believe this is a duplicate of #326.

Going the other way is #731.

@thomasvl thomasvl closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants