Skip to content

[http-client-csharp] Prevent List/Get request-builder collisions - #12183

Draft
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 12 commits into
mainfrom
copilot/http-client-csharp-fix-duplicate-request-builders
Draft

Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 12 commits into
mainfrom
copilot/http-client-csharp-fix-duplicate-request-builders

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

List-to-Get normalization collapsed singleton GET and pageable LIST operations onto the same REST request-builder signature, causing CS0111 despite their distinct request paths.

  • Collision handling: Check stable input names and projected C# signatures before applying List-to-Get normalization. Retain the original List name when REST or public declarations would collide, including generated Async variants.
  • Compatibility: Preserve non-colliding overloads and existing explicit, published-API, acronym, and URL naming. Compare generic arguments recursively so IEnumerable<int> and IEnumerable<int?> remain distinct signatures.
  • Regression coverage: Cover operation order, explicit-name peers, List/GetAll and async-name collisions, valid overloads, unique declarations, and URI/lookup/initial-page/next-page binding.
GetByResourceGroup  → CreateGetByResourceGroupRequest  → …/singletonTrackedResources/default
ListByResourceGroup → CreateListByResourceGroupRequest → …/singletonTrackedResources

@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 Oct 14, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix duplicate REST request builders for getByResourceGroup and listByResourceGroup [http-client-csharp] Prevent List/Get request-builder collisions Oct 14, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 7542403

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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

False collision checks can unnecessarily rename existing APIs for exact-name peers and async-only streaming operations.

2 open findings
What changed in this PR

Prevents C# List-to-Get normalization from creating duplicate request builders for distinct operations, addressing #12175.

Changes:

  • Checks projected names and parameter signatures before normalization.
  • Compares generic parameter types recursively.
  • Adds regression coverage for collisions, valid overloads, and request binding.
File Description
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator/​src/​Shared/​MethodSignatureHelper.cs Recursively compares generic arguments.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ClientProviders/​ClientProviderTests.cs Tests naming collisions, overloads, and request binding.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ClientProvider.cs Adds collision-aware List normalization.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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

Public-name collision checks run before URL projection and can unnecessarily rename valid existing APIs.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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

Wrapper-dependent request-builder names and unnecessary URL-related API renames remain unresolved.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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

Wrapper-dependent REST naming can invalidate earlier calls, and pre-emission signature comparisons can rename valid APIs unnecessarily.

1 open finding
2 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Compare final parameter order before detecting API collisions

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

These parameter lists precede the sync/async reordering in ScmMethodProviderCollection.cs:1398–1450: for protocol-only ListWidgets and convenience-enabled GetWidgetsAsync, each with an optional string path parameter and a required int query parameter, the overlapping protocol declarations actually take (int, string, RequestOptions) and (string, int, RequestOptions). Comparing the identical pre-emission lists incorrectly renames the valid GetWidgets/GetWidgetsAsync API to ListWidgets/ListWidgetsAsync; compare each emitted variant's final parameter types and order, and add a regression for this pair.

🧠 Review effort: Balanced

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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

Collision detection still misses next-page and reordered protocol signatures that can produce duplicate C# declarations.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment on lines +320 to +323
if (otherRestName == normalizedName &&
HasEquivalentParameterTypes(
RestClientProvider.GetMethodParameters(serviceMethod, ScmMethodKind.CreateRequest, this, applyBackCompat: false),
RestClientProvider.GetMethodParameters(other, ScmMethodKind.CreateRequest, this, applyBackCompat: false)))
Comment on lines +347 to +350
if (candidateNames.Intersect(otherNames, StringComparer.Ordinal).Any() &&
HasEquivalentParameterTypes(
RestClientProvider.GetMethodParameters(serviceMethod, kind, this),
RestClientProvider.GetMethodParameters(other, kind, this)))

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.

[http-client-csharp] List/Get normalization creates duplicate REST request builders

3 participants