Fix detectModelConflicts false positive for API version enums in multi-service scenarios#3842
Merged
JialinHuang803 merged 5 commits intoAzure:mainfrom Mar 13, 2026
Conversation
Skip models with UsageFlags.ApiVersionEnum in detectModelConflicts to avoid false positive name conflicts in multi-service scenarios where each service defines its own Versions enum (e.g., compute smoke test with Compute and ComputeDisk services). This is consistent with existing patterns in emitModels.ts and crossLanguageDef.ts that already filter out API version enums. Fixes Azure#3841 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests cover: - No conflicts with distinct model names - True conflict with duplicate model names across namespaces - API version enums (Versions) not treated as conflicts in multi-service Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ompute Add @@clientName decorators in client.tsp to rename conflicting ActionGroup and ActionGroupsProperties models with namespace prefixes. Regenerated compute smoke test now has no model conflicts, so enableModelNamespace is false and models use simpler names (e.g., VirtualMachine instead of ComputeVirtualMachine). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
qiaozha
approved these changes
Mar 13, 2026
8 tasks
JialinHuang803
added a commit
to JialinHuang803/autorest.typescript
that referenced
this pull request
Apr 9, 2026
…i-service scenarios (Azure#3842) * Fix detectModelConflicts false positive for API version enums Skip models with UsageFlags.ApiVersionEnum in detectModelConflicts to avoid false positive name conflicts in multi-service scenarios where each service defines its own Versions enum (e.g., compute smoke test with Compute and ComputeDisk services). This is consistent with existing patterns in emitModels.ts and crossLanguageDef.ts that already filter out API version enums. Fixes Azure#3841 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add unit tests for detectModelConflicts Tests cover: - No conflicts with distinct model names - True conflict with duplicate model names across namespaces - API version enums (Versions) not treated as conflicts in multi-service Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove unit test file per review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Resolve ActionGroup model conflicts with @clientName and regenerate compute Add @@clientName decorators in client.tsp to rename conflicting ActionGroup and ActionGroupsProperties models with namespace prefixes. Regenerated compute smoke test now has no model conflicts, so enableModelNamespace is false and models use simpler names (e.g., VirtualMachine instead of ComputeVirtualMachine). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
The
detectModelConflictsfunction inpackages/typespec-ts/src/utils/namespaceUtils.tsincorrectly reports model name conflicts when multiple services each define their ownVersionsenum. In multi-service scenarios (e.g., thecomputesmoke test combiningComputeandComputeDiskservices), TCGC returns bothVersionsenums, and the function flags them as a name conflict.This is a false positive because API version enums are not generated in multi-service scenarios (already handled in
emitModels.tsandcrossLanguageDef.ts).Fix
Skip models with
UsageFlags.ApiVersionEnumin the conflict detection loop, consistent with existing patterns in:emitModels.ts(lines 220-223)crossLanguageDef.ts(lines 32-38)Validation
pnpm buildpassespnpm formatpassesFixes #3841