Xsd2Code - V30 and V3.4

Feb 3, 2011 at 9:28 PM

HI guys,

Quick question. I just started playing around with Xsd2Code... I D/L'd a version last nov., I believe it's v.30 (at least that's what it says when I try to reinstall the exe... I can't find a version number anywhere)... So, this version will generate a C# class, with minimal serialization attributes... Such that I can share that one generated file between a native c# project and a silverlight project and all works nicely. With 3.4, this seems to be lost. Extra serialization Elements are generated that are not supported in silverlight.. was this added? Is there a way to have it not add those 2 extra attributes? The two being added that where never added before are:

   [System.SerializableAttribute()]
   [System.ComponentModel.DesignerCategoryAttribute("code")]

 

How things use to be generated was like so (without those 2 extra attributes):

 

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]

 

Thanks for any info!!

Ken

Feb 3, 2011 at 11:00 PM

Hi there,

Looking at the source code, I believe the change might have been around this bug: http://xsd2code.codeplex.com/workitem/11761

 

So what happened originally, when GenerateXmlAttributes was selected, the .NET version was 2.0, the two added elements that exist now (which are invalid for Silverlight) where properly removed:

[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]

 

The rest of the XML attributes added where global between a native C# library and the Silverlight library. This allows for a simple class generation that can be linked to both types of projects (native and silverlight). The generated Serialize/DeSerialze implementations work great out of the box as well, no changes needed to be made.

Feb 3, 2011 at 11:11 PM
Edited Feb 3, 2011 at 11:15 PM

Actually, as I'm figuring out how to use the code compare here... that doesn't seem to be the area (close), it must be in the initial generation of the C# class where these attributes are now being added...Hmmm... what would be an even nicer addition is adding a list box (just thinking quickly here) to the XSD configuration window that would bring up all the XML attributes that would be added for the generation of that C# from the XSD... The user can then select the one's they want to keep and discard... The RemoveDefaultXmlAttributes (perhaps a new name) will always be called and remove all items not selected or add the one's selected if they are missing...