Skip to content

Promote: resilient HttpClientFactory and AOT-safe AssemblyInfo (4.0)#394

Merged
ptr727 merged 6 commits into
mainfrom
develop
Jul 10, 2026
Merged

Promote: resilient HttpClientFactory and AOT-safe AssemblyInfo (4.0)#394
ptr727 merged 6 commits into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Promotes v4.0 to main for a stable release.

Included

  • HttpClientFactory - reusable resilient HTTP client factory (Polly retry + circuit breaker, connection pooling), with HttpClientOptions for tuning and both a shared client and a resilience-handler surface.
  • AssemblyInfo - AOT-safe identity helper; For<T>() substitutes for Assembly.GetExecutingAssembly() (Native AOT), plus app name/version and a default User-Agent.
  • Download routed through the factory (signatures unchanged).
  • List<T> public members changed to Collection<T> / ReadOnlyCollection<T> (breaking API change).
  • Library AOT verification gated behind PublishAot; Sandbox is a Native AOT smoke test proving the pipeline and identity resolution under AOT.
  • Deterministic mocked resilience tests exercising the Polly pipeline offline.
  • CA1002/CA2007 and test-code analyzer cleanups.

See HISTORY.md for the full v4.0 entry.

🤖 Generated with Claude Code

ptr727 added 2 commits July 10, 2026 11:04
Add a reusable HttpClientFactory (Polly retry/circuit breaker) with AssemblyInfo, an AOT-safe GetExecutingAssembly substitute, and HttpClientOptions. Route Download through the factory. Gate library AOT verification behind PublishAot and prove it via the Sandbox Native AOT smoke test. Also resolve CA1002/CA2007 and test-code analyzer findings.
Add deterministic, network-free tests that exercise the HttpClientFactory Polly pipeline via a stub inner transport: retry on transient status, no retry on non-transient, retry on timeout, and no retry on caller cancellation. Re-adds the documented test-scoped CA2007 suppression (xUnit1030 conflict). Test-only; no library change.
Copilot AI review requested due to automatic review settings July 10, 2026 18:56
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.46602% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.37%. Comparing base (1568ac1) to head (7eff371).
⚠️ Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
Utilities/HttpClientFactory.cs 83.49% 15 Missing and 2 partials ⚠️
Utilities/FileEx.cs 73.17% 11 Missing ⚠️
Utilities/AssemblyInfo.cs 77.77% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #394      +/-   ##
==========================================
+ Coverage   40.62%   46.37%   +5.75%     
==========================================
  Files          10       13       +3     
  Lines        1024     1160     +136     
  Branches       99      108       +9     
==========================================
+ Hits          416      538     +122     
- Misses        580      592      +12     
- Partials       28       30       +2     

☔ 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.

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

Promotes the v4.0 release to main by introducing a reusable resilient HttpClientFactory (Polly-based retry + circuit breaker + pooling), adding an AOT-safe AssemblyInfo identity helper, and routing Download through the new client factory while updating public collection surfaces away from List<T>.

Changes:

  • Add HttpClientFactory + HttpClientOptions and wire Download to use the factory-created client.
  • Add AssemblyInfo for AOT-safe assembly/app identity and default User-Agent; update Sandbox to exercise identity + resilience paths.
  • Apply the breaking public API shift from List<T> to Collection<T> / ReadOnlyCollection<T>, and add/adjust tests + analyzer config to match.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.json Bumps the stable release version to 4.0.
UtilitiesTests/StringCompressionTests.cs Uses deterministic RNG API suitable for analyzers in test data generation.
UtilitiesTests/StringCompressionAsyncTests.cs Same RNG change for async compression tests.
UtilitiesTests/HttpClientOptionsTests.cs Adds default-value coverage for the new HttpClient configuration options.
UtilitiesTests/HttpClientFactoryTests.cs Adds basic behavioral tests for shared vs caller-owned clients and handler creation.
UtilitiesTests/HttpClientFactoryResilienceTests.cs Adds offline deterministic tests for retry/circuit behavior via a stub transport.
UtilitiesTests/FileExAsyncTests.cs Adjusts cancellation to use CancelAsync() in async test flow.
UtilitiesTests/ExtensionsTests.cs Adjusts cancellation to use CancelAsync() in async test flow.
UtilitiesTests/ConsoleTests.cs Ensures Console.Out is restored via try/finally to avoid cross-test pollution.
UtilitiesTests/AssemblyInfoTests.cs Adds coverage for AOT-safe assembly identity and default User-Agent generation.
UtilitiesTests/.editorconfig Updates test-scoped analyzer settings (xUnit-specific constraints).
Utilities/Utilities.csproj Gates AOT verification behind PublishAot and adds resilience package reference.
Utilities/StringHistory.cs Changes public StringList exposure to ReadOnlyCollection<string> and internalizes mutation.
Utilities/StringCompression.cs Updates await using disposal to satisfy analyzer requirements around ConfigureAwait.
Utilities/HttpClientOptions.cs Introduces a best-practice defaults options type for resilient HTTP clients.
Utilities/HttpClientFactory.cs Introduces the resilient HTTP client factory (retry/circuit breaker/pooling + UA).
Utilities/GlobalUsings.cs Adds global using for collection types used in the breaking API update.
Utilities/FileEx.cs Updates directory enumeration API to safe collection types and updates await using patterns.
Utilities/Extensions.cs Adds source-generated logging helpers for HTTP retry/circuit breaker events.
Utilities/Download.cs Routes download HTTP usage through the new factory while keeping signatures stable.
Utilities/AssemblyInfo.cs Introduces AOT/trim-safe identity helpers and a default User-Agent builder.
Utilities/.editorconfig Removes prior library-wide analyzer relaxations now addressed by code changes.
Sandbox/Program.cs Refactors sandbox entrypoint into async flow exercising new samples and async logger flush.
Sandbox/HttpClientSample.cs Adds a sample that drives resilience behavior deterministically without external dependencies.
Sandbox/AssemblyIdentitySample.cs Adds a sample validating AOT-safe identity resolution under AOT and non-AOT runs.
README.md Updates release notes for v4.0, highlighting breaking changes and the main new features.
HISTORY.md Adds detailed v4.0 release history entry documenting new features and breaking changes.
Directory.Packages.props Centralizes the new Microsoft.Extensions.Http.Resilience package version.
cspell.json Adds “Polly” to the spelling dictionary.
.vscode/tasks.json Adds a convenience task for publishing the Sandbox as Native AOT.
.vscode/launch.json Adds a launch configuration for running Sandbox in a non-AOT debug scenario.

Comment thread Utilities/HttpClientFactory.cs
Narrow IsTransientFailure to retry only transient HTTP status, request timeouts, and network/IO errors; do not retry caller cancellation, an open circuit, or other exceptions (including programming errors). Adds two mocked tests. Addresses the Copilot finding on the develop->main release PR.
Copilot AI review requested due to automatic review settings July 10, 2026 19:08

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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Comment thread Utilities/HttpClientFactory.cs
Remove CreateClient(ProductInfoHeaderValue) to eliminate the CreateClient(null) ambiguity; callers set the user agent via HttpClientOptions. Addresses a Copilot finding on the develop->main release PR before the stable 4.0 API ships.
Copilot AI review requested due to automatic review settings July 10, 2026 19:21

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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.

Comment thread Sandbox/Program.cs
Comment thread .vscode/launch.json
Comment thread Utilities/FileEx.cs
Update doc comments that still said 'list' for the Collection<T>/ReadOnlyCollection<T> return types on FileEx.EnumerateDirectories/EnumerateDirectory and StringHistory.StringList. Docs only. Addresses a Copilot finding on the develop->main release PR.
Copilot AI review requested due to automatic review settings July 10, 2026 19:32

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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Comment thread Utilities/HttpClientFactory.cs Outdated
Refine IsTransientFailure so a status-bearing HttpRequestException is transient only for a transient status (408/429/>=500); network HttpRequestException (no status) and IOException stay transient. Centralize the transient-status predicate. Add positive and negative mocked tests. Addresses Copilot findings on the develop->main release PR.
Copilot AI review requested due to automatic review settings July 10, 2026 19:50

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

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

@ptr727
ptr727 merged commit 166ab0a into main Jul 10, 2026
12 checks passed
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