Skip to content

Hide continuation-token parameters on nextLink-paged C# operations - #12469

Draft
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 15 commits into
mainfrom
copilot/dont-expose-continuationtoken
Draft

Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 15 commits into
mainfrom
copilot/dont-expose-continuationtoken

Conversation

Copilot AI commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

nextLink-paged operations can expose a bare continuation-token request parameter even though callers resume paging with a nextLink URL. These incompatible token formats invite incorrect requests.

  • Metadata: Preserve the request-token marker even when the response has no continuation token.
  • Public API: Omit marked tokens from sync/async convenience and protocol signatures; pass default internally. Leave token-only paging unchanged.
  • Compatibility: Retain published token-bearing signatures as [EditorBrowsable(Never)] overloads that still send the token, preserve trailing optional arguments, and coexist with optional-parameter compatibility overloads.

Representative convenience signature:

- GetRooms(int? maxPageSize = default, string continuationToken = default, CancellationToken cancellationToken = default)
+ GetRooms(int? maxPageSize = default, CancellationToken cancellationToken = default)

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Nov 2, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@12469

commit: 871a1b2

… overloads

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix exposure of @continuationToken request parameter Hide continuation-token parameters on nextLink-paged C# operations Nov 2, 2026
…ressions

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Add opt-in SupportsPageResumption to the response APIs and preserve unbranded paging signatures by default.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Replace the paging metadata reference with IsContinuationToken and preserve grouped parameter forwarding and unbranded paging behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move isContinuationToken to InputPropertyTypeBase and remove InputHttpParameterBase.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Critical overload-matching and paging-argument errors can drop published tokenless methods and generate invalid constructor calls, breaking compilation and backward compatibility.

3 open issues
What changed in this PR

This PR adds support for hiding raw continuation-token parameters on nextLink-paged C# operations when the response provider supports page resumption, addressing #12468.

Changes:

  • Preserve request continuation-token metadata independently of response-token metadata.
  • Omit marked tokens from eligible public signatures and pass default internally, leaving token-only paging unchanged.
  • Add hidden compatibility overloads, regression tests, and updated code-model fixtures.

Paths below are relative to packages/http-client-csharp/.

File Description
generator/​TestProjects/​Spector/​http/​payload/​pageable/​tspCodeModel.json Update paging token markers.
generator/​TestProjects/​Local/​Sample-TypeSpec/​tspCodeModel.json Update sample token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​test/​TypeSpecInputConverterTests.cs Test marker deserialization and updates.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputQueryParameterConverter.cs Deserialize query token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputPathParameterConverter.cs Deserialize path token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputMethodParameterConverter.cs Deserialize method token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputHeaderParameterConverter.cs Deserialize header token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputEndpointParameterConverter.cs Deserialize endpoint token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputBodyParameterConverter.cs Deserialize body token markers.
generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputParameter.cs Store and update token metadata.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​TestHelpers/​ResumableClientResultProvider.cs Add a resumption-capable test provider.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​TestHelpers/​MockHelpers.cs Allow response-provider injection in async setup.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmMethodProviderCollectionTests.cs Test token omission and options-bag preservation.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ClientProviders/​TestData/​ClientProviderTests/​BackCompatibility_NextLinkContinuationToken/​TestClient.cs Define published token-bearing test signatures.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ClientProviders/​ClientProviderTests.cs Test hidden compatibility overloads.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Abstractions/​ClientResponseApiTests.cs Test page-resumption capability defaults and overrides.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ScmMethodProviderCollection.cs Filter tokens and preserve internal argument forwarding.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ClientProvider.cs Integrate token-bearing compatibility overloads.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​Abstractions/​IClientResponseApi.cs Define the page-resumption capability.
generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​Abstractions/​ClientResponseApi.cs Expose an overridable capability flag.
emitter/​test/​Unit/​operation-paging.test.ts Test request-token metadata preservation.
emitter/​src/​type/​input-type.ts Add optional token metadata to the input schema.
emitter/​src/​lib/​operation-converter.ts Mark request tokens without requiring response tokens.

Review effort: Balanced

…ation

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Merge current main, retaining continuation-token tests and honoring the lifecycle visibility revert. Warn and retain raw-token APIs on signature collisions, preserve published tokenless methods during regeneration, and fix mixed grouped parameter forwarding.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Page-resumption overload generation can leave public partial methods without implementations, causing CS8795, and make previously valid calls ambiguous through overlapping optional arguments.

2 open issues
3 resolved since last review

Review effort: Balanced

Retain renamed partial implementations, handle optional-argument and custom-code collisions, generalize the signature-collision warning, and streamline token filtering and compatibility allocations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Critical compatibility regressions can produce duplicate partial implementations, make previously valid calls ambiguous, and omit published continuation-token overloads.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

High severity Match the published token parameter by position

packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ScmMethodProviderCollection.cs:292

If the last contract names the token resumeToken but the current input names it token and there is no current partial declaration, this name check returns -1, so AddContinuationTokenOverloads never retains the published overload (for example, using the existing CustomProtocolLast fixture without CustomProtocol). Match the baseline parameter structurally/positionally and restore its published name, rather than requiring it to match the current token name.

2 resolved since last review

Review effort: Balanced

Deduplicate grouped partial implementations, preserve null/default call compatibility, simplify method construction, and verify request builders with file-based baselines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge main, preserving converter-test coverage. Clarify the token-omission policy helper, split assignments, cover empty segments, and validate generated code through TestData baselines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Critical overload-collision gaps can drop required partial implementations and introduce ambiguous calls, causing compilation failures for customizations and published contracts.

3 open issues
2 resolved since last review

Review effort: Balanced

Recognize renamed custom tokens, prioritize explicit partial implementations, and detect collisions across all argument counts. Simplify legacy caching and generated suppression comments with regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because subtle named-argument and optional-parameter interactions can make previously valid paging calls fail to compile or become ambiguous.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

This branch has not been deployed

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

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't expose a @continuationToken request parameter on nextLink-paged operations

3 participants