Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
14 stars 40 forks source link

[tcgc] support negation for scope in tcgc decorators #1596

Open tadelesh opened 4 weeks ago

tadelesh commented 4 weeks ago

Support scope like !java to represent all languages except java. Real use case could refer this: https://github.com/Azure/azure-rest-api-specs/blob/4883fa5dbf6f2c9093fac8ce334547e9dfac68fa/specification/batch/Azure.Batch/routes.tsp#L133.

live1206 commented 1 week ago
  1. Use ! for negation
  2. When negate multiple scopes: !(java, csharp) or !(java | csharp)
  3. Since negation means excluding the defined scopes from the rest, we don't want to mix the negation usage with normal usages. So, it is illegal to write "!java, csharp"
  4. If agreed with 3, we will store the negation scopes or the normal scopes into state
tadelesh commented 1 week ago
  1. Use ! for negation
  2. When negate multiple scopes: !(java, csharp) or !(java | csharp)
  3. Since negation means excluding the defined scopes from the rest, we don't want to mix the negation usage with normal usages. So, it is illegal to write "!java, csharp"
  4. If agreed with 3, we will store the negation scopes or the normal scopes into state

agree with 3. only allow !(java, chsarp)

another situation is setting one decorator multiple times. e.g.:

@clientName("B", "!csharp")
@clientName("A", "java")
model T {}

the result should be the later override the former: T for csharp, B for else.

live1206 commented 1 week ago

Have we considered to avoid multiple usage of the same decorator? or we want to allow it for @clientName?

tadelesh commented 1 week ago

Have we considered to avoid multiple usage of the same decorator? or we want to allow it for @clientName?

see discussion here: https://github.com/Azure/typespec-azure/pull/1606#discussion_r1778791173