-
Couldn't load subscription status.
- Fork 318
Open
Labels
emitter:protobufThe protobuf emitterThe protobuf emitterfeatureNew feature or requestNew feature or requesttriaged:core
Milestone
Description
Unions are currently not supported in the protobuf emitter. There are a few challenges associated with converting unions to protobuf oneof declarations:
oneofdeclarations are inline fields of a message.oneoffields share a field index space with the message that they are declared within.oneofdeclarations must be named and must have a name for each variant of theoneof.
Possible Solution 1: Require named unions
We could aggressively limit support for oneof declarations to named union declarations in TypeSpec, and only support the following form:
union Foo {
@field(1) a: int32;
@field(2) b: string;
}
@message model Bar {
@field(1) value: Foo
}We would then emit the following:
message Foo {
oneof value {
int32 a = 1;
string b = 2;
}
}
message Bar {
Foo value = 1;
}
This seems like one of the only approaches that preserves (1) the field indices declared within the union in their own field index space, (2) the name of the field within the message Bar and (3) the field names of the union.
rhamzeh and BenjaminTitmusGMSL
Metadata
Metadata
Assignees
Labels
emitter:protobufThe protobuf emitterThe protobuf emitterfeatureNew feature or requestNew feature or requesttriaged:core