Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 914 [details]
example of problem
Please see attached screen shot of settings and code.
Basically, when the project is set to link everything in the simulator, the PropertyInfo.CanWrite on a reflected object returns False always.
Code in screenshot from Tweetstation's sqldata class used in my project.
This is normal because:
a) CanWrite returns true only if the property has a 'setter' method;
b) The static analysis of the linker cannot detect the use of reflection that indirectly use a setter (or a getter or invoking...)
c) The linker will eliminate unused setters from properties (it's part of its job);
Workarounds are (in order of preference):
1) Add a [Preserve] attribute on the setter (or of the type with AllMembers=true) so the linker won't eliminate it;
2) Use the setter somewhere inside your code - so the linker will see it's 'used' by the application;
3) Use "--linkskip=XXX" where XXX is the assembly where the setter is located. The linker won't link that specific assembly (but the rest of your application will be linked);
4) Use "--linksdk" (i.e. "Link SDK assemblies only") so that user code won't be linked (and that will include the setter)