Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: Added examples for With-methods #8650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
N-Olbert wants to merge 1 commit into ChilliCream:main
base: main
Choose a base branch
Loading
from N-Olbert:docs-3467

Conversation

@N-Olbert
Copy link
Contributor

@N-Olbert N-Olbert commented Sep 2, 2025

Summary of the changes (Less than 80 chars)

  • Docs: Added examples for With-methods
  • Test: Added validation for disposed HttpClient

Related

Test: Added validation for disposed HttpClient
@github-actions github-actions bot added 📚 documentation This issue is about working on our documentation. 🌶️ strawberry shake labels Sep 2, 2025
.ExecuteAsync();
```

> Note: The provided `HttpClient` will be disposed once `ExecuteAsync` completes.
Copy link
Contributor Author

@N-Olbert N-Olbert Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I emphasized this since it was very common in .NET Framework 4 to have one singleton HttpClient-instance that is used for each and every request.
This is also still the recommended way (docs) if one doesn`t use dependency injection / IHttpClientFactory.

With this in mind, something like

private static readonly HttpClient httpClient = new HttpClient();
var result1 = await client.GetSomething.WithHttpClient(httpClient).ExecuteAsync();
var result2 = await client.GetSomethingElse.WithHttpClient(httpClient).ExecuteAsync();
...

will break.

I wonder whether it might make sense to add a boolean to control whether the client should be disposed to WithHttpClient (I could add that) @michaelstaib

@N-Olbert N-Olbert marked this pull request as ready for review September 2, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

📚 documentation This issue is about working on our documentation. 🌶️ strawberry shake

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /