Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate name between class and namespace. #529

Open
devl-up opened this issue Sep 13, 2024 · 1 comment
Open

Duplicate name between class and namespace. #529

devl-up opened this issue Sep 13, 2024 · 1 comment

Comments

@devl-up
Copy link

devl-up commented Sep 13, 2024

When generating the hierarchy of my XSD, there seem to be a clash between a classname and a namespace.

This class get's generated

namespace Be.Fr.Cbso.Dict.Dom
{
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Serialization;
    
    
    [GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.1.1162.0")]
    [SerializableAttribute()]
    [XmlTypeAttribute("aln", Namespace="http://www.nbb.be/be/fr/cbso/dict/dom/")]
    [DebuggerStepThroughAttribute()]
    [DesignerCategoryAttribute("code")]
    [XmlRootAttribute("aln", Namespace="http://www.nbb.be/be/fr/cbso/dict/dom/")]
    public partial class Aln : Instance.StringItemType
    {
    }
}

Under the Be.Fr.Cbso.Dict.Dom namespace with name Aln

Problem is there is also a namespace with the exact same name

Be.Fr.Cbso.Dict.Dom.Aln

namespace Be.Fr.Cbso.Dict.Dom.Aln
{
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Serialization;
    
    
    [GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.1.1162.0")]
    [SerializableAttribute()]
    [XmlTypeAttribute("m0", Namespace="http://www.nbb.be/be/fr/cbso/dict/dom/aln")]
    [DebuggerStepThroughAttribute()]
    [DesignerCategoryAttribute("code")]
    [XmlRootAttribute("m0", Namespace="http://www.nbb.be/be/fr/cbso/dict/dom/aln")]
    public partial class M0_2 : Dtr.Type.DomainItemType
    {
    }
}

Which gives me a compilation error. Is this a problem with how the XSD is structured or a bug ? (I'm not the maintainer / owner of the XSD, but it's one generated by our national bank, and used by many other companies)

@mganss
Copy link
Owner

mganss commented Sep 13, 2024

Try substituting the Aln class name for something else using the --tns option. See https://github.com/mganss/XmlSchemaClassGenerator?tab=readme-ov-file#substituting-generated-c-type-and-member-names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant