Add OData header writing to ODataJsonOutputContext#3483
Open
Add OData header writing to ODataJsonOutputContext#3483
Conversation
Copilot
AI
changed the title
[WIP] Add support for writing OData-specific headers
Add OData header writing to ODataJsonOutputContext
Jan 16, 2026
- Add Message property to ODataMessageInfo to optionally carry message reference - Update ODataMessageWriter to pass message to ODataMessageInfo - Add WriteODataHeaders() method to ODataJsonOutputContext - Headers (OData-Version, Content-Type) are now written when message is available - Maintains backward compatibility - headers only written when message provided Co-authored-by: odero <380686+odero@users.noreply.github.com>
- Combine charset check with parameter iteration (single pass) - Add StringBuilder capacity hint to reduce allocations - Make BuildContentTypeHeader static - Add comments about parameter safety Co-authored-by: odero <380686+odero@users.noreply.github.com>
f51c4ce to
9ea1862
Compare
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.
The new
ODataUtf8JsonWriter-based serializer writes payloads but not OData headers (OData-Version, Content-Type). This works when usingODataMessageWriter(which writes headers first), but fails whenODataJsonOutputContextis created directly (e.g., in URI conversion utilities).Changes
ODataMessageInfo
Messageproperty to carry message reference when header writing is neededODataMessageWriter
ODataMessageInfowhen creating output contextODataJsonOutputContext
BuildContentTypeHeader()assembles Content-Type from media type, parameters, and charsetExample
Backward compatible - existing code paths unaffected.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.