Foundry-Local icon indicating copy to clipboard operation
Foundry-Local copied to clipboard

Make `HttpClient` injectable for C# SDK

Open aaronpowell opened this issue 7 months ago • 0 comments

The HttpClient used by the C# SDK is created in the StartServiceAsync, which means that you have no ability to interact with it - this can be seen in the unit tests having to rely on reflection to provide a mock implementation.

This also becomes a problem if you want to adjust the timeout, add some resilience layer, or anything of that nature.

Making the HttpClient something provided by the constructor, or alternatively a HttpClientFactory, allows for more flexibility in working with the SDK.

Doing this would allow for some better logging and telemetry with the Aspire integration.

AB#66988

aaronpowell avatar May 29 '25 04:05 aaronpowell