Skip to content

Remove ambiguous CreateClient user-agent overload#396

Merged
ptr727 merged 1 commit into
developfrom
feature/remove-useragent-overload
Jul 10, 2026
Merged

Remove ambiguous CreateClient user-agent overload#396
ptr727 merged 1 commit into
developfrom
feature/remove-useragent-overload

Conversation

@ptr727

@ptr727 ptr727 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Removes the HttpClientFactory.CreateClient(ProductInfoHeaderValue) overload. With CreateClient(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:

HttpClientFactory.CreateClient(new HttpClientOptions { UserAgent = ua });

No caller used the removed overload (the sibling integrations and Download use GetClient() / CreateClient(options)). The user-agent test is repointed to the options path; the now-moot null-argument test is removed. The unused System.Net.Http.Headers using is dropped.

Verification

  • dotnet build - 0 warnings / 0 errors.
  • dotnet test - 150 passed.
  • dotnet format style --verify-no-changes clean.

Addresses a Copilot finding on the develop->main release PR (#394); done before the stable 4.0 API is published.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 10, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 from HttpClientFactory.
  • Updated the User-Agent test to use HttpClientOptions.UserAgent and removed the null-argument overload test that is no longer applicable.
  • Dropped the now-unused System.Net.Http.Headers using from HttpClientFactory.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

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.19%. Comparing base (2b52e73) to head (5bb337f).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit 464a31c into develop Jul 10, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/remove-useragent-overload branch July 10, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants