ARTICLE AD BOX
By "thread-safe" I mean: If two threads simultaneously read from the same XDocument, will there be trouble?
By "read" I mean: The code uses only non-mutating operations, e.g. read a value with myXDocument.Root.Elements("SomeTag").Attribute("SomeAttribute").Value, but no mutating operations such as XElement.Add.
Why do I ask:
A "naive" implementation would be thread-safe, since only read operations are performed. However, an "optimized" implementation might also use and mutate internal state during read operations.I was unable to find explicit thread-safety guarantees in the documentation, but I might have overlooked something. Apparently, the documentation used to contain the usual "static public methods are thread-safe, everything else might not be" disclaimer, but it is no longer present in the current version.
Ideally, an answer would reference an "official source", either the .NET documentation or a statement/blog entry from a member of the .NET development team.
