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

Protocol buffer enum first character dropped in grpc_generator.cc #939

Closed
uwemaurer opened this issue Aug 28, 2020 · 0 comments · Fixed by #941
Closed

Protocol buffer enum first character dropped in grpc_generator.cc #939

uwemaurer opened this issue Aug 28, 2020 · 0 comments · Fixed by #941

Comments

@uwemaurer
Copy link

I noticed that in a proto file when there is no package set, then the enums are missing the first character.

syntax = "proto3";

enum Status {
    CREATED = 0;
    PROCESSING = 1;
}

message InfoResponse {
    Status status = 1;
}

will produce tatus instead of Status


export class InfoResponse extends jspb.Message {
  getStatus(): tatus;
  setStatus(value: tatus): InfoResponse;

  serializeBinary(): Uint8Array;
  toObject(includeInstance?: boolean): InfoResponse.AsObject;
  static toObject(includeInstance: boolean, msg: InfoResponse): InfoResponse.AsObject;
  static serializeBinaryToWriter(message: InfoResponse, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): InfoResponse;
  static deserializeBinaryFromReader(message: InfoResponse, reader: jspb.BinaryReader): InfoResponse;
}

export namespace InfoResponse {
  export type AsObject = {
    status: tatus,
  }
}

export enum Status { 
  CREATED = 0,
  PROCESSING = 1,
}

It can be fixed by setting a package but it worked fine with empty package with version 1.1.0

I think this change is responsible:
cd059a2#diff-2e729f9088e537bfeb6fefc318963a96

return enum_name.substr(1); instead of

if (!js_field_type.empty() && js_field_type[0] == '.') {
      js_field_type = js_field_type.substr(1);
    }
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

Successfully merging a pull request may close this issue.

1 participant