Updating useRestrictiveXamlReader flag documentation and expectations - #13018
Open
dipeshmsft wants to merge 1 commit into
Open
Updating useRestrictiveXamlReader flag documentation and expectations#13018dipeshmsft wants to merge 1 commit into
dipeshmsft wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates WPF XamlReader documentation for restrictive-reader behavior, usage, and security expectations.
Changes:
- Documents
useRestrictiveXamlReaderacrossLoad,LoadAsync, andParse. - Adds restrictive-mode security guidance.
- Expands parameter, return-value, and exception documentation.
Suppressed comments (2)
xml/System.Windows.Markup/XamlReader.xml:689
- This overload returns
object, not aTask, and WPF completes the event-based load throughLoadCompleted; the copied paragraph therefore describes behavior this API doesn't have. It also omits that the returned root can be populated later and that parsing is asynchronous only when the root containsx:SynchronousMode="Async"(otherwise the load is synchronous). Replace the task paragraph with the event-based async behavior documented by the sibling overload.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <see cref="T:System.ArgumentException" />, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <see cref="M:System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader,System.Boolean)" />.</remarks>
xml/System.Windows.Markup/XamlReader.xml:729
- This overload returns
object, not aTask, and WPF completes the event-based load throughLoadCompleted; the copied paragraph therefore describes behavior this API doesn't have. It also omits that the returned root can be populated later and that parsing is asynchronous only when the root containsx:SynchronousMode="Async"(otherwise the load is synchronous). Replace the task paragraph with the event-based async behavior documented by the sibling overload.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <see cref="T:System.ArgumentException" />, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <see cref="M:System.Windows.Markup.XamlReader.Load(System.IO.Stream,System.Windows.Markup.ParserContext,System.Boolean)" />.</remarks>
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+596
to
+598
| <remarks>Restrictive mode is a defense-in-depth measure. Don't treat a restrictive parse of untrusted XAML as safe or as a replacement for isolation in a low-privilege sandbox. | ||
|
|
||
| This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <see cref="T:System.ArgumentException" />, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <see cref="M:System.Windows.Markup.XamlReader.Load(System.IO.Stream,System.Boolean)" />.</remarks> |
gewarren
approved these changes
Aug 21, 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.
Summary
In this PR, I have updated the XamlReader document, especifically useRestrictiveXamlReader flags usage, capabilities and constraints. This is in alignment with the change here: dotnet/docs-desktop#2278
Internal previews