Add support oneOf enum key
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
Now in generated classes with oneOf field require is using for checking not null only one element.
Proto:
oneof location_oneof {
ProtoBaseStationLocation BaseStationLocationInfo = 6;
ProtoDeviceLocation DeviceLocationInfo = 7;
}
Generated code in Wire:
init {
require(countNonNull(BaseStationLocationInfo, DeviceLocationInfo) <= 1) {
"At most one of BaseStationLocationInfo, DeviceLocationInfo may be non-null"
}
}
But some servers send responses with oneOfField for choosing result as in protobuf lib. And wire failes decoding because countNotNull > 1.
Genereted code in ProtoBuf:
private int locationOneofCase_ = 0;
private java.lang.Object locationOneof_;
public enum LocationOneofCase
implements com.google.protobuf.Internal.EnumLite {
BASESTATIONLOCATIONINFO(6),
DEVICELOCATIONINFO(7),
LOCATIONONEOF_NOT_SET(0);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Wire's oneof generation and decoding logic, using the shown generated Kotlin and protobuf Java representations as the comparison. Done means Wire can decode responses containing multiple oneof fields when servers use the protobuf-style oneof case representation, without failing the non-null check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100