Skip to content

Fix: CT parameter name uniqueness in CancellationToken overload generation#339

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

Fix: CT parameter name uniqueness in CancellationToken overload generation#339
Copilot wants to merge 2 commits intorepo-assist/feat-cancellationtoken-issue-212-2026-03-23-448c1cde90ec7d95from
copilot/sub-pr-336

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

If an OpenAPI spec defines a parameter named cancellationToken, the generated overload would emit two parameters with the same name — one from the spec and one for the injected CancellationToken.

Changes

  • Track used parameter names: The parameter-fold now returns the usedNames set alongside providedParameters instead of discarding it with |> snd
  • Unique CT parameter naming: The injected CT parameter resolves to the first unused name in the sequence cancellationTokencancellationToken1cancellationToken2 → …, matching the existing UniqueNameGenerator convention
  • Position-based extraction unaffected: invokeCode already extracts the CT argument by position (last in args), so it correctly handles the CT regardless of the name chosen
let usedNames, providedParameters =
    ((Set.empty, []), orderedParameters)
    ||> List.fold(fun (names, parameters) current -> ...)
    |> fun (names, ps) -> names, List.rev ps

let ctParamName =
    Seq.initInfinite(fun i -> if i = 0 then "cancellationToken" else $"cancellationToken{i}")
    |> Seq.find(fun n -> not(Set.contains n usedNames))

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…I params named 'cancellationToken'

Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/7d588ec7-c4df-4a6c-89f8-9c13c2472d29
Copilot AI changed the title [WIP] [WIP] Address feedback on CancellationToken support for OpenApiClientProvider Fix: CT parameter name uniqueness in CancellationToken overload generation Mar 23, 2026
Copilot AI requested a review from sergey-tihon March 23, 2026 22:26
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