<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6127132400597215190.post6744328721714063659..comments</id><updated>2010-04-01T09:40:04.042-07:00</updated><category term='gadgets'/><category term='BlockZombies'/><category term='graphics'/><category term='HLSL'/><category term='XBLIG'/><category term='WP7'/><category term='music'/><category term='XML'/><category term='art'/><category term='game'/><category term='XNA'/><category term='networking'/><category term='Tunescape'/><category term='C#'/><category term='ld48'/><category term='unmanaged'/><category term='audio'/><category term='game design'/><category term='water'/><category term='TV3D'/><category term='wireless'/><category term='terrain'/><category term='Android'/><category term='WPF'/><category term='vista'/><category term='KFF'/><title type='text'>Comments on Nostatic Software Dev Blog: C# Xml List Serialization Behavior</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.nostatic.org/feeds/6744328721714063659/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html'/><author><name>Mike</name><uri>http://www.blogger.com/profile/13599208082890099005</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_1eC00ALSHt4/TQadQYzk0dI/AAAAAAAAFyY/KozsMa89wKA/S220/AvatarRetro2.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-1290236501492726184</id><published>2010-04-01T09:23:04.446-07:00</published><updated>2010-04-01T09:23:04.446-07:00</updated><title type='text'>Hi Mike,

Maybe related to this is the non-intuiti...</title><content type='html'>Hi Mike,&lt;br /&gt;&lt;br /&gt;Maybe related to this is the non-intuitive behaviour of serializing/deserializing List(List(T)). I write round brackets, the post doesn&amp;#39;t seem to accept the angle brackets. If the &amp;quot;inner&amp;quot; List(T) is actually null, it is deserialized as a List(T)-object with Count=0. Which is also not &amp;quot;the correct behavior...&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Bart Donders&lt;br /&gt;the Netherlands</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/1290236501492726184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/1290236501492726184'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1270138984446#c1290236501492726184' title=''/><author><name>Bart</name><uri>http://www.blogger.com/profile/03935717055824902919</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1802948357'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='April 1, 2010 9:23 AM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-4537066183358400925</id><published>2009-10-16T17:41:26.935-07:00</published><updated>2009-10-16T17:41:26.935-07:00</updated><title type='text'>Hey Mike, I stumbled onto your post and thought I&amp;...</title><content type='html'>Hey Mike, I stumbled onto your post and thought I&amp;#39;d shed a little more light on the matter.&lt;br /&gt;&lt;br /&gt;My guess for the cause of this behavior has to do more with the guts of List(Of T); if you look at the list&amp;#39;s Items() collection you&amp;#39;ll see it&amp;#39;s declared as a ReadOnly instance of IList(Of T).&lt;br /&gt;&lt;br /&gt;The fact that it&amp;#39;s ReadOnly says that it&amp;#39;s not compatible with serialization, which works against public properties.&lt;br /&gt;&lt;br /&gt;Then again, it&amp;#39;s nothing I would have expected either--but at least it looks like there&amp;#39;s a reason for the behavior.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/4537066183358400925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/4537066183358400925'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1255740086935#c4537066183358400925' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1555272146'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='October 16, 2009 5:41 PM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-231732371894641014</id><published>2009-02-19T14:57:00.000-08:00</published><updated>2009-02-19T14:57:00.000-08:00</updated><title type='text'>Hi Pete - I understand "why" it happens, and that ...</title><content type='html'>Hi Pete - I understand "why" it happens, and that it is not too difficult to work around, I just don't think it is the correct behavior. Default initialization of properties just should not interact with serialization in this manner.&lt;BR/&gt;&lt;BR/&gt;It would be easy for Microsoft to fix. I've since rolled my own Xml serializer to work around this, and other issues/limitations with the way that .NET serialization works (the biggest one being the inability to serialize interfaces).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/231732371894641014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/231732371894641014'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1235084220000#c231732371894641014' title=''/><author><name>Mike</name><uri>http://www.blogger.com/profile/13599208082890099005</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp1.blogger.com/_1eC00ALSHt4/R1XswmXcsLI/AAAAAAAABDE/IbHIhFnBzws/S220/menu-small.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1411135018'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='February 19, 2009 2:57 PM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-7268990725197422803</id><published>2009-02-19T11:39:00.000-08:00</published><updated>2009-02-19T11:39:00.000-08:00</updated><title type='text'>//&lt;br&gt;// Only a proof of concept.&lt;br&gt;//&lt;br&gt;&lt;br&gt;sta...</title><content type='html'>//&lt;BR/&gt;// Only a proof of concept.&lt;BR/&gt;//&lt;BR/&gt;&lt;BR/&gt;static void Main(string[] args)&lt;BR/&gt;{&lt;BR/&gt;    XmlTest xmlTest = new XmlTest();&lt;BR/&gt;    xmlTest.setList();&lt;BR/&gt;&lt;BR/&gt;    // Outputs 3&lt;BR/&gt;    Console.WriteLine(xmlTest.IntegerList.Count);&lt;BR/&gt;&lt;BR/&gt;    TextWriter writer = new StreamWriter(&amp;quot;test.xml&amp;quot;);&lt;BR/&gt;    XmlSerializer serializer = new XmlSerializer(typeof(XmlTest));&lt;BR/&gt;    serializer.Serialize(writer, xmlTest);&lt;BR/&gt;    writer.Close();&lt;BR/&gt;&lt;BR/&gt;    FileStream fs = new FileStream(&amp;quot;test.xml&amp;quot;, FileMode.Open);&lt;BR/&gt;    XmlReader reader = new XmlTextReader(fs);&lt;BR/&gt;    xmlTest = (XmlTest)serializer.Deserialize(reader);&lt;BR/&gt;    fs.Close();&lt;BR/&gt;&lt;BR/&gt;    // Outputs 3&lt;BR/&gt;    Console.WriteLine(xmlTest.IntegerList.Count);&lt;BR/&gt;    Console.ReadKey();&lt;BR/&gt;}&lt;BR/&gt;&lt;BR/&gt;[Serializable]&lt;BR/&gt;public class XmlTest&lt;BR/&gt;{&lt;BR/&gt;    public void setList(){ integerList = new List&amp;lt; int &amp;gt; { 1, 2, 3 };}&lt;BR/&gt;&lt;BR/&gt;    private List&amp;lt; int &amp;gt; integerList = null;&lt;BR/&gt;&lt;BR/&gt;    public List&amp;lt; int &amp;gt; IntegerList&lt;BR/&gt;    {&lt;BR/&gt;        get { return integerList; }&lt;BR/&gt;        set { integerList = value; }&lt;BR/&gt;    }&lt;BR/&gt;}</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/7268990725197422803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/7268990725197422803'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1235072340000#c7268990725197422803' title=''/><author><name>Pete</name><uri>http://www.blogger.com/profile/04491650742282324106</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1707898520'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='February 19, 2009 11:39 AM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-4264684333097484898</id><published>2009-02-19T11:36:00.000-08:00</published><updated>2009-02-19T11:36:00.000-08:00</updated><title type='text'>Mike,&lt;br&gt;&lt;br&gt;The reason for the discrepancy is as ...</title><content type='html'>Mike,&lt;BR/&gt;&lt;BR/&gt;The reason for the discrepancy is as follows.  Have a look at the integerList instance field;  this is &amp;#39;populated&amp;#39; upon instantiation.  Your example then serializes to a .xml file (in this case test.xml) -- so far so good.  Just before de-serialization {1,2,3} is already in the list because you&amp;#39;ve just used the &amp;quot;new&amp;quot; modifier.  De-serialization occurs, and you&amp;#39;re left with {1,2,3,1,2,3}.  &lt;BR/&gt;&lt;BR/&gt;Add something like: &lt;BR/&gt;&lt;BR/&gt;public void setList(){ integerList = new List&amp;lt; int &amp;gt; { 1, 2, 3 };} &lt;BR/&gt;&lt;BR/&gt;to the XMLTest class; call it just before you do your serialize.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/4264684333097484898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/4264684333097484898'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1235072160000#c4264684333097484898' title=''/><author><name>Pete</name><uri>http://www.blogger.com/profile/04491650742282324106</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1707898520'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='February 19, 2009 11:36 AM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-8138231109859317006</id><published>2007-12-05T13:16:00.000-08:00</published><updated>2007-12-05T13:16:00.000-08:00</updated><title type='text'>Yeah, I'm usually too lazy to do that, though. Esp...</title><content type='html'>Yeah, I'm usually too lazy to do that, though. Especially when I have lots of relatively simple objects.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/8138231109859317006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/8138231109859317006'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1196889360000#c8138231109859317006' title=''/><author><name>Mike</name><uri>http://www.blogger.com/profile/13599208082890099005</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://bp1.blogger.com/_1eC00ALSHt4/R1XswmXcsLI/AAAAAAAABDE/IbHIhFnBzws/S220/menu-small.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1411135018'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='December 5, 2007 1:16 PM'/></entry><entry><id>tag:blogger.com,1999:blog-6127132400597215190.post-3402867527272848681</id><published>2007-12-03T16:04:00.000-08:00</published><updated>2007-12-03T16:04:00.000-08:00</updated><title type='text'>Generally the XMLSerializer likes to deal with fie...</title><content type='html'>Generally the XMLSerializer likes to deal with fields. I generally create pure data objects that I use for my serialization and facade those with the actual access objects. That means I also can control the public interface of my objects, since XMLSerialization insists on having everything public (unlike the binary formatter).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/3402867527272848681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6127132400597215190/6744328721714063659/comments/default/3402867527272848681'/><link rel='alternate' type='text/html' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html?showComment=1196726640000#c3402867527272848681' title=''/><author><name>ether</name><uri>http://www.blogger.com/profile/16911611449176929088</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.nostatic.org/2007/12/c-xml-list-serialization-behavior.html' ref='tag:blogger.com,1999:blog-6127132400597215190.post-6744328721714063659' source='http://www.blogger.com/feeds/6127132400597215190/posts/default/6744328721714063659' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-487124314'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.displayTime' value='December 3, 2007 4:04 PM'/></entry></feed>
