-
Notifications
You must be signed in to change notification settings - Fork 68
[tcgc] crash if duplicate models / enums across namespaces when flattened with namespace flag or multi service #3775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…cgc/duplicateModelNames
commit: |
|
All changed packages have been documented.
Show changes
|
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
packages/typespec-client-generator-core/src/validations/types.ts
Outdated
Show resolved
Hide resolved
|
Shall we have some discussions with TypeSpec team to see their suggestions for such kind of validation, since it will impact perf. |
|
You can try these changes here
|
…cgc/duplicateModelNames
…cgc/duplicateModelNames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide to check the cross namespace collision after createSdkContext, I believe the algorithm could be much easier, just check all types in SdkPackage.
| // Build a map of namespace names to their types for resolving string targets | ||
| const namedNamespaces = new Map<string, Namespace>(); | ||
| for (const ns of listAllUserDefinedNamespaces(tcgcContext)) { | ||
| if (ns.name) { | ||
| namedNamespaces.set(ns.name, ns); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespace name could have collision under different namespace. Since @clientLocation for operation with string could collide with existed namespace only limited to the first layer's namespace under @service namespace, the algorithm needs to be updated. But I think we could leave it for anther PR. Maybe revert the change for check in namespace is the fastest way.
| // Ensure we always run validation at least once (with AllScopes) | ||
| if (languageScopes.size === 0) { | ||
| languageScopes.add(AllScopes); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When createSdkContext, we already have the emitter name, no need to all scopes.
Resolve: #1039