google / google/protobuf.dart

Mixins need to enforce read-only behavior for default instance

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

Description

For each protobuf class there is a default instance, which should be read-only. Mixins may add extra fields and a way to set them. Any mixin with a setter should throw an exception if the instance is read-only.

Currently the _isReadOnly getter is private. We should make it public. In the meantime, a mixin can implement the check like this:

```
if (this is ReadonlyMessageMixin) {
throw new UnsupportedError(
"attempted to set on a read-only message (${info_.messageName})");
}
```

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.