You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix C# paging helper naming collisions and long filenames - #12292
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.
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
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
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 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.
…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
…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
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
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.
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.
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.
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.
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.
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12147.
Summary
<ClientName>.Collections.cs, following option 2 discussed in the issue.ClientProvider.CollectionResultProviderslazily creates and caches this partial declaration.<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 append2,3, etc. For example, two operations normalized toGetAllproduceGetAllCollectionResultandGetAllCollectionResult2.RemoveOrInternalize, and skip removed nested types during emission. Preserve existing ownership-based retention for other nested types andkeepAllbehavior.Generated SDK public APIs and paging iteration logic are unchanged. Internal helper names and qualified locations change with the nested layout.
Validation
net8.0with the initial nested layout and emitted five per-client collections files instead of per-operation files.pnpm formatpassed after the latest changes.Spector HTTP runtime integration tests were not run.