Replace Emptyable<T> with SetTracker pattern for explicit null support#3342
Merged
jar-stripe merged 6 commits intomasterfrom Mar 24, 2026
Merged
Replace Emptyable<T> with SetTracker pattern for explicit null support#3342jar-stripe merged 6 commits intomasterfrom
jar-stripe merged 6 commits intomasterfrom
Conversation
to v2 APIs only when the user explicitly sets a value to null
…ervingDictConverter - BaseOptions.SetTracker needs [JsonIgnore]/[STJS.JsonIgnore] so the PropertiesHaveJsonAttributes wholesome test passes - SystemTextJsonTestUtils: accept STJNullPreservingDictionaryConverter on Dictionary properties (applied by codegen for metadata mutation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Generated by sdk-codegen. Replaces Emptyable<T> wrapper with SetTracker pattern: private backing fields + property setters that call SetTracker.Track(). Adds STJNullPreservingDictionaryConverter to metadata/map properties with nullable elements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Breaking: removes public interfaces IEmptyable and IEmptyable<T>. These are no longer used — all emptyable Options properties now use the SetTracker pattern with standard nullable types instead. Also removes internal Emptyable<T> class, EmptyableConverter, STJEmptyableConverter, and their tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
This was referenced Mar 24, 2026
xavdid-stripe
approved these changes
Mar 24, 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 needs to distinguish "never set" from "explicitly set to null" on Options properties so that:
field=(empty string) to clear a value"field": nullin JSON to clear a valuekey=to delete a key; v2 sends"key": nullThe previous
Emptyable<T>wrapper approach required callers to use a different type. The new SetTracker pattern uses standard nullable properties with backing fields that track whether the setter was called.What?
IEmptyableandIEmptyable<T>, internal typeEmptyable<T>, and their convertersBaseOptions.SetTrackernow has[JsonIgnore]/[STJS.JsonIgnore]to pass wholesome testsSTJNullPreservingDictionaryConverteron Dictionary propertiesthis.SetTracker.Track()to record explicit setsIHasSetTracking+SetTrackerSTJNullPreservingDictionaryConverteron metadata/map properties with nullable elementsSee Also
Changelog
nulland the SDK will send an empty string for V1 APIs and a null value for V2 APIs.nullif that property is defined as nullable in our API Ref. If you currently pre-initialize your Options values to null this could have unintended consequences.IEmptyable,IEmptyable<T>,Emptyable<T>,EmptyableConverter<T>, andSTJEmptyableConverter<T>— replaced by SetTracker pattern on Options properties.