Skip to content

Update mappers instead of replacing field values - #13836

Merged
PureWeen merged 127 commits into
mainfrom
dev/fix-mapper-field-ordering
Jul 22, 2023
Merged

PureWeen merged 127 commits into
mainfrom
dev/fix-mapper-field-ordering

Conversation

@mattleibow

@mattleibow mattleibow commented Mar 10, 2023 •

Copy link
Copy Markdown
Member

PENDING PRs:

  1. Use [AppendTo|PrependTo|Replace]Mapping for Focus commands #15040
  2. Use PrependToMapping method to replace Window MapTitle method #15041
  3. Implement all permutations of InputTransparent and CascadeInputTransparent #14846
  4. Ensure "text boxes" preserve cursor location #15099
  5. Implement all permutations of InputTransparent and CascadeInputTransparent #14846
  6. Text needs to be set before other properties #16116
  7. Move most controls to use ModifyMapping (and variants) #15058

Description of Change

Update mappers instead of replacing field values to prevent field/type reference ordering to influence the way mappers are set.

Currently we assume that UseMauiApp is the first part of MAUI that updates the mappers, however we can directly influence that very easily:

// load Core mappers
ElementHandler.ElementMapper.GetKeys();
ViewHandler.ViewMapper.GetKeys();
ButtonHandler.Mapper.GetKeys();

// then load Controls mappers
Button.ControlsButtonMapper.GetKeys();
Element.ControlsElementMapper.GetKeys();
VisualElement.ControlsVisualElementMapper.GetKeys();

By first forcing all the Core types to load, the Controls mappers are not correctly set up to handle changes later on. Because we first load Button.ControlsButtonMapper and then Element.ControlsElementMapper, the properties in Element are not available to Button.

This PR removes the need for ordering and makes sure that Button is chained to Element so we can ADD to Element and Button automatically gets the new properties.

Context: #11662 (comment)

BREAKING

There is technically a breaking change in that we are no longer use the Controls*Mapper fields anymore since they actually break with AOT as they would run in random orders (hence this PR). So as a result, if someone did this, it would no longer work:

Button.ControlsButtonMapper.AppendToMapping(...);

The reason for this is that we don't use this field and thus would never reach the handlers. However, I am not sure this way is common as most people should have been using the base mapper:

ButtonHandler.Mapper.AppendToMapping(...);

To help avoid and catch any of these issues, I have marked it as obsolete so that there is a build warning. However, regardless of what version of maui you are using, always use the base handler mappers.

Issues Fixed

Fixes #11662

Tasks

  • Code
    • Application.RemapForControls();
    • VisualElement.RemapForControls();
    • Label.RemapForControls();
    • Button.RemapForControls();
    • CheckBox.RemapForControls();
    • DatePicker.RemapForControls();
    • RadioButton.RemapForControls();
    • FlyoutPage.RemapForControls();
    • Toolbar.RemapForControls();
    • Window.RemapForControls();
    • Editor.RemapForControls();
    • Entry.RemapForControls();
    • Picker.RemapForControls();
    • SearchBar.RemapForControls();
    • TabbedPage.RemapForControls();
    • TimePicker.RemapForControls();
    • Layout.RemapForControls();
    • ScrollView.RemapForControls();
    • RefreshView.RemapForControls();
    • Shape.RemapForControls();
    • WebView.RemapForControls();
  • Tests

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@mattleibow
mattleibow force-pushed the dev/fix-mapper-field-ordering branch 2 times, most recently from 4db28df to 5cba950 Compare March 10, 2023 23:27
@PureWeen PureWeen self-assigned this Mar 20, 2023
@ghost

ghost commented Mar 23, 2023

Copy link
Copy Markdown

🚨 API change(s) detected @davidbritch FYI

@mattleibow

Copy link
Copy Markdown
Member Author

/rebase

@github-actions

github-actions Bot commented Apr 6, 2023

Copy link
Copy Markdown
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

1 similar comment
@github-actions

github-actions Bot commented Apr 7, 2023

Copy link
Copy Markdown
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@mattleibow mattleibow added the do-not-merge Don't merge this PR label Apr 14, 2023
@mattleibow
mattleibow marked this pull request as draft April 14, 2023 20:11
@mattleibow
mattleibow marked this pull request as ready for review April 28, 2023 11:23
@mattleibow

This comment was marked as outdated.

@mattleibow
mattleibow force-pushed the dev/fix-mapper-field-ordering branch from a0d35b1 to 405ce17 Compare July 21, 2023 19:37
@mattleibow
mattleibow marked this pull request as ready for review July 21, 2023 19:41

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I kicked off some extra UI Tests here

https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=8126594&view=results

If those don't seem to have any additional fails beyond what we're currently fixing, then I'd say merge.

@jknaudt21 jknaudt21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be great to see doc comments for the new mappers, but I don't want to block a merge because of it.

@mattleibow

mattleibow commented Jul 21, 2023 •

Copy link
Copy Markdown
Member Author

I will start mapper docs here: #16296

Still need to figure out the best way...

🧑‍🤝‍🧑

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some properties not updating (eg VisualState setter not working for Button BackgroundColor) with AOT enabled

4 participants