google / google/built_value.dart

[Bug] Code Generation Attempt Unintendedly Triggered

Open
#1,303 3 comments 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
p2 / bug
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

Given the abstract class (as well as a mixin version of the code) any sub-classes seem to trigger code generation attempts. However, I'm creating a wrapper class that consumes Built generated classes. This seems like buggy behavior. Either that, or it highlights the need for some kind of `@built_ignore()` annotation.

``` dart
abstract class BuiltJsonSerializable,
V extends Builder> {
Serializer get serializer;

Map toJsonMap() => jsonDecode(toJsonString());

String toJsonString() => standardSerializers.toJson(serializer, toModel());

T? toModel();

T? modelFromJsonString(String serialized) {
try {
T? model = standardSerializers.fromJson(serializer, serialized);
return model;
} on DeserializationError catch (e) {
Get.log('[${T.toString()} DESERIALIZATION ERROR] ${e.toString()}');
return null;
}
}
}
```

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.