microsoft / microsoft/typespec

[http-client-csharp] Support composes client option for extension properties

Open
#11,715 1 comment 1 reaction 1 assignee Claimed by @jorgerangel-msft View on GitHub
emitter:client:csharp feature
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

## Description

Add support in the C# emitter for a `@clientOptions` option named `"composes"`. It indicates that the decorated model provides extension properties for another client options model.

```tsp
@alternateType(
{ identity: "OpenAI.Responses.CreateResponseOptions" },
"csharp"
)
model OpenAICreateResponseOptions {}

@clientOptions({
name: "composes",
value: OpenAICreateResponseOptions,
scope: "csharp"
})
model FoundryCreateResponseOptions {
agent: AgentReference;
agentConversationId: string;
sessionId: string;
}
```

Model-valued `clientOptions` support is tracked separately in https://github.com/Azure/typespec-azure/issues/5256.

## Expected behavior

The C# emitter should generate the properties declared by `FoundryCreateResponseOptions` as extension properties on the alternate type associated with `OpenAICreateResponseOptions`, `OpenAI.Responses.CreateResponseOptions`. Conceptually, the output should follow this shape:

```csharp
public static class FoundryCreateResponseOptionsExtensions
{
extension (OpenAI.Responses.CreateResponseOptions _)
{
public AgentReference Agent { get; set; }
public string AgentConversationId { get; set; }
public string SessionId { get; set; }
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.