google / google/protobuf.dart

protoc_plugin does not test dart_name extension handling

Open
#607 2 comments 0 reactions 0 assignees View on GitHub
testing
Dominant language
Dart
Stars
572
Forks
196
Avg merge
1h 59m
Merged PRs (30d)
2

Description

https://github.com/google/protobuf.dart/blob/8792f2aca21c087e9c061cb40aaa88af3cc6c3e4/protoc_plugin/lib/names.dart#L457-L458

The line above handles [`dart_name` extension][1] and it's currently not tested in protoc_plugin tests. I can change that line to

```dart
var name = _nameOption(field);
if (name.isNotEmpty) {
assert(false);
}
```

and I can still compile all of the protos used in the tests to Dart and all tests pass.

Not too important, but conversion of names to snake_case and then back during serialization seems quite delicate, and we have a few attributes/properties related to names of fields (`dart_name`, `json_name`). It would be good if we had good coverage here so that (1) code could be refactored without breakage (2) I could look at the tests for the intended behavior when the code gets tricky.

[1]: https://github.com/google/protobuf.dart/blob/8792f2aca21c087e9c061cb40aaa88af3cc6c3e4/protoc_plugin/protos/dart_options.proto#L76-L78

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.