Skip to content

Generated code doesn't compile if an element is named Content #45

@Guymestef

Description

@Guymestef

Hello,

I've got a naming collision when an element is named Content in the xsd file.

When I generate the model for the following xsd files:
https://www.rixml.org/images/docs/schemas/RIXML-2_5.xsd
https://www.rixml.org/images/docs/schemas/RIXML-Common-2_5.xsd
https://www.rixml.org/images/docs/schemas/RIXML-datatypes-2_5.xsd

With this config file:

<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns="http://www.microsoft.com/xml/schema/linq">
 <CodeGeneration>
   <SplitCodeFiles By="Namespace" />
 </CodeGeneration>
 <Namespaces>
   <Namespace DefaultVisibility="public" Schema="http://www.rixml.org/2017/9/RIXML" Clr="Pretrade.Api.PublicationExport.Services.Features.Attachment.Models.Rixml" />
   <Namespace DefaultVisibility="public" Schema="http://www.rixml.org/2017/9/RIXML-datatypes" Clr="Pretrade.Api.PublicationExport.Services.Features.Attachment.Models.Rixml.DataTypes" />
 </Namespaces>
 <Validation>
   <VerifyRequired>false</VerifyRequired>
 </Validation>
 <Transformation>
   <Deanonymize strict="false" />
 </Transformation>
</Configuration>
        var rixml = new Research
        {
            researchID = "my-id",
            createDateTime = DateTime.UtcNow,
            language = "eng",
            Product = new[]
            {
                new Product
                {
                    Content = new Content
                    {
                        Title = new Title
                        {
                            TypedValue = "My title"
                        }
                    }
                }
            }
        };

The model cannot be used due to the following errors:

  • Ambiguity between 'Product.Content' and 'Product.Content'
  • 'Content' : member names cannot be the same as their enclosing type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions