fix(http-server-csharp): prevent _2 suffix on generated class/interface names from library namespace collisions - #11496
Draft
abatishchev with Copilot wants to merge 2 commits into
Draft
fix(http-server-csharp): prevent _2 suffix on generated class/interface names from library namespace collisions#11496abatishchev with Copilot wants to merge 2 commits into
_2 suffix on generated class/interface names from library namespace collisions#11496abatishchev with Copilot wants to merge 2 commits into
Conversation
|
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. |
4 tasks
…cting collection to @service namespaces When a library namespace (e.g. Azure.ResourceManager) defines interfaces or models with the same name as those in the user's @service namespace, the emitter previously collected both, causing alloy-js to rename the second occurrence with a _2 suffix (e.g. OperationsController_2, IOperations_2, ErrorResponse_2). Fix getServiceInterfaces (service-discovery.ts) and getServiceModels (service-resolution.ts) to restrict their initial collection to @service-decorated namespaces via listServices(program). A fallback to the old all-namespace behaviour is kept for TypeSpec programs without @service. Models transitively referenced by service operations (in any namespace) are still discovered and emitted through discoverReferencedModels/discoverModelsInType. Closes #11493 Co-authored-by: abatishchev <351644+abatishchev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix generated classes with incorrect naming convention
fix(http-server-csharp): prevent Jul 30, 2026
_2 suffix on generated class/interface names from library namespace collisions
commit: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a library namespace (e.g.
Azure.ResourceManager) defines interfaces or models with the same name as those in the user's@servicenamespace, the emitter was collecting both, causing alloy-js to rename the second occurrence with a_2suffix — producing invalid C# where the class name and constructor name no longer match:Root cause
getServiceInterfacesandgetServiceModelstraversed all non-standard namespaces in the global namespace tree, including library namespaces likeAzure.ResourceManager. ARM RP specs define concreteOperationsinterfaces and common types (e.g.ErrorResponse) in those namespaces; when the same name appeared in the user's service namespace, both were emitted and the second got_2appended to its class declaration.Changes
service-discovery.ts—getServiceInterfaces: Now callslistServices(program)and only collects interfaces from@service-decorated namespaces. Falls back to the previous all-namespace scan when no@servicedecorator is present (e.g. unit tests).service-resolution.ts—getServiceModels: Same scoping applied to the initial namespace model collection and thediscoverReferencedModelsstarting points. Models transitively referenced by service operations (regardless of which namespace they live in) continue to be discovered and emitted viadiscoverModelsInType.test/service-discovery.test.ts: New regression tests covering both the interface/controller case and the model case.