[http-client-csharp] Place contentType after body per .NET SDK parameter ordering guideline#10403
Draft
[http-client-csharp] Place contentType after body per .NET SDK parameter ordering guideline#10403
Conversation
… per .NET SDK parameter ordering guideline Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/1e1f8979-043f-491d-99fb-56cc88deb5ec Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix contentType header order in non-multipart operations
[http-client-csharp] Place contentType after body in non-multipart operations per .NET SDK parameter ordering guideline
Apr 16, 2026
Contributor
|
@copilot we should also ensure we run Generate.ps1 to regenerate all the test libraries |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/ef9e7dc8-4921-4b05-a1f3-3250a6daabf4 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Contributor
Author
Ran |
…ble, improve helper method, simplify docs, add test Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/fccee42c-bdca-4682-959f-10d2a38d1cad Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[http-client-csharp] Place contentType after body in non-multipart operations per .NET SDK parameter ordering guideline
[http-client-csharp] Place contentType after body per .NET SDK parameter ordering guideline
Apr 16, 2026
commit: |
…union scenario Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/13f79d47-a99d-4a0f-9e22-2fb882de151c Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Contributor
Author
Ran |
…ng string and extensible enum Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/db78a7d0-362c-4f81-bed0-5e27e4f10088 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Operations with a
contentTypeheader placed it before body, violating the .NET SDK parameter ordering guideline. This applies to all operations (both multipart and non-multipart).Before:
After:
Changes
RestClientProvider.GetMethodParameters: Added acontentTypesorting bucket (350) between body (200/300) and optional query/header (400). Content-type headers detected viaInputHeaderParameter.IsContentTypeare routed to this bucket instead of the regular required/optional header buckets. Updated theIsMultipartFormDatacontent-type insertion to also use thecontentTypebucket for consistency.BackCompatProvider: AddedHasContentTypeBeforeBodyInLastContracthelper that checksclient.BackCompatProvider.LastContractViewfor a matching method wherecontentTypeappears beforecontent(body). If the previous contract had that ordering, the content-type parameter falls through to the regular header bucket to preserve backward compatibility.TestGetMethodParameters_ContentTypeAfterBody(bool isRequired, bool isExtensibleEnum)using[TestCase]to cover all four combinations of required/optional and string/extensible-enum content-type headers. AddedContentTypeOrderPreservedFromLastContractViewvalidating that the previous ordering is preserved when the last contract had contentType before body, andContentTypeAfterBodyInLastContractViewvalidating correct ordering when the last contract already had contentType after body.backward-compatibility.mdwith a new "Content-Type Parameter Ordering" section documenting the back-compat preservation case.