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

parsing an extension isn't working properly #15

Closed
mwildehahn opened this issue Dec 20, 2014 · 2 comments
Closed

parsing an extension isn't working properly #15

mwildehahn opened this issue Dec 20, 2014 · 2 comments
Assignees
Labels

Comments

@mwildehahn
Copy link

i have something like the following proto structure:

// file: soa.proto

message ActionResponse {
    optional bool success = 1 [default = false];
    extensions 100 to max;
}
message Response {
    repeated ActionResponse actions = 1;
}

in another file i register these extensions:

// file: response_registry.proto
message UserServiceResponses {
    extend soa.ActionResponse {
        optional actions.AuthenticateUser.Response authenticate_user = 101;
    }
}

to parse the message properly I had to muck with the compiler to make all of the extensionRegistry variables public and then do:

let response = Response.parseFromNSData(data!, extensionRegistry: ResponseRegistryRoot.sharedInstance.extensionRegistry)

i think the issue is that the extensionRegistry gets instantiated for each root object, so the extensionRegistry attached to Response doesn't have any knowledge of the extensions added within response_registry.proto file.

is there something I'm missing?

it seems like either the extensionRegistry should be public and you should be able to parse with whatever extensionRegistry you want, or you have a single extensionRegistry instance so you don't have this issue.

I saw there was a //TODO marked above extensionRegistry, so not sure if this is just something you haven't gotten to yet.

@alexeyxo alexeyxo added the bug label Dec 21, 2014
@alexeyxo alexeyxo self-assigned this Dec 21, 2014
@mwildehahn mwildehahn reopened this Dec 21, 2014
@mwildehahn
Copy link
Author

let me know if you want any help with this.

mwildehahn added a commit to mwildehahn/protobuf-swift that referenced this issue Dec 21, 2014
alexeyxo added a commit that referenced this issue Dec 22, 2014
@alexeyxo
Copy link
Owner

Thanks a lot!

alexeyxo added a commit that referenced this issue Dec 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants