Scrutor.Extensions.HttpClient
7.0.1
dotnet add package Scrutor.Extensions.HttpClient --version 7.0.1
NuGet\Install-Package Scrutor.Extensions.HttpClient -Version 7.0.1
<PackageReference Include="Scrutor.Extensions.HttpClient" Version="7.0.1" />
<PackageVersion Include="Scrutor.Extensions.HttpClient" Version="7.0.1" />
<PackageReference Include="Scrutor.Extensions.HttpClient" />
paket add Scrutor.Extensions.HttpClient --version 7.0.1
#r "nuget: Scrutor.Extensions.HttpClient, 7.0.1"
#:package Scrutor.Extensions.HttpClient@7.0.1
#addin nuget:?package=Scrutor.Extensions.HttpClient&version=7.0.1
#tool nuget:?package=Scrutor.Extensions.HttpClient&version=7.0.1
Scrutor.Extensions.HttpClient
A tiny companion for Scrutor that lets its
assembly-scanning register each matched class as a typed
HttpClient
(via IHttpClientFactory) instead of a plain service — the one thing Scrutor
deliberately doesn't do out of the box.
services.Scan(scan => scan
.FromAssemblyOf<IWeatherClient>()
.AddClasses(c => c.AssignableTo<IApiClient>())
.AsMatchingInterface()
.AsHttpClient("weather")); // ← every scanned client becomes a typed HttpClient
Install
dotnet add package Scrutor.Extensions.HttpClient
Usage
- Register a named
HttpClientwith your shared configuration. - Make your API clients implement a common marker interface (and, for
.AsMatchingInterface(), anI{ClassName}interface each). - Scan for them and finish the chain with
.AsHttpClient("<name>").
// 1. A named client carrying the shared config (base address, handlers, Polly, …).
services.AddHttpClient("weather", client =>
{
client.BaseAddress = new Uri("https://api.example.com");
});
// 2 + 3. Register every IApiClient implementation as a typed client of "weather".
services.Scan(scan => scan
.FromAssemblyOf<IWeatherClient>()
.AddClasses(classes => classes.AssignableTo<IApiClient>())
.AsMatchingInterface()
.AsHttpClient("weather"));
Now each scanned client is resolved from IHttpClientFactory with the "weather"
client's configuration injected:
public sealed class WeatherClient(HttpClient http) : IWeatherClient
{
public Task<Forecast?> GetAsync(string city) =>
http.GetFromJsonAsync<Forecast>($"forecast/{city}");
}
Overloads
| Call | Behaviour |
|---|---|
.AsHttpClient("name") |
Registers each scanned class as a typed client bound to the named client "name" — they share its configuration. |
.AsHttpClient() |
Registers each scanned class as a typed client with its own default client (named after the service type). |
Both are IServiceTypeSelector extensions, so they slot onto the end of any Scrutor
.Scan(...) chain (.AsMatchingInterface(), .AsSelf(), .As<T>(), …).
Compatibility
- Scrutor 7.x — the package major tracks Scrutor's major (
7.x↔ Scrutor 7.x). - Targets
net8.0andnetstandard2.0(so it's usable from .NET Framework 4.6.2+, .NET Core 2.0+, and modern .NET alike).
Trimming / AOT
This bridges Scrutor's runtime assembly scan and closes the generic
AddHttpClient<TClient,TImplementation> over the scanned types via reflection, so it
is not trim- or Native-AOT-safe. The public methods are annotated with
[RequiresUnreferencedCode] / [RequiresDynamicCode], so a trimmed/AOT build gets an
honest warning at the call site rather than silent breakage.
Building
CI is defined in C# with Fallout (a NUKE fork); the GitHub Actions workflow is generated from the build, never hand-edited.
./build.cmd Test # run the spec suite
./build.cmd Pack # test + pack the NuGet package
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 9.0.0 && < 11.0.0)
- Scrutor (>= 7.0.0 && < 8.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 9.0.0 && < 11.0.0)
- Scrutor (>= 7.0.0 && < 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Scrutor.Extensions.HttpClient:
| Package | Downloads |
|---|---|
|
TvdbClient
C# Api Client (HttpClient) for TVDB Api |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 7.0.1 | 87 | 7/24/2026 | |
| 7.0.0 | 83 | 7/24/2026 | |
| 7.0.0-preview.1 | 43 | 7/24/2026 | |
| 5.1.2-rc-0001-g687aa97e2f | 394 | 2/2/2025 | |
| 5.1.2-alpha.3 | 116 | 1/20/2025 | |
| 5.1.2-alpha.2 | 306 | 1/17/2025 | |
| 5.1.2-alpha | 156 | 1/17/2025 | |
| 5.0.1 | 254 | 1/17/2025 | |
| 5.0.0 | 172 | 1/16/2025 | |
| 1.0.0 | 191 | 1/16/2025 |