Skip to content

Better error unknown #16

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 6 commits into from
Jul 20, 2017
Merged

Better error unknown #16

merged 6 commits into from
Jul 20, 2017

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Jul 20, 2017

No description provided.

@kevmoo kevmoo requested a review from natebosch July 20, 2017 19:18
@@ -58,6 +58,17 @@ class JsonSerializableGenerator
// TODO: support overriding the field set with an annotation option
var fieldsList = classElement.fields.where((e) => !e.isStatic).toList();

var undefinedFields =
fieldsList.where((fe) => fe.type.isUndefined).toList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need toList?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate reiterating iterables – even trivially. Can have unintended perf and behavior affects.

So I just never do it.

@@ -151,6 +162,19 @@ class JsonSerializableGenerator
fieldsToSet.remove(arg.name);
}

var undefinedArgs = [ctorArguments, ctorNamedArguments]
.expand((l) => l)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need Iterable.followedBy :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed!

var undefinedArgs = [ctorArguments, ctorNamedArguments]
.expand((l) => l)
.where((pe) => pe.type.isUndefined)
.toList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why toList()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -296,15 +320,17 @@ class JsonSerializableGenerator
{ParameterElement ctorParam}) {
name = _fieldToJsonMapKey(name, field);
var result = "json['$name']";
return _writeAccessToJsonValue(result, field.type, ctorParam: ctorParam);
DartType targetType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] var targetType = ctorParam?.type ?? field.type; or var targetType = (ctorParam ?? field).type;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants