You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using XmlNodeReader.MoveToAttribute returns false it leaves the XmlReader in an inconsistent state which can lead to follow-up exceptions.
Use-case: we are calling some deserialization API not owned by us which only accepts XmlReader. We already have an in-memory XmlDocument and need to call the deserialization method on a lot of nodes, so we want to use XmlNodeReader instead of doing an unnecessary format/parse roundtrip through an intermediate string for every node we have to deserialize.
In some cases the code calls MoveToAttribute to detect whether an optional attribute is present. This part works, but when it then subsequently calls ReadStartElement this leads to an exception. See attached example which reduces the call sequence to present the problem.
The error happens on both Desktop Framework and .NET Core.
When using
XmlNodeReader.MoveToAttribute
returns false it leaves the XmlReader in an inconsistent state which can lead to follow-up exceptions.Use-case: we are calling some deserialization API not owned by us which only accepts XmlReader. We already have an in-memory XmlDocument and need to call the deserialization method on a lot of nodes, so we want to use XmlNodeReader instead of doing an unnecessary format/parse roundtrip through an intermediate string for every node we have to deserialize.
In some cases the code calls
MoveToAttribute
to detect whether an optional attribute is present. This part works, but when it then subsequently callsReadStartElement
this leads to an exception. See attached example which reduces the call sequence to present the problem.The error happens on both Desktop Framework and .NET Core.
The text was updated successfully, but these errors were encountered: