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 705 [details]
Greetings and please see attached code for example.
Size, SizeF, Rectangle, and RectangeF (and possibly others) members de-serialize to 0 value when run on device if SDK assemblies are linked. When run on simulator, they de-serialize fine. In the example, a project-level struct de-serializes fine, perhaps because I am not linking app.
I did not test serializing these on device: the sample data.xml file was created on simulator.
I did not experiment whether this is a generic struct issue.
I'll have a look asap, since I'm working in enhancing the linker support for xml serialization and data contracts (bug #1415).
Huge thanks for attaching a test case to the report!
Confirmed. There's a serialization issue when the linker is used - but it's something indirect. i.e. the linker does not eliminate the private fields, nor does it removes the the [Serializable] attributes on those types.
Oops, my bad, you're using XML serialization :-| So the linker removes the setter (as it's not _directly_ used) which makes the properties not available for xml serialization.
I'll try to hack around that by using the properties internally (instead of the fields) so the linker will consider them "in use".
p.s. Note that Rectangle[F] are not very XML serialization friendly since it will serialize several times the same values (as Point[F], Size[F] and floats).
Automatic properties solved the issue - sadly it cannot guarantee the order of fields and that's important since the structs are also used by unmanaged code (so the memory representation is important).
Anyway I kept the fields + ctor changes to use the properties. That should be enough to ensure they don't get linked away (and works perfectly with your test case).
Thanks a lot for the report + test case!