-
Notifications
You must be signed in to change notification settings - Fork 68
Fix namespace duplication when @clientNamespace matches namespace flag #3849
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
Conversation
|
❌ There is undocummented changes. Run The following packages have changes but are not documented.
Show changes |
|
You can try these changes here
|
commit: |
.chronus/changes/copilot-fix-namespace-duplication-issue-2026-0-27-18-6-46.md
Outdated
Show resolved
Hide resolved
9d74c00 to
803d764
Compare
|
@copilot I messed up. Please force push the final 7 commits only to this branch. |
I've prepared the branch locally with exactly 7 commits (removed the empty "Initial plan" commit). However, I cannot force push due to authentication limitations. The local branch now has the correct history: To complete the force push, you'll need to run: git fetch origin copilot/fix-namespace-duplication-issue
git reset --hard 5a28391 # Reset to base
git cherry-pick baf0699 e556348 ce62184 6550e39 527d292 86882c2 803d764 # Apply 7 commits
git push --force origin copilot/fix-namespace-duplication-issueOr alternatively, if you trust my local state, you can pull the prepared branch from the Actions runner (though this typically isn't accessible). |
cc01510 to
4db8856
Compare
Co-authored-by: JoshLove-msft <[email protected]>
Co-authored-by: JoshLove-msft <[email protected]>
Remove Check 2 which is redundant with Check 3's equality check. Check 3 already includes `|| joinedSegments === context.namespaceFlag` which covers the exact match scenario that Check 2 handled. Co-authored-by: JoshLove-msft <[email protected]>
…0-27-18-6-46.md Co-authored-by: Timothee Guerin <[email protected]>
The previous check was too broad - it would skip replacement whenever joinedSegments started with the namespace flag, even when replacement was needed. The refined check only skips replacement when: 1. The namespace flag is an extension of the user-defined namespace 2. AND the joinedSegments already starts with the flag This correctly handles scenarios like: - joinedSegments="Azure.Search.Documents.Foo" with flag="Azure.Search" and userNs="Azure.Search.Documents" → DO replacement (flag doesn't extend userNs) - joinedSegments="Azure.Search.Documents" with flag="Azure.Search.Documents" and userNs="Azure.Search" → SKIP replacement (flag extends userNs, already has flag) Co-authored-by: JonathanCrd <[email protected]>
Co-authored-by: JoshLove-msft <[email protected]>
4db8856 to
35a5d2d
Compare
Namespace Duplication Fix - Complete
Summary
Fixed a bug where using
@clientNamespacedecorator with the same value as the TCGCnamespaceoption causes incorrect namespace concatenation.Minimal Fix (2 checks)
getClientNamespace(): Return early if override equals namespace flag - handles client namespacegetNamespaceFullNameWithOverride(): Return early if namespace flag extends user namespace AND segments start with flag - handles models/types in same or nested namespacesChanges Made
getClientNamespace()function to check if override matches namespace flag before replacementgetNamespaceFullNameWithOverride()with precise duplication detection that only skips replacement when the flag is an extension of the user namespaceThe Problem
When a spec defines:
@clientNamespace("Azure.Search.Documents")namespace: "Azure.Search.Documents"The namespace was being incorrectly duplicated to
Azure.Search.Documents.Search.Documents.Root Cause
The function used simple string replacement that would find a user-defined namespace and replace it with the flag value, causing duplication when the override already contained the desired final namespace.
The Fix
Added checks to return early if:
This prevents unnecessary string replacements that cause duplication while still allowing legitimate replacements when needed.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.