Skip to content

Generic complexType generated when generating XML Schema #119855

@davidmullin

Description

@davidmullin

Description

When generating WSDL (using CoreWCF), if my class structure is sufficiently complex, the schema generator apparently gives up and generates a complextType entry like:

<xs:complexType name="MyClassOf_x007B_0_x007D__x007B__x0023__x007D_">

This is in addition to entries for MyClassOfString and MyClassOfInt. If my class contains a generic property, then it errors when generating the properties (not surprising, since the generic type is "x007B_0_x007D__x007B__x0023__x007D").

Simplified version of my class:

[DataContract]
public class MyClass<T> : BaseClass
{
	[DataMember]
	public T Value { get; set;}
}

I have tried with both the current version of CoreWCF (1.8.0), and an older version (1.5.1) to no effect. However, if I try it with .Net 8 (and CoreWCF 1.5.1) it does not do this.

Full call stack of the exception at the end.

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: CoreWCF.Description.DataContractSerializerOperationBehavior\r\n contract: http://tempuri.org/:IClientModelService
----> System.Xml.Schema.XmlSchemaException: Invalid 'type' attribute: 'Name cannot begin with the '{' character, hexadecimal value 0x7B.'.
----> System.Xml.XmlException: Name cannot begin with the '{' character, hexadecimal value 0x7B.
at System.Xml.XmlConvert.VerifyNCName(String name, ExceptionType exceptionType)
at System.Xml.XmlQualifiedName.Verify()
at System.Xml.Schema.Preprocessor.ValidateQNameAttribute(XmlSchemaObject xso, String attributeName, XmlQualifiedName value)
--- End of inner ExceptionDetail stack trace ---
at System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
at System.Xml.Schema.Preprocessor.ValidateQNameAttribute(XmlSchemaObject xso, String attributeName, XmlQualifiedName value)
at System.Xml.Schema.Preprocessor.PreprocessElementContent(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessLocalElement(XmlSchemaElement element)
at System.Xml.Schema.Preprocessor.PreprocessParticle(XmlSchemaParticle particle)
at System.Xml.Schema.Preprocessor.PreprocessComplexType(XmlSchemaComplexType complexType, Boolean local)
at System.Xml.Schema.Preprocessor.Preprocess(XmlSchema schema, String targetNamespace, ArrayList imports)
at System.Xml.Schema.Preprocessor.Execute(XmlSchema schema, String targetNamespace, Boolean loadExternals)
at System.Xml.Schema.XmlSchemaSet.PreprocessSchema(XmlSchema& schema, String targetNamespace)
at System.Xml.Schema.XmlSchemaSet.Reprocess(XmlSchema schema)
at CoreWCF.Description.MessageContractExporter.Compile()
at CoreWCF.Description.DataContractSerializerMessageContractExporter.Compile()
at CoreWCF.Description.MessageContractExporter.ExportMessage(Int32 messageIndex, Object state)
at CoreWCF.Description.MessageContractExporter.ExportMessageContract()
at CoreWCF.Description.DataContractSerializerOperationBehavior.CoreWCF.Description.IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext)
at CoreWCF.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
--- End of inner ExceptionDetail stack trace ---
at CoreWCF.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
at CoreWCF.Description.WsdlExporter.CallExportContract(WsdlContractConversionContext contractContext)
at CoreWCF.Description.WsdlExporter.ExportContract(ContractDescription contract)
at CoreWCF.Description.WsdlExporter.ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, BindingParameterCollection bindingParameters)
at CoreWCF.Description.WsdlExporter.ExportEndpoints(IEnumerable`1 endpoints, XmlQualifiedName wsdlServiceQName, BindingParameterCollection bindingParameters)
at CoreWCF.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
at CoreWCF.Description.ServiceMetadataExtension.EnsureInitialized()
at CoreWCF.Description.ServiceMetadataExtension.get_Metadata()
at CoreWCF.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
at CoreWCF.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
at CoreWCF.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequestAsync(HttpContext requestContext)
at CoreWCF.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(HttpContext requestContext)
at CoreWCF.Description.ServiceMetadataExtension.HttpGetImpl.HandleRequest(HttpContext httpContext)

Reproduction Steps

I tried to produce a simple repro, but apparently it requires that the class hierarchy be sufficiently complex in order for it to go down this path. My simple repro generated MyClassOfString and MyClassOfInt, but not MyClassOf_x007B_0_x007D__x007B__x0023__x007D_

Expected behavior

I expect it to be able to generate the XML Schema without rendering a generic complexType

Actual behavior

Generates a generic complexType and, if that type contains a generic property, it raises an exception.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Xmlneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions