Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 18 additions & 1 deletion docs/samples/client/csharp/SampleService/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ model XmlModelWithNamespace {
foo: string;
}

model Wrapper {
@doc("header parameter")
@header
p1: string;

@doc("body parameter")
@body
action: RoundTripModel;

@doc("path parameter")
@path
p2: string;
}

union DaysOfWeekExtensibleEnum {
string,
Monday: "Monday",
Expand Down Expand Up @@ -500,13 +514,16 @@ op helloAgain(
@route("/noContentType")
@doc("Return hi again")
@get
@convenientAPI(false)
op noContentType(
@header p1: string,
@body action: RoundTripModel,
@path p2: string,
): RoundTripModel;

op noContentTypeOverride(info: Wrapper): RoundTripModel;

@@override(noContentType, noContentTypeOverride);

@route("/demoHi")
@doc("Return hi in demo2")
@get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {
fromMethodParameter,
fromSdkServiceMethod,
getMethodParameterSegments,
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,
methodParameterSegments: getMethodParameterSegments(sdkContext, parameter),
});
}
return parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ function fromQueryParameter(
decorators: p.decorators,
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
readOnly: isReadOnly(p),
methodParameterSegments: getMethodParameterSegments(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -480,6 +481,7 @@ function fromPathParameter(
decorators: p.decorators,
readOnly: isReadOnly(p),
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
methodParameterSegments: getMethodParameterSegments(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -510,6 +512,7 @@ function fromHeaderParameter(
readOnly: isReadOnly(p),
decorators: p.decorators,
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
methodParameterSegments: getMethodParameterSegments(sdkContext, p),
};

sdkContext.__typeCache.updateSdkOperationParameterReferences(p, retVar);
Expand Down Expand Up @@ -538,6 +541,7 @@ function fromBodyParameter(
decorators: p.decorators,
readOnly: isReadOnly(p),
crossLanguageDefinitionId: p.crossLanguageDefinitionId,
methodParameterSegments: getMethodParameterSegments(sdkContext, p),
};

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

export function getMethodParameterSegments(
sdkContext: CSharpEmitterContext,
p: SdkHttpParameter | SdkModelPropertyType,
): InputMethodParameter[] | undefined {
// methodParameterSegments is a 2D array where each segment array represents a path to a method parameter
// For spread body cases, there could be multiple paths, but we simplify by taking the first element
// We need the complete segment path (e.g., ['Params', 'foo'] for accessing params.foo)
const methodParameterSegments = (p as any).methodParameterSegments;
if (!methodParameterSegments || methodParameterSegments.length === 0) {
return undefined;
}

// Take the first segment path (simplification - no spector scenario for multiple paths yet)
const firstSegmentPath = methodParameterSegments[0];
if (!firstSegmentPath || firstSegmentPath.length === 0) {
return undefined;
}

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

// Convert each element in the segment path to an InputMethodParameter
// This preserves the full path information (e.g., ['Params', 'foo'])
for (const segment of firstSegmentPath) {
const methodParam = segment 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 @@ -208,6 +208,7 @@ export interface InputQueryParameter extends InputPropertyTypeBase {
explode: boolean;
scope: InputParameterScope;
serializedName: string;
methodParameterSegments?: InputMethodParameter[];
}

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

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

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

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

export interface InputEnumType extends InputTypeBase {
Expand Down
Loading
Loading