Skip to content

Replace CancellationToken overloads with a single optional parameter#340

Draft
Copilot wants to merge 3 commits intorepo-assist/feat-cancellationtoken-issue-212-2026-03-23-448c1cde90ec7d95from
copilot/sub-pr-336-again
Draft

Replace CancellationToken overloads with a single optional parameter#340
Copilot wants to merge 3 commits intorepo-assist/feat-cancellationtoken-issue-212-2026-03-23-448c1cde90ec7d95from
copilot/sub-pr-336-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

The implementation generated two overloads per operation (with/without CancellationToken) while the intended API surface was a single method with an optional cancellationToken parameter defaulting to CancellationToken.None.

Changes

  • Optional parameter instead of overloads: Each generated method now has a single optional cancellationToken: CancellationToken parameter. Passing null as optionalValue to ProvidedParameter correctly encodes default(CancellationToken) in CLI metadata — identical to how C# encodes ct = default for struct parameters.
  • Simplified compileOperation: Removed includeCancellationToken: bool flag; CT parameter is always appended unconditionally.
  • Simplified invokeCode: CT is always extracted from the last argument position — no conditional branch.
  • Reduced generated surface area: N methods instead of 2N per client type.
// Before: two overloads generated per operation
[ compileOperation uniqueName op false; compileOperation uniqueName op true ]

// After: single method with optional CT parameter
[ compileOperation uniqueName op ]
// Parameter: ProvidedParameter("cancellationToken", typeof<CancellationToken>, optionalValue = (null: obj))

Callers with no CT argument continue to work unchanged; callers that want explicit cancellation pass the token directly.


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI and others added 2 commits March 23, 2026 22:24
… generated methods

Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/4498d505-289e-4053-b797-faf89db707dd
…ken parameter

Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/4498d505-289e-4053-b797-faf89db707dd
Copilot AI changed the title [WIP] [WIP] Address feedback on CancellationToken support in OpenApiClientProvider methods Replace CancellationToken overloads with a single optional parameter Mar 23, 2026
Copilot AI requested a review from sergey-tihon March 23, 2026 22:27
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