Skip to content

feat: keyed refit generated client DI registration - #2297

Merged
glennawatson merged 2 commits into
reactiveui:mainfrom
rmja:feature/keyed-refit-generated-client
Aug 5, 2026
Merged

feat: keyed refit generated client DI registration#2297
glennawatson merged 2 commits into
reactiveui:mainfrom
rmja:feature/keyed-refit-generated-client

Conversation

@rmja

@rmja rmja commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Fixes #2296.

What is the new behavior?

Adds AddKeyedRefitGeneratedClient<T> to Refit.HttpClientFactory, the keyed counterpart to
AddRefitGeneratedClient<T>. Before this, Refit.HttpClientFactory offered keyed registration only on the
reflection-capable path (AddRefitClient / AddKeyedRefitClient), so Native AOT and trimmed applications —
which are steered toward AddRefitGeneratedClient<T> — could not register the same interface more than once
with different configuration without giving up the AOT-clean path.

What is the current behavior?

There are only reflection based overloads for registering keyed clients.

What might this PR break?

Nothing

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

rmja added 2 commits August 5, 2026 11:55
…rity

AddRefitGeneratedClient<T> had no keyed counterpart, so Native AOT and
trimmed apps could not register the same Refit interface more than once
with different configuration without falling back to the reflection path.

Adds AddKeyedRefitGeneratedClient<T> on IServiceCollection mirroring all
five AddRefitGeneratedClient<T> overloads with a leading serviceKey. The
client and its SettingsFor<T> register as keyed services, the underlying
HttpClient name defaults to UniqueName.ForType<T>(serviceKey), and handler
composition follows AddKeyedRefitClient so both keyed paths behave alike.
No reflection fallback and no RequiresUnreferencedCode annotation.

Purely additive.
@glennawatson
glennawatson merged commit 873c8bd into reactiveui:main Aug 5, 2026
14 checks passed
@glennawatson

Copy link
Copy Markdown
Contributor

Thanks again.

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddRefitGeneratedClient<T> has no keyed counterpart

2 participants