feat: add lazy paging with generated PagedEnumerable methods - #2332
Merged
Merged
Conversation
- Drop the package reference and its central version entry. - Remove the inline suppressions that only existed for its rules.
- Record that the .NET 11 assemblies are built without runtime-async. - Record that response buffering propagates caller cancellation.
- Add PagedEnumerable, a lazy sequence of items or pages over a Refit method that returns one page. - Generate methods that return PagedEnumerable from [Paged] and [PageToken], for cursors, offsets, headers and links. - Require an explicit origin policy before a generated method follows a next link. - Report misconfigured paged methods as RF013. - Add runnable examples for S3, Azure Blob Storage, Cosmos DB, Graph, GitHub, Google Cloud Storage, Jira and DynamoDB. - Document paging and the public API baseline workflow in CLAUDE.md.
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2332 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 194 206 +12
Lines 10138 10805 +667
Branches 1947 2106 +159
==========================================
+ Hits 10138 10805 +667 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ChrisPulman
approved these changes
Sep 20, 2026
- Hand the caller's cancellation token to the async iterator instead of default.
glennawatson
enabled auto-merge (squash)
September 20, 2026 08:52
|
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
A Refit method can return
PagedEnumerable<TPage, TItem>, and the source generator writes the paging loop.PagedEnumerable<TPage, TItem>reads a paged list lazily withawait foreach. It wraps a Refit method that returns one page, yields the items or the API's own page objects, and sends a fresh request per page.[Paged]and[PageToken]make the generator emit the loop.[Paged]names the item and continuation members of the page, and[PageToken]marks the parameter that carries the token.Origins,SameOriginorAnyOrigindecides it, and a refused link is never requested.WithMaxPages,WithPrefetch, cancellation of the request in flight, and observable forms. Each page is disposed as the consumer moves on.IApiResponse.GetLinkreadsLinkresponse headers.RF013.docs/breaking-changes.mdgains the V16 and V15 sections.CLAUDE.mddescribes paging and the public API baseline workflow.Why
Every list API that returns pages makes callers hand-write the same request loop, and each service names the next page differently: S3 and Google Cloud Storage use a token in the body, Cosmos DB a header, Graph and GitHub a link, Jira an offset. There is no linked issue.
Breaking changes
None. The public API baselines only gain lines.
How this was verified
Tests cover every type this adds, the generator output and its diagnostics, and generated clients paging against a fake server. The example project runs every service scenario against local stand-ins.
Notes for the reviewer
Parser.Paging.csandEmitter.Inline.Paged.cs. The parser resolves the attribute members against the page type. The emitter writes a sibling request-building member plus the method that hands it toPagedEnumerable, so each page rebuilds its request.RF007when a paged method cannot be generated inline.Checklist