mamift / LinqToXsdCore

LinqToXsd ported to .NET Core (targets .NET Standard 2 for generated code and .NET Core 3.1, .NET 5+ for the code generator CLI tool).
Microsoft Public License
41 stars 15 forks source link

Wrong generated code for union property. #10

Closed rvuistin closed 4 years ago

rvuistin commented 4 years ago

You can reproduce the problem with the NoVoidTypeOfExpressionsInGeneratedCodeEver test and the Schemas\XSD\W3C XMLSchema v1.xsd schema.

Generated code: return XTypedServices.ParseUnionValue(x, void.TypeDefinition); instead of: return XTypedServices.ParseUnionValue(x, null);

Happens in CreateFieldReference when typeName is an empty string instead of a null value:

    XObjectsCore.dll!Xml.Schema.Linq.CodeGen.CodeDomHelper.CreateFieldReference(string typeName, string fieldName) Line 465 C#
    XObjectsCore.dll!Xml.Schema.Linq.CodeGen.ClrPropertyInfo.GetSimpleTypeClassExpression() Line 1251   C#
>   XObjectsCore.dll!Xml.Schema.Linq.CodeGen.ClrPropertyInfo.AddGetStatements(System.CodeDom.CodeStatementCollection getStatements) Line 1020   C#
    XObjectsCore.dll!Xml.Schema.Linq.CodeGen.ClrPropertyInfo.AddToType(System.CodeDom.CodeTypeDeclaration parentTypeDecl, System.Collections.Generic.List<Xml.Schema.Linq.CodeGen.ClrAnnotation> annotations, Xml.Schema.Linq.GeneratedTypesVisibility visibility) Line 674 C#
    XObjectsCore.dll!Xml.Schema.Linq.CodeGen.TypePropertyBuilder.GenerateCode(Xml.Schema.Linq.CodeGen.ClrBasePropertyInfo property, System.Collections.Generic.List<Xml.Schema.Linq.CodeGen.ClrAnnotation> annotations) Line 30 C#
    XObjectsCore.dll!Xml.Schema.Linq.CodeGen.XTypedElementBuilder.CreateAttributeProperty(Xml.Schema.Linq.CodeGen.ClrBasePropertyInfo propertyInfo, System.Collections.Generic.List<Xml.Schema.Linq.CodeGen.ClrAnnotation> annotations) Line 782    C#
mamift commented 4 years ago

Hello, thanks for reporting this. It is now fixed in https://github.com/mamift/LinqToXsdCore/commit/0cfb38ff7e654f1919cc22f27715e3ceb23accb8.