MvvmCross icon indicating copy to clipboard operation
MvvmCross copied to clipboard

LinkerPleaseInclude should move to using the new DynamicDependency

Open DavidMarquezF opened this issue 1 year ago • 2 comments

Description

LinkerPleaseInclude has proven necessary in order to link apps without runtime issues. However, the current suggested way of doing is by including the LinkerPleaseInclude class which has the attribute Preserve. This attribute is marked as deprecated and will stop working at some point, which will cause a lot of MvvmCross apps to crash with release mode at runtime.

Here I see two options (correct me if I'm wrong):

  1. Use the new trimmer configurations to preserve the whole LinkerPleaseInclude classe (see this)
  2. Check if now there are better ways to avoid this to happen (I know this issue comes from the linker not playing well with reflection if I'm not mistaken). Maybe it's unrelated, but it seems like one of the maintainers from MVVM Toolkit already battled with this

Intended Use-Case

Avoid runtime crashes for trimmed MvvmCross apps in the future

DavidMarquezF avatar Aug 01 '24 08:08 DavidMarquezF

Yeah, I've tried that already. Most of MvvmCross core will have to be marked as referencing external assemblies. I.e. it is not linker safe.

Mainly because of the built in IoC container. Also for bindings lots of reflection use.

So easier said than done and a ton of work.

Cheesebaron avatar Aug 01 '24 16:08 Cheesebaron

Would the new changes you're trying to do with regards to moving to the Microsoft IoC already remove a lot of possible issues?

If so, then I guess that to fix the binding reflection issues it would be possible to go binding by binding and adding the DynamicDependency attribute and defining the members that will be used in the binding?

I agree it's a ton of work, but just figuring out if this would be the approach in case we wanted to fix it

DavidMarquezF avatar Aug 02 '24 15:08 DavidMarquezF