Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

The issue requested verification that duplicate client name detection works correctly when combining positive scopes with negation scopes (e.g., "python" with "!csharp").

Changes

  • Added test verifying conflict detection when scopes overlap:

    @clientName("Foo", "python")    // applies to python only
    @clientName("Foo", "!csharp")   // applies to all except csharp

    Both resolve to "Foo" in python scope → conflict detected ✓

  • Added test verifying no conflict when scopes don't overlap:

    @clientName("Foo", "csharp")    // applies to csharp only
    @clientName("Foo", "!csharp")   // excludes csharp

    No overlap → no conflict ✓

Notes

  • Existing validation logic in src/validations/types.ts already handles this correctly
  • Negation syntax uses ! not ~ (issue description mentioned ~csharp but actual syntax is !csharp)
Original prompt

This section details on the original issue you should resolve

<issue_title>[TCGC] Client name validation for negation scope case</issue_title>
<issue_description>Current logic could not detect such conflict.</issue_description>

<agent_instructions>Make sure if there are two models with the same client name set, we raise the appropriate error / warning.
For example, if I want to generate something like @@clientName(ModelOne, "Foo", "python") and @@clientName(ModelTwo, "Foo", "~csharp"), I'm not sure we raise the appropriate name-conflict validation. Please check if we do. If we do, add a test and submit the PR. If we do not, update the code so the test / other tests you add work</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Jan 13, 2026
Copilot AI and others added 3 commits January 13, 2026 20:07
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add client name validation for negation scope case Add tests for client name validation with negation scopes Jan 13, 2026
Copilot AI requested a review from iscai-msft January 13, 2026 20:13
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 26, 2026
…opilot/validate-client-name-negation-scope
@iscai-msft iscai-msft marked this pull request as ready for review January 26, 2026 20:59
@tadelesh
Copy link
Member

The issue aims to solve the problem in this function:

function getDefinedLanguageScopes(program: Program): Set<string | typeof AllScopes> {
.
This function only gathering all positive scopes, but does not take negation scopes into account.
For example, if there is @clientName("XXX", "~csharp"), the validation should apply to AllScopes except csharp.

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.

[TCGC] Client name validation for negation scope case

3 participants