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

Old PR redux: helpers for common .Serialization.cs patterns, header cleanup #113

Merged
merged 1 commit into from
May 22, 2024

Conversation

trrwilson
Copy link
Collaborator

This PR is a contemporary followup to the earlier one -- better now that we're fully aligned with a codegen base:
#48

The helper still brings some utility in centralizing logic and eliminating duplication in the custom layer.

It also opportunistically fixes a lot of ugly copy/paste header errors in the Assistants folder.

To rehash the helper PR (longer description there):

  • Custom classes should implement an internal static Foo DeserializeFoo(JsonElement, ModelReaderWriterOptions) (as before)
  • Now, they should also implement a matching internal static void SerializeFoo(Foo, Utf8JsonWriter, options)
  • All of the IJsonModel<Foo> implementations can then just defer to the CustomSerializationHelpers methods, allowing everything but the serialize/deserialize methods to be one trivial line
  • The helpers also centralize format/error checking and other repeated patterns, reducing overall line count and "noise"

@trrwilson trrwilson merged commit 6623671 into main May 22, 2024
1 check passed
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.

1 participant