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

System.Text.Json Serialization Support in .NET SDK Objects #3033

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jar-stripe
Copy link
Contributor

@jar-stripe jar-stripe commented Nov 27, 2024

Why?

Users reported in #2495 and #1979 that Stripe.net objects did not behave as expected when serialized using System.Text.Json. System.Text.Json has become the standard for modern .NET, and the Stripe.net SDK objects should support serializing using it.

What?

  • Added System.Text.Json attributes for each property in the Stripe Entity and Options types.
  • Added Wholesome tests to verify that each type has the correct properties
  • Implemented System.Text.Json converters for AnyOf, ExpandableField, StripeObject, and UnixDateTime
  • Implemented System.Text.Json custom converter for IEnumerable (for StripeList and StripeSearchResult)

modified PropertiesHaveJsonAttributes to check for equivalent STJ attributes
…son attributes

added json converters for system text json to ensure we conform to our API and existing SDK behavior
migrated manually managed files
updated wholesome tests for better reporting
added NewtonsoftAndSystemTextJsonOutputTheSameObject wholesome test, to ensure all stripe entities serialize the same through json.net and system text json

added STJEnumerableObjectConverter because STJ serializes IEnumerable implementations as arrays and not objects
added test to verify that enumerable item types have the proper STJ converters
updated wholesome tests
@jar-stripe jar-stripe changed the title Jar/coexist system text json System.Text.Json Serialization Support in .NET SDK Objects Nov 27, 2024
@jar-stripe jar-stripe marked this pull request as ready for review November 27, 2024 00:09
@jar-stripe jar-stripe requested review from pakrym-stripe, a team, xavdid-stripe and prathmesh-stripe and removed request for a team and xavdid-stripe November 27, 2024 00:10
@jar-stripe
Copy link
Contributor Author

The build failure is not expected, and appears to be due to a significant difference between .NET 6 and .NET 8.

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