Skip to content

cleanup(test): remove unneeded convert functions for build_config enum #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions json_serializable/test/yaml/build_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Builder extends Object with _$BuilderSerializerMixin {
fromJson: _autoApplyFromJson)
final AutoApply autoApply;

@JsonKey(name: 'build_to', toJson: _buildToToJson, fromJson: _buildToFromJson)
@JsonKey(name: 'build_to')
final BuildTo buildTo;

final AutoApply defaultEnumTest;
Expand Down Expand Up @@ -84,12 +84,6 @@ AutoApply _autoApplyFromJson(String input) =>
String _autoApplyToJson(AutoApply value) =>
_toJson(value, _autoApplyConvert, 'autoApply');

BuildTo _buildToFromJson(String input) =>
_fromJson(input, _buildToConvert, 'buildTo');

String _buildToToJson(BuildTo value) =>
_toJson(value, _buildToConvert, 'buildTo');

// TODO: remove all of this and annotate the fields on the enum – once we have
// https://github.com/dart-lang/json_serializable/issues/38
T _fromJson<T>(String input, Map<String, T> convertMap, String fieldName) {
Expand Down Expand Up @@ -122,8 +116,3 @@ const _autoApplyConvert = const {
'all_packages': AutoApply.allPackages,
'root_package': AutoApply.rootPackage
};

const _buildToConvert = const {
'cache': BuildTo.cache,
'source': BuildTo.source,
};
4 changes: 2 additions & 2 deletions json_serializable/test/yaml/build_config.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Builder _$BuilderFromJson(Map json) {
autoApply: $checkedConvert(json, 'auto_apply',
(v) => v == null ? null : _autoApplyFromJson(v as String)),
buildTo: $checkedConvert(json, 'build_to',
(v) => v == null ? null : _buildToFromJson(v as String)),
(v) => $enumDecodeNullable('BuildTo', BuildTo.values, v as String)),
defaultEnumTest: $checkedConvert(
json,
'defaultEnumTest',
Expand Down Expand Up @@ -105,7 +105,7 @@ abstract class _$BuilderSerializerMixin {
writeNotNull('is_optional', isOptional);
writeNotNull(
'auto_apply', autoApply == null ? null : _autoApplyToJson(autoApply));
writeNotNull('build_to', buildTo == null ? null : _buildToToJson(buildTo));
writeNotNull('build_to', buildTo?.toString()?.split('.')?.last);
writeNotNull(
'defaultEnumTest', defaultEnumTest?.toString()?.split('.')?.last);
val['builder_factories'] = builderFactories;
Expand Down