Skip to content

Conversation

@iscai-msft
Copy link
Contributor

@iscai-msft iscai-msft commented Jan 14, 2026

Resolve: #1039

@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 14, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/typespec-client-generator-core@3775

commit: b958a84

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 14, 2026

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - fix ✏️

Correctly detect name collisions with --namespace flag and or multi service usage

@tadelesh
Copy link
Member

Shall we have some discussions with TypeSpec team to see their suggestions for such kind of validation, since it will impact perf.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 20, 2026

You can try these changes here

🛝 Playground 🌐 Website

@iscai-msft iscai-msft requested a review from tadelesh January 28, 2026 18:04
@iscai-msft iscai-msft enabled auto-merge January 28, 2026 18:05
Copy link
Member

@tadelesh tadelesh left a 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.

Comment on lines +61 to +67
// 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);
}
}
Copy link
Member

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);
}
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linter Rule] Add warning if service spec has naming conflict cross namespace

4 participants