AspNetCore: Add DataContractSerializer options for configurable reader quotas#578
Draft
Copilot wants to merge 6 commits into
Draft
AspNetCore: Add DataContractSerializer options for configurable reader quotas#578Copilot wants to merge 6 commits into
Copilot wants to merge 6 commits into
Conversation
…quotas Agent-Logs-Url: https://github.com/OpenRIAServices/OpenRiaServices/sessions/5a0cc47c-e686-4199-838a-29c01beb0bcf Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenRIAServices/OpenRiaServices/sessions/5a0cc47c-e686-4199-838a-29c01beb0bcf Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
…nused helpers Agent-Logs-Url: https://github.com/OpenRIAServices/OpenRiaServices/sessions/5a0cc47c-e686-4199-838a-29c01beb0bcf Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenRIAServices/OpenRiaServices/sessions/5a0cc47c-e686-4199-838a-29c01beb0bcf Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenRIAServices/OpenRiaServices/sessions/5a0cc47c-e686-4199-838a-29c01beb0bcf Co-authored-by: Daniel-Svensson <3167509+Daniel-Svensson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add DataContractSerializer options to ASP.NET Core
AspNetCore: Add DataContractSerializer options for configurable reader quotas
May 19, 2026
|
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.



Exposes per-format serializer options so hosts can restrict XML reader quotas to mitigate denial-of-service (DoS) risks. By default all quotas remain at
Max(current behavior unchanged).New public API
Options classes (
Serialization/DataContractSerializerOptions.cs):DataContractSerializerOptions— base class withReaderQuotas(XmlDictionaryReaderQuotas, mutable, defaults to max values)BinaryDataContractSerializerOptions : DataContractSerializerOptionsXmlDataContractSerializerOptions : DataContractSerializerOptionsBuilder methods (
OpenRiaServicesOptionsBuilder):AddXmlSerialization(Action<XmlDataContractSerializerOptions>? configure, bool defaultProvider = false)— new overload; existingAddXmlSerialization(bool)delegates to itConfigureBinarySerialization(Action<BinaryDataContractSerializerOptions> configure)— replaces the default binary provider in-place, preserving sharedDataContractCacheInternal wiring
BinaryMessageReader.Rent()acceptsXmlDictionaryReaderQuotasand applies them on every call (thread-static cache remains safe —SetInputreinitializes with the provided quotas each time)DataContractRequestSerializerstores_readerQuotasfrom its provider's options and passes them through toBinaryMessageReader.Rent()BinaryXmlSerializationProvider/TextXmlSerializationProvidereach hold their own options instance and pass it to every created serializerDataContractSerializationProvider.CopyDataContractCacheFrom()replaces direct internal-field access for cache sharing