Skip to content

Remove .NET MAUI internals usage#452

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

Remove .NET MAUI internals usage#452
jfversluis wants to merge 17 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
jfversluis force-pushed the jfversluis-fix-maui-internals branch from 06644aa to 2cc6860 Compare July 7, 2026 13:00
@jfversluis

Copy link
Copy Markdown
Member Author

@TheCodeTraveler this PR is now rebased on latest main and remains green locally. Could you please prioritize the final review/merge sooner rather than later? We are getting close to merging the .NET MAUI 11 change that removes the internals access this PR fixes for Maui.Markup.

Copilot AI review requested due to automatic review settings July 16, 2026 18:58
@jfversluis
jfversluis force-pushed the jfversluis-fix-maui-internals branch from 2cc6860 to 7f2cb79 Compare July 16, 2026 18:58

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
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 July 16, 2026 19:12
@jfversluis
jfversluis force-pushed the jfversluis-fix-maui-internals branch from 7f2cb79 to f51d60f Compare July 16, 2026 19:12

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread src/CommunityToolkit.Maui.Markup/TypedBindingsExtensions.Handlers.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/BindablePropertyHelpers.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
Copilot AI review requested due to automatic review settings July 16, 2026 19:30

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread src/CommunityToolkit.Maui.Markup/ImageExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/PlaceholderExtensions.cs Outdated
jfversluis and others added 6 commits July 17, 2026 20:26
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>
Copilot AI review requested due to automatic review settings July 17, 2026 18:27
@jfversluis
jfversluis force-pushed the jfversluis-fix-maui-internals branch from 2c2aae9 to b56ed2e Compare July 17, 2026 18:27

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread .github/workflows/dotnet-build.yml Outdated
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>
Copilot AI review requested due to automatic review settings July 17, 2026 18:32

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.

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/ImageButton receivers. 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

Comment thread src/CommunityToolkit.Maui.Markup/TypedBindingsExtensions.Handlers.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/TypedGesturesExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/TypedBindingExtensions.cs Outdated
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>
Copilot AI review requested due to automatic review settings July 17, 2026 18:42
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>

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Low

Copilot AI review requested due to automatic review settings July 17, 2026 18:47

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread src/CommunityToolkit.Maui.Markup/ElementExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/DynamicResourceHandlerExtensions.cs Outdated
Comment thread src/CommunityToolkit.Maui.Markup/DynamicResourceHandlerExtensions.cs Outdated
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>
Copilot AI review requested due to automatic review settings July 17, 2026 18:52

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 2
  • Review effort level: Low

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>
Copilot AI review requested due to automatic review settings July 17, 2026 18:59

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.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Low

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