Skip to content

Conversation

@suda
Copy link

@suda suda commented Nov 25, 2025

This PR adds the option to generate the optional fields in protobuf emitter:

model Message {
  @field(1) requiredField: string;
  @field(2) optionalField?: int32;
}

With emit-optional: false (default):

message Message {
  string requiredField = 1;
  int32 optionalField = 2;
}

With emit-optional: true:

message Message {
  string requiredField = 1;
  optional int32 optionalField = 2;
}

This is another attempt to get this implemented after #4100 #4311 #4312 by @w01fgang. I tried to follow @witemple-msft
c suggestion to use the built-in optionality and added the emit-optional that defaults to the current behavior.

@suda
Copy link
Author

suda commented Nov 25, 2025

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:protobuf The protobuf emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant