Skip to content

Remove .NET MAUI internals usage#452

Open
jfversluis wants to merge 7 commits into
mainfrom
jfversluis-fix-maui-internals
Open

Remove .NET MAUI internals usage#452
jfversluis wants to merge 7 commits into
mainfrom
jfversluis-fix-maui-internals

Conversation

@jfversluis

Copy link
Copy Markdown
Member

Summary

  • Replace MAUI internal FontElement/TextElement/ImageElement/PlaceholderElement/PaddingElement usage with public concrete BindableProperty mappings.
  • Narrow dynamic-resource helpers to public Element APIs instead of internal IDynamicResourceHandler/BindableObject internals.
  • Replace the custom internal TypedBindingBase-derived implementation with public Binding-based typed binding behavior.
  • Add typed-binding regression coverage for read-only/default TwoWay targets, setter write-back, OneWayToSource initial and late BindingContext pushes, object-valued paths, Binding.DoNothing, invalid convert-back values, and captured-value binding contexts.

Validation

  • Product-code internals scan: no matches for Microsoft.Maui.Controls.Internals, .Internals, FontElement, TextElement, ImageElement, PlaceholderElement, PaddingElement, IDynamicResourceHandler, TypedBindingBase, BindingExpression, SetValueCore, GetContext, ApplyCore, UnapplyCore, GetRealizedMode, BindingExpressionPart, BindingFlags.NonPublic, GetMethod/GetField/GetProperty in src/CommunityToolkit.Maui.Markup.
  • Unit tests: 402/402 passed via the NUnit executable runner.
  • Sample app: net10.0-windows10.0.19041.0 Debug build succeeded.
  • Pack: CommunityToolkit.Maui.Markup.99.0.4-internalsfix.nupkg built locally.
  • MAUI 11 PR #34070 smoke app: built with Microsoft.Maui.Controls 11.0.0-ci.pr34070.6.26324.9 and launched on Windows; app stayed running after startup with no FieldAccessException/startup crash.

Notes

  • TypedBinding.cs was removed because public BindingBase cannot be subclassed equivalently outside MAUI internals. The replacement preserves common path binding behavior and explicit setter write-back using public APIs.
  • Dynamic-resource helpers now require Element, matching the public MAUI dynamic-resource API surface.

Copilot AI review requested due to automatic review settings June 24, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown

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 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, and TypedBindingBase-derived typed binding) with public BindableProperty access and Binding/converters.
  • Added BindablePropertyHelpers to map supported controls to their public BindableProperty equivalents.
  • 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.

Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
Copilot AI review requested due to automatic review settings June 25, 2026 10:16
@jfversluis jfversluis force-pushed the jfversluis-fix-maui-internals branch from 63480f5 to 407abc2 Compare June 25, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings June 25, 2026 10:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings June 25, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs
Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs
Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs
Copilot AI review requested due to automatic review settings June 30, 2026 07:36
@jfversluis jfversluis force-pushed the jfversluis-fix-maui-internals branch from 8960a71 to 06644aa Compare June 30, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs
jfversluis and others added 6 commits July 7, 2026 14:58
Replace MAUI internal helper dependencies with public API mappings and public Binding-based typed binding behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Narrow padding and text color helpers back to public supported surfaces, add explicit typed binding removal for setter write-back handlers, and cover the adjusted behavior in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document RemoveTypedBinding for typed bindings with setter write-back handlers and explain why target-side write-back restores the public binding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat conversion-style ConvertBack failures as skipped source updates and cover the behavior with a typed binding regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Select Xcode 26.5 for the macOS Build workflow so the .NET iOS and MacCatalyst 26.5 workloads used by the latest .NET 10 SDK do not resolve to Xcode 26.6.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add ScrollView and derived ScrollView padding coverage to prove the public overloads remain unambiguous and preserve fluent return types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jfversluis jfversluis force-pushed the jfversluis-fix-maui-internals branch from 06644aa to 2cc6860 Compare July 7, 2026 13:00
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>
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.

2 participants