Remove ambiguous CreateClient user-agent overload#396
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the HttpClientFactory.CreateClient(ProductInfoHeaderValue) overload to eliminate an ambiguous public API call site (CreateClient(null)) now that CreateClient(HttpClientOptions? options = null) exists, and standardizes custom User-Agent configuration through HttpClientOptions.
Changes:
- Removed the
CreateClient(ProductInfoHeaderValue userAgent)overload fromHttpClientFactory. - Updated the User-Agent test to use
HttpClientOptions.UserAgentand removed the null-argument overload test that is no longer applicable. - Dropped the now-unused
System.Net.Http.Headersusing fromHttpClientFactory.cs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Utilities/HttpClientFactory.cs |
Removes the ambiguous User-Agent overload and the unused headers using. |
UtilitiesTests/HttpClientFactoryTests.cs |
Repoints User-Agent coverage to HttpClientOptions and removes the obsolete null-overload test. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #396 +/- ##
===========================================
- Coverage 46.37% 46.19% -0.19%
===========================================
Files 13 13
Lines 1160 1156 -4
Branches 107 107
===========================================
- Hits 538 534 -4
Misses 592 592
Partials 30 30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
HttpClientFactory.CreateClient(ProductInfoHeaderValue)overload. WithCreateClient(HttpClientOptions? = null)also present,CreateClient(null)was an ambiguous call, an easy public-API foot-gun. Callers set a custom user agent via the options object instead:No caller used the removed overload (the sibling integrations and
DownloaduseGetClient()/CreateClient(options)). The user-agent test is repointed to the options path; the now-moot null-argument test is removed. The unusedSystem.Net.Http.Headersusing is dropped.Verification
dotnet build- 0 warnings / 0 errors.dotnet test- 150 passed.dotnet format style --verify-no-changesclean.Addresses a Copilot finding on the develop->main release PR (#394); done before the stable 4.0 API is published.
🤖 Generated with Claude Code