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

Cannot serialize XML with nested classes (2) - Microsoft.XmlSerializer.Generator 2.2.0 #36925

Closed
NUnitTester opened this issue May 23, 2020 · 1 comment

Comments

@NUnitTester
Copy link

The problems ocure while transforming a project from .NET Framework to .NET Core 3.1 with
Microsoft.XmlSerializer.Generator 2.2.0.
It seems to be a bug in the generator. There should be no reason to analyze types that are not serialzed.

The following example works fine with .NET Frameworks but fails in .NET Core.

    [Serializable]
    [XmlRoot("Info", Namespace = "N1")]
    public class Info1
    {
        [Flags]
        public enum Flag : uint
        {
            F1 = 1,
            F2 = 2,
            All = 3,
        }

        [XmlAttribute("flags")] 
        public Flag F { get; set; }
    }

    [Serializable]
    [XmlRoot("Info", Namespace = "N2")]
    public class Info2
    {
        [Flags]
        public enum Flag : uint
        {
            F1 = 1,
            F2 = 2,
            All = 3,
        }

        [XmlAttribute("flags")] 
        public Flag F { get; set; }
    }

Error Message:
There was an error reflecting type 'DbGenerator.Info2.Flag'.
Types 'DbGenerator.Info2.Flag' and 'DbGenerator.Info1.Flag' both use the XML type name, 'Flag', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type.

Should not they have the same namespace as outdie the class including it? N1 or N2?

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Serialization untriaged New issue has not been triaged by the area owner labels May 23, 2020
@HongGit HongGit added bug and removed untriaged New issue has not been triaged by the area owner labels Jun 25, 2020
@HongGit HongGit added this to the Future milestone Jun 25, 2020
@HongGit
Copy link
Contributor

HongGit commented Oct 8, 2020

same issue as #36921 and same workaround

@HongGit HongGit closed this as completed Oct 8, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants