Skip to content
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

feat: Add JsonSerializable(createJsonMeta) #1164

Merged
merged 16 commits into from Jun 28, 2022

Conversation

rrousselGit
Copy link
Contributor

As discussed before, this adds an option for generating a constant Map of property name: json name

fixes #972

///
/// This constant can be used by other code-generators to support features
/// such as [fieldRename].
final bool? createJsonMeta;
Copy link
Collaborator

Choose a reason for hiding this comment

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

"meta" is pretty vague here. Maybe createFieldMap? Let's talk before you start rewriting everything...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

xFieldMap sounds good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

assert(config.createJsonMeta);

final buffer =
StringBuffer('const _\$${element.name}JsonMeta = <String, String> {');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Careful using element.name – if it's already private you'll end up with double _ which makes analyzer sad.

I have a helper around here somewhere for this"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I haven't seen another util for this

@kevmoo
Copy link
Collaborator

kevmoo commented Jun 27, 2022

still hacking on the failures @rrousselGit ?

@rrousselGit
Copy link
Contributor Author

Indeed.

I don't quite understand why the CI says generated code is outdated. It isn't for me locally

@kevmoo
Copy link
Collaborator

kevmoo commented Jun 27, 2022

@rrousselGit – need to do another rebuild. After a pub upgrade?

@rrousselGit
Copy link
Contributor Author

Looks like it's good now 😄

@kevmoo kevmoo merged commit 25c6138 into google:master Jun 28, 2022
@kevmoo
Copy link
Collaborator

kevmoo commented Jun 28, 2022

good job on this!

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.

Expose utilities to allow other code-generators to know how an object is serialized
2 participants