All kinds of syntax errors, bad auto-properties, multiple base classes

Sep 28, 2010 at 6:58 PM

I had high hopes for this tool but I'm getting all kinds of problems with it when I attempt to use it on a relatively complex schema.

First off, the Beta 3 version doesn't work with Visual Studio 2008, so I can't use the latest version.

When I generate with Automatic Properties, Generate XML Attributes, and UseGenericBaseClass set to true (targetting .Net 3.5), here's a summary of the issues I get:

All kinds of badly formed attributes, like this:

[System.Xml.Serialization.XmlElementAttribute("CueResourceReference"typeof(string)Form=System.Xml.Schema.XmlSchemaForm.UnqualifiedDataType="IDREF")]

 

Notice the space missing between "CueResourceReference" and typeof.  Additionally, there is a comma and a space missing between Unqualified and DataType=.  Also, I get a bunch of properties that are *not* generated as auto-properties, but no backing field is generated for them either, so that creates a number of compiler errors:

    [System.Xml.Serialization.XmlTextAttribute()]
    public ReleaseRelationshipType Value {get; set;}

        
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string UserDefinedValue {
            get {
                return this.userDefinedValueField;
            }
            set {
                this.userDefinedValueField = value;
            }
        }
    }

This should of course be an auto property.

If I fix all the above errors, I end up with problems with the code because it's attempting to do multiple inheritance, things like

public partial class ReleaseDetailsByTerritory : ReleaseSummaryDetailsByTerritory, EntityBase<ReleaseDetailsByTerritory>


If I turn off UseGenericBaseClass, that particular problem goes away, but the generated code is four times as large.  However, it still doesn't work for me once all the generated code is cleaned up, since just trying to create an XmlSerializer with one of the types makes it throw an exception, saying that certain properties can't be serialized.

Hopefully some upcoming release fixes all of these problems, as it would certainly be nice to deal with lists instead of the array garbage that XSD.exe generates, however in the meantime I'll have to stick to using xsd.exe.

Coordinator
Sep 28, 2010 at 7:30 PM
Hi,
First thank you for your feedback.
I don't know at this time why version 3.3 beta 3 doesn't work with vs2008.
But all your problems are fixed in the last release.
I'll try to find a quick solution to this problem of compatibility with Visual Studio 2010.
Pascal.

2010/9/28 wompeter <notifications@codeplex.com>

From: wompeter

I had high hopes for this tool but I'm getting all kinds of problems with it when I attempt to use it on a relatively complex schema.

First off, the Beta 3 version doesn't work with Visual Studio 2008, so I can't use the latest version.

When I generate with Automatic Properties, Generate XML Attributes, and UseGenericBaseClass set to true (targetting .Net 3.5), here's a summary of the issues I get:

All kinds of badly formed attributes, like this:

[System.Xml.Serialization.XmlElementAttribute("CueResourceReference"typeof(string)Form=System.Xml.Schema.XmlSchemaForm.UnqualifiedDataType="IDREF")]

 

Notice the space missing between "CueResourceReference" and typeof.  Additionally, there is a comma and a space missing between Unqualified and DataType=.  Also, I get a bunch of properties that are *not* generated as auto-properties, but no backing field is generated for them either, so that creates a number of compiler errors:

    [System.Xml.Serialization.XmlTextAttribute()]
    public ReleaseRelationshipType Value {get; set;}

        
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string UserDefinedValue {
            get {
                return this.userDefinedValueField;
            }
            set {
                this.userDefinedValueField = value;
            }
        }
    }

This should of course be an auto property.

If I fix all the above errors, I end up with problems with the code because it's attempting to do multiple inheritance, things like

public partial class ReleaseDetailsByTerritory : ReleaseSummaryDetailsByTerritory, EntityBase<ReleaseDetailsByTerritory>


If I turn off UseGenericBaseClass, that particular problem goes away, but the generated code is four times as large.  However, it still doesn't work for me once all the generated code is cleaned up, since just trying to create an XmlSerializer with one of the types makes it throw an exception, saying that certain properties can't be serialized.

Hopefully some upcoming release fixes all of these problems, as it would certainly be nice to deal with lists instead of the array garbage that XSD.exe generates, however in the meantime I'll have to stick to using xsd.exe.

Read the full discussion online.

To add a post to this discussion, reply to this email (Xsd2Code@discussions.codeplex.com)

To start a new discussion for this project, email Xsd2Code@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Coordinator
Sep 28, 2010 at 8:02 PM

I really don't understand the problem with vs2008. I tried it on a VM machine running Windows XP SP2 with VS2008 installed and I had no problem to run the version 3.3 beta 3!

I need help to find this bug !

Sep 28, 2010 at 9:19 PM

Hi pcabanel - thanks for the response - that's great to hear that those bugs are fixed already!

I've tracked down the exact sequence of steps to reproduce the issue with VS2008.

First, I had installed version 3.2 for VS 2008, thinking that I didn't want to use a beta version.  Then when I ran into the bugs, I installed the beta version right over top of 3.2, without removing 3.2 first.

In both installers I chose to install for all users.

 

If you follow that sequence of steps, when you attempt to use the context menu item to run Xsd2Code, you get a popup warning saying "The Add-in supporting this command could not be loaded.  Do you wish to remove the command?  If you choose yes, you can re-create the cmmand by reinstalling the Add-in".

I also noticed that there are now two versions of Xsd2Code in "Add/Remove Programs" after that.  Uninstalling 3.3 makes it impossible to uninstall 3.2 without re-running the installer and repairing the 3.2 installation first.

 

However, good news - I tried doing a clean install of 3.3 beta 3 after removing everything first, and it seems to work!  So the "fix" is just to make sure that you uninstall 3.2 first ....  I'll try it out now to see if I can go forward with it.

Thanks!

 

 

Sep 28, 2010 at 9:48 PM

I've just tried using it, and it looks like the attribute syntax and multiple inheritance problems have been dealt with.

However I'm still getting over 100 errors with auto-properties not being generated properly.  It looks like it's always the very last property in the class code that has the problem.  It's being generated as a full property instead of an auto-property, and there is no backing field for it.

 

Sep 28, 2010 at 11:11 PM

I turned Auto-properties off, and I tried again.  I ran into problems with the base class inheritance, with the message

There was an error reflecting type '[type name]'. ---> System.InvalidOperationException: Cannot serialize object of type '[type name]'.  Please consider changing XmlText member of the base class to string array.

So I turned off the base classes... and now I'm running into the top-voted issue, detailed here: http://xsd2code.codeplex.com/workitem/9877.

So I changed the collection type to Array... and now I'm back to the same code that Xsd.exe generates!   :D