Refactor HttpClientFactoryExtensions to simplify code structure#2042
Merged
ChrisPulman merged 2 commits intoreactiveui:mainfrom Jan 31, 2026
Merged
Refactor HttpClientFactoryExtensions to simplify code structure#2042ChrisPulman merged 2 commits intoreactiveui:mainfrom
ChrisPulman merged 2 commits intoreactiveui:mainfrom
Conversation
- Extract duplicated extension method implementations into 4 core methods - Use T4 template to auto-generate all 16 overload variants Note: This change is API-compatible but binary-incompatible: - All method parameters now use optional parameter syntax - No code changes required for existing usage - But applications referencing this library need to be recompiled
ChrisPulman
approved these changes
Jan 31, 2026
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What kind of change does this PR introduce?
IHttpClientBuilderto simplify Refit client configurationWhat is the current behavior?
Currently, when configuring Refit clients, developers must manually specify the HTTP client configuration name as a string, which is error-prone and difficult to maintain. For example:
Additionally, existing extension method implementations have significant code duplication, making maintenance difficult.
What is the new behavior?
IHttpClientBuilderextension methods that automatically retrieve the HttpClient name frombuilder.NameWhat might this PR break?
This change is API-compatible but binary-incompatible:
API compatible: All existing code continues to work without modification
Binary incompatible: Applications referencing this library need recompilation due to some required parameters becoming optional
Parameter changes:
Impact on existing code:
Other information:
Technical implementation:
Added 4 core private methods:
AddRefitClientCore(non-generic, non-keyed)AddKeyedRefitClientCore(non-generic, keyed)AddRefitClientCore<T>(generic, non-keyed)AddKeyedRefitClientCore<T>(generic, keyed)T4 template generates 16 variants covering:
Improved error handling: