Skip to content

Default values missing #5

Open
Open
@Ni42

Description

@Ni42

Per this documentation: https://developers.google.com/protocol-buffers/docs/proto3#default fields are supposed to return their default value even if the parsed proto doesn't contain that value. Right now, I have to manually check for hasField() and implement the default value myself.

For example, check out FortType in this proto:
https://github.com/AeonLucid/POGOProtos/blob/master/src/POGOProtos/Map/Fort/FortData.proto
For FortType::GYM (0), my FortData proto doesn't contain any value on type, so getType() will return null, instead it should return FortType::GYM() (the first defined enum value).

Same thing for "owned_by_team": if it's 0, my proto doesn't contain data, and I have to manually check for hasOwnedbyTeam() and then assume 0 if it's missing, instead of just doing getOwnedByTeam()->value().

I shouldn't have to do this work myself judging from the specs.
Same thing applies to proto2: https://developers.google.com/protocol-buffers/docs/proto#optional

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions