Skip to content

Fix C# paging helper naming collisions and long filenames - #12292

Open
Dapeng Zhang (ArcturusZhang) wants to merge 13 commits into
microsoft:mainfrom
ArcturusZhang:arcturuszhang-issue-12147-fix
Open

Dapeng Zhang (ArcturusZhang) wants to merge 13 commits into
microsoft:mainfrom
ArcturusZhang:arcturuszhang-issue-12147-fix

Conversation

@ArcturusZhang

@ArcturusZhang Dapeng Zhang (ArcturusZhang) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #12147.

Summary

  • Nest operation-specific paging helpers inside their owning client and emit them together in <ClientName>.Collections.cs, following option 2 discussed in the issue. ClientProvider.CollectionResultProviders lazily creates and caches this partial declaration.
  • Simplify helper names to <OperationName>[Async]CollectionResult[OfT], without a redundant client-name prefix or original-name fallback. Resolve same-client normalized-name and sync/async collisions in input operation order: keep the first name unchanged, then append 2, 3, etc. For example, two operations normalized to GetAll produce GetAllCollectionResult and GetAllCollectionResult2.
  • Traverse nested helpers in library visitors and dependency analysis, preserving downstream customization and response models referenced only by helper bodies. Omit the implementation-only collections partial from public API stubs.
  • Preserve reference-based pruning: client ownership alone does not retain paging helpers. Resolve handwritten references within their containing type, remove unused helpers and otherwise-unreferenced dependencies with RemoveOrInternalize, and skip removed nested types during emission. Preserve existing ownership-based retention for other nested types and keepAll behavior.
  • Disable duplicate compatibility-overload synthesis in the collections partial. Propagate client name and namespace updates to the collections partial and cached nested helpers while retaining visitor constructor customizations.
  • Document provider ownership and naming; add regression coverage for collisions, long operation names, nested member visitation, dependency retention and pruning, compatibility overloads, and cached identity updates; regenerate the checked-in sample output and update helper-name fixtures.

Generated SDK public APIs and paging iteration logic are unchanged. Internal helper names and qualified locations change with the nested layout.

Validation

  • C# emitter/generator build passed.
  • Core generator suite: 2,919 passed, rerun after the pruning fix.
  • Client-model suite: 2,479 passed after the pruning fix, using a temporary short Windows drive mapping to avoid existing fixture path limitations. The four pruning cases also passed after extending coverage to same-named helpers in another client.
  • Regenerated local sample suite: 730 passed, rerun after the latest fixes; regeneration produced no additional checked-in output changes.
  • Full C# regeneration completed for the initial nested layout; the affected local sample was regenerated and rebuilt after subsequent changes. The full generated pageable Spector SDK was also built successfully for net8.0 with the initial nested layout and emitted five per-client collections files instead of per-operation files.
  • New compatibility, cached-identity, and pruning regressions were observed failing before implementation and passing after the fixes.
  • Cop checks, repository-configured Oxlint, and root pnpm format passed after the latest changes.

Spector HTTP runtime integration tests were not run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
@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 16, 2026
@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

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

commit: a2e0ce0

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Document the collections partial declaration and let the output library reuse the client-owned provider.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Drop redundant client prefixes and original-name fallback; document client-local numeric collision suffixes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
…erty

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f

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

Naming collisions and compatibility and identity propagation defects can produce uncompilable generated SDKs.

3 open issues
What changed in this PR

Addresses #12147 by nesting C# paging helpers inside their owning clients, reducing filename length and separating helper names across clients.

Changes:

  • Groups helpers into per-client .Collections.cs files with deterministic collision suffixes.
  • Extends visitor and dependency traversal to nested helpers and excludes collections partials from API stubs.
  • Adds regression coverage, updates fixtures, and regenerates sample output.

Paths below omit packages/http-client-csharp/generator/. Prefixes: Sample = TestProjects/Local/Sample-TypeSpec/src/Generated; Core = Microsoft.TypeSpec.Generator; ClientModel = Microsoft.TypeSpec.Generator.ClientModel.

File Description
Sample/​SampleTypeSpecClient.cs Uses nested paging helpers.
Sample/​SampleTypeSpecClient.Collections.cs Groups client paging helpers.
Sample/​ExperimentalSamples.cs Uses nested paging helpers.
Sample/​ExperimentalSamples.Collections.cs Groups experimental paging helpers.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithPagingCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithNextLinkCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​ExperimentalSamplesGetAllCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​ExperimentalSamplesGetAllCollectionResult.cs Removed; helper moved into client.
Sample/​CollectionResults/​ExperimentalSamplesGetAllAsyncCollectionResultOfT.cs Removed; helper moved into client.
Sample/​CollectionResults/​ExperimentalSamplesGetAllAsyncCollectionResult.cs Removed; helper moved into client.
Core/​test/​ReferenceMap/​ProviderReferenceMapAnalyzerTests.cs Tests nested-helper dependency retention.
Core/​test/​OutputLibraryVisitorTests.cs Tests nested member visitation.
Core/​src/​ReferenceMap/​ProviderReferenceMapAnalyzer.BodyReferences.cs Includes nested providers in dependency analysis.
Core/​src/​LibraryVisitor.cs Recursively visits nested members.
ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​OptionsBagOverride_PagingMethodExpandsBagForCollectionResult(Protocol).cs Updates qualified helper reference.
ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​OptionsBagOverride_PagingMethodExpandsBagForCollectionResult(Convenience).cs Updates qualified helper reference.
ClientModel/​test/​Providers/​ScmMethodProviderCollectionTests.cs Finds helpers in nested providers.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NormalizedDateTimeReinjectedParameterFiltersNextLinkArguments.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInHeaderOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInHeaderOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInHeaderAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInHeader.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInBodyOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInBodyOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInBodyAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NextLinkInBody.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NestedNextLinkInBodyOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NestedNextLinkInBodyOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NestedNextLinkInBodyAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​NestedNextLinkInBody.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​InheritedNextLinkInBodyOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​InheritedNextLinkInBodyOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​InheritedNextLinkInBodyAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​NextLinkTests/​InheritedNextLinkInBody.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ListPageableTests/​NoNextLinkOrContinuationTokenOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ListPageableTests/​NoNextLinkOrContinuationTokenOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ListPageableTests/​NoNextLinkOrContinuationTokenAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ListPageableTests/​NoNextLinkOrContinuationToken.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​NestedContinuationTokenInBodyOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​NestedContinuationTokenInBodyOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​NestedContinuationTokenInBodyAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​NestedContinuationTokenInBody.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInHeaderOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInHeaderOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInHeaderAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInHeader.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInBodyOfTAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInBodyOfT.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInBodyAsync.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​ContinuationTokenTests/​ContinuationTokenInBody.cs Updates helper-name baseline.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​NextLinkTests.cs Uses nested helper names and lookups.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​ListPageableTests.cs Uses nested helper names and lookups.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​ContinuationTokenTests.cs Uses nested helper names and lookups.
ClientModel/​test/​Providers/​CollectionResultDefinitions/​CollectionResultDefinitionTests.cs Tests ownership, collisions, and bounded filenames.
ClientModel/​test/​Providers/​ClientProviders/​TestData/​ClientProviderCustomizationTests/​SuppressedPagingProtocolMethodKeepsPagingHelpers/​TestClient.cs References nested helper from custom code.
ClientModel/​test/​Providers/​ClientProviders/​ClientProviderTests.cs Updates paging-helper assertions.
ClientModel/​test/​Providers/​ClientProviders/​ClientProviderCustomizationTests.cs Checks retained nested helpers.
ClientModel/​src/​ScmOutputLibrary.cs Registers per-client collections partials.
ClientModel/​src/​Providers/​CollectionResultDefinition.cs Adds nesting and local name disambiguation.
ClientModel/​src/​Providers/​ClientProvider.cs Lazily caches collections provider.
ClientModel/​src/​Providers/​ClientCollectionsProvider.cs Defines partial containing paging helpers.
Microsoft.TypeSpec.Generator.ClientModel.StubLibrary/​src/​StubLibraryVisitor.cs Excludes collections partials from stubs.
docs/​architecture.md Documents helper ownership and naming.

Review effort: Balanced

Avoid duplicate compatibility overloads in the collections partial and propagate client identity updates to cached nested paging helpers while preserving constructor customizations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 19, 2026 08:52

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

Helper naming still permits collisions with ordinary client methods, producing generated C# that cannot compile.

1 open issue
2 resolved since last review

Review effort: Balanced

@ArcturusZhang

Copy link
Copy Markdown
Member Author

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

Nested ownership prevents pruning unused paging helpers and their dependencies when paging methods are suppressed or replaced.

2 open issues

Review effort: Balanced

Retain paging helpers through generated or handwritten references instead of client ownership, resolve handwritten nested references in their containing type, and omit removed helpers during emission.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:08

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

One or more issues must be addressed before approval.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve namespace-relative qualified nested references during pruning

packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator/​src/​ReferenceMap/​ProviderReferenceMapAnalyzer.Helpers.cs:776

With RemoveOrInternalize, suppressing the generated paging methods and referencing new TestClient.GetItemsCollectionResult(client, options) from another handwritten type in namespace Sample still removes the helper: NamedTypeSymbolProvider.cs:690–699 records the relative qualifier as namespace TestClient, but AddNamespaceBodyDependencyType only performs scoped lookup for empty namespaces. Resolve namespace-relative qualified nested references too, and add a pruning regression so this valid custom code does not fail with CS0426.

Review effort: Balanced

@JoshLove-msft

Copy link
Copy Markdown
Contributor

Review summary: two P2 correctness issues remain in the current diff:

  • Nested replacement providers lose their members. LibraryVisitor.cs:90 now calls VisitTypeCore, which traverses the original provider's members and overwrites those on the replacement returned by VisitType. Traverse the returned provider and add a replacement-provider regression. Existing discussion.
  • Paging helpers can collide with client methods. CollectionResultDefinition.cs:198 checks only helper-to-helper collisions. Pageable GetItems alongside a regular GetItemsCollectionResult operation produces a nested type and method with the same name (CS0102). This limitation has been acknowledged and explicitly deferred. Existing discussion.

No additional high-confidence findings from the review. These summarize the existing threads rather than duplicate inline comments.

--generated by Copilot

…per names

Reserve generated and custom client member names and the enclosing type name before allocating numeric paging helper suffixes.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 21, 2026 06:37
…sitors

Preserve and visit the members of the provider returned by VisitType, including nested and serialization providers, instead of overwriting them with the original members.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 22, 2026 06:37

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

Qualified custom-reference pruning and cached helper-name collisions after client renames can still produce SDKs that fail to compile.

3 open issues
1 resolved since last review

Review effort: Balanced

…ied references

Reallocate cached paging helper names after client identity updates while preserving customized constructors. Resolve unresolved relative type qualifiers within their lexical scope without broadening absolute or resolved references.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f

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

Shared visitor and dependency-pruning changes require maintainer confirmation of compatibility with downstream generator customizations.

1 open issue
2 resolved since last review

Review effort: Balanced

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 27, 2026 06:17

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

Helper naming can disconnect handwritten partial customizations, and cached paging bodies can retain obsolete helper identities after client renaming.

3 open issues

Review effort: Balanced

Invalidate spec views and client member caches on reset so paging bodies and nested helpers rebuild against the same client identity.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:03

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

Shared visitor, reset, and pruning changes require maintainer review, with an unresolved custom-reference retention defect.

2 open issues
2 resolved since last review

Review effort: Balanced

foreach (var dependency in customCodeView.BodyDependencyTypes)
{
AddNamespaceBodyDependencyType(roots, dependency, customNamespace, customMemberNames, generatedTypeNames);
AddNamespaceBodyDependencyType(roots, dependency, containingTypeName, customMemberNames, generatedTypeNames);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Fixed in 0fefae8, with additional import-form coverage in a2e0ce0. Static-imported containing types now supply candidates for unresolved nested-helper references. The pruning regression suppresses all generated paging methods and verifies that the referenced helper and its dependencies survive while another client’s same-named helper remains prunable.


🤖 arcturus-copilot

…orts

Include static-imported containing types when resolving unresolved references so referenced nested paging helpers survive pruning.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:41

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

Shared visitor, reset, and pruning changes warrant human review of downstream compatibility, alongside the unresolved static-import dependency issue.

3 open issues

Review effort: Balanced

- `MethodProvider`: Client methods and operations
- `PropertyProvider`: Model properties with accessors

Paging helpers are nested in their owning client and emitted together in

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.

I don't think we need this documentation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Removed the added paging-helper section from architecture.md in a2e0ce0. Kept the provider’s XML documentation describing its purpose.


🤖 arcturus-copilot

case QualifiedNameSyntax qualifiedName:
AddQualifiedUnresolvedDependencyType(dependencies, qualifiedName);
AddSyntaxTypeReference(qualifiedName.Right, dependencies, semanticModel, namespaceCandidates);
AddQualifiedUnresolvedDependencyType(dependencies, qualifiedName, semanticModel, namespaceCandidates);

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.

can we please add unit tests to exercise this new path?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Added QualifiedGenericBodyDependenciesIncludeTypeArguments in a2e0ce0 to exercise the qualified generic path: it checks the helper’s qualified identity and arity, retention of the generic argument dependency, and absence of an unqualified helper candidate. QualifiedBodyDependenciesPreserveReferenceScope also covers relative, absolute, resolved-type, resolved-qualifier, and parent-scope references.


🤖 arcturus-copilot

if (type != null)
{
var methods = new List<MethodProvider>();
foreach (var methodProvider in typeProvider.Methods)

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.

I'm curious why the change from typeProvider to type? Was this just an existing bug?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an existing bug, but this also contributes to the fix here.
I will let copilot reply this with some details and reasons.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ VisitType(typeProvider) can return a replacement provider (type). Reading members from the original typeProvider and then applying them through type.Update(...) overwrites that replacement’s members. That bug already existed for top-level and serialization providers.

It matters here because paging helpers are moving into nested types. This PR changes nested traversal from VisitType to VisitTypeCore so their members still receive visitor callbacks. Previously, a replacement nested provider was returned directly with its members intact; routing it through the old VisitTypeCore would instead overwrite those members. Traversing the returned type prevents that regression and also corrects the existing behavior for top-level and serialization replacements. Added regressions for all three cases.


🤖 arcturus-copilot

/// <summary></summary>
public partial class ExperimentalSamples
{

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.

nit: do we know why there's a blank line?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a minor issue in our writer - we always assume there would be other stuff above when we are writing nested type (which is the last thing we write in a class)
I will see if we could fix it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Fixed in a2e0ce0. The writer assigned NestedTypes.Any() to sectionWritten, so it emitted a separator even when no members preceded the nested types. It now checks both conditions; added writer baselines for nested-only declarations and declarations with a preceding field, and regenerated the sample outputs.


🤖 arcturus-copilot

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

When paging methods are suppressed, unnormalized global:: static imports cause pruning to delete a referenced nested helper, breaking compilation of the handwritten factory.

2 open issues
1 resolved since last review

Review effort: Balanced

Resolve static imports to their type identities, cover qualified generic dependencies, and avoid a leading separator in nested-only declarations. Remove unnecessary architecture documentation and regenerate fixtures.

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

Copilot-Session: 268abd28-b2c0-4898-87f0-4ca429090c1f
Copilot AI balanced review requested due to automatic review settings October 29, 2026 03:31

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

A critical cross-file dependency-resolution risk could remove a referenced generated type and break SDK compilation, requiring human assessment.

1 open issue
1 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.

[http-client-csharp] Simplify paging helper generation to improve robustness and downstream customization

4 participants