Azure / typespec-azure

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

TCGC: @methodLocation decorator #914

Open l0lawrence opened 1 month ago

l0lawrence commented 1 month ago

Is it possible to move parameters that persist on each operation to the client instead with a decorator of some sort? In EventGrid this shows up in the case of

client() publish(topic_name, events) receive(topic_name, subscription_name, max_events) ack(topic_name, subscription_name, lock_tokens)

to

client(topic_name, subscription_name) publish(events) receive(max_events) ack(lock_tokens)

typespec spec: https://github.com/Azure/azure-rest-api-specs/blob/9df71d5a717e4ed5e6728e7e6ba2fead60f62243/specification/eventgrid/Azure.Messaging.EventGrid/main.tsp#L261

iscai-msft commented 1 month ago

I see the need for this decorator, what about something like @parameterScope. Going to post this in the dpg sync chat and have people respond

tadelesh commented 1 month ago

similar with https://github.com/Azure/typespec-azure/issues/493?

m-nash commented 1 month ago

main.tsp

interface foo { op myOp(x: int, y: int) : void }

client.tsp

@clientName("FooClientOptions", "csharp") model myClientInitModel { x: int; }

@@client(foo, { additionalInitialization: myClientInitModel })

//typegraph from tcgc

SdkOperation { parameters: [ {x: int, location: client}, { y: int, location: operation } ] }

SdkMethod { parameters: [ { y: int, location: operation } ] }

lmazuel commented 1 month ago

similar with #493?

Yes, I agree it's a duplicate, I'm closing #493