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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Scrutor.Extensions.HttpClient" Version="7.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Scrutor.Extensions.HttpClient" Version="7.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Scrutor.Extensions.HttpClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Scrutor.Extensions.HttpClient --version 7.0.1
                    
#r "nuget: Scrutor.Extensions.HttpClient, 7.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Scrutor.Extensions.HttpClient@7.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Scrutor.Extensions.HttpClient&version=7.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Scrutor.Extensions.HttpClient&version=7.0.1
                    
Install as a Cake Tool

Scrutor.Extensions.HttpClient

NuGet Downloads Build & Test Built with Fallout License

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

  1. Register a named HttpClient with your shared configuration.
  2. Make your API clients implement a common marker interface (and, for .AsMatchingInterface(), an I{ClassName} interface each).
  3. 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.0 and netstandard2.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

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 is deprecated because it is no longer maintained.
5.0.0 172 1/16/2025
1.0.0 191 1/16/2025 1.0.0 is deprecated because it has critical bugs.