Skip to content
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

Implement scope negation for TCGC #1783

Merged
merged 32 commits into from
Nov 8, 2024
Merged

Conversation

live1206
Copy link
Member

@live1206 live1206 commented Nov 1, 2024

Resolves #1596

There are 2 formats of scope negation:

@clientName("A", "!(python, java)")
Model foo

is equivalent to

@clientName("A", "!python, !java")
Model foo

We allow combination of normal scope and negation scope for different scopes

@clientName("A", "!python, csharp")
Model foo

Combination of same scope is also allowed

@clientName("A", "!python, python")
Model foo

is equivalent to

@clientName("A", "!python")
@clientName("A", "python")
Model foo

and equivalent to

@clientName("A")
Model foo

The rule for decorator override:

  • for the same scope, the later decorator value wins regardless it's defined with normal scope or scope negation

Detailed override cases can be found in the tests of this PR.

@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Nov 1, 2024
@live1206 live1206 changed the title Implement scope negation Implement scope negation for TCGC Nov 1, 2024
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.

please also change the documentation for the scope parameter in decorators.tsp to explain the patten could be used in scope

packages/typespec-client-generator-core/src/decorators.ts Outdated Show resolved Hide resolved
packages/typespec-client-generator-core/src/decorators.ts Outdated Show resolved Hide resolved
@azure-sdk
Copy link
Collaborator

azure-sdk commented Nov 6, 2024

All changed packages have been documented.

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

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

Implement scope negation for TCGC decorators

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

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.

the algorithm looks good. please merge before you refine the test.

@live1206 live1206 added this pull request to the merge queue Nov 8, 2024
Merged via the queue into Azure:main with commit d0d9485 Nov 8, 2024
22 checks passed
@live1206 live1206 deleted the scope-negation branch November 8, 2024 03:00
markcowl pushed a commit to markcowl/typespec-azure that referenced this pull request Dec 5, 2024
Resolves Azure#1596

There are 2 formats of scope negation:
```
@clientName("A", "!(python, java)")
Model foo
```
is equivalent to
```
@clientName("A", "!python, !java")
Model foo
```
We allow combination of normal scope and negation scope for different
scopes
```
@clientName("A", "!python, csharp")
Model foo
```
Combination of same scope is also allowed
```
@clientName("A", "!python, python")
Model foo
```
is equivalent to
```
@clientName("A", "!python")
@clientName("A", "python")
Model foo
```
and equivalent to
```
@clientName("A")
Model foo
```

The rule for decorator override:
- for the same scope, the later decorator value wins regardless it's
defined with normal scope or scope negation

Detailed override cases can be found in the tests of this PR.
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] support negation for scope in tcgc decorators
4 participants