Skip to content

Add new PDictionary.TryOpenFile overloads that returns the error in case of failure. - #198

Merged
rolfbjarne merged 2 commits into
mainfrom
dev/rolf/try-open-file-exception
Nov 11, 2026
Merged

rolfbjarne merged 2 commits into
mainfrom
dev/rolf/try-open-file-exception

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

No description provided.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 13:52

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.

🟡 Changes recommended

The new three-argument TryOpenFile overload makes previously valid calls using inferred output variables or discards ambiguous, causing compilation failures and breaking source compatibility.

1 open issue
What changed in this PR

Adds error-reporting overloads to PDictionary.TryOpenFile, allowing Xamarin.MacDev callers to inspect why loading a plist dictionary failed.

Changes:

  • Adds overloads that return an exception alongside the result.
  • Routes existing overloads through shared error-handling logic.
  • Updates documentation to describe failure behavior.
File Description
Xamarin.MacDev/​PListObject.cs Adds exception outputs and consolidates plist dictionary loading and failure handling.

Review effort: Balanced

Comment thread Xamarin.MacDev/PListObject.cs Resolved
… overloads.

Calls such as 'TryOpenFile (path, out var dict, out var isBinary)' or
'TryOpenFile (path, out var dict, out _)' would otherwise be ambiguous
between the 'out bool' and 'out Exception?' overloads. Prefer the existing
'out bool' overload so source compatibility is preserved.

Co-authored-by: Copilot App <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.

🔵 Needs a closer look

The new three-argument overload breaks source compatibility for consumers using C# 12 or earlier by making previously valid calls ambiguous.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Low severity Add tests for exception and binary-format overload outputs

Xamarin.MacDev/​PListObject.cs:826

The existing NUnit tests in tests/PListObjectTests.cs call only the legacy overloads, leaving the new exception outputs untested. Add coverage for both new overloads asserting a null exception on success and a non-null exception with a null dictionary for missing files, malformed content, and non-dictionary roots; also check isBinary for XML and binary inputs through the four-argument overload.

1 resolved since last review

Review effort: Balanced

@rolfbjarne
rolfbjarne merged commit bb78186 into main Nov 11, 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.

3 participants