Remove .NET MAUI internals usage#452
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes reliance on .NET MAUI internal APIs from CommunityToolkit.Maui.Markup by replacing internal element/property access and custom internal binding infrastructure with public BindableProperty mappings and public Binding-based typed binding behavior, along with expanded regression tests.
Changes:
- Replaced uses of MAUI internals (e.g.,
FontElement/TextElement/PaddingElement, internal dynamic resource handlers, andTypedBindingBase-derived typed binding) with publicBindablePropertyaccess andBinding/converters. - Added
BindablePropertyHelpersto map supported controls to their publicBindablePropertyequivalents. - Updated/expanded unit tests to validate the new typed-binding behavior and updated property expectations.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Maui.Markup/TypedGesturesExtensions.cs | Updates member-name extraction to avoid treating captured values as bindable paths for typed gesture bindings. |
| src/CommunityToolkit.Maui.Markup/TypedBindingsExtensions.Handlers.cs | Introduces SetTypedBinding implementation using public Binding plus manual source write-back and handler tracking. |
| src/CommunityToolkit.Maui.Markup/TypedBindingExtensions.cs | Switches expression-based typed binding to compute public binding paths (or captured-value fallback) and delegates to SetTypedBinding. |
| src/CommunityToolkit.Maui.Markup/TypedBinding.cs | Removes internal TypedBindingBase-based implementation that depended on MAUI internals. |
| src/CommunityToolkit.Maui.Markup/PlaceholderExtensions.cs | Replaces internal placeholder properties with public property mapping via helpers. |
| src/CommunityToolkit.Maui.Markup/ImageExtensions.cs | Replaces internal image element properties with public property mapping via helpers. |
| src/CommunityToolkit.Maui.Markup/ElementExtensions.cs | Replaces internal font/text/padding properties and narrows dynamic-resource removal to Element. |
| src/CommunityToolkit.Maui.Markup/DynamicResourceHandlerExtensions.cs | Narrows dynamic-resource helpers to public Element API surface. |
| src/CommunityToolkit.Maui.Markup/BindablePropertyHelpers.cs | Adds helper methods that map supported control types to their public BindableProperty equivalents. |
| src/CommunityToolkit.Maui.Markup.UnitTests/BindingHelpers.cs | Updates test reflection helpers to avoid MAUI internal types while still validating bindings. |
| src/CommunityToolkit.Maui.Markup.UnitTests/TypedBindingExtensionsTests.cs | Adds/updates typed-binding regression tests for captured values, OneWayToSource push behavior, and write-back edge cases. |
| src/CommunityToolkit.Maui.Markup.UnitTests/GesturesExtensionsTests.cs | Updates expectations for typed gesture binding modes under the new binding approach. |
| src/CommunityToolkit.Maui.Markup.UnitTests/TextTests.cs | Updates expected BindableProperty references from internal element properties to public control properties. |
| src/CommunityToolkit.Maui.Markup.UnitTests/ElementExtensionsTests.cs | Updates font-related expected properties to public control properties. |
| src/CommunityToolkit.Maui.Markup.UnitTests/PaddingElementExtensionsTests.cs | Updates padding tests to use helper-mapped public padding properties. |
| src/CommunityToolkit.Maui.Markup.UnitTests/PaceholderExtensionsTests.cs | Updates placeholder tests to use public placeholder properties. |
| src/CommunityToolkit.Maui.Markup.UnitTests/ImageExtensionTests.cs | Updates image tests to use public image bindable properties. |
| src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockApplication.cs | Removes obsolete internal system-resource provider registration. |
| src/CommunityToolkit.Maui.Markup.UnitTests/UnitExpressionSearch.cs | Removes test helper that depended on MAUI internals. |
| src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockResourcesProvider.cs | Removes obsolete internal system resource provider implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
63480f5 to
407abc2
Compare
8960a71 to
06644aa
Compare
06644aa to
2cc6860
Compare
|
@TheCodeTraveler this PR is now rebased on latest |
2cc6860 to
7f2cb79
Compare
7f2cb79 to
f51d60f
Compare
Track source-originated target updates so manual typed-binding write-back does not ConvertBack and overwrite the source during normal source-to-target binding updates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use Xcode 26.6 for the latest .NET iOS and MacCatalyst workload used by the macOS sample build. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore compile-time constraints for font helpers, ensure ScrollView padding uses its public property, and consume tracked binding target updates before returning during binding application. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use supported public MAUI control overloads for image and placeholder helpers so unsupported receivers fail at compile time instead of through helper lookup at runtime. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fix malformed XML doc comments introduced while narrowing image and placeholder helper overloads. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Extract full member paths from typed gesture expressions so nested command and command-parameter bindings target the correct public properties. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2c2aae9 to
b56ed2e
Compare
Avoid brittle exact Xcode patch selection while still selecting a 26.x Xcode version required by the current .NET iOS and MacCatalyst workloads. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
src/CommunityToolkit.Maui.Markup/ImageExtensions.cs:5
- The file summary says these are "Extension methods for IImage", but the public API is now constrained to
Image/ImageButtonreceivers. Updating the summary to match the new surface avoids misleading docs/IntelliSense.
/// <summary>
/// Extension methods for IImage
/// </summary>
- Files reviewed: 20/20 changed files
- Comments generated: 3
- Review effort level: Low
Share expression path parsing between typed bindings and gestures, and track final target values for source-driven typed binding updates that use string formatting, target null values, or fallback values. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Default command parameter typed bindings without parameter handlers or setters to OneTime so the public binding behavior matches the non-observable pathless getter semantics, while preserving explicit caller binding modes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Correct XML documentation return text for dynamic resource helpers now constrained to Element rather than Layout. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Handle common compiled getter traversal failures for pathless typed bindings by returning fallback target values, and fail fast when command parameter write-back omits required parameter handlers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Validation
Notes
TypedBinding.cswas removed because publicBindingBasecannot be subclassed equivalently outside MAUI internals. The replacement preserves common path binding behavior and explicit setter write-back using public APIs.Element, matching the public MAUI dynamic-resource API surface.