Skip to content

Add PDictionary.OpenFile and TryOpenFile methods#172

Merged
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/pdict-openfile
Apr 30, 2026
Merged

Add PDictionary.OpenFile and TryOpenFile methods#172
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/pdict-openfile

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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

rolfbjarne and others added 3 commits April 28, 2026 17:56
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>

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.

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.OpenFile overloads that return a non-null PDictionary or throw on failure/non-dictionary roots.
  • Add PDictionary.TryOpenFile overloads that return bool with an annotated out PDictionary? and optional out bool isBinary.
  • Expand PListObjectTests with 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.

Comment thread tests/PListObjectTests.cs
Comment thread tests/PListObjectTests.cs
Comment thread tests/PListObjectTests.cs
Comment thread tests/PListObjectTests.cs
Comment thread Xamarin.MacDev/PListObject.cs
Comment thread tests/PListObjectTests.cs
Comment thread tests/PListObjectTests.cs
Comment thread tests/PListObjectTests.cs
@rolfbjarne rolfbjarne merged commit 83aaadf into main Apr 30, 2026
11 checks passed
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