Skip to content

feat(csharp): expose metadata on paginated responses#14762

Merged
patrickthornton merged 1 commit into
mainfrom
patrick/csharp/expose-metadata
Apr 9, 2026
Merged

feat(csharp): expose metadata on paginated responses#14762
patrickthornton merged 1 commit into
mainfrom
patrick/csharp/expose-metadata

Conversation

@patrickthornton
Copy link
Copy Markdown
Contributor

@patrickthornton patrickthornton commented Apr 8, 2026

Description

Equivalent of #10629 in C#.

Added three new properties to Page<TItem>:

  • Response (object?), the full deserialized API response object
  • StatusCode (HttpStatusCode), the HTTP status code
  • Headers (ResponseHeaders?), the HTTP response headers

Pager now explicitly calls .WithRawResponse() so Page can have Response. There was a somewhat suboptimal design decision made here to avoid a breaking change; namely, I'd rather have expanded the interface of Pager to Pager<TResponse, TItem> so users wouldn't have to cast Response to the correct type to use it, but that would break any code that implemented the interface. I'd theoretically be alright with this since getting the raw response here is a relatively fringe use case compared to the status code or headers, but it's still a compromise.

Code example:

  var pager = await client.Users.ListAsync(request);
  await foreach (var page in pager.AsPagesAsync())
  {
      // HTTP metadata
      Console.WriteLine(page.StatusCode);   // e.g., HttpStatusCode.OK
      Console.WriteLine(page.Headers);      // ResponseHeaders

      // Full response (cast to access non-item fields)
      var response = (ListUsersPaginationResponse)page.Response!;
      Console.WriteLine(response.TotalCount);
  }

Testing

Regeneration of all pagination fixtures.

  • Unit tests added/updated
  • Manual testing completed

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

@patrickthornton patrickthornton force-pushed the patrick/csharp/expose-metadata branch from fc6f1f1 to 6bfaf63 Compare April 8, 2026 20:14
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

SDK Generation Benchmark Results

Comparing PR branch against latest nightly baseline on main (2026-04-08T04:49:09Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
csharp-sdk square 132s 171s 126s -6s (-4.5%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-04-08T04:49:09Z). Trigger benchmark-baseline to refresh.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

SDK Generation Benchmark Results

Comparing PR branch against latest nightly baseline on main (2026-04-08T04:49:09Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
csharp-sdk square 132s 171s 132s +0s (+0.0%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-04-08T04:49:09Z). Trigger benchmark-baseline to refresh.

@patrickthornton patrickthornton force-pushed the patrick/csharp/expose-metadata branch from 23073cf to ca604d8 Compare April 9, 2026 15:35
@patrickthornton patrickthornton force-pushed the patrick/csharp/expose-metadata branch from ca604d8 to c599d03 Compare April 9, 2026 15:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

SDK Generation Benchmark Results

Comparing PR branch against latest nightly baseline on main (2026-04-09T04:46:50Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
csharp-sdk square 95s 138s 92s -3s (-3.2%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-04-09T04:46:50Z). Trigger benchmark-baseline to refresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants