Add PDictionary.OpenFile and TryOpenFile methods#172
Merged
Conversation
Add convenience methods for loading plist files as PDictionary: - OpenFile: returns a PDictionary or throws (never returns null) - TryOpenFile: returns bool with PDictionary as out parameter Both have overloads accepting an 'out bool isBinary' parameter. Add comprehensive tests covering valid dictionaries, non-dictionary plists, missing files, and invalid content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PObject.FromFile can return PArray, PString, PNumber, PReal, PBoolean, PDate, or PData depending on the root element of the plist file. Add tests for each case to demonstrate this behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verify that OpenFile throws FormatException (with the actual type name in the message) and TryOpenFile returns false for all non-dict root plist types: array, string, integer, real, boolean, date, and data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds convenience APIs to load plist files directly as PDictionary, aligning with the library’s plist parsing utilities and improving ergonomics for consumers.
Changes:
- Add
PDictionary.OpenFileoverloads that return a non-nullPDictionaryor throw on failure/non-dictionary roots. - Add
PDictionary.TryOpenFileoverloads that returnboolwith an annotatedout PDictionary?and optionalout bool isBinary. - Expand
PListObjectTestswith coverage for valid dictionaries, non-dictionary roots, missing files, and invalid content.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
Xamarin.MacDev/PListObject.cs |
Adds OpenFile/TryOpenFile APIs on PDictionary; adjusts one parsing exception type. |
tests/PListObjectTests.cs |
Adds new tests for the new APIs and additional PObject.FromFile root-type scenarios. |
dalexsoto
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add convenience methods for loading plist files as PDictionary:
Both have overloads accepting an 'out bool isBinary' parameter.
Add comprehensive tests covering valid dictionaries, non-dictionary plists,
missing files, and invalid content.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com