Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(http-server-csharp): align controller argument order - #11903

Draft
sophia-ramsey wants to merge 1 commit into
mainfrom
sramsey/csharp-parameter-ordering
Draft

fix(http-server-csharp): align controller argument order#11903
sophia-ramsey wants to merge 1 commit into
mainfrom
sramsey/csharp-parameter-ordering

Conversation

@sophia-ramsey

Copy link
Copy Markdown
Member

This pull request addresses the ordering of controller call arguments in the generated C# code for the HTTP server emitter, ensuring that positional arguments match the order defined in the business interface. It introduces a mapping from canonicalized HTTP operations back to their original source operations, updates the controller and action rendering logic to use this mapping, and adds comprehensive tests to verify the new behavior.

Controller argument ordering and operation source mapping:

  • The controller action now aligns positional call arguments with the parameter order from the original business interface operation, rather than the default HTTP parameter order. This ensures that the generated C# controller methods call the business logic with arguments in the expected order. (.chronus/changes/http-server-csharp-controller-parameter-ordering-2026-9-8.md)
  • Introduced a new OperationSources context and a canonicalOperationSourceMap in service resolution, which tracks the original source operation for each canonicalized HTTP operation. This mapping is provided throughout the emitter to ensure correct argument ordering. (packages/http-server-csharp/src/context/operation-source-context.ts [1] packages/http-server-csharp/src/service-resolution.ts [2]
  • Updated the ControllerAction and Controller components to use the source operation from OperationSources when rendering method call arguments, ensuring correct positional mapping. (packages/http-server-csharp/src/components/controller-action/controller-action.tsx [1] [2] [3] [4] [5]; packages/http-server-csharp/src/components/controllers/controllers.tsx Ff671f60L9R9, [6] [7]

Testing and validation:

  • Added and updated tests to verify that controller action call arguments and generated interface methods use the correct parameter order, matching the business interface definition. (packages/http-server-csharp/src/components/controller-action/controller-action.test.tsx [1] packages/http-server-csharp/src/components/controllers/controllers.test.tsx [2]
  • Added a test to ensure that the canonical operation to source operation mapping is correctly tracked during service type resolution. (packages/http-server-csharp/src/service-resolution.test.ts packages/http-server-csharp/src/service-resolution.test.tsR113-R135)

Emitter integration:

  • Integrated the new OperationSources context into the emitter so that all components have access to the canonical operation source mapping during code generation. (packages/http-server-csharp/src/emitter.tsx [1] [2]

These changes together ensure that the generated C# controllers call business logic methods with arguments in the correct order, improving correctness and maintainability of the generated code.

@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-server-csharp@11903

commit: c8d3b68

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • βœ… @typespec/http-server-csharp
Show changes

@typespec/http-server-csharp - fix ✏️

Align positional controller call arguments with the generated business-interface parameter order.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

πŸ› Playground 🌐 Website πŸ› VSCode Extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant