Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b86f3eb
Initial plan
Copilot Jan 30, 2026
4865ac9
Add correspondingMethodParams to TypeScript input parameter types
Copilot Jan 30, 2026
4873b4a
Add CorrespondingMethodParams property to C# input parameter types
Copilot Jan 30, 2026
0c6ce45
Fix double semicolons in parameter converters
Copilot Jan 30, 2026
3174687
Use methodParameterSegments instead of correspondingMethodParams
Copilot Jan 30, 2026
c6b2499
Implement CorrespondingMethodParams mapping for convenience to protoc…
Copilot Feb 4, 2026
529f1ca
Store complete segment path in CorrespondingMethodParams for property…
Copilot Feb 4, 2026
67bc763
Rename CorrespondingMethodParams to MethodParameterSegments to match …
Copilot Feb 4, 2026
6380618
Use ModelProviderSnippets.GetPropertyExpression for property navigation
Copilot Feb 4, 2026
0b641c4
Fixes
JoshLove-msft Feb 4, 2026
4af3af7
Iterate through protocol parameters to maintain correct argument order
Copilot Feb 4, 2026
9f05275
Fix body parameter conversion for override scenarios and add Update s…
Copilot Feb 4, 2026
219d0d7
Fix body parameter wrapping for extracted property values in override…
Copilot Feb 4, 2026
cba20c5
Use implicit cast to RequestContent instead of explicit wrapping
Copilot Feb 4, 2026
bfcccb0
working
JoshLove-msft Feb 5, 2026
3ca609e
delete
JoshLove-msft Feb 5, 2026
dc1e98c
Merge branch 'main' of https://github.com/microsoft/typespec into cop…
JoshLove-msft Feb 5, 2026
8410c7a
regen
JoshLove-msft Feb 5, 2026
7a8be94
regen
JoshLove-msft Feb 5, 2026
757f95e
Add extensive unit tests for MethodParameterSegments functionality
Copilot Feb 5, 2026
bf421aa
Fix TypeScript test errors in method-parameter-segments.test.ts
Copilot Feb 5, 2026
b3c8065
fix tests
JoshLove-msft Feb 5, 2026
75f9b36
format
JoshLove-msft Feb 5, 2026
a39750f
Merge branch 'main' of https://github.com/microsoft/typespec into cop…
JoshLove-msft Feb 5, 2026
8c06911
regen
JoshLove-msft Feb 5, 2026
1caf895
fix generate script
JoshLove-msft Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {
fromMethodParameter,
fromSdkServiceMethod,
getCorrespondingMethodParams,
getParameterDefaultValue,
} from "./operation-converter.js";
import { fromSdkType } from "./type-converter.js";
Expand Down Expand Up @@ -182,6 +183,7 @@ function fromSdkClient(
skipUrlEncoding: false,
readOnly: isReadOnly(parameter),
crossLanguageDefinitionId: parameter.crossLanguageDefinitionId,
correspondingMethodParams: getCorrespondingMethodParams(sdkContext, parameter),
});
}
return parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ function fromQueryParameter(
decorators: p.decorators,
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
readOnly: isReadOnly(p),
correspondingMethodParams: getCorrespondingMethodParams(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -472,6 +473,7 @@ function fromPathParameter(
decorators: p.decorators,
readOnly: isReadOnly(p),
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
correspondingMethodParams: getCorrespondingMethodParams(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -502,6 +504,7 @@ function fromHeaderParameter(
readOnly: isReadOnly(p),
decorators: p.decorators,
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
correspondingMethodParams: getCorrespondingMethodParams(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -530,6 +533,7 @@ function fromBodyParameter(
decorators: p.decorators,
readOnly: isReadOnly(p),
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
correspondingMethodParams: getCorrespondingMethodParams(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -920,6 +924,30 @@ function getArraySerializationDelimiter(
return format ? collectionFormatToDelimMap[format] : undefined;
}

export function getCorrespondingMethodParams(
sdkContext: CSharpEmitterContext,
p: SdkHttpParameter | SdkModelPropertyType,
): InputMethodParameter[] | undefined {
// methodParameterSegments is a 2D array where each segment array represents a path to a method parameter
// We need to get the last element of each segment array which is the actual method parameter
const methodParameterSegments = (p as any).methodParameterSegments;
Comment thread
JoshLove-msft marked this conversation as resolved.
if (!methodParameterSegments || methodParameterSegments.length === 0) {
return undefined;
}

const namespace = getClientNamespaceString(sdkContext) ?? "";
const methodParams: InputMethodParameter[] = [];

for (const segments of methodParameterSegments) {
if (segments && segments.length > 0) {
const methodParam = segments[segments.length - 1] as SdkMethodParameter;
methodParams.push(fromMethodParameter(sdkContext, methodParam, namespace));
}
}

return methodParams.length > 0 ? methodParams : undefined;
}

function getResponseType(
sdkContext: CSharpEmitterContext,
type: SdkType | undefined,
Expand Down
5 changes: 5 additions & 0 deletions packages/http-client-csharp/emitter/src/type/input-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export interface InputQueryParameter extends InputPropertyTypeBase {
explode: boolean;
scope: InputParameterScope;
serializedName: string;
correspondingMethodParams?: InputMethodParameter[];
}

export interface InputPathParameter extends InputPropertyTypeBase {
Expand All @@ -218,6 +219,7 @@ export interface InputPathParameter extends InputPropertyTypeBase {
serverUrlTemplate?: string;
scope: InputParameterScope;
serializedName: string;
correspondingMethodParams?: InputMethodParameter[];
}

export interface InputHeaderParameter extends InputPropertyTypeBase {
Expand All @@ -227,6 +229,7 @@ export interface InputHeaderParameter extends InputPropertyTypeBase {
isContentType: boolean;
scope: InputParameterScope;
serializedName: string;
correspondingMethodParams?: InputMethodParameter[];
}

export interface InputBodyParameter extends InputPropertyTypeBase {
Expand All @@ -235,6 +238,7 @@ export interface InputBodyParameter extends InputPropertyTypeBase {
defaultContentType: string;
scope: InputParameterScope;
serializedName: string;
correspondingMethodParams?: InputMethodParameter[];
}

export interface InputEndpointParameter extends InputPropertyTypeBase {
Expand All @@ -244,6 +248,7 @@ export interface InputEndpointParameter extends InputPropertyTypeBase {
scope: InputParameterScope;
serializedName: string;
isEndpoint: boolean;
correspondingMethodParams?: InputMethodParameter[];
}

export interface InputEnumType extends InputTypeBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text.Json;

namespace Microsoft.TypeSpec.Generator.Input
Expand All @@ -26,6 +27,7 @@ protected InputParameter(
}

public InputParameterScope Scope { get; internal set; }
public IReadOnlyList<InputMethodParameter>? CorrespondingMethodParams { get; internal set; }
Comment thread
JoshLove-msft marked this conversation as resolved.
Outdated

/// <summary>
/// Update the instance with given parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ internal static InputBodyParameter ReadInputBodyParameter(ref Utf8JsonReader rea
IReadOnlyList<string>? contentTypes = null;
string? defaultContentType = null;
IReadOnlyList<InputDecoratorInfo>? decorators = null;
IReadOnlyList<InputMethodParameter>? correspondingMethodParams = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
Expand All @@ -79,7 +80,8 @@ internal static InputBodyParameter ReadInputBodyParameter(ref Utf8JsonReader rea
|| reader.TryReadString("scope", ref scope)
|| reader.TryReadComplexType("contentTypes",options, ref contentTypes)
|| reader.TryReadComplexType("defaultContentType", options, ref defaultContentType)
|| reader.TryReadComplexType("decorators", options, ref decorators);
|| reader.TryReadComplexType("decorators", options, ref decorators)
|| reader.TryReadComplexType("correspondingMethodParams", options, ref correspondingMethodParams);

if (!isKnownProperty)
{
Expand All @@ -101,6 +103,7 @@ internal static InputBodyParameter ReadInputBodyParameter(ref Utf8JsonReader rea
parameter.Scope = InputParameter.ParseScope(type, name, scope);
parameter.ContentTypes = contentTypes ?? throw new JsonException($"{nameof(InputBodyParameter)} must have a contentTypes.");
parameter.DefaultContentType = defaultContentType ?? throw new JsonException($"{nameof(InputBodyParameter)} must have a defaultContentType.");
parameter.CorrespondingMethodParams = correspondingMethodParams;

return parameter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ internal static InputEndpointParameter ReadInputEndpointParameter(ref Utf8JsonRe
string? serverUrlTemplate = null;
bool isEndpoint = false;
IReadOnlyList<InputDecoratorInfo>? decorators = null;
IReadOnlyList<InputMethodParameter>? correspondingMethodParams = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
Expand All @@ -82,7 +83,8 @@ internal static InputEndpointParameter ReadInputEndpointParameter(ref Utf8JsonRe
|| reader.TryReadString("scope", ref scope)
|| reader.TryReadBoolean("skipUrlEncoding", ref skipUrlEncoding)
|| reader.TryReadBoolean("isEndpoint", ref isEndpoint)
|| reader.TryReadComplexType("decorators", options, ref decorators);
|| reader.TryReadComplexType("decorators", options, ref decorators)
|| reader.TryReadComplexType("correspondingMethodParams", options, ref correspondingMethodParams);

if (!isKnownProperty)
{
Expand All @@ -103,8 +105,9 @@ internal static InputEndpointParameter ReadInputEndpointParameter(ref Utf8JsonRe
parameter.IsApiVersion = isApiVersion;
parameter.DefaultValue = defaultValue;
parameter.IsEndpoint = isEndpoint;
parameter.Scope = InputParameter.ParseScope(type, name, scope);;
parameter.Scope = InputParameter.ParseScope(type, name, scope);
parameter.SkipUrlEncoding = skipUrlEncoding;
parameter.CorrespondingMethodParams = correspondingMethodParams;

return parameter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ internal static InputHeaderParameter ReadInputHeaderParameter(ref Utf8JsonReader
string? access = null;
string? collectionFormat = null;
IReadOnlyList<InputDecoratorInfo>? decorators = null;
IReadOnlyList<InputMethodParameter>? correspondingMethodParams = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
Expand All @@ -82,7 +83,8 @@ internal static InputHeaderParameter ReadInputHeaderParameter(ref Utf8JsonReader
|| reader.TryReadString("scope", ref scope)
|| reader.TryReadString("arraySerializationDelimiter", ref arraySerializationDelimiter)
|| reader.TryReadBoolean("isContentType", ref isContentType)
|| reader.TryReadComplexType("decorators", options, ref decorators);
|| reader.TryReadComplexType("decorators", options, ref decorators)
|| reader.TryReadComplexType("correspondingMethodParams", options, ref correspondingMethodParams);

if (!isKnownProperty)
{
Expand All @@ -102,9 +104,10 @@ internal static InputHeaderParameter ReadInputHeaderParameter(ref Utf8JsonReader
parameter.SerializedName = serializedName ?? throw new JsonException($"{nameof(InputHeaderParameter)} must have a serializedName.");
parameter.IsApiVersion = isApiVersion;
parameter.DefaultValue = defaultValue;
parameter.Scope = InputParameter.ParseScope(type, name, scope);;
parameter.Scope = InputParameter.ParseScope(type, name, scope);
parameter.ArraySerializationDelimiter = arraySerializationDelimiter;
parameter.IsContentType = isContentType;
parameter.CorrespondingMethodParams = correspondingMethodParams;

return parameter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal static InputPathParameter ReadInputPathParameter(ref Utf8JsonReader rea
string? serverUrlTemplate = null;
bool allowReserved = false;
IReadOnlyList<InputDecoratorInfo>? decorators = null;
IReadOnlyList<InputMethodParameter>? correspondingMethodParams = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
Expand All @@ -85,7 +86,8 @@ internal static InputPathParameter ReadInputPathParameter(ref Utf8JsonReader rea
|| reader.TryReadString("scope", ref scope)
|| reader.TryReadBoolean("explode", ref explode)
|| reader.TryReadBoolean("skipUrlEncoding", ref skipUrlEncoding)
|| reader.TryReadComplexType("decorators", options, ref decorators);
|| reader.TryReadComplexType("decorators", options, ref decorators)
|| reader.TryReadComplexType("correspondingMethodParams", options, ref correspondingMethodParams);

if (!isKnownProperty)
{
Expand All @@ -106,9 +108,10 @@ internal static InputPathParameter ReadInputPathParameter(ref Utf8JsonReader rea
parameter.SerializedName = serializedName ?? throw new JsonException($"{nameof(InputPathParameter)} must have a serializedName.");
parameter.IsApiVersion = isApiVersion;
parameter.DefaultValue = defaultValue;
parameter.Scope = InputParameter.ParseScope(type, name, scope);;
parameter.Scope = InputParameter.ParseScope(type, name, scope);
parameter.Explode = explode;
parameter.SkipUrlEncoding = skipUrlEncoding;
parameter.CorrespondingMethodParams = correspondingMethodParams;

return parameter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ internal static InputQueryParameter ReadInputQueryParameter(ref Utf8JsonReader r
string? collectionFormat = null;
bool explode = false;
IReadOnlyList<InputDecoratorInfo>? decorators = null;
IReadOnlyList<InputMethodParameter>? correspondingMethodParams = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
Expand All @@ -82,7 +83,8 @@ internal static InputQueryParameter ReadInputQueryParameter(ref Utf8JsonReader r
|| reader.TryReadString("scope", ref scope)
|| reader.TryReadString("arraySerializationDelimiter", ref arraySerializationDelimiter)
|| reader.TryReadBoolean("explode", ref explode)
|| reader.TryReadComplexType("decorators", options, ref decorators);
|| reader.TryReadComplexType("decorators", options, ref decorators)
|| reader.TryReadComplexType("correspondingMethodParams", options, ref correspondingMethodParams);

if (!isKnownProperty)
{
Expand All @@ -103,8 +105,9 @@ internal static InputQueryParameter ReadInputQueryParameter(ref Utf8JsonReader r
parameter.SerializedName = serializedName ?? throw new JsonException($"{nameof(InputQueryParameter)} must have a serializedName.");
parameter.IsApiVersion = isApiVersion;
parameter.DefaultValue = defaultValue;
parameter.Scope = InputParameter.ParseScope(type, name, scope);;
parameter.Scope = InputParameter.ParseScope(type, name, scope);
parameter.ArraySerializationDelimiter = arraySerializationDelimiter;
parameter.CorrespondingMethodParams = correspondingMethodParams;

return parameter;
}
Expand Down
Loading