Migrate core deserialization and default JSON library to System.Text.Json#3327
Merged
jar-stripe merged 5 commits intomasterfrom Mar 19, 2026
Merged
Migrate core deserialization and default JSON library to System.Text.Json#3327jar-stripe merged 5 commits intomasterfrom
jar-stripe merged 5 commits intomasterfrom
Conversation
Contributor
Author
|
@mbroshi-stripe I'm working to rebuild the commit history so this is less insane to review |
…hanges System.Text.Json migration for stripe-dotnet. This commit contains all hand-written (non-generated) changes: - Add STJ package references and multi-TFM support - STJ converter implementations (AnyOf, Expandable, DateTime, Enum, etc.) - Engine swap: deserialize/serialize paths now use System.Text.Json - Base entity/service/options classes updated with STJ attributes - Hand-written entity and service classes updated with STJ attributes - Request serialization migrated to STJ - All tests updated for STJ as primary deserializer - Wholesome tests for STJ attribute coverage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Machine-generated changes from OpenAPI spec codegen. All files in this commit contain the "File generated from our OpenAPI spec" header. Adds System.Text.Json attributes ([JsonPropertyName], [JsonConverter], etc.) to all generated entity and service option classes. This commit can be skipped during review — the hand-written infrastructure that drives these attributes is in the previous commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
bc5bab4 to
2cbf0c6
Compare
…hase1 Committed-By-Agent: claude # Conflicts: # src/Stripe.net/Entities/Charges/ChargePaymentMethodDetailsCardPresent.cs # src/Stripe.net/Entities/Charges/ChargePaymentMethodDetailsInteracPresent.cs # src/Stripe.net/Entities/ConfirmationTokens/ConfirmationTokenPaymentMethodPreviewCardGeneratedFromPaymentMethodDetailsCardPresent.cs # src/Stripe.net/Entities/Mandates/MandatePaymentMethodDetailsBacsDebit.cs # src/Stripe.net/Entities/PaymentAttemptRecords/PaymentAttemptRecordPaymentMethodDetailsCardPresent.cs # src/Stripe.net/Entities/PaymentAttemptRecords/PaymentAttemptRecordPaymentMethodDetailsInteracPresent.cs # src/Stripe.net/Entities/PaymentIntents/PaymentIntentPaymentMethodOptionsUsBankAccount.cs # src/Stripe.net/Entities/PaymentMethods/PaymentMethodCardGeneratedFromPaymentMethodDetailsCardPresent.cs # src/Stripe.net/Entities/PaymentRecords/PaymentRecordPaymentMethodDetailsCardPresent.cs # src/Stripe.net/Entities/PaymentRecords/PaymentRecordPaymentMethodDetailsInteracPresent.cs # src/Stripe.net/Entities/Reserve/Holds/Hold.cs # src/Stripe.net/Entities/Reserve/Holds/HoldReleaseSchedule.cs # src/Stripe.net/Entities/Reserve/Plans/Plan.cs # src/Stripe.net/Entities/Reserve/Plans/PlanFixedRelease.cs # src/Stripe.net/Entities/Reserve/Plans/PlanRollingRelease.cs # src/Stripe.net/Entities/Reserve/Releases/Release.cs # src/Stripe.net/Entities/Reserve/Releases/ReleaseSourceTransaction.cs # src/Stripe.net/Entities/Tax/Registrations/RegistrationCountryOptions.cs # src/Stripe.net/Entities/Tax/Registrations/RegistrationCountryOptionsLk.cs # src/Stripe.net/Entities/Terminal/Configurations/Configuration.cs # src/Stripe.net/Entities/Terminal/Configurations/ConfigurationCellular.cs # src/Stripe.net/Entities/Terminal/Configurations/ConfigurationStripeS710.cs # src/Stripe.net/Entities/V2/Billing/MeterEventAdjustments/MeterEventAdjustment.cs # src/Stripe.net/Entities/V2/Billing/MeterEventSessions/MeterEventSession.cs # src/Stripe.net/Services/PaymentIntents/PaymentIntentPaymentMethodOptionsUsBankAccountOptions.cs # src/Stripe.net/Services/PaymentLinks/PaymentLinkUpdateOptions.cs # src/Stripe.net/Services/SubscriptionItems/SubscriptionItemDeleteOptions.cs # src/Stripe.net/Services/Tax/Registrations/RegistrationCountryOptionsLkOptions.cs # src/Stripe.net/Services/Tax/Registrations/RegistrationCountryOptionsOptions.cs # src/Stripe.net/Services/Terminal/Configurations/ConfigurationCellularOptions.cs # src/Stripe.net/Services/Terminal/Configurations/ConfigurationCreateOptions.cs # src/Stripe.net/Services/Terminal/Configurations/ConfigurationStripeS710Options.cs # src/Stripe.net/Services/Terminal/Configurations/ConfigurationUpdateOptions.cs
Contributor
Author
|
Ok this should be good to review; the first commit is all the manual changes, the second commit is generated code, and then there is some clean up to fix tests after that. |
…d-trip test Delete NewtonsoftAndSystemTextJsonDeserializeTheSameObject which iterated over ~4700 entity types with reflection-heavy object population, causing CI timeouts (7+ minutes, killed by SIGTERM). Replace with a focused test in DeserializationTest that exercises every property type pattern (string, long, bool, decimal, decimal_string, DateTime, nested object, list, expandable field, map, StripeList) through both STJ and Newtonsoft deserialization and verifies equivalence. Add DecimalStringConverter attributes to close the one coverage gap. Other wholesome tests already verify all types have correct STJ attributes (PropertiesHaveAllNecessaryJsonAttributes, CorrectSystemTextJsonConvertersForTypes) and that serialization output matches (OutputTheSameObject). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
xavdid-stripe
approved these changes
Mar 19, 2026
This was referenced Mar 26, 2026
This was referenced Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
stripe-dotnet currently uses Newtonsoft.Json as its primary JSON serializer but has carried System.Text.Json (STJ) attributes in parallel since 2024. This PR promotes STJ becomes the primary serializer for all request serialization, response deserialization, and public
ToJson()output, and is implemented so that STJ will serialize and deserialize correctly without relying on custom options.Newtonsoft.Json remains available for backward compatibility (
ToJson()previously used Newtonsoft;RawJObjectis still populated).What?
#if NET6_0_OR_GREATERconditional compilation gates from STJ attributes and adds backfill for STJ on .NET 4.6.2 and .net 5.StripeClient,ApiRequestor, andEventUtilitySTJStripeEntityConverterandSTJStripeOptionsConverterasJsonConverterFactoryclasses that every entity/options class references via[JsonConverter]STJDefaultConverter<T>to be the shared read/write implementation used by both factory converters[JsonExtensionData]support toSTJDefaultConverterforExtraParamsonBaseOptionsDecimalStringConverter(Newtonsoft) fordecimal_stringfields — writes decimals as JSON strings to match STJ's[JsonNumberHandling]behaviorInt64StringConverter(Newtonsoft) forint64_stringfields — same pattern as above (cherry-picked from PR Add runtime support for V2 int64 string-encoded fields #3321)[JsonConverter(typeof(STJEventConverter))]toEventclass for pre-2017 event compatibilityToJson()to use STJ instead of NewtonsoftSTJMemberSerializationOptInand related infrastructure (no longer needed with per-type converters)[JsonConverter(typeof(STJStripeEntityConverter))]to all entity classes[JsonConverter(typeof(STJStripeOptionsConverter))]to all options classesThis PR also fixes an issue with serializing Stripe's decimal strings
[JsonConverter(typeof(DecimalStringConverter))]ondecimal_stringNewtonsoft propertiesTests:
NewtonsoftAndSystemTextJsonOutputTheSameObjectvalidates parity between serializersSee Also
Changelog