You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 873c8bd
Browse filesBrowse the repository at this point in the historyBrowse files
feat: keyed refit generated client DI registration (#2297)
* feat: add AddKeyedRefitGeneratedClient for keyed generated-only DI parity
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.
* Remove note changes in breaking-changes since it is not really breaking
/// <summary>Adds a source-generated Refit client to the dependency injection container under the specified service key, without any reflection fallback.</summary>
695
+
/// <typeparam name="T">The type of the Refit interface.</typeparam>
696
+
/// <param name="serviceKey">A key used to associate with the specific Refit client instance.</param>
697
+
/// <param name="settings">The settings used to configure the instance.</param>
698
+
/// <returns>The HTTP client builder for chaining.</returns>
699
+
[SuppressMessage(
700
+
"Design",
701
+
"SST2307:Generic method type parameters should be inferable from the parameters",
702
+
Justification="The Refit interface type is intentionally specified explicitly by callers.")]
/// <summary>Adds a source-generated Refit client to the dependency injection container under the specified service key, without any reflection fallback.</summary>
720
+
/// <typeparam name="T">The type of the Refit interface.</typeparam>
721
+
/// <param name="serviceKey">A key used to associate with the specific Refit client instance.</param>
722
+
/// <param name="settings">The settings used to configure the instance.</param>
723
+
/// <param name="httpClientName">Allows the name of the underlying HttpClient to be changed.</param>
724
+
/// <returns>The HTTP client builder for chaining.</returns>
725
+
[SuppressMessage(
726
+
"Design",
727
+
"SST2307:Generic method type parameters should be inferable from the parameters",
728
+
Justification="The Refit interface type is intentionally specified explicitly by callers.")]
/// <summary>Adds a source-generated Refit client to the dependency injection container under the specified service key, without any reflection fallback.</summary>
747
+
/// <typeparam name="T">The type of the Refit interface.</typeparam>
748
+
/// <param name="serviceKey">A key used to associate with the specific Refit client instance.</param>
749
+
/// <param name="settingsAction">An action used to configure the Refit settings from the service provider.</param>
750
+
/// <returns>The HTTP client builder for chaining.</returns>
/// <summary>Adds a source-generated Refit client to the dependency injection container under the specified service key, without any reflection fallback.</summary>
773
+
/// <typeparam name="T">The type of the Refit interface.</typeparam>
774
+
/// <param name="serviceKey">A key used to associate with the specific Refit client instance.</param>
775
+
/// <param name="settingsAction">An action used to configure the Refit settings from the service provider.</param>
776
+
/// <param name="httpClientName">Allows the name of the underlying HttpClient to be changed.</param>
777
+
/// <returns>The HTTP client builder for chaining.</returns>
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
75
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey) where T : class { }
76
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings) where T : class { }
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction) where T : class { }
79
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings, string? httpClientName) where T : class { }
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
75
82
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Registering Refit clients by Type with HttpClientFactory requires runtime generic type and method instantiation.")]
76
83
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Registering Refit clients with HttpClientFactory requires reflected interface and request metadata.")]
77
84
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddRefitClient(System.Type refitInterfaceType) { }
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
75
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey) where T : class { }
76
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings) where T : class { }
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction) where T : class { }
79
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings, string? httpClientName) where T : class { }
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
75
82
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Registering Refit clients by Type with HttpClientFactory requires runtime generic type and method instantiation.")]
76
83
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Registering Refit clients with HttpClientFactory requires reflected interface and request metadata.")]
77
84
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddRefitClient(System.Type refitInterfaceType) { }
Copy file name to clipboardExpand all lines: src/Refit.HttpClientFactory/PublicAPI/net462/PublicAPI.txt
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,11 @@ public static class HttpClientFactoryExtensions
31
31
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction) where T : class { }
32
32
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitClient<T>(object? serviceKey, Refit.RefitSettings? settings, string? httpClientName) where T : class { }
33
33
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
34
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey) where T : class { }
35
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings) where T : class { }
36
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction) where T : class { }
37
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, Refit.RefitSettings? settings, string? httpClientName) where T : class { }
38
+
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddKeyedRefitGeneratedClient<T>(object? serviceKey, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction, string? httpClientName) where T : class { }
34
39
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddRefitClient(System.Type refitInterfaceType) { }
35
40
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddRefitClient(System.Type refitInterfaceType, Refit.RefitSettings? settings) { }
36
41
public Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddRefitClient(System.Type refitInterfaceType, System.Func<System.IServiceProvider, Refit.RefitSettings?>? settingsAction) { }
0 commit comments