From 768479ba7b26ecbba637e556cc396ea5e372eb65 Mon Sep 17 00:00:00 2001 From: 33modeling <33modeling@gmail.com> Date: Wed, 2 Sep 2026 21:13:10 +0900 Subject: [PATCH] Document LINQ to XML thread safety Explain that concurrent reads are safe when no thread modifies the XObject, XDocument, or XElement instance. Fix dotnet/runtime#123068 --- xml/System.Xml.Linq/XDocument.xml | 4 ++++ xml/System.Xml.Linq/XElement.xml | 4 ++++ xml/System.Xml.Linq/XObject.xml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/xml/System.Xml.Linq/XDocument.xml b/xml/System.Xml.Linq/XDocument.xml index 0074c924332..e5d43261385 100644 --- a/xml/System.Xml.Linq/XDocument.xml +++ b/xml/System.Xml.Linq/XDocument.xml @@ -55,6 +55,10 @@ ## Remarks For details about the valid content of an , see [Valid Content of XElement and XDocument Objects](/dotnet/standard/linq/valid-content-xelement-xdocument-objects). +## Thread safety + + An instance is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it. + ## Examples diff --git a/xml/System.Xml.Linq/XElement.xml b/xml/System.Xml.Linq/XElement.xml index 3cd83140a5f..ade48a64312 100644 --- a/xml/System.Xml.Linq/XElement.xml +++ b/xml/System.Xml.Linq/XElement.xml @@ -85,6 +85,10 @@ Some methods can be used from XAML. For more information, see [LINQ to XML Dynamic Properties](/dotnet/desktop/wpf/data/linq-to-xml-dynamic-properties). +## Thread safety + + An instance is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it. + ## Examples diff --git a/xml/System.Xml.Linq/XObject.xml b/xml/System.Xml.Linq/XObject.xml index 60870c7909a..1aad632b0e5 100644 --- a/xml/System.Xml.Linq/XObject.xml +++ b/xml/System.Xml.Linq/XObject.xml @@ -61,6 +61,10 @@ Note that annotations are not part of the XML infoset; they are not serialized or deserialized. +## Thread safety + + An instance, including an instance of a derived type, is safe for concurrent read operations as long as no thread modifies it. If the instance is modified, you must synchronize all access to it. + ]]> LINQ to XML overview