Skip to content

[http-client-csharp] Allow @@override options bag to apply to protocol methods (currently only convenience) #11214

Description

@m-nash

Summary

When an operation is customized with an options-bag parameter model via @@override, only the convenience method adopts the options bag. The protocol method still lists every parameter individually, so operations with many parameters keep a large protocol signature. It would be useful for the options-bag grouping to apply to the protocol method as well.

Reproduction

main.tsp:

import "@typespec/http";
using Http;

@service(#{ title: "Widget Service" })
@server("https://example.com", "endpoint")
namespace WidgetService;

model Widget { id: string; }

@route("/widgets/{id}") @get
op getWidget(@path id: string, @query filter?: string, @query top?: int32, @query skip?: int32): Widget;

client.tsp:

import "./main.tsp";
import "@typespec/http";
import "@azure-tools/typespec-client-generator-core";
using Http;
using Azure.ClientGenerator.Core;

model GetWidgetOptions {
  @path id: string;
  @query filter?: string;
  @query top?: int32;
  @query skip?: int32;
}

op getWidgetCustomized(options: GetWidgetOptions): void;

@@override(WidgetService.getWidget, getWidgetCustomized);

tspconfig.yaml:

emit: ["@typespec/http-client-csharp"]
options:
  "@typespec/http-client-csharp":
    package-name: "WidgetService"

Actual

// protocol method - still fully flattened, ignores the override's options bag
public virtual ClientResult GetWidget(string id, string filter = default, int? top = default, int? skip = default, RequestOptions options = null)

// convenience method - correctly uses the options bag
public virtual ClientResult<Widget> GetWidget(GetWidgetOptions options, CancellationToken cancellationToken = default)

Expected / request

The @@override options-bag shape should also apply to the protocol method, so the modeled parameters (path/query/body) are grouped into the options model rather than listed individually, keeping only the trailing RequestOptions/RequestContext. Operations with many parameters (e.g. tiler/imaging APIs with 20-40+ query params) would then get a compact protocol signature instead of a very long one.

Versions

  • @typespec/compiler: 1.13.0
  • @typespec/http-client-csharp: 1.0.0-alpha.20260703.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharpfeatureNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions