Skip to content

Commit ee74ab3

Browse files
authored
cleanup(test): remove unneeded convert functions for build_config enum (#226)
1 parent 26e7a32 commit ee74ab3

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

json_serializable/test/yaml/build_config.dart

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Builder extends Object with _$BuilderSerializerMixin {
3636
fromJson: _autoApplyFromJson)
3737
final AutoApply autoApply;
3838

39-
@JsonKey(name: 'build_to', toJson: _buildToToJson, fromJson: _buildToFromJson)
39+
@JsonKey(name: 'build_to')
4040
final BuildTo buildTo;
4141

4242
final AutoApply defaultEnumTest;
@@ -84,12 +84,6 @@ AutoApply _autoApplyFromJson(String input) =>
8484
String _autoApplyToJson(AutoApply value) =>
8585
_toJson(value, _autoApplyConvert, 'autoApply');
8686

87-
BuildTo _buildToFromJson(String input) =>
88-
_fromJson(input, _buildToConvert, 'buildTo');
89-
90-
String _buildToToJson(BuildTo value) =>
91-
_toJson(value, _buildToConvert, 'buildTo');
92-
9387
// TODO: remove all of this and annotate the fields on the enum – once we have
9488
// https://github.com/dart-lang/json_serializable/issues/38
9589
T _fromJson<T>(String input, Map<String, T> convertMap, String fieldName) {
@@ -122,8 +116,3 @@ const _autoApplyConvert = const {
122116
'all_packages': AutoApply.allPackages,
123117
'root_package': AutoApply.rootPackage
124118
};
125-
126-
const _buildToConvert = const {
127-
'cache': BuildTo.cache,
128-
'source': BuildTo.source,
129-
};

json_serializable/test/yaml/build_config.g.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Builder _$BuilderFromJson(Map json) {
5151
autoApply: $checkedConvert(json, 'auto_apply',
5252
(v) => v == null ? null : _autoApplyFromJson(v as String)),
5353
buildTo: $checkedConvert(json, 'build_to',
54-
(v) => v == null ? null : _buildToFromJson(v as String)),
54+
(v) => $enumDecodeNullable('BuildTo', BuildTo.values, v as String)),
5555
defaultEnumTest: $checkedConvert(
5656
json,
5757
'defaultEnumTest',
@@ -105,7 +105,7 @@ abstract class _$BuilderSerializerMixin {
105105
writeNotNull('is_optional', isOptional);
106106
writeNotNull(
107107
'auto_apply', autoApply == null ? null : _autoApplyToJson(autoApply));
108-
writeNotNull('build_to', buildTo == null ? null : _buildToToJson(buildTo));
108+
writeNotNull('build_to', buildTo?.toString()?.split('.')?.last);
109109
writeNotNull(
110110
'defaultEnumTest', defaultEnumTest?.toString()?.split('.')?.last);
111111
val['builder_factories'] = builderFactories;

0 commit comments

Comments
 (0)