yeqown / protoc-gen-fieldmask

Generate FieldMask utility functions for protobuf
MIT License
34 stars 9 forks source link

Generating filter and prune functions with actual field name prefix would be more natural #9

Closed vaidasn closed 2 years ago

vaidasn commented 2 years ago

Currently functions with fixed names FieldMask_Filter and FieldMask_Prune are generated for a FieldMask field. However it would be more natural to generate functions that start with actual field name prefix instead of fixed FieldMask. Further on the function FieldMaskWithMode could follow the same pattern.

Example proto file:

syntax = "proto3";

import "google/protobuf/field_mask.proto";
import "fieldmask/option.proto";

message UserInfoRequest {
  string user_id = 1;
  google.protobuf.FieldMask read_mask = 2 [
    (fieldmask.option.Option).in = {gen: true},
    (fieldmask.option.Option).out = {gen: true, message:"UserInfoResponse"}
  ];
}

message Address {
  string country = 1;
  string province = 2;
}

message UserInfoResponse {
  string user_id = 1;
  string name = 2;
  string email = 3;
  Address address = 4;
}

could generate functions ReadMask_Filter, ReadMask_Prune, and ReadMask_WithMode