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

Custom options in dlang #5700

Closed
deviator opened this issue Feb 8, 2019 · 1 comment
Closed

Custom options in dlang #5700

deviator opened this issue Feb 8, 2019 · 1 comment
Assignees
Labels

Comments

@deviator
Copy link

deviator commented Feb 8, 2019

I try to improve D language plugin dcarp/protobuf-d#14.
I have simple file for testing:

syntax = "proto3";
package msg;

import "google/protobuf/descriptor.proto";

enum DMessageType {
    CLASS = 0;
    STRUCT = 1;
}

extend google.protobuf.MessageOptions {
    DMessageType d_message_type = 2022;
}

message OneData {
    option (d_message_type) = STRUCT;
    bool input = 1;
}

In plugin source code I add output for study and get this output:

{
    "dependencies": [
        "google\/protobuf\/descriptor.proto"
    ],
    "enumTypes": [
        {
            "name": "DMessageType",
            "values": [
                {
                    "name": "CLASS"
                },
                {
                    "name": "STRUCT",
                    "number": 1
                }
            ]
        }
    ],
    "extensions": [
        {
            "extendee": ".google.protobuf.MessageOptions",
            "jsonName": "dMessageType",
            "label": 1,
            "name": "d_message_type",
            "number": 2022,
            "oneofIndex": -1,
            "type": 14,
            "typeName": ".msg.DMessageType"
        }
    ],
    "messageTypes": [
        {
            "fields": [
                {
                    "jsonName": "input",
                    "label": 1,
                    "name": "input",
                    "number": 1,
                    "oneofIndex": -1,
                    "type": 8
                }
            ],
            "name": "OneData",
            "options": null // < here no custom options
        }
    ],
    "name": "msg\/one.proto",
    "package_": "msg",
    "syntax": "proto3"
}

Extension is parsed by protoc (check type too) but don't send information about it to plugin input (options field never contains custom options, only standard if added). Why?

This problem repeats for FileOptions too: array of options contains only standard options like javaPackage and other, but no custom options. What I do wrong?

@BSBandme BSBandme self-assigned this Feb 20, 2019
@BSBandme
Copy link
Contributor

I'm not sure about the reason but I think protoc didn't link with the generated code that has your custom option.

I think one way for resolving the problem is rebuilding protoc linked with your generated code that generated by old protoc.

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