Bug 4141 - InvalidCastException while generating classes from XSD
Summary: InvalidCastException while generating classes from XSD
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 2.10.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-28 22:24 UTC by Ramon Rodriguez
Modified: 2013-08-09 04:24 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
XSD files used to reproduce this bug (52.15 KB, application/zip)
2012-03-28 22:24 UTC, Ramon Rodriguez
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Ramon Rodriguez 2012-03-28 22:24:31 UTC
Created attachment 1597 [details]
XSD files used to reproduce this bug

While trying to generate deserialization classes with the xsd.exe tool using an XSD file, an System.InvalidCastException is thrown. The same works under .NET 4.0


The following trace was obtained with --debug=casts turned on


cd $WORKDIR
xsd /c obj_bhaRun.xsd


System.InvalidCastException: Unable to cast object of type 'System.Xml.Schema.XmlSchemaAttributeGroupRef' to type 'System.Xml.Schema.XmlSchemaAttribute'.
  at System.Xml.Serialization.XmlSchemaImporter.CollectAttributeUsesNonOverlap (System.Xml.Schema.XmlSchemaObjectCollection src, System.Xml.Serialization.ClassMap map) [0x00012] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:759 
  at System.Xml.Serialization.XmlSchemaImporter.ImportAttributes (System.Xml.XmlQualifiedName typeQName, System.Xml.Serialization.ClassMap cmap, System.Xml.Schema.XmlSchemaObjectCollection atts, System.Xml.Schema.XmlSchemaAnyAttribute anyat, System.Xml.Serialization.CodeIdentifiers classIds) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:708 
  at System.Xml.Serialization.XmlSchemaImporter.BuildClassMap (System.Xml.Serialization.XmlTypeMapping map, System.Xml.XmlQualifiedName typeQName, System.Xml.Schema.XmlSchemaComplexType stype) [0x0009a] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:698 
  at System.Xml.Serialization.XmlSchemaImporter.BuildPendingMaps () [0x00026] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:657 
  at System.Xml.Serialization.XmlSchemaImporter.ImportTypeCommon (System.Xml.XmlQualifiedName name, System.Xml.XmlQualifiedName qname, System.Xml.Schema.XmlSchemaType stype, Boolean isNullable) [0x000aa] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:487 
  at System.Xml.Serialization.XmlSchemaImporter.ImportTypeMapping (System.Xml.XmlQualifiedName name) [0x0003d] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:453 
  at Mono.Util.Driver.GenerateClasses () [0x002a5] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/tools/mono-xsd/NewMonoXSD.cs:425 
  at Mono.Util.Driver.Run (System.String[] args) [0x0075c] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/tools/mono-xsd/NewMonoXSD.cs:293 
  at Mono.Util.Driver.Main (System.String[] args) [0x00019] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/tools/mono-xsd/NewMonoXSD.cs:79
Comment 1 Atsushi Eno 2013-08-09 04:24:03 UTC
Fixed in git master [d21b0aa].