Repository navigation
[trimming] Customization-preserving mapper infrastructure - #40725
Conversation
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
/review expert-review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Inherited mapping wrappers can cause stack overflows, parent swaps can leave stale cached mappings, and captured child mappings can miss later framework remaps.
3 open issues
What changed in this PR
This is layer 2 of the trimmable-handlers stack from #29952, built on #40721. It introduces mapper infrastructure intended to preserve application customizations across framework remaps, preparing for lazy remapping in the next layer while keeping current remaps eager.
Changes:
- Adds framework mapping cells, ordered customization records, snapshot lookups, and chain-aware cache invalidation.
- Seals applicable Core mappers and routes Controls remaps through internal framework-specific helpers.
- Expands mapper regression tests, restores animation-test state more completely, and documents remapping behavior.
| File | Description |
|---|---|
src/Core/tests/UnitTests/PropertyMapperExtensionTests.cs |
Tests property customization preservation and capture behavior. |
src/Core/tests/UnitTests/CommandMapperExtensionTests.cs |
Tests command customization preservation and capture behavior. |
src/Core/src/PropertyMapperExtensions.cs |
Routes customizations and framework remaps separately. |
src/Core/src/PropertyMapper.cs |
Adds framework cells, customization records, and cache versioning. |
src/Core/src/MappingCustomizationSequence.cs |
Orders customizations across both mapper types. |
src/Core/src/Handlers/Window/WindowHandler.cs |
Seals built-in Window property mappings. |
src/Core/src/Handlers/WebView/WebViewHandler.cs |
Seals built-in WebView property mappings. |
src/Core/src/Handlers/View/ViewHandler.cs |
Seals shared view property and command mappings. |
src/Core/src/Handlers/Toolbar/ToolbarHandler.cs |
Seals built-in Toolbar property mappings. |
src/Core/src/Handlers/TimePicker/TimePickerHandler.cs |
Seals built-in TimePicker property mappings. |
src/Core/src/Handlers/TabbedView/TabbedViewHandler.cs |
Seals the TabbedView property mapper. |
src/Core/src/Handlers/SwipeView/SwipeViewHandler.cs |
Seals built-in SwipeView property mappings. |
src/Core/src/Handlers/Stepper/StepperHandler.cs |
Seals built-in Stepper property mappings. |
src/Core/src/Handlers/Slider/SliderHandler.cs |
Seals built-in Slider property mappings. |
src/Core/src/Handlers/ShapeView/ShapeViewHandler.cs |
Seals built-in shape property mappings. |
src/Core/src/Handlers/SearchBar/SearchBarHandler2.Android.cs |
Seals Material3 SearchBar property mappings. |
src/Core/src/Handlers/SearchBar/SearchBarHandler.cs |
Seals SearchBar property and command mappings. |
src/Core/src/Handlers/ScrollView/ScrollViewHandler.cs |
Seals built-in ScrollView property mappings. |
src/Core/src/Handlers/RefreshView/RefreshViewHandler.cs |
Seals built-in RefreshView property mappings. |
src/Core/src/Handlers/RadioButton/RadioButtonHandler.cs |
Seals built-in RadioButton property mappings. |
src/Core/src/Handlers/Picker/PickerHandler.cs |
Seals built-in Picker property mappings. |
src/Core/src/Handlers/Page/PageHandler.cs |
Seals built-in Page property mappings. |
src/Core/src/Handlers/NavigationPage/NavigationViewHandler.cs |
Seals the navigation property mapper. |
src/Core/src/Handlers/Label/LabelHandler.cs |
Seals built-in Label property mappings. |
src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs |
Seals built-in ImageButton property mappings. |
src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.cs |
Seals built-in FlyoutView property mappings. |
src/Core/src/Handlers/Entry/EntryHandler2.Android.cs |
Seals Material3 Entry property and command mappings. |
src/Core/src/Handlers/Entry/EntryHandler.cs |
Seals Entry property and command mappings. |
src/Core/src/Handlers/Editor/EditorHandler2.Android.cs |
Seals Material3 Editor property and command mappings. |
src/Core/src/Handlers/Editor/EditorHandler.cs |
Seals Editor property and command mappings. |
src/Core/src/Handlers/DatePicker/DatePickerHandler.cs |
Seals built-in DatePicker property mappings. |
src/Core/src/Handlers/ContentButton/ContentButtonHandler.cs |
Seals built-in ContentButton property mappings. |
src/Core/src/Handlers/CheckBox/CheckBoxHandler.cs |
Seals built-in CheckBox property mappings. |
src/Core/src/Handlers/Button/ButtonHandler.cs |
Seals the main Button property mapper. |
src/Core/src/Handlers/Application/ApplicationHandler.cs |
Seals built-in Application property mappings. |
src/Core/src/CommandMapperExtensions.cs |
Separates command customizations from Controls remaps. |
src/Core/src/CommandMapper.cs |
Adds command cells, customization records, and snapshot composition. |
src/Controls/tests/Core.UnitTests/Animations/StoryboardTests.cs |
Clears recorded customization and cached state during cleanup. |
src/Controls/src/Core/Window/Window.Mapper.cs |
Moves Window remaps to framework helpers. |
src/Controls/src/Core/WebView/WebView.Mapper.cs |
Moves Android WebView remaps to framework helpers. |
src/Controls/src/Core/VisualElement/VisualElement.Mapper.cs |
Moves shared property and focus remaps to framework helpers. |
src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs |
Moves Toolbar remaps to framework helpers. |
src/Controls/src/Core/TimePicker/TimePicker.Mapper.cs |
Moves the iOS update-mode remap to a framework helper. |
src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs |
Moves tabbed-page remaps to framework helpers. |
src/Controls/src/Core/Switch/Switch.Mapper.cs |
Moves the Apple OnColor prepend to a framework helper. |
src/Controls/src/Core/SwipeView/SwipeView.Mapper.cs |
Moves the background append to a framework helper. |
src/Controls/src/Core/Stepper/Stepper.Mapper.cs |
Moves the increment append to a framework helper. |
src/Controls/src/Core/Slider/Slider.Mapper.cs |
Moves the iOS tap-update remap to a framework helper. |
src/Controls/src/Core/Shape/Shape.Mapper.cs |
Moves the stroke-dash remap to a framework helper. |
src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs |
Moves SearchBar property and focus remaps to framework helpers. |
src/Controls/src/Core/ScrollView/ScrollView.Mapper.cs |
Moves the iOS touch-delay remap to a framework helper. |
src/Controls/src/Core/RefreshView/RefreshView.Mapper.cs |
Moves the Windows pull-direction remap to a framework helper. |
src/Controls/src/Core/RadioButton/RadioButton.Mapper.cs |
Moves content remaps to framework helpers. |
src/Controls/src/Core/Picker/Picker.Mapper.cs |
Moves Picker remaps to framework helpers. |
src/Controls/src/Core/NavigationPage/NavigationPage.Mapper.cs |
Moves Apple navigation remaps to framework helpers. |
src/Controls/src/Core/Label/Label.Mapper.cs |
Moves Label remaps while retaining two public appends. |
src/Controls/src/Core/ImageButton/ImageButton.Mapper.cs |
Moves Android ripple remaps to framework helpers. |
src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs |
Moves flyout remaps to framework helpers. |
src/Controls/src/Core/Entry/Entry.Mapper.cs |
Moves Entry property and focus remaps to framework helpers. |
src/Controls/src/Core/Element/Element.Mapper.cs |
Moves accessibility remaps to framework helpers. |
src/Controls/src/Core/Editor/Editor.Mapper.cs |
Moves Editor property and focus remaps to framework helpers. |
src/Controls/src/Core/DatePicker/DatePicker.Mapper.cs |
Moves the iOS update-mode remap to a framework helper. |
src/Controls/src/Core/ContentPage/ContentPage.Mapper.cs |
Moves keyboard and Apple page remaps to framework helpers. |
src/Controls/src/Core/ContentButton/ContentButton.Mapper.cs |
Moves Android ripple remaps to framework helpers. |
src/Controls/src/Core/CheckBox/CheckBox.Mapper.cs |
Moves the color remap to a framework helper. |
src/Controls/src/Core/Button/Button.Mapper.cs |
Moves Button remaps to framework helpers. |
src/Controls/src/Core/Application/Application.Mapper.cs |
Moves the Android soft-input remap to a framework helper. |
docs/design/HandlerResolution.md |
Documents eager remapping, customization ordering, and exceptions. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 7 findings · ⚠️ 2 breaking changes
Reviewed commit db8f20b.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
Source assessment incomplete (13/14 dimensions); finding count is partial.
See inline comments for details.
This comment has been minimized.
This comment has been minimized.
7dd2952 to
fcc983b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Direct replacements can apply overridden transformations twice, while customized mappings can invoke an outdated parent or leave nonmatching views unhandled after chain changes.
2 open issues
3 resolved since last review
Review effort: Balanced
|
/review expert-review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fcc983b to
df9d3fb
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Successive AppendToMapping calls lose the first append’s SetPropertyCore wrapper, dropping registration-specific notifications or guards; the mapping layers need corrected composition and a regression test.
1 open issue
5 resolved since last review
Review effort: Balanced
| mapping = _customizations[i](mapping); | ||
| mappings[i + 1] = mapping; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 5 findings · ⚠️ 4 breaking changes
Reviewed commit df9d3fb.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| internal static new void RemapForControls() | ||
| { | ||
| StepperHandler.Mapper.AppendToMapping(nameof(Stepper.Increment), MapInterval); | ||
| StepperHandler.Mapper.AppendToMappingForControls(nameof(Stepper.Increment), MapInterval); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - For apps appending callbacks to StepperHandler.Mapper's Increment and Interval keys before the first UseMauiApp, changing an attached Stepper.Increment previously ran the Increment callback before the Controls redirect and Interval callback; now Interval runs before Increment. On iOS/MacCatalyst, with Value=50, a 0-100 range and Increment changing from 1 to 2, an Increment callback reading UIStepper.StepValue therefore observes 2 instead of 1. The shared redirect also reverses callback order on Android and Windows. The documentation and author response acknowledge this intentional change, but no compatibility opt-out preserves the previously working callback timing. Provide that opt-out for the stack's intended main/.NET 12 default.
| mappings[0] = mapping; | ||
| for (var i = 0; i < customizationCount; i++) | ||
| { | ||
| mapping = _customizations[i](mapping); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Successive helper customizations drop earlier SetPropertyCore override transformations, changing notifications and guards even for apps customizing after UseMauiApp. Using the WrappingPropertyMapper fixture added here, initialize Background and append callbacks A and B: previously an update ran three registration wrappers followed by core, A and B; now only two wrappers run. Register saves the transformed mappings, but this loop passes the raw first composition into the second customization, bypassing the first append's wrapper. A registration-specific disabled guard on that append is likewise lost. Preserve each prior registered transformation when composing subsequent customizations rather than silently changing notification frequency. Add a two-append regression case; the current wrapping test covers a direct replacement followed by only one append.
| var modificationCount = _frameworkModifications.Count; | ||
| var customizationCount = _customizations.Count; | ||
| var mappings = new Action<IElementHandler, IElement>?[customizationCount + 1]; | ||
| var mapping = _hasLocalMapping ? _localMapping : GetChainedPropertyAsOf(Chained, _key, _chainedMappingSequence); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Deferred resolution changes previously working, single-threaded startup captures without any framework remap. Start with an empty unsealed first parent and a second parent mapping K to A, chain a child to both, append C on the child, then first-assign K to B on the first parent before the first update. Previously the child ran A,C; now it selects B,C and suppresses A. CommandMapper similarly changes C to B,C after a later first assignment on an unsealed parent. An independent IPropertyMapper parent changed from A to B before the child's first invocation also changes A,C to B,C. The documented untracked-change exception acknowledges these cases but supplies no compatibility opt-out preserving captured delegates and absence. Preserve the captures separately from explicit framework remaps, or provide an opt-out for the intended main/.NET 12 default.
|
|
||
| // A caller that wraps an inherited mapping of a built-in mapper must still observe a later framework | ||
| // remap of the key on this mapper, as it would have when the remaps ran at startup. | ||
| return GetChainedPropertyDirect(key) is null ? null : CaptureInheritedProperty(key); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - On Android and MacCatalyst, Opacity is inherited by an untouched LabelHandler.Mapper. ReferenceEquals(LabelHandler.Mapper.GetProperty("Opacity"), ViewHandler.ViewMapper.GetProperty("Opacity")) previously returned true and now returns false because this lookup returns a child-bound InheritedCapture. An existing startup extension that installs a customization only when that check confirms the shared mapping now skips it without app changes. The design document acknowledges the identity change but provides no compatibility opt-out or public direct-lookup alternative; GetPropertyDirect is internal. Provide a way to retain the previous shared-delegate lookup semantics for the intended main/.NET 12 default. This example does not apply to iOS or Windows, where Label defines Opacity locally.
| // replacement that wraps the returned mapping then still includes framework remaps that run lazily | ||
| // later, as they would have when the remaps ran at startup. | ||
| var sequence = MappingCustomizationSequence.Current; | ||
| return new Action<TViewHandler, TVirtualView>((h, v) => GetPropertyAsOf(key, sequence)?.Invoke(h, v)); |
There was a problem hiding this comment.
[moderate] Backward Compatibility and Migration - The typed indexer ignores a GetProperty override for an already-customized local key. In a subclass whose override returns a no-op while disabled, initialize K and append a callback while enabled, disable the subclass, then capture and invoke mapper[K]. Previously the captured no-op ran. Now the getter obtains that no-op but discards it, and GetPropertyAsOf returns the registered customization without consulting the override, executing the original mapping and append despite suppression. CommandMapper's local-key indexer has the same GetCommand override bypass. Preserve the override's returned mapping while maintaining recursion-safe captures, and test an overridden getter on an already-customized key; the added SetPropertyCore guard tests do not cover it.
Built-in Core handler property and command mappers now seal their framework mappings after construction (WithFrameworkMappingsSealed). Each sealed mapping is held in a framework cell that Controls remaps update in place, so delegates obtained earlier through GetProperty, GetCommand or the indexers observe later remaps. Replacing a key, or assigning any key after sealing, is recorded as a sequenced app customization. The public AppendToMapping, PrependToMapping, ModifyMapping and ReplaceMapping helpers are routed through the same records. Framework remaps compose underneath recorded customizations, merged views and compositions are invalidated through ChainVersion, chained lookups resolve as of the customization sequence, and GetProperty/GetCommand overrides are honored. Controls remaps switch from the public helpers to internal *ForControls helpers that modify the framework mapping. They still run eagerly from UseMauiApp and the existing static constructors; Label keeps its public AppendToMapping calls for Android IsTextSelectable and Apple FlowDirection. This is layer 2 of the stack splitting #29952. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- An unsealed mapper's indexer returns the chained mapping for an inherited key, so wrapping it no longer recurses into the wrapper. - Chain versions use stamps from a shared monotonic counter, so replacing a chained mapper always invalidates merged views and compositions. - Sealed mappers hand out inherited mappings bound to themselves, so a wrapper still observes a later framework remap on that mapper. Internal lookups resolve directly, so merged views, command invocation and the transform-mapping check are unchanged. - Each customization registers an index-bound mapping through SetPropertyCore. GetProperty/GetCommand return it without allocating, and SetPropertyCore override transformations apply. - Recorded customizations keep the chained mappers they were created with when Chained is later replaced or cleared. - A framework remap of an inherited key builds on the parent's mapping as of the remap, which restores main's behavior for app customizations of the parent registered before UseMauiApp. - Compositions are rebuilt when a customization is recorded concurrently. Adds regression and fall-through tests for both mappers and documents the behavior changes in HandlerResolution.md. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…e chain - A direct replacement through Add or the indexer already went through an overridden SetPropertyCore, so its customization record stores the registration without transforming it again. - The typed public ModifyMapping overload, and the Append/Prepend helpers built on it, map virtual views of another type through the mapper's current Chained, as a mapping added through Add does. - Allocation and identity checks in the mapper tests tolerate customizations recorded by tests running in parallel. Documents the startup-only threading contract for mapper customization and how untracked parent changes are observed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
df9d3fb to
a6fe0ad
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Selected Tests
🧪 Test selection — click to expand
🧪 UI tests — the full suite on every platform❌ maui-pr-uitests #1703227 failed — 2 tests failed on iOS, MacCatalyst. See Failed tests below. GPT-6.2 Sol: Run the full UI suite on all four platforms because shared property and command mapping changes affect base handlers. 🧪 Ran — 77 categories on Android, iOS, MacCatalyst, WindowsThe complete 📊 Results — failed: 93 passed, 4 failed of 98 jobs❌ Failed tests (2)
🔗 All test results · Build logs 🧪 Device tests —
|
| Platform | Categories |
|---|---|
| Android | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| iOS | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| MacCatalyst | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| Windows | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
📊 Results — failed: 2 passed, 4 failed of 6 jobs
❌ Failed tests (8)
| Test | Failed on | Error |
|---|---|---|
A root replacement leaves the incoming root's own animations running .A root replacement leaves the incoming root's own animations running (UIKit) |
iOS, MacCatalyst | Assert.NotNull() Failure: Value is null |
A root replacement started from the assignment's PropertyChanging animates once its own page lands .A root replacement started from the assignment's PropertyChanging animates once its own page lands (UIKit) |
iOS, MacCatalyst | The queued replacement swapped the root without animating. |
Changing the destination's Opacity during a flight doesn't reveal it under the snapshot |
Android, MacCatalyst | System.NullReferenceException : Arg_NullReferenceException |
Under the More tab, a shared element on the overflow root flies |
iOS, MacCatalyst | |
Under the More tab, push, pop and pop-to-root complete after a page transition |
iOS, MacCatalyst | |
WorkItemExecution.com.microsoft.maui.controls.devicetests-Signed Work Item |
Android | The Helix Work Item failed. Often this is due to a test crash. Please see the 'Artifacts' tab above for additional logs. |
WorkItemExecution.Controls Tests Work Item |
MacCatalyst | The Helix Work Item failed. Often this is due to a test crash. Please see the 'Artifacts' tab above for additional logs. |
WorkItemExecution.Controls.DeviceTests-Selected Work Item |
iOS | The Helix Work Item failed. Often this is due to a test crash. Please see the 'Artifacts' tab above for additional logs. |
🔗 All test results · Build logs
⏭️ Skipped — what neither suite runs
Device tests — 3 categories, 0 platforms
Categories not run: Graphics, Essentials, BlazorWebView
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | all categories | all categories |
| iOS | all categories | all categories |
| MacCatalyst | all categories | all categories |
| Windows | all categories | all categories |
GPT-6.2 Sol — Run the full UI suite on all four platforms because shared property and command mapping changes affect base handlers.
- PropertyMapper and CommandMapper change shared dispatch; ViewHandler, Element and VisualElement wire it into all four platforms.
- Android Entry, Editor and SearchBar mapper changes also warrant the explicit Material3 lane.
MAI Code 2 — Cross-platform mapper and handler customization infrastructure change; run the full UI suite and all Controls/Core device-test units.
PropertyMapper,CommandMapper, mapper extensions, customization sequencing, and Controls mapper remapping affect shared handler behavior across every control.- Changes span Controls remaps and Core handlers for many controls, so limiting UI coverage by a few categories would miss plausible regressions.
- Shared code affects Android, iOS, Mac Catalyst, and Windows; no platform or specific test category is safely excluded.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| iOS | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| MacCatalyst | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| Windows | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
GPT-6.2 Sol — Run all Controls and Core device tests on Android, iOS, Mac Catalyst, and Windows to validate shared mapper behavior.
- Shared PropertyMapper, CommandMapper and ViewHandler changes affect all Controls and Core device categories.
- No direct changes to the Graphics, Essentials or BlazorWebView projects warrant separate runs.
MAI Code 2 — Shared mapper infrastructure affects Controls and Core device handlers on every platform; run both complete device-test projects without adding Graphics, Essentials, or BlazorWebView.
PropertyMapperandCommandMapperunderpin Core handlers and Controls mapper remaps with broad shared behavior.- Controls and Core are selected as complete umbrellas; no Graphics, Essentials, or BlazorWebView project is changed.
- The implementation is cross-platform, with the Android-specific Editor/Entry/SearchBar changes also covered by the shared all-platform selection.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
There was a problem hiding this comment.
Expert Review — 6 findings · ⚠️ 4 breaking changes
Reviewed commit a6fe0ad.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| internal static new void RemapForControls() | ||
| { | ||
| StepperHandler.Mapper.AppendToMapping(nameof(Stepper.Increment), MapInterval); | ||
| StepperHandler.Mapper.AppendToMappingForControls(nameof(Stepper.Increment), MapInterval); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - For an app appending callbacks to StepperHandler.Mapper's Increment and Interval keys before its first UseMauiApp, changing an attached Stepper.Increment previously ran Increment's callback before the Controls redirect and Interval's callback; now Interval runs before Increment. On iOS/MacCatalyst, with Value=50, range 0-100 and Increment changing from 1 to 2, an Increment callback reading UIStepper.StepValue therefore observes 2 instead of 1. The shared redirect also reverses callback order on Android and Windows. The documentation and author response acknowledge this intentional change, but no compatibility opt-out preserves the previously working timing. Provide that opt-out for the intended main/.NET 12 default; migration guidance alone does not retain existing behavior.
| mappings[0] = mapping; | ||
| for (var i = 0; i < customizationCount; i++) | ||
| { | ||
| mapping = _customizations[i](mapping); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Successive helper customizations drop earlier SetPropertyCore override transformations, including when registered after UseMauiApp. With the WrappingPropertyMapper fixture added here, initialize Background and append callbacks A and B: previously each update executed three registration wrappers followed by core, A and B; now only two wrappers execute. Register saves the transformed delegates, but this loop feeds the raw first composition into the second customization, bypassing the first append's registered wrapper. A guard capturing a disabled flag for that first append is likewise lost: core and A now run when they previously were suppressed. Preserve prior registered transformations when composing subsequent helpers. Add a two-append regression case; the current wrapping test covers a direct replacement followed by only one append.
| var modificationCount = _frameworkModifications.Count; | ||
| var customizationCount = _customizations.Count; | ||
| var mappings = new Action<IElementHandler, IElement>?[customizationCount + 1]; | ||
| var mapping = _hasLocalMapping ? _localMapping : GetChainedPropertyAsOf(Chained, _key, _chainedMappingSequence); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Deferred resolution changes previously working single-threaded startup captures without any framework remap. Chain a child to an empty unsealed first parent and a second parent mapping K to A, append C on the child, then first-assign K to B on the first parent before the first update. Previously the child ran A,C; now it selects B,C and suppresses A. CommandMapper similarly changes C to B,C after a later first assignment on its unsealed parent. An independent IPropertyMapper parent changed from A to B before the child's first invocation also changes A,C to B,C. The documentation and author replies acknowledge the untracked-change exception, but no compatibility opt-out preserves captured delegates and absence. Preserve these captures separately from explicit framework remaps, or provide the opt-out for the intended main/.NET 12 default.
|
|
||
| // A caller that wraps an inherited mapping of a built-in mapper must still observe a later framework | ||
| // remap of the key on this mapper, as it would have when the remaps ran at startup. | ||
| return GetChainedPropertyDirect(key) is null ? null : CaptureInheritedProperty(key); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - On Android and MacCatalyst, Opacity is inherited by an untouched LabelHandler.Mapper. ReferenceEquals(LabelHandler.Mapper.GetProperty("Opacity"), ViewHandler.ViewMapper.GetProperty("Opacity")) previously returned true and now returns false because this lookup returns a child-bound InheritedCapture. A previously working startup extension that installs a customization only when this check confirms the shared mapping now skips that customization without app changes. The design document acknowledges the identity change but provides no compatibility opt-out or public direct-lookup alternative; GetPropertyDirect is internal. Provide a way to retain shared-delegate lookup semantics for the intended main/.NET 12 default. This example excludes iOS and Windows, where Label defines Opacity locally.
| // replacement that wraps the returned mapping then still includes framework remaps that run lazily | ||
| // later, as they would have when the remaps ran at startup. | ||
| var sequence = MappingCustomizationSequence.Current; | ||
| return new Action<TViewHandler, TVirtualView>((h, v) => GetPropertyAsOf(key, sequence)?.Invoke(h, v)); |
There was a problem hiding this comment.
[moderate] Backward Compatibility and Migration - The typed indexer stops honoring GetProperty overrides for already-customized local keys. In a subclass returning a no-op while disabled, initialize K and append a callback while enabled, disable the subclass, then capture and invoke mapper[K]. The getter obtains the overridden no-op but discards it; GetPropertyAsOf returns the stored customization without consulting the override, executing the original mapping and callback instead of suppressing them as before. CommandMapper's local-key indexer similarly bypasses GetCommand overrides at line 488. Preserve the overridden lookup result with recursion-safe capture semantics and add cases for overridden getters on already-customized keys; the SetPropertyCore guard tests do not exercise this contract.
|
|
||
| // Button is not an ILabel: the framework layers must fall through without casting it. | ||
| mapper.UpdateProperty(null, new Button(), nameof(IView.Background)); | ||
| Assert.Equal(string.Empty, log); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - The strongly typed ModifyMappingForControls mismatch case remains nondiscriminating: this ILabel mapper has no chained fallback, so Button produces an empty log even if the helper drops previousMethod. The new standalone fallback theories go through ApplyFrameworkHelper's IPropertyMapper(IElement, IElementHandler) parameter and therefore exercise the separate erased-interface overload, not this strongly typed overload. Add a standalone strongly typed modification over a logging IView parent and update a Button; assert the parent runs and the Controls callback does not. Otherwise a dropped fallback in this overload still leaves these assertions satisfied.
…40728) <!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `837a686cae779f71c330b133bcfa58aa05f4b04c` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 8.5/10 | ↑ Rebased on layer 2 `df9d3fbaca`. Core 1,235 tests pass under `dotnet test` and xunit.console. Controls 7,476 pass, 30 skipped.<br>↑ A non-`ElementHandler` Toolbar handler regression test fails without the latest fix and passes with it.<br>↑ Mapper-related Controls test classes also pass when each runs alone.<br>↑ Device tests on the iOS 27 simulator and an Android emulator pass for the `Label`, `TabbedPage` and `RadioButton` categories.<br>↑ The new factory tests fail when `??=` is changed to `=`.<br>↑ Controls.Core compiles for Android, iOS and MacCatalyst with 0 warnings.<br>↑ Two code reviews found an order-dependent test and a test-restore problem, both fixed. They found no product issues.<br>↓ Windows was not compiled locally, and no UI tests were run.<br>↓ CI has not run on this head. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change This is **layer 3 of 5** in a stack that splits #29952 ("[trimming] Trimmable element handlers") into reviewable pieces. It is stacked on #40725 (base branch `simonrozsival-handlers-stack-l2-mapper-infrastructure`, currently `df9d3fbaca`). The stack ultimately targets `main` (.NET 12). 1. #40721: context-aware handler activation and a Hot Reload `FullName` fix. 2. #40725: mapper infrastructure that preserves customizations. Controls remaps still run eagerly there. 3. **This PR: lazy Controls mapper remapping.** The DI default handler table is unchanged. 4. #29952 itself, rebuilt on this layer: `[ElementHandler]` attributes, removal of the eager DI default table, resolution precedence and caches. 5. The Copilot guidance PR #40715. Controls used to apply all of its mapper remaps at startup: `UseMauiApp` called every control's static `RemapForControls()`, and `Element`, `VisualElement`, `Label` and `Switch` also remapped from static constructors. This layer applies each remap the first time an instance of that type is attached to a handler. #29952 needs this so a control's remap code doesn't root that control's handler when the app never uses it. Layer 2's customization records make the change safe: on sealed mappers, app customizations compose with the Controls remaps whichever runs first. #### Mechanism - New Core internals: - `IControlsMapperRemappable`, with a single `RemapForControls()` method. - `OneTimeInitializationAction`, a blocking execute-once action backed by `Lazy<bool>`. Concurrent callers wait until the action completes. Tests are added for both behaviors. - `ElementHandler.SetVirtualView()` calls `RemapForControls()` when the virtual view implements `IControlsMapperRemappable`. The call runs after `VirtualView` is set and before the platform view is created and properties are mapped. - The Controls `Element` implements the interface. The `Element.Handler` setter calls the hook before `SetVirtualView`, so compatibility renderers that don't derive from `ElementHandler` are covered too. - Each Controls `*.Mapper.cs` now overrides `internal void RemapForControls()`. The override calls `base.RemapForControls()` and then runs a static `RemapForControlsOnce()` through its own `OneTimeInitializationAction`. Attaching a `Label`, for example, runs the `Element`, `VisualElement` and `Label` remaps in that order. Unrelated control types don't share a global lock. - `Toolbar` is not an `Element`, so it implements `IControlsMapperRemappable` itself. Its `Handler` setter calls the hook too, so custom toolbar handlers that don't derive from `ElementHandler` are covered. - `RemappingHelper.cs` and the empty `Layout.Mapper.cs` are deleted. - The `Switch` static constructor, which only remapped, is removed. `Label`'s static constructor now registers only its two public `AppendToMapping` calls, Android `IsTextSelectable` and Apple `FlowDirection`, which main also recorded at `Label` type initialization. Everything else in Label's remap runs lazily. - `CheckBox` keeps its static constructor for `CommandProperty.DependsOn(CommandParameterProperty)`. A test checks that the command dependency is set before any handler is attached. - The `TabbedPage` remap (`TabbedViewHandler.PlatformViewFactory`) and the Android `RadioButton` remap (`RadioButtonHandler.PlatformViewFactory`) install their factory through `InstallPlatformViewFactory()`, which uses `??=`. A factory the app installed before the first attach is kept. New device tests cover both an unset factory and an app factory installed first. #### Hosting `AppHostBuilderExtensions.SetupDefaults` no longer calls the eager `RemapForControls` builder extension, which is removed. It still registers the default handlers through `AddControlsHandlers()`, and it still calls `Animations.ControlsNavigationTransitionHooks.Install()`. That call used to run from inside the removed extension. `ControlsDeviceTestExtensions` no longer calls the removed extension. #### Behavior changes Lazy remapping is the intended .NET 12 behavior that makes trimming possible, so there is no runtime switch that restores startup remapping. `docs/design/HandlerResolution.md` lists these changes with migration guidance, next to layer 2's. - **Remaps run when the first control of each type is attached, not during `UseMauiApp`.** On sealed mappers, app customizations compose with the Controls remaps no matter when they are registered, as described in layer 2. - **Copying mapper keys at startup misses the Controls keys.** Before the first instance of a type is attached, the global mappers don't contain the keys its remap adds, for example the `BackgroundColor` redirect. Mappings already read through `GetProperty`, `GetCommand` or the indexers still observe later remaps. Migration: - Chain the custom mapper to the built-in one, for example `new PropertyMapper<ILabel, ILabelHandler>(LabelHandler.Mapper) { ... }`. - Or customize the built-in mapper with `AppendToMapping`, `PrependToMapping`, `ModifyMapping` or `ReplaceMapping`. - If a copy is unavoidable, take it after a control of that type has been attached, for example from `HandlerChanged`. - **Framework remaps of inherited keys build on the parent's mapping as of the first attachment.** A remap now also includes app customizations of the parent's key that were registered after `UseMauiApp` but before that attachment. Migration: register customizations that should apply everywhere before the first control is attached, for example in `MauiProgram`, or customize the child mapper's key. - **Platform view factories.** An app factory installed before the first `TabbedPage` or Android `RadioButton` is attached is kept and replaces the Controls factory. Reading the property during startup to wrap the Controls factory now returns `null`. - **Unchanged from main:** `Label`'s two public appends are still recorded at `Label` type initialization. #### Deviations from the #29952 head (`5db8263312`) - `VisualElement.Mapper.cs` keeps the iOS/MacCatalyst `UpdateCollectionViewAccessibilityTraits` code from main. The #29952 head deleted it by accident. - Three `VisualElementMapperTests` tests read global mapper keys without attaching a handler. They passed only when an earlier test in the same process had attached one. They now call `new VisualElement().RemapForControls()` first. The affected tests are `BackgroundKeyIsMappedBeforeControlsBackgroundColorAndImageSourceKeys`, `SemanticsKeyIsMappedBeforeControlsSemanticPropertiesKeys` and `RealDerivedHandlerMappers_MapCanonicalKeysBeforeTheControlsRedirectKeys`. The #29952 head has the same order dependency. - The `Switch.Mapper.cs` comment now says "before the first Switch is attached to a handler" instead of "is created". - `Label.Mapper.cs` registers the two public appends from a static constructor (`#if ANDROID || IOS || MACCATALYST`) instead of inside the lazy remap. This addresses review feedback on #29952 and on this PR. - `TabbedPage.Mapper.cs` and `RadioButton.Mapper.cs` move the `??=` install into `InstallPlatformViewFactory()`. New device tests: `TabbedPagePlatformViewFactoryTests.cs` and `RadioButtonTests.Android.cs`. - Left for layer 4: the `TrySetValue` moves out of `Element.cs`, the `IElementHandler.cs` newline fix, `[ElementHandler]` attributes, the `AddMauiControlsHandlers` no-op and the related device-test edits, and the Windows `PreventGestureBubbling` refactor. #### Docs The "Controls mapper remapping" section of `docs/design/HandlerResolution.md` keeps layer 2's mapper semantics and now describes lazy remapping. It covers: - the two attach hooks; - the per-type one-time actions and their base-first order; - command dependency setup and the platform view factory behavior; - Label's appends, recorded at type initialization. The section's "Behavior changes" list adds the lazy-remapping entries above to layer 2's entries. #### Validation Run with the .NET SDK `12.0.100-alpha.1.26523.103`: | Command | Result | | --- | --- | | `dotnet build Microsoft.Maui.BuildTasks.slnf` | Passed | | `dotnet build src/Core/src/Core.csproj --disable-build-servers -nodeReuse:false` (all local TFMs) | Passed, 0 warnings, 0 errors | | `LANG=en_US.UTF-8 dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj` | Passed: 1,235 | | `LANG=en_US.UTF-8 dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj` | Passed: 7,476, skipped 30 | | From `artifacts/bin/Core.UnitTests/Debug/net12.0`: `DOTNET_MODIFIABLE_ASSEMBLIES=debug dotnet exec --roll-forward Major --runtimeconfig Microsoft.Maui.UnitTests.runtimeconfig.json --depsfile Microsoft.Maui.UnitTests.deps.json ~/.nuget/packages/xunit.runner.console/2.9.3/tools/netcoreapp2.0/xunit.console.dll Microsoft.Maui.UnitTests.dll -nocolor` | Total 1,230, Failed 0 (run on the previous layer 2 base) | | `dotnet test … Controls.Core.UnitTests.csproj --no-build --filter "FullyQualifiedName~.<Class>"`, run once per class, for 12 mapper-related classes (`VisualElementMapperTests`, `ControlsMapperTests`, `ElementTests`, `VisualElementTests`, `ToolbarTests`, `LabelTests`, `RadioButtonTests`, `TabbedPageTests`, `HostBuilderHandlerTests`, `StoryboardTests`, `SemanticPropertyUnitTests`, `WindowsTests`) | All passed | | `dotnet build src/Controls/src/Core/Controls.Core.csproj -f net12.0-ios27.1 --disable-build-servers -nodeReuse:false` | Passed, 0 warnings | | Same for `-f net12.0-maccatalyst27.0` and `-f net12.0-android37.0` | Passed, 0 warnings | | `pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Label" -SkipXcodeVersionCheck` (iOS 27 simulator) | 99 passed, 5 skipped | | Same with `-Platform android -DeviceUdid emulator-5556` | 113 passed, 1 skipped | | `… -Platform ios -TestFilter "Category=TabbedPage"` | 90 passed, 3 skipped. Run before the restack; the new factory class passed again after it (2/2). | | `… -Platform android -TestFilter "Category=TabbedPage"` | 73 passed. Run before the restack; the new factory class passed again after it (2/2). | | `… -Platform android -TestFilter "Category=RadioButton"` | 4 passed | | The new factory tests with `??=` temporarily changed to `=` (iOS TabbedPage, Android RadioButton) | The app-factory test fails, as expected | | `dotnet format whitespace --folder --verify-no-changes --include <changed .cs files>` | Passed | | `git diff --check` | Clean | Not run: Windows build, UI tests, CI. ### Issues Fixed Part of #29952. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `cdeafb72937dc746d00866464afe6553904c7d9f` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 7/10 | ↑ Two review rounds addressed: most-specific interface resolution, plus Hot Reload replacement of attribute and default handlers (scoped per app, reinstalled after removal). Each fix has tests that fail without it.<br>↑ Rebased onto the reviewed lower layers. Core 1,279 tests pass under dotnet test and xunit.console, and Controls 7,532 pass. Controls compiles for Android, iOS and MacCatalyst.<br>↑ The new Android compatibility-renderer default activation device test passes 3/3 on an emulator.<br>↓ CI and the full device suites on this head are not yet assessed.<br>↓ Windows paths are compile-only; no Windows device coverage is added. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change <!-- Enter description of the fix in this section --> Follow-up to #28357 targeting **main / .NET 12**. Rebased onto the trimmable-styles merge (#33561), `04d36966ed9d334c056872d83741e973d61f6c55`. #### Stack This PR is **layer 4 of 5** in a stack split from the original single PR for easier review. It is based on #40728, and its own diff covers only the attribute-based resolution: 1. #40721: context-aware handler activation and Hot Reload type matching. 2. #40725: mapper infrastructure that preserves app customizations, the `*ForControls` remap helpers and sealed framework mappings. 3. #40728: lazy Controls mapper remapping on first handler attachment. 4. **This PR**: `[ElementHandler]` attributes on Controls types, removal of the eager default DI registrations, resolution precedence and caches, Hot Reload cache invalidation, Material3 and Apple Shell attribute selection, Windows `PreventGestureBubbling` overrides and the constructor-argument diagnostic. 5. #40715: Copilot guidance for working with handlers and mappers. The sections below describe the combined feature; the activation, mapper and lazy-remap sections are reviewed in layers 1–3. The combined tree is unchanged from the reviewed `5db8263312bf8ea352e8f5a40b04e148c235f4cc` except for the follow-up below. Built-in Controls primarily declare `[ElementHandler]` instead of being rooted by an eager default DI registration table. Controls-specific mapper changes run lazily when handlers attach, while preserving recorded application customizations. Open review items are listed below; this description is not a merge-readiness approval. #### Attribute-based handler resolution `ElementHandlerAttribute` remains internal. The concrete handler type is statically referenced for trimming/AOT. Although the attribute has `Inherited = false`, the factory explicitly walks the base-type hierarchy for fallback. Nested control-specific attributes preserve conditional Android Material3 selection and Windows CollectionView handler selection without unconditionally referencing both alternatives on the active path. `GetHandler(Type)` and `GetHandlerType(Type)` share the resolution order: 1. Exact DI registration. 2. Attribute declared directly on the requested type. 3. The more specific of the nearest registered base class and the nearest inherited attribute. An inherited attribute ranks like the built-in registration its declaring class used to have; a registration on that class or a subclass wins. 4. The most specific registered interface. With Controls defaults on, the `IContentButton`/`IContentView` defaults compete here as interface registrations. 5. Content interface fallbacks: `IContentButton` → `ContentButtonHandler`, then `IContentView` → `ContentViewHandler`. A conditional attribute can declare no handler, for example Apple `ShellItem` when `UseiOSShellHandler` is off; resolution then continues as if it were absent. An exact `AddHandler` still overrides defaults. A registration for `Button` applies to an unannotated `FancyButton : Button`, but registering `IButton` or `View` does not divert it from `ButtonHandler`. Factory registrations remain authoritative even when `GetHandlerType` cannot report an `ImplementationType` and therefore returns `null`. Controls enables an `ElementHandlerDefaultsEnabled` policy per app's handler collection: `TryAddHandler` does not replace a directly declared default or the `IContentButton`/`IContentView` defaults, but still registers custom derived types that only inherit an attribute fallback. Apps without Controls defaults retain normal `TryAddHandler` behavior; `AddHandler` always remains an override. `UseMauiApp` enables the policy before registration callbacks execute regardless of builder-chain order. `AddMauiControlsHandlers` remains a non-obsolete compatibility no-op returning the original collection, without enabling defaults or eagerly remapping controls. #### Cache ownership and invalidation Only attribute and assignable-registration lookups are cached. The complete resolution result and constructor-activation strategy are **not** cached; current registrations and delegates are consulted on every request, and transient requests create fresh handlers. Each factory owns its resolution caches and builds its assignable index from current descriptors, including raw DI registrations. Built-in collection mutations (`Add`, `Insert`, indexer replacement, `Remove`, `RemoveAt`, `Clear`) advance a version. Hot Reload metadata updates, cache clearing, replaced-view callbacks and reset advance a checked generation before views are recreated. Hot Reload registration replacement also changes the collection version. A new cache generation replaces the old dictionaries, preventing concurrent old-generation readers from repopulating new state. Custom collections without mutation tracking do not retain resolution caches. Descriptor lookup stays consistent with indexer/list changes; removing the last registration restores the preceding descriptor for that service type. Cache lookup supports concurrent readers, but collection mutation retains the standard `IServiceCollection` contract and must not run concurrently with resolution. #### Context-aware activation without an activation cache `ElementExtensions.ToHandler` delegates reflection-based construction to the factory. A public parameterless constructor is preferred when present; otherwise `ActivatorUtilities.CreateInstance` resolves dependencies from the current context (including its Android context). Value-type handlers keep default construction. The constructor-presence check avoids using `MissingMethodException` as ordinary control flow, including first activation, without additional cache ownership/invalidation complexity. Direct public `GetHandler` callers retain parameterless-constructor behavior. Custom factories retain their existing exception-based injection fallback. Dependency failures propagate without retrying the entire injection. Factory activation still uses the current service provider/`IMauiContext`, and activated factory types participate in Hot Reload replacement. Historical matched **.NET 11** managed Release microbenchmarks measured warm injected activation at roughly 9 µs with exception-first construction versus 0.10–0.16 µs when missing-constructor exceptions were avoided. Constructor checks were comparable to a factory-owned activation cache; shared-host noise prevents claiming a small difference between those alternatives. These are **not .NET 12 measurements, Android startup claims, or APK-size results**. #### Lazy mapper remapping and main integration Controls `Element.SetHandler` invokes the remap hook before attaching any handler, including compatibility renderers. `ElementHandler.SetVirtualView` also invokes it for direct attachment outside Controls. Each remappable type calls its base hook and owns a blocking one-time initialization action; unrelated controls do not share a global initialization lock. Built-in mapper declarations seal their initial framework mappings. Controls property/command remaps update those mappings underneath recorded app customizations, preserving direct indexer overrides and `AppendToMapping`, `PrependToMapping`, `ModifyMapping`, and `ReplaceMapping` in registration order, including keys that are absent until a lazy remap and keys inherited from chained mappers. See `docs/design/HandlerResolution.md` for the ordering rules. Command-property dependency setup remains in control initialization, independent of handler attachment. The main rebase preserves newer upstream functionality: - `ContentButton` has its own handler attribute, `IContentButton` fallback, sealed mapper and lazy Android ripple remapping. - Switch OnColor remapping uses the lazy hook and customization-preserving prepend behavior on Apple platforms. - Android toolbar drawer-toggle remapping and the current Android/Windows common-mapping scope are retained. - RoundRectangle retains `IShapeWithStroke`; Shell retains the reentrant-navigation unsubscribe fix; handler instrumentation is preserved. - Android ListView/TableView/Frame compatibility attributes retain context-accepting activation through the factory's current-context injection path. - HybridWebView remains a deferred factory registration. Cell attributes retain their platform scopes, and Windows CollectionView feature-switch selection remains conditional. - Controls navigation-transition hooks are installed independently of the removed eager remapping helper. Obsolete eager registration/remapping helpers and Android-context-specific handler interfaces/attributes are removed. Detailed resolution and activation contracts are documented in `docs/design/HandlerResolution.md`. #### Updated Android APK measurements (.NET 12) **Trimmable styles + handlers reduce the plain template's signed NativeAOT APK by 756 KiB (4.64%) compared with neither optimization.** Since styles are already merged into main, this PR's incremental saving over styles alone is **712 KiB**. The 4.64% figure is the combined effect, not a handlers-only measurement. | Framework state | NativeAOT APK (bytes) | Release/CoreCLR APK (bytes) | | --- | ---: | ---: | | Neither styles nor handlers | 16,686,161 | 18,591,480 | | Trimmable styles only | 16,641,105 | 18,591,480 | | Trimmable styles + handlers | 15,912,017 | 18,398,968 | Styles alone save 44 KiB with NativeAOT. Ordinary Release/CoreCLR saves **188 KiB (1.04%)** with handlers; styles alone do not change that APK's size under its default settings. Measured the same unmodified `dotnet new maui -n Template --framework net12.0` source, **without `--sample-content`**, as signed ARM64 APKs. Framework revisions were `f38825f543a18fdcf5ac672b73835e50edd159f6` (neither), `04d36966ed9d334c056872d83741e973d61f6c55` (styles), and `9d2e9cf9b649b647777ec885cd31d1e303e3d49e` (both). The matched local builds use SDK `12.0.100-alpha.1.26523.103`, Android workload `37.99.0-preview.1.358`, and the same MAUI package version `12.0.0-pr29952.local`, with separate feeds/caches. Non-MAUI dependencies, runtime native libraries, signing key, app source and relevant build settings were matched and package hashes checked. NativeAOT uses full trimming and default trimmable styles; ordinary Release uses CoreCLR, partial trimming and default composite R2R. Both retain the SDK's default trimmable typemap and shipped/default profile policy: **no app-trained or custom MIBC**. These are APK file-size measurements, **not startup/JIT/runtime measurements**. No handlers-only arm was measured; the incremental handler saving includes its interaction with merged styles. Local artifact build commands (all **passed**): `bash artifacts/apk-styles-handlers-20261126/build-app.sh baseline aot`, `bash artifacts/apk-styles-handlers-20261126/build-app.sh none aot`, `bash artifacts/apk-styles-handlers-20261126/build-app.sh both aot`, and the same three commands with `release` instead of `aot`. The historical directory name `none` contains the styles-only revision; provenance is checked against `source.sha`, not inferred from directory labels. `python3 artifacts/apk-styles-handlers-20261126/measure.py` — **passed**; verifies all six APKs and records exact source/settings/package/profile identities in `results.json` alongside retained commands, logs and binlogs. These scripts and outputs are local investigation artifacts, not files added by this PR. #### Local validation after the styles rebase (9d2e9cf) The latest English-locale `net12.0` runs passed: - `LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj -c Release -p:MauiPlatforms= -m:1 -v:q` — **1,198 passed**. - `LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -c Release -p:MauiPlatforms= -m:1 -v:q` — **7,522 passed, 30 skipped**. - `LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj -c Release -p:MauiPlatforms= -m:1 -v:q` — **910 passed, 71 skipped**. The previously reported comma-decimal failures were independently reproduced on clean main and pass with the English locale; they are not this PR's regressions. Existing coverage includes collection mutation/raw registrations, custom unversioned collections, metadata and handler replacement, context/app isolation, dependency errors without retry, constructor preference/value types, first-use exception elimination, recorded mapper customization and ContentButton activation/type lookup. Local Android framework packaging and the six trimmed/NativeAOT template builds above passed. This does **not** establish device/UI behavior or iOS/MacCatalyst/Windows validation for this head; CI attribution and remaining review findings are still being assessed. #### Review follow-up in 714715d - **Handler precedence:** An inherited attribute ranks like the built-in registration its declaring class used to have. The most specific concrete candidate wins, and registered concrete types outrank interfaces. With Controls defaults on, `IContentButton`/`IContentView` defaults compete as interface registrations, and `TryAddHandler` no longer replaces them. - **Mapper customizations:** Lazy Controls remaps now compose underneath app customizations, as if they had run at startup. This covers post-seal assignments to absent keys, child customizations of parent keys that only appear in a later lazy remap, and delegates read before a remap. App-created mapper chains keep capture-at-customization semantics, and wrapping a mapping read from a mapper no longer recurses. - **Apple Shell:** `UseiOSShellHandler` again selects `ShellHandler` or `ShellRenderer`, along with the item, section and content handlers. Conditional attributes may declare no handler, so inactive handlers remain trimmable. - **CI fixes:** Hot Reload handler replacement matches by type name; xunit.console loads the test assembly twice. The Material3 Picker expectation is corrected, there is a blocking `OneTimeInitializationAction` test, and the constructor-argument diagnostic is clearer. Validation: Core unit tests passed 1,223/1,223 under `dotnet test` and xunit.console with `DOTNET_MODIFIABLE_ASSEMBLIES=debug`. Controls unit tests passed 7,530, with 30 skipped. `Controls.Core` compiles for `net12.0-ios27.1` and `net12.0-maccatalyst27.0`. The new Shell resolution device tests passed 2/2 on MacCatalyst via `.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter "Category=Shell" -IncludeClasses "Microsoft.Maui.DeviceTests.ShellHandlerResolutionTests"`. Android and iOS device runs and CI are not yet assessed on this head, and the APK measurements above predate it. Follow-up in 5db8263: lazy RadioButton (Android) and TabbedPage remaps keep a `PlatformViewFactory` the app sets during startup. Resolution fetches its cache once per request, and the typed `*ForControls` mapper helpers check view and handler types before casting. Follow-up when splitting the stack: - Restores the iOS/MacCatalyst `UpdateCollectionViewAccessibilityTraits` refresh on semantics changes. A rebase in 7fba985 had accidentally dropped it. - `VisualElementMapperTests` trigger the lazy remap before reading global mapper keys. They previously passed only when another test had attached a handler first. - `HandlerResolution.md` gains the lower layers' more precise activation and remapping text. Validation on `c1de79de46`: - Core unit tests: 1,225 passed under `dotnet test` and xunit.console. - Controls unit tests: 7,530 passed, 30 skipped. - The three mapper key-order tests pass when run on their own. - `Controls.Core` compiles for `net12.0-android37.0`, `net12.0-ios27.1` and `net12.0-maccatalyst27.0`. Review follow-up (rebased; now in cdeafb7): - **Interface resolution:** resolution now picks the most specific matching interface before reporting an ambiguity. A concrete `IContentButton` with `IButton` and `IContentView` registered resolves to `ContentButtonHandler`, or to a registered `IContentButton` handler. Unrelated registrations remain ambiguous. - **Hot Reload:** pending handler replacements also apply to handlers resolved from `[ElementHandler]` or the content interface defaults. These have no collection descriptor, so the replacement is registered for the requested view type the next time it is resolved. - **Lower layers:** this PR was rebased onto #40728. That carries the lower layers' review fixes: injected handlers are never retained as singletons, the mapper fixes, and Label's public appends are back at type initialization. HandlerResolution.md now has a combined "Behavior changes" section with migration guidance. Second review round: - **Hot Reload:** replacements of attribute and default handlers apply only to the collection passed to `RegisterHandlers`. A newly registered collection receives replacements that were already applied to the previous one, and a replacement whose registration was removed is installed again. - **Registration order:** HandlerResolution.md documents the changes. `AddHandler` before `UseMauiApp()` now wins, `AddMauiControlsHandlers()` no longer restores a replaced handler, and `RemoveAll` followed by `TryAddHandler` no longer replaces an attributed default (use `AddHandler`). - **Android device test:** `CompatibilityRendererDefaultActivationTests` covers default activation of the `ListView`, `TableView` and `Frame` renderers with the current Android `Context`. Validation on `cdeafb7293`: - Core unit tests: 1,279 passed under `dotnet test` and xunit.console. - Controls unit tests: 7,532 passed, 30 skipped. - `Controls.Core` compiles for Android, iOS and MacCatalyst. - The Android device test above passed 3/3. Earlier validation on `a0f29fdbde`: - Core unit tests: 1,271 passed under `dotnet test` and xunit.console. - Controls unit tests: 7,531 passed, 30 skipped. - `Controls.Core` compiles for `net12.0-android37.0`, `net12.0-ios27.1` and `net12.0-maccatalyst27.0`. #### Behavior changes - **`AddMauiControlsHandlers()`:** Remains a compatibility no-op. Calling it after registering a custom handler, for example `AddHandler(typeof(Button), typeof(CustomButtonHandler))`, no longer restores `ButtonHandler`. Remove the custom registration instead. - **Custom `IMauiHandlersFactory` implementations:** Not supported. Built-in defaults are resolved from attributes by the built-in factory, not exposed as descriptors in `IMauiHandlersCollection`, so a replacement factory can no longer resolve Controls views. A follow-up will discourage and eventually remove this extension point. `IMauiContext.Handlers` exposes the interface, so this needs a replacement design rather than just `[Obsolete]`. - **Lazy remaps:** Controls mapper remaps run on each control type's first attachment instead of at `UseMauiApp`. App customizations made during startup are preserved as described above. Label keeps its pre-PR timing: its remaps already ran lazily from its static constructor. Windows CollectionView, ListView and TableView device coverage is left to the Windows controls maintainers. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Supports the trimmable handler work started in #28357. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…ps (#40715) <!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `9fc89e163e09ad84e46d29176e995dc810548920` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 8.5/10 | ↑ Every rule was rechecked against the final restacked #29952 head (`cdeafb7`): the source, `docs/design/HandlerResolution.md` including its new Behavior changes section, and the resolved review threads.<br>↑ The committed Pester suite `Review-Expert.Tests.ps1` passes 13/13 locally with Pester 5.9.0. It checks the pinned hash, the 32 headings, mapper routing to dimension 3 with negative cases, and C# routing to dimensions 12 and 18. Its positive cases fail when the mapper rules are removed.<br>↓ The routing change has not been exercised in a live `/review` run, and I have not inspected the PowerShell Script Tests CI result for this head.<br>↓ No automated validation exists for instruction or agent files. The skill-validation workflow covers only `.github/skills/**`, which this PR does not change.<br>↓ The guidance follows the stack's design, so it must be revisited if a lower layer changes before merge. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change This is the top layer of the trimmable-handlers stack: 1. #40721: context-aware handler activation 2. #40725: customization-preserving mapper infrastructure 3. #40728: lazy Controls mapper remaps 4. #29952: trimmable `[ElementHandler]` resolution 5. **This PR**: agent guidance The base is the #29952 branch, `dev/simonrozsival/net10.0-use-element-handler-attributes`. Merge this PR after #29952 and the layers below it. It changes only agent guidance, expert-review routing and its tests, not product code. It records the stack's handler and mapper practices so future agents follow them: - **New `.github/instructions/handler-registration.instructions.md`**, path-scoped to Controls `*.Mapper.cs` partials, Core/Controls hosting, `Handlers/Element`, `PropertyMapper*`/`CommandMapper*`, `ElementExtensions`, Hot Reload, handler-resolution and mapper tests, and `HandlerResolution.md`. It covers: - **Built-in defaults:** built-in controls declare their default handler with the internal `[ElementHandler]` attribute on the control class (platform-scoped), not with DI. `AddMauiControlsHandlers()` is a no-op. DI is for app/library overrides and interfaces. HybridWebView's existing `SetupDefaults` factory is an exception to keep, not a pattern to copy: a factory delegate only defers construction, so the handler stays rooted. - **Construction:** attribute-resolved handlers need a public parameterless constructor. Only `ToHandler()` injects constructor arguments; a handler that needs them should be registered with an `AddHandler` factory. The factory's provider resolves the current `IMauiContext` only on context-taking paths such as `ToHandler()`, not on public `GetHandler(Type)`. There is no activation cache, and custom `IMauiHandlersFactory` implementations are unsupported. - **Feature switches:** handler selection that depends on a feature switch uses a nested `ElementHandlerAttribute` subclass that checks a `[FeatureSwitchDefinition]` switch (Material3, Windows CollectionView, Apple Shell). `GetHandlerType()` may return `null`. - **Resolution:** - It covers precedence, `GetHandler`/`GetHandlerType` consistency, interface ambiguity, Hot Reload replacement of attribute handlers, non-singleton injected handlers and `TryAddHandler` semantics. - To replace a built-in handler, use `AddHandler`; it wins regardless of registration order. - Mapper customization is documented as startup-only. - It links to `HandlerResolution.md` rather than duplicating it, and asks for observable changes to be recorded in that doc's Behavior changes section. - **Lazy remaps:** remaps run on first attach, base type first. `Toolbar`, which is not an element, triggers its remap from its own handler setter. - Remaps use the `*ForControls` helpers, not the public customization APIs. Label's Android `IsTextSelectable` and Apple `FlowDirection` public appends are the documented exception; they run from `static Label()`, not the remap. - Static factories are installed through `InstallPlatformViewFactory()` with `??=`, and `DependsOn` stays in type initialization. - Remapped mappers call `.WithFrameworkMappingsSealed()`. `SwitchHandler.Mapper` and `TextButtonMapper`/`ImageButtonMapper` remain unsealed exceptions. - A framework remap of an inherited key builds on the parent's mapping as it is at first attachment. - For inherited keys, sealed mappers return child-bound mappings and unsealed ones return the chained mapping. Internals use `PropertyMapper.GetPropertyDirect`. - **Testing:** - Platform attribute branches need device tests. Tests that toggle a switch use `DisableParallelization` and restore it. - Mapper-preservation tests cover customizations both before and after the remap. - Tests that read global mappers must trigger the lazy remap first (`new VisualElement().RemapForControls()`). - Tests must not assume `Type` identity across assembly loads. - **`handler-patterns.instructions.md`**: adds bullets on sealing (with the unsealed exceptions) and the remap helpers, plus a short "Registering Built-in Handlers" section that links to the new file. - **`maui-expert-reviewer.md`**: replaces the outdated "use `ModifyMapping` for Controls-layer overrides" check. - Dimension 3 gets checks for remaps, sealing, unsealed exceptions, child-key remaps, `??=`, `DependsOn` and test-order independence. - Dimension 12 gets checks for resolution consistency, unsupported custom factories and the `AddMauiControlsHandlers()` no-op. - Dimension 18 gets checks for attributes, feature-switch selection and device coverage. The existing HybridWebView factory is exempt from the built-in-handler check. - Dimensions 12 and 18 activate for every `.cs` file, both in the rulebook's Conditional Dimensions table and in `Review-Expert.ps1`. Self-reviews that pick dimensions from the rulebook, such as try-fix Step 6, therefore also reach the `[ElementHandler]` checks. - **Dimension Routing** now routes Controls `*.Mapper.cs` partials, Core mapper infrastructure (`PropertyMapper*`, `CommandMapper*`, `MappingCustomizationSequence.cs`) and `*Mapper*Tests.cs` to dimension 3, so mapper-only changes get the remap and test-order checks. - **`.github/scripts/Review-Expert.ps1`**: mirrors those three routing rules in `Get-ExpertExpectedDimensions` and updates the pinned routing SHA-256. This changes only routing data; it adds no tokens, checkouts or PR-code execution. - **New `.github/scripts/Review-Expert.Tests.ps1`**: Pester regression tests for the routing, run by the existing `powershell-script-tests.yml` gate. That workflow now also triggers on `.github/agents/maui-expert-reviewer.md`, so a rulebook routing edit without a matching hash update fails CI. - **`copilot-instructions.md`**: adds a short "Handlers and Mappers" pointer, because a focused `applyTo` cannot match control class files (`Label.cs`, `Button.cs`, ...). - **`README-AI.md`**: indexes the handler instruction files. No skills changed: `code-review` delegates handler checks to `maui-expert-reviewer`, and no other skill describes handler registration. **Validation:** No automated tests exist for instruction or agent markdown, and `skill-validation.yml` runs only for `.github/skills/**`. - `pwsh -c 'Import-Module Pester -RequiredVersion 5.9.0; Invoke-Pester .github/scripts/Review-Expert.Tests.ps1'`: **passed**, 13/13. - With the three mapper routing rules temporarily removed from `Review-Expert.ps1`, the same run failed 6 of 13 tests, so the suite catches the original gap. `git diff --check` is clean. ### Issues Fixed Follow-up to #29952; no separate issue. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…ns survive (#40930) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change Since #28357, `Label`'s Controls remap ran only from `Label`'s static constructor. The remap uses `ReplaceMapping` for `Text`, `LineBreakMode`, `MaxLines`, `TextType`, `TextTransform` and `FormattedText`, which drops whatever is already mapped. An app that customizes `LabelHandler.Mapper` in `MauiProgram` (after `UseMauiApp`) lost those customizations as soon as the first `Label` was created. In .NET 9 the remap ran inside `UseMauiApp`, so app customizations layered on top of it. - `UseMauiApp` runs `Label`'s remap again, right after the `VisualElement` remap, as it did before #28357. - The `Label` static constructor and `UseMauiApp` both go through `RemappingHelper.RemapIfNeeded`, the guard `Element` and `VisualElement` already use. The remap runs once, whichever comes first. On `net11`, `AddControlsHandlers()` still registers `LabelHandler` eagerly, so running the remap at startup doesn't root anything that wasn't already rooted. On `main`, #40725 and #40728 fix this differently: customization-preserving mappers plus lazy remapping. That change is too large for servicing. `CheckBox` uses the same static-constructor pattern for `CheckBoxHandler.Mapper`'s `Color` key. It's left out of this PR to keep it focused. **Tests:** `LabelMapperCustomizationTests` runs the scenario against fresh copies of the MAUI assemblies in a collectible `AssemblyLoadContext`, because the `Label` type initializer only runs once per process. It calls `UseMauiApp`, appends `Text` and `LineBreakMode` mappings, creates a `Label`, and checks that both appended mappings run. **Validation:** - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter FullyQualifiedName~LabelMapperCustomizationTests` - Without the fix: **fails** (`Expected: ["Text", "LineBreakMode"]`, `Actual: []`). - With the fix: **passes**. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj`: **passed**, 6840 tests, 0 failed, 30 skipped. - Not run: platform TFM builds, device tests and UI tests. The change contains no platform-specific code. ### Issues Fixed Fixes #40929 ### Let AI finish this PR - [ ] **Let the MAUI agent address review feedback and fix remaining issues on this PR.** Maintainers still decide whether it is merged. For PRs from forks, the agent opens a follow-up PR that keeps your commits. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
df9d3fbacadf4ad80a64e21167e3032349618b8adotnet testand xunit.console. Ten consecutive full Core runs passed before the rebase onto #40721's latest commit. Controls 7,467 pass, 30 skipped.↑ Every regression test added in review fails on the commit before its fix, and the inherited-key wrapper tests overflow the stack there.
↑ Controls.Core compiles for Android, iOS and MacCatalyst. Core builds with 0 warnings.
↓ Three review findings are declined and documented: concurrent customization, and untracked parent changes.
↓ Windows was not compiled locally and no device tests were run.
↓ CI has not run on this head.
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!
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
This is layer 2 of 5 in a stack that splits #29952 ("[net12.0] Trimmable element handlers") into reviewable pieces. It is stacked on #40721 (base branch
simonrozsival-handlers-stack-l1-activation), and the stack ultimately targetsmain(.NET 12).FullNamefix.OneTimeInitializationAction,IControlsMapperRemappable, per-typeRemapForControlsand the attach hooks. The DI default table is still present.[ElementHandler]attributes, removal of the eager DI default table, resolution precedence and versioned caches.This layer makes the order in which framework remaps and app customizations run irrelevant for sealed mappers. Layer 3 relies on that when it makes the remaps lazy. On its own, this layer behaves like main for apps that customize mappers after
UseMauiApp.PropertyMapper/CommandMapperSealFrameworkMappings()/WithFrameworkMappingsSealed()marks the mappings added so far as built-in. Each one is held in a cell whose delegate never changes.ModifyFrameworkMappingupdates the cell in place, so delegates the app obtained earlier still include later framework remaps.MappingCustomizationSequenceorders every app customization across all mappers.MappingCustomizationrecord: the framework layer plus the customizations in order.GetProperty/GetCommandand the typed indexers return a mapping as of the current sequence. It includes later framework remaps but not later app customizations, sovar previous = mapper[key]; mapper[key] = (h, v) => { previous(h, v); ... };cannot recurse into itself.ChainVersionsums the versions of a mapper and its chain. Merged views and compositions are rebuilt when any mapper in the chain changes.GetProperty/GetCommandare honored when a record is created.Extensions
AppendToMapping,PrependToMapping,ModifyMappingandReplaceMappinghelpers for both mappers are routed through the customization records. Mappers that are notPropertyMapper/CommandMapperkeep the old capture-and-add path.ReplaceMappingForControls,ModifyMappingForControls,AppendToMappingForControlsandPrependToMappingForControlshelpers modify the framework layer instead. Their typed overloads fall through to the previous mapping when the handler or view type doesn't match.Built-in mappers and Controls remaps
.WithFrameworkMappingsSealed(). That includesViewHandler.ViewMapper/ViewCommandMapperand the Entry, Editor and SearchBar command mappers.*.Mapper.csremaps switch from the public helpers to the*ForControlshelpers. Otherwise they are unchanged:UseMauiApp(AppHostBuilderExtensions.RemapForControls).Element/VisualElementstill run theirs throughRemappingHelper, andLabel/Switchthrough their static constructors.Labelkeeps the publicAppendToMappingfor AndroidIsTextSelectableand AppleFlowDirection, as in [trimming] Trimmable element handlers #29952.Behavior changes
These are also documented, with migration guidance, under "Behavior changes" in
docs/design/HandlerResolution.md.UseMauiApp, for example from a handler's static constructor. It matches what main already does for customizations registered afterUseMauiApp.StepperHandler.MapperIncrementandInterval. ChangingIncrementused to run the app'sIncrementcallback before the Controls redirect toInterval; it now runs it after theIntervalcallback.LabelHandler.Mapper,GetProperty/GetCommandand the indexers return a child-bound mapping for keys inherited fromViewHandler.ViewMapper, not theViewMapperdelegate itself.FlyoutViewHandler.MapperFlowDirection, builds on the parent mapping as of the remap. App customizations ofViewMapperregistered beforeUseMauiApptherefore still run forFlyoutPage.Chainedis later replaced or cleared.Review fixes (7dd2952)
var previous = child[key]; child[key] = (h, v) => previous(h, v);, no longer recurses infinitely. This applies to both mappers, including the inheritedFocuscommand onButtonHandler.CommandMapper.SetPropertyCore, so:GetProperty/GetCommanddon't allocate for customized keys, which matters on the animation path;SetPropertyCoreoverride apply to customized keys.Review fixes (df9d3fb)
Addor the indexer applies an overriddenSetPropertyCoretransformation once, not twice.ModifyMappingoverload, and theAppendToMapping/PrependToMappingoverloads built on it, map virtual views of another type through the mapper's currentChained, asAdddoes.HandlerResolution.mddocuments that mapper customization is a startup operation, and how a child observes untracked parent changes: first assignments on unsealed mappers, and parents that aren'tPropertyMapper/CommandMapper.Tests and docs
PropertyMapperExtensionTestsandCommandMapperExtensionTestsgain tests covering:GetProperty/GetCommandand indexer wrappers;GetProperty/GetCommandoverrides;SetPropertyCoreoverride transformations and parent customizations under child remaps;StoryboardTestsnow removes the recordedScalecustomization when it restoresViewMapper, so later tests see the original mapping.docs/design/HandlerResolution.mdgains a "Controls mapper remapping" section describing the eager remaps in this layer. It lists the mappers that aren't sealed and Label's two public appends, and has a "Behavior changes" section with migration guidance.Validation
Run with the .NET SDK
12.0.100-alpha.1.26523.103:dotnet build src/Core/src/Core.csproj -c Release -p:MauiPlatforms= -m:1 -v:qLANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj -c Release -p:MauiPlatforms= -m:1 -v:qLANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -c Release -p:MauiPlatforms= -m:1 -v:qartifacts/bin/Core.UnitTests/Release/net12.0:DOTNET_MODIFIABLE_ASSEMBLIES=debug dotnet exec --roll-forward Major --runtimeconfig Microsoft.Maui.UnitTests.runtimeconfig.json --depsfile Microsoft.Maui.UnitTests.deps.json ~/.nuget/packages/xunit.runner.console/2.9.3/tools/netcoreapp2.0/xunit.console.dll Microsoft.Maui.UnitTests.dll -nocolordotnet build src/Controls/src/Core/Controls.Core.csproj -f net12.0-android37.0 -c Release --disable-build-servers -nodeReuse:false-f net12.0-ios27.1and-f net12.0-maccatalyst27.0dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include <changed .cs files> --verify-no-changesSearchBarHandler2.Android.cs. Running it on the base for the same files gives the same errors.dotnet format whitespace --folderpasses for every other changed file.git diff --checkNot run: Windows build, device tests, CI.
Issues Fixed
Part of #29952.