Skip to content

Support for setters and getters insertion points #2684

Closed
@dopuskh3

Description

@dopuskh3

Adding insertion points in various field modifier could help extending generated classes with additional logic in those.

I think about implementing nullable support by using these insertion points the following way:

I will create a protobuf plugin that does the following:

  • when a specific option is present on a message (say 'allowNullableFields') then the plugin looks for a map[int]->bool map.
  • If the map exists then insert code that set value to true for the corresponding field ID in the map in various setters scopes.
  • If the map does not exists then the protobuf plugin fail compiling the corresponding schema.
  • Also the plugin will generate a hasXXX method for each of the field that will simply look for the field id in the map an return true if the corresponding value is set to true.

Sounds like a less intrusive approach to solve issue #1606 but still requires additional insertion points.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @dopuskh3@xfxyjwf@iamneal

      Issue actions

        Support for setters and getters insertion points · Issue #2684 · protocolbuffers/protobuf