By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

Question about C# classes generated from a .xsd via xsd.exe in VS 2003

P: n/a
I have a schema that has been in existence over 1 year. I have been making a few minor modifications to it recently and suddenly
the generated C# classes have made a radical change.

I have just compared the xsd source to the last compiled version on 8/25/06 and they are identical, yet the generated C# is
different. I do not know enough about XSD and schemas to understand how the original output was generated, but I need to get it
back.

I am showing an excerpt from the schema and the old and new generated C# class.

<xs:complexType name="ListenerItem">
<xs:sequence>
<xs:choice id="HostFormat">
<xs:element name="HostName" type="mstns:FullyQualifiedNameType" />
<xs:element name="HostAddress" type="mstns:IPAddressTypeV4" />
<xs:element name="Any" type="xs:string" />
</xs:choice>
<xs:element ref="mstns:ClientType" />
<xs:element name="HostPort" type="mstns:PortNumberType" />
<xs:element name="NumThreads" type="xs:unsignedInt" />
<xs:element name="InitialState" type="mstns:ListenerState" />
<xs:element name="Name" type="xs:string" nillable="false"></xs:element>
<xs:element name="AllowGenericStation" type="xs:boolean" nillable="false" default="false"></xs:element>
<xs:element name="AllowClientSuppliedStation" type="xs:boolean" nillable="false" default="false" />
<xs:element name="AllowHostLookup" type="xs:boolean" nillable="false" default="false" />
<xs:element name="ClientVersion" type="mstns:ClientVersion" />
<xs:element name="EncryptionRequirements" type="mstns:EncryptionEnum" />
<xs:element name="AuthenicationRequirementsRequired" type="mstns:AuthenicationEnum" />
<xs:element name="AuthenicationRequirementsAllowed" type="mstns:AuthenicationEnum" />
<xs:element name="KeepAliveInterval" type="xs:unsignedInt" default="5" />
<xs:element name="KeepAliveUnits" type="KeepAliveUnitsType" default="Minutes" />
</xs:sequence>
</xs:complexType>

OLD C# Code
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/XMLSchema.xsd")]
public class ListenerItem {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Host Address", typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Any" , typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Host Name", typeof(string))]
[System.Xml.Serialization.XmlChoiceIdentifierAttrib ute("ItemElementName")]
public string Item;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public AddressTypeChoiceWithAny ItemElementName; <------------ see this line below

/// <remarks/>
public ClientType ClientType;
.......

NEW C# Code
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/XMLSchema.xsd")]
public class ListenerItem {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Host Address", typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Any" , typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Host Name", typeof(string))]
[System.Xml.Serialization.XmlChoiceIdentifierAttrib ute("ItemElementName")]
public string Item;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public ItemChoiceType1 ItemElementName; <-------------- See type changed

/// <remarks/>
public ClientType ClientType;
.......

I would expect that most of you would say that I am crazy or that I have not been generating from the xsd that I though that I
had, but I have gone back in VSS for over the past year and that part of the schema has not changed and the generated C# has not
changed until today.

Could someone please tell me what to put into the schema to turn ItemChoiceType1 back to AddressTypeChoiceWithAny?

Thanks
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com
Sep 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Roy Chastain" <ro*@kmsys.comwrote in message
news:39********************************@4ax.com...
>I have a schema that has been in existence over 1 year. I have been making
a few minor modifications to it recently and suddenly
the generated C# classes have made a radical change.
...
I would expect that most of you would say that I am crazy or that I have
not been generating from the xsd that I though that I
had, but I have gone back in VSS for over the past year and that part of
the schema has not changed and the generated C# has not
changed until today.
I see that you already know the answer to the question. Now, all you have to
do is believe it and figure out how it happened.

Either:

1) If you don't change anything, but something changes anyway, then it's
because something changed, possibly because you changed it.
2) If you change something, but the outputs don't change, then either you
didn't change it, or you're looking at the wrong outputs.

But you already know this, you just prefer to think that something magical
happened instead. It didn't. Get that clear in your mind, and you can begin
to solve the real problem.

John

"Once you have elimintated the impossible, that which remains, no matter how
unlikely, is the truth.", S. Holmes
Sep 12 '06 #2

P: n/a
Hi Roy,

The xsd.exe analyzes the whole schema and generates the class. A small
change may result in a big change as John mentioned. Do you have any
concern on the change of the generated class? If so, maybe we can find a
workaround for that.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Sep 13 '06 #3

P: n/a
Even though you havent changed the schema, did you upgrade your framework
from .NET 1.0/1.1 to .NET 2.0?

Thanks,
Priya

"Roy Chastain" <ro*@kmsys.comwrote in message
news:39********************************@4ax.com...
>I have a schema that has been in existence over 1 year. I have been making
a few minor modifications to it recently and suddenly
the generated C# classes have made a radical change.

I have just compared the xsd source to the last compiled version on
8/25/06 and they are identical, yet the generated C# is
different. I do not know enough about XSD and schemas to understand how
the original output was generated, but I need to get it
back.

I am showing an excerpt from the schema and the old and new generated C#
class.

<xs:complexType name="ListenerItem">
<xs:sequence>
<xs:choice id="HostFormat">
<xs:element name="HostName" type="mstns:FullyQualifiedNameType" />
<xs:element name="HostAddress" type="mstns:IPAddressTypeV4" />
<xs:element name="Any" type="xs:string" />
</xs:choice>
<xs:element ref="mstns:ClientType" />
<xs:element name="HostPort" type="mstns:PortNumberType" />
<xs:element name="NumThreads" type="xs:unsignedInt" />
<xs:element name="InitialState" type="mstns:ListenerState" />
<xs:element name="Name" type="xs:string" nillable="false"></xs:element>
<xs:element name="AllowGenericStation" type="xs:boolean" nillable="false"
default="false"></xs:element>
<xs:element name="AllowClientSuppliedStation" type="xs:boolean"
nillable="false" default="false" />
<xs:element name="AllowHostLookup" type="xs:boolean" nillable="false"
default="false" />
<xs:element name="ClientVersion" type="mstns:ClientVersion" />
<xs:element name="EncryptionRequirements" type="mstns:EncryptionEnum" />
<xs:element name="AuthenicationRequirementsRequired"
type="mstns:AuthenicationEnum" />
<xs:element name="AuthenicationRequirementsAllowed"
type="mstns:AuthenicationEnum" />
<xs:element name="KeepAliveInterval" type="xs:unsignedInt" default="5" />
<xs:element name="KeepAliveUnits" type="KeepAliveUnitsType"
default="Minutes" />
</xs:sequence>
</xs:complexType>

OLD C# Code

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/XMLSchema.xsd")]
public class ListenerItem {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Host Address",
typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Any" ,
typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Host Name",
typeof(string))]

[System.Xml.Serialization.XmlChoiceIdentifierAttrib ute("ItemElementName")]
public string Item;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public AddressTypeChoiceWithAny ItemElementName; <------------ see
this line below

/// <remarks/>
public ClientType ClientType;
......

NEW C# Code

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/XMLSchema.xsd")]
public class ListenerItem {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Host Address",
typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Any" ,
typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("Host Name",
typeof(string))]

[System.Xml.Serialization.XmlChoiceIdentifierAttrib ute("ItemElementName")]
public string Item;

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public ItemChoiceType1 ItemElementName; <-------------- See type
changed

/// <remarks/>
public ClientType ClientType;
......

I would expect that most of you would say that I am crazy or that I have
not been generating from the xsd that I though that I
had, but I have gone back in VSS for over the past year and that part of
the schema has not changed and the generated C# has not
changed until today.

Could someone please tell me what to put into the schema to turn
ItemChoiceType1 back to AddressTypeChoiceWithAny?

Thanks
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
http://www.kmsys.com

Sep 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.