-
Notifications
You must be signed in to change notification settings - Fork 412
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
Conversation
@@ -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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need Iterable.followedBy :)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why toList()?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
No description provided.