Skip to content

Fix plist parsing after long-form boolean elements - #203

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/plist-resource-truncation
Nov 20, 2026
Merged

rolfbjarne merged 1 commit into
mainfrom
dev/rolf/plist-resource-truncation

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Consume the whole boolean element so its closing tag does not end the containing dictionary or array. Add tests for <true/>, <true></true>, and <true> </true>, and the same forms for <false>.

Fixes dotnet/macios#27414

Note

This pull request was generated by Copilot.

Consume the whole boolean element so its closing tag does not end the containing dictionary or array. Cover both boolean values with short, long, and whitespace-containing XML forms.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the XML plist boolean parsing change.

No open issues 🎉

What changed in this PR

Fixes XML plist boolean parsing in Xamarin.MacDev so long-form boolean elements do not prematurely end the containing dictionary or array.

Changes:

  • Uses XmlReader.Skip() to consume the entire boolean element.
  • Adds dictionary and array regression tests for self-closing, explicit closing-tag, and whitespace-containing forms of both boolean values.
File Description
Xamarin.MacDev/​PListObject.cs Consumes complete boolean elements to preserve parsing of subsequent entries.
tests/​PListObjectTests.cs Verifies boolean values and subsequent entries across six XML forms in dictionaries and arrays.

Review effort: Balanced

@rolfbjarne
rolfbjarne enabled auto-merge (squash) November 20, 2026 16:58
@rolfbjarne

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed d90f3bc2 against main at 4490e9b6. This is a static, read-only review.

  • Root cause: ReadBool was the only XML value reader that advanced the reader by hand. On a long-form <true></true>/<false></false>, Read() left the reader on the closing tag, so ReadDict broke out early, failed its dict end-tag check and returned false, which ReadObject ignores. Every later key or array item was silently dropped (the dotnet/macios#27414 Firebase plist).
  • The fix: ReadBool is only reached from ReadObject with the reader on the <true>/<false> element (callers: the constructor, ReadArray and ReadDict all check for an element first). On that element Skip() behaves like Read() for <true/>, and for <true></true> or <true>\n\t</true> it moves past the matching end tag (whitespace nodes are not ignored by these reader settings, so they are consumed with the element). The following dict/array loops and their end-tag checks then line up.
  • Other value types (integer, real, date, data, string) already use ReadElementContentAs*, and empty <dict>/<array> are handled, so booleans were the only affected type. The binary reader does not move the stream for booleans and is unaffected.
  • Tests: PObject.FromString falls through to the XML reader for <-prefixed input, so both new tests exercise the fixed path. The long-form cases would fail on the count assertion without the fix, and the self-closing cases guard against regressions. The APIs they use exist.
  • Non-blocking: content inside a boolean element is now ignored. Apple's parser rejects <true> </true>, so the whitespace cases accept slightly more than CoreFoundation does. That is harmless and much better than truncating the container.

@rolfbjarne
rolfbjarne merged commit 6ff1255 into main Nov 20, 2026
8 checks passed
rolfbjarne added a commit to dotnet/macios that referenced this pull request Nov 24, 2026
Update Xamarin.MacDev to include the fix from dotnet/macios-devtools#203. The parser now reads complete `<true></true>` and `<false></false>` elements, keeping all following entries when converting plist resources to binary.

The dependency update also includes:

* dotnet/macios-devtools#198: add plist-loading overloads that return errors.
* dotnet/macios-devtools#200: use LF line endings in XML plist headers.
* dotnet/macios-devtools#201: update CI.
* dotnet/macios-devtools#202: check all profiles in both provisioning-profile folders when selecting one.

Add a regression test that converts plists with both boolean values to binary and checks that no entries are lost.

Fixes #27414

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
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.

[.NET 11] BundleResource .plist loses every key after the first <false></false> in Release builds

3 participants