StubHttp.CreateGeneratedClient(string) method¶
Defined in
Type: StubHttp
Namespace: Refit.Testing
Assembly: Refit.Testing.dll
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471
Overloads¶
- 1.
public T CreateGeneratedClient<T>(string hostUrl) - 2.
public T CreateGeneratedClient<T>(string hostUrl, RefitSettings baseSettings)
1. Overload¶
public T CreateGeneratedClient<T>(string hostUrl)
Summary:
Creates a source-generated Refit implementation of T whose HTTP requests are
routed through this handler, without falling back to reflection. Use it in trim- or AOT-compiled test
hosts where the reflection-based CreateClient is unavailable.
Type parameters
| Name | Description |
|---|---|
T | The Refit interface to implement; a generated implementation must be registered for it. |
Parameters
| Name | Type | Description |
|---|---|---|
hostUrl | string | The base address the client sends requests to. |
Returns: T -- A source-generated Refit client that sends every request to this handler.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | No generated implementation is registered for T. |
2. Overload¶
public T CreateGeneratedClient<T>(string hostUrl, RefitSettings baseSettings)
Summary:
Creates a source-generated Refit implementation of T whose HTTP requests are
routed through this handler, starting from the supplied settings and without falling back to reflection.
Type parameters
| Name | Description |
|---|---|
T | The Refit interface to implement; a generated implementation must be registered for it. |
Parameters
| Name | Type | Description |
|---|---|---|
hostUrl | string | The base address the client sends requests to. |
baseSettings | [RefitSettings](# | The settings to route through this handler. |
Returns: T -- A source-generated Refit client that sends every request to this handler.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | No generated implementation is registered for T. |