Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Flows correspondingMethodParams metadata from TCGC through the emitter to the C# generator. This enables mapping from convenience method parameters to protocol parameters for @override decorator scenarios.

TypeScript Changes

  • Added correspondingMethodParams?: InputMethodParameter[] to InputQueryParameter, InputPathParameter, InputHeaderParameter, InputBodyParameter, and InputEndpointParameter
  • Created getCorrespondingMethodParams() helper in operation-converter.ts to extract method parameters from TCGC's methodParameterSegments (a 2D array structure)
  • Updated all parameter creation functions (fromQueryParameter, fromPathParameter, etc.) to populate the property

C# Changes

  • Added CorrespondingMethodParams property to InputParameter base class
  • Updated serialization converters (InputQueryParameterConverter, InputPathParameterConverter, InputHeaderParameterConverter, InputBodyParameterConverter, InputEndpointParameterConverter) to deserialize the property

Implementation Details

The implementation uses TCGC's methodParameterSegments property, which is a 2D array where:

  • First dimension represents different method parameter mappings
  • Second dimension is the segment path to the property
  • The last element of each segment array is extracted as the actual SdkMethodParameter

Property is optional and uses type casting (p as any).methodParameterSegments to handle cases where TCGC may not provide it.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for Override decorator</issue_title>
<issue_description>See Azure/azure-sdk-for-net#51956 for the spector scenario, though this should be implemented in this repo in the unbranded generator. I am going to file a follow up issue asking that all non-Azure features are covered in the unbranded spector scenarios. There is nothing Azure specific about the override decorator. It is basically implemented in TCGC, but the one piece we need to handle in the C# generator is the conversion from the convenience method model to the protocol parameters. In order to do this mapping, we will need to flow through the correspondingMethodParams from TCGC. We should add this as a property on all of the types defined in the union here https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/emitter/src/type/input-type.ts#L177. We would then need to flow this through to the C# input types. The corresponding C# type for the property is InputMethodParameter. This would need to be a property one each of the protocol parameter Input types. We would then need to use this mapping when calling the protocol methods to get the correct method arguments.</issue_description>

Comments on the Issue (you are @copilot in this section)

@JoshLove-msft This is blocked on needing more metadata - https://github.com/Azure/typespec-azure/issues/3488

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 30, 2026
p: SdkHttpParameter | SdkModelPropertyType,
): InputMethodParameter[] | undefined {
// correspondingMethodParams is only available on SdkHttpParameter and SdkModelPropertyType
const correspondingParams = (p as any).correspondingMethodParams;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot we should be using methodParametersSegements instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use methodParameterSegments in commit 3174687. The function now iterates through the 2D array structure and extracts the last segment from each array which represents the actual method parameter.

Copilot AI and others added 2 commits January 30, 2026 18:38
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for Override decorator in C# generator Add correspondingMethodParams to input parameter types for override decorator support Jan 30, 2026
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Override decorator

2 participants