Equivalency: Equals/hashCode and null values
- Dominant language
- Dart
- Stars
- 572
- Forks
- 196
- Avg merge
- 1h 59m
- Merged PRs (30d)
- 2
Description
I have:
```protobuf
message MSG {
int32 a = 1
}
```
when using equals / hashCode with MSG i would expect the following to be true:
```dart
assert(MSG(a:0) == MSG());
assert(MSG(a:0).hashCode == MSG().hashCode);
```
The [protobuf message differencer](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/message_differencer.h#L124-L146) provides two comparison modes, `Equivalent` and `Equals`.
For Dart, however, I am not sure what to do to switch the generated Dart code to use the `Equivalent` mode for `equals` and `hashCode`.
I stumbled upon this issue when I had a protobuf message doing a round trip via a C++ server.
The dart code sent `MSG(a:0)` and the C++ Server responded with a message where the field `a` is not present, since the C++ protobuf code doesn't send 0 int values.
Since my Dart code heavily depends on `equals` and `hashCode` and I have several message types with several fields that could be zero which can originate from both Dart code and C++ code, I would like to solve the issue somehow in the generated code (either on C++ or Dart side).
Contributor guide
Assessment
This issue has not been assessed yet.