Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description

Fixes #13872

Runtime bindings were not resolving properties inherited from parent interfaces. For example, IReadOnlyList<T>.Count would return null because Count is defined on IReadOnlyCollection<T>, not directly on IReadOnlyList<T>.

Changes

  • Added GetProperty() method in BindingExpression.cs that searches both base classes and implemented interfaces recursively (similar to how GetIndexer() already handles this case)
  • Updated SetupPart() to use the new GetProperty() method
  • Added unit test Maui13872 that verifies bindings to IReadOnlyList<T>.Count work correctly with all XAML inflators (Runtime, XamlC, SourceGen)

Test Results

All 1790 XAML unit tests pass:

  • Passed: 1764
  • Skipped: 26
  • Failed: 0

…ount

Fixes #13872

The runtime binding expression was not resolving properties inherited from parent interfaces. For example, IReadOnlyList<T>.Count would return null because Count is defined on IReadOnlyCollection<T>, not directly on IReadOnlyList<T>.

Added GetProperty() method that searches both base classes and implemented interfaces recursively, similar to how GetIndexer() already handles this case.
Copilot AI review requested due to automatic review settings November 28, 2025 20:36
Copilot finished reviewing on behalf of StephaneDelcroix November 28, 2025 20:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where runtime bindings failed to resolve properties inherited from parent interfaces. For example, IReadOnlyList<T>.Count would return null because the Count property is defined on IReadOnlyCollection<T>, not directly on IReadOnlyList<T>.

Key changes:

  • Added recursive interface search capability to property resolution in runtime bindings
  • Refactored property lookup logic into a dedicated GetProperty() method that mirrors the existing GetIndexer() pattern
  • Added comprehensive test coverage for the fix across all XAML inflators

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Controls/src/Core/BindingExpression.cs Adds GetProperty() method with recursive interface search and refactors SetupPart() to use it instead of inline property lookup
src/Controls/tests/Xaml.UnitTests/Issues/Maui13872.xaml XAML test file demonstrating both compiled and uncompiled bindings to IReadOnlyList<T>.Count
src/Controls/tests/Xaml.UnitTests/Issues/Maui13872.xaml.cs Test code-behind with view model and test assertions validating the fix works with all inflators

@StephaneDelcroix StephaneDelcroix added this to the .NET 10.0 SR3 milestone Nov 29, 2025
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.

Compiled Binding to Array.Count provides no result

2 participants