-
Notifications
You must be signed in to change notification settings - Fork 412
Support nullable
on class annotation, and other cleanup
#61
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
I want to do 2 more flavors of changes on top of the |
final bool includeIfNull; | ||
|
||
/// `true` if the generator should validate all values for `null` in |
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.
These comments are a bit confusing to me, maybe just change validate
/verification
to check
/checks
? Currently it sounds like its validating that things are null or something, I don't really understand it :).
Same goes for other similar comments below.
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.
yup
/// | ||
/// Setting to `false` eliminates `null` verification in generated code, but | ||
/// does not prevent `null` values from being created. Annotated classes | ||
/// must implement their own `null` validation. |
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.
... , otherwise you may get runtime errors.
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.
Did a rewrite. PTAL
Map _defaultMap() => {}; | ||
|
||
@JsonSerializable(nullable: false) | ||
class KitchenSinkNullable extends Object |
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.
Isn't this really a KitchenSinkNonNullable
?
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.
Yup. PTAL
@@ -143,15 +146,16 @@ class JsonSerializableGenerator | |||
buffer.writeln(' ${field.type} get ${field.name};'); | |||
} | |||
|
|||
var includeIfNull = annotation.read('includeIfNull').boolValue; | |||
var classIncludeIfNull = annotation.read('includeIfNull').boolValue; |
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 am not a huge fan of passing this around everywhere, it might make more sense to read the JsonKey
annotations upfront and fill in defaults, so you can just pass a single configuration object around? Maybe a class that wraps up a FieldElement
and a JsonKey
?
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.
Done...a bit... At least for the class annotation
json_annotation: fix doc comments
114945a
to
f9c2c8e
Compare
No description provided.