Skip to content

Null message fields should not be instantiated #309

@darioielardi

Description

@darioielardi

Given, for example, the following proto definitions:

message Address {
  string street = 1;
}

message User {
  Address address = 1;
}

the current behavior, when decoding an incoming User message, is to initialize the Address generated class even if the field is unset, filling it with empty ( zero ) values, which should not happen.

This is crucial for a variety of situations, for example using value wrappers, which are Protobuf Well-Known Types and represents the Google solutions to distinct a scalar field zero value from its default value. This is actually not possible with the current dart implementation, because the wrapper generated class is instantiated anyway and the inner value becomes a zero value.

Also, I think this is what was referred in #245.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions