XSD.EXE - Incorrect Class Generated for Abstract Type With Derived Types - by John Saunders

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


5
0
Sign in
to vote
ID 362727 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 8/20/2008 6:21:21 PM
Access Restriction Public

Description

[MVP reporting on behalf of community member from http://forums.msdn.microsoft.com/en-US/asmxandxml/thread/7e425e82-be1f-4bcf-9513-862ea1ecf487]

A particular set of classes are created by hand. XSD.EXE creates a schema from those classes. It is then asked to create classes from the schema that it created. It generates a property of type string[][] from the schema that it generated itself, instead of generating TheBaseType[].

I was able to reproduce this on VS2008 SP1 Beta 1. The original poster says: "I am using VS2008 (9.0.21022.8 RTM), Team System Development Edition, with .NET 3.5.  The version of XSD given in the generated code is 2.0.50727.1432.  The OS version is Windows XP Professional SP2.  VS has VB 2008, VC# 2008, and VC++ 2008, according to the Help/About... window."
Sign in to post a comment.
Posted by nightst4r on 6/17/2010 at 9:03 AM
Was this bug addressed in vs 2010?
Posted by Ed [MSFT] on 11/3/2008 at 1:49 PM
Sorry for the delay - The work around would be to do something like the following in the generated xsd.

<xs:complexType name="TheBaseType" abstract="true">
    <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="Remarks" type="xs:string" />
    </xs:sequence>
<!-- add this dummy attribute -->
<xs:attribute name="dummy" type="xs:string" />
</xs:complexType>


This will generate an array of TheBaseType as opposed to string[][]

HTH,
Ed

Posted by John Saunders on 10/23/2008 at 7:52 PM
Thanks, Erica. I appreciate you being proactive about this.
Posted by Erica [MSFT] on 10/23/2008 at 7:13 PM
Hi John-

I have reactivated this bug to get more information for you on the workaround.

Sorry for the delay.

Thanks,

Erica Mohler
Microsoft Program Manager
Posted by John Saunders on 10/11/2008 at 6:06 PM
Hi, I haven't heard back, and it's been a week. I'd like to be able to post the workaround on the forum where this originated. I'd also like to know how I should characterize the likelihood of future releases of the XML Serializer.
Posted by Paul Kohler on 10/8/2008 at 5:20 PM
I get a similar issue. We are using XSD.exe version 2.0.50727.1432
(Win 2003 SP2, NETFX3.5, VSTS 2008 etc)
Posted by John Saunders on 10/1/2008 at 11:27 AM
Thank you for following up on this. Can you please provide the details of the workaround so that I can inform the poster or anyone else who comes across this problem?

Also, your comment was the first time I had publicly heard someone from Microsoftt say what I had assumed - that only the most critical bugs in XmlSerializer and xsd.exe were being fixed. Has this been publicly stated before? I've been assuming it was true and directling Community members to WCF accordingly.
Posted by Ed [MSFT] on 10/1/2008 at 10:10 AM
Thanks for finding this. We have investigated the issue and it is a bug. A workaround is to modify the generated schema to trick the code generation logic to not generate the multi-dimensional array. You can do this by adding a dummy attribute to the schema type. Unfortunately, we're only proactively fixing the most critical customer impactful issues in XmlSerializer and xsd.exe. If this issue is causing business impact please contact Microsoft Product Support Services and we will be happy to explore various options.

Ed Pinto
Posted by John Saunders on 8/22/2008 at 2:56 AM
Thank you for your rapid response. I will update the poster.
Posted by Microsoft on 8/22/2008 at 2:32 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team