Skip to content

Conversation

scott-ferguson-unity
Copy link
Collaborator

@scott-ferguson-unity scott-ferguson-unity commented Oct 7, 2025

Change from using ReadString() to ReadElementString() when deserialization a byte array. The expectation for ToByteArrayHex() and ToByteArrayBase64() is that the XmlDocument will be left at the start of next Xml element. But with just a ReadString() the document is left at the end tag of the current element, not the start of the next element. Changing to ReadElementString() changes this behavior.

This only affects the mobile profile - the Mono desktop profile uses a different implementation that doesn't have this issue. I also validated the CoreCLR matches the Mono Desktop profile behavior.

  • Should this pull request have release notes?
    • Yes
    • No
  • Do these changes need to be back ported?
    • Yes
    • No
  • Do these changes need to be upstreamed to mono/mono or dotnet/runtime repositories?
    • Yes
    • No

Reviewers: please consider these questions as well! ❤️

Release notes

Fixed UUM-195284 @scott-ferguson-unity
IL2CPP: Fix XML Deserialization of a byte array leaving the reader at the wrong element

Change from using ReadString() to ReadElementString() when
deserialization a byte array.  The expectation ToByteArrayHex() and
ToByteArrayBase64() is that the XmlDocument will be left at the start of
next Xml element.  But with just a ReadString() the document is left at
the end tag of the current element, not the start of the next element.
Changing to ReadElementString() changes this behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants