In MvvmCross library there is a class Playground.Droid.LinkerPleaseInclude.cs https://github.com/MvvmCross/MvvmCross/blob/develop/ContentFiles/Android/LinkerPleaseInclude.cs
At line 103 there is a method:
public void Include(MvxTaskBasedBindingContext context)
{
context.Dispose();
var context2 = new MvxTaskBasedBindingContext();
context2.Dispose();
}
Inside this method it is created an instance of MvxTaskBasedBindingContext class and then immediately it is disposed. Question: Why it is necessary here to create this instance and after to dispose it?
The LinkerPleaseInclude.cs is a concept used to prevent Mono's linker from stripping these types from your application. You can read more about this here:
https://github.com/mono/linker/blob/master/src/linker/README.md
What the code you're seeing does prevents these types from being marked and swept by the linker so they are "included" in your application even after the linker strips IL code.
It uses static analysis of your application to determine what assemblies, types, and members are used. If it does not detect these items to be valid, they are marked and swept.
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With