uno.extensions icon indicating copy to clipboard operation
uno.extensions copied to clipboard

[MVUX / Navigation] Update ViewModelMappings

Open dr1rrb opened this issue 2 years ago • 4 comments

What would you like to be added:

Improve the way ViewModelMappings is being generated.

Why is this needed:

  1. We are generating them in the "assembly name" namespace,
    • This can be confusing
    • When generating it from the head project, it forces user to use #pragma code
  2. There is no way to easily merge mappings from multiple projects
  3. Users have to explicitly reference generated code

Proposed solution

Following the KeyPropety generator, we can generate some internal types that will register mappings to a static registry using [ModuleInitializer] attribute.

For which Platform:

  • [x] iOS
  • [x] Android
  • [x] WebAssembly
  • [x] WebAssembly renders for Xamarin.Forms
  • [x] Windows
  • [ ] Build tasks

dr1rrb avatar Nov 17 '22 16:11 dr1rrb

@dr1rrb is work still required on this?

nickrandolph avatar Nov 10 '23 13:11 nickrandolph

Question: will this issue fix also resolve below (found today in latest stable Uno 5 with Uno.Extensions.* 3.0.11)?

Page datacontext is set to TModel instead of bindable viewmodel after NavigateViewModelAsync<TModel>() when TModel is not defined in the same assembly as where it was registered in views/routes

Workaround: register bindable model instead of model in app views and routes (as indicated in point 3 in the issue description)

If not, I will register a separate issue

VincentH-Net avatar Nov 22 '23 08:11 VincentH-Net

Hey @VincentH-Net, yes the issue you have refers to the point 2 (which leads you to point 3 :) ).

And yes @nickrandolph the issue is still relevant :)

dr1rrb avatar Nov 22 '23 14:11 dr1rrb

@dr1rrb, @nickrandolph I imagine this issue is still relevant?

agneszitte avatar May 24 '24 15:05 agneszitte