One builder per client - #17
Merged
Merged
Conversation
pokornyd
force-pushed
the
client-builders
branch
from
September 2, 2026 12:06
fea5c2a to
80b61d9
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## vnext #17 +/- ##
========================================
Coverage ? 90.76%
========================================
Files ? 510
Lines ? 10076
Branches ? 953
========================================
Hits ? 9145
Misses ? 606
Partials ? 325
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Client registration currently has a large number of overloads for the same underlying setup: delegates, configuration roots, sections, pre-built options, named clients, HTTP configuration, and resilience configuration.
This PR replaces that surface with the standard
Add...+ builder pattern used acrossMicrosoft.Extensions.*.Each product now has three
Add…Clientoverloads and one…Client.Createmethod, all using the sameI…ClientBuilder. The shared registration flow lives insrc/common/Clientsinstead of being repeated per product.Builder API
Optionsexposes the client'sOptionsBuilder<TOptions>, so standard APIs such asConfigure,Configure<TDep>,Bind,BindConfiguration, andValidateare available directly.HttpClientexposes the namedIHttpClientBuilderregistered by the SDK. Management also exposesSubscriptionHttpClient.ConfigureResiliencereplaces the default resilience pipeline.ServicesandNameare available for additional client-specific registrations.Consumer configuration runs after the SDK's own setup, including HTTP client configuration.
Createuses the same builder and registration path as DI-backed clients, but over a private container owned by the client. This keeps standalone and registered clients on the same composition path. The existing ManagementCreate(options)constructor remains.The old fluent options builders have been removed. Their endpoint helpers now live directly on the options types:
UsePreviewApiUseProductionApiUseCustomEndpointSingle properties can be configured directly.
The Caching package's registration overloads are replaced by five
Use…methods onIDeliveryClientBuilder.Shared registration
src/common/Clientsnow contains the common registration implementation.ClientBuilder<TOptions>backs each product-specific sealed builder.ClientRegistrationhandles the shared sequence:Each product supplies a
TransportRecipe<TOptions>describing its transport. Management registers two transports, one for each scope.No generic builder types are exposed publicly.
Resilience configuration is read lazily by the handler because
ConfigureResilienceruns after the transport registration is created.The unnamed
IOptions<T>alias for the default client is registered throughIConfigureNamedOptions. ResolvingIOptionsMonitor<T>while it is being constructed causes recursive container resolution, so it cannot be implemented as a normalConfigure<IOptionsMonitor<T>>registration.Compatibility
This is a breaking API change for the upcoming major versions.
Removed registration forms have direct builder-based replacements documented in the upgrade guides for Sync, Management, and Delivery.
There are three behavioral/API changes worth calling out:
Createand the Management constructor now throwOptionsValidationExceptionfor invalid options, matching container-based validation.CopyTois now public on all three options types so pre-built options can be used with named clients:The model generator still needs to compile against both the currently published packages and the new builder-based packages. It therefore registers Delivery and Management through the options-instance overload, which is supported by both surfaces.
Verification
Both build legs complete with 0 warnings.
Full test suite:
Tests removed with the old registration APIs were matched to their replacements. Coverage for the
CustomAssetDomainquery-string and fragment rules was also restored.DI descriptors and the complete HTTP handler chains were compared before and after for all three named clients. Base addresses, resolved timeouts, connection lifetimes, and handler ordering are unchanged.
The public API snapshots now contain only the new builder-based surface.