Of course, in a perfect world, there shouldn't be any runtime difference and let's hope these posts are of transient nature.
This post draws reader's attention to the difference of the runtime behaviour of System.Xml.Serialization.XmlSerializer in Mono and in CLR.
In CLR, if the serializer is presented with a class that has read-only auto-property, the runtime will throw an exception, System.InvalidOperationException, whose origin can be traced to the sgen.exe. However, when the same piece of IL code is executed in Mono (without compilation), there is no exception and in fact Mono would blissfully serialize/deserialize those read-only auto-properties, which is clearly wrong.
This runtime discrepancy only arises only if you use read-only auto-property like this:
[Serializable] public class Sample { public String Name { get; private set; } // .... }
Mono can handle any other forms of read-only property constructs.
No comments:
Post a Comment