Bug 1520 - On device, Size/SizeF/Rectangle/RectangeF and possibly others do not de-serialize properly when SDK libraries are linked
Summary: On device, Size/SizeF/Rectangle/RectangeF and possibly others do not de-seria...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-10-16 15:25 UTC by t9mike
Modified: 2011-10-17 19:05 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Solution (5.50 KB, application/x-gzip)
2011-10-16 15:25 UTC, t9mike
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description t9mike 2011-10-16 15:25:25 UTC
Created attachment 705 [details]
Sample Solution

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.
Comment 1 Sebastien Pouliot 2011-10-16 20:38:24 UTC
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!
Comment 2 Sebastien Pouliot 2011-10-17 09:52:49 UTC
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.
Comment 3 Sebastien Pouliot 2011-10-17 15:54:57 UTC
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).
Comment 4 Sebastien Pouliot 2011-10-17 19:05:56 UTC
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!

ref: 41806c4e58730d7150e97f219e7ad9ffc91fc55f