question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add XmlEnumAttribute Support

See original GitHub issue

Suppose I have the following enum:

    public enum SessionTypeEnum
    {
        /// <remarks />
        [XmlEnum("My Training List")] MyTrainingList,

        /// <remarks />
        [XmlEnum("Training List")] TrainingList,

        /// <remarks />
        [XmlEnum("Service List")]
        ServiceList
    }

When I serialize an object with a property of the above enum, the selected value is not the Name property specified in the XmlEnum attribute.

e.g. for ServiceList, I expect the serializer to generate “Service List”, but it generates ServiceList. Do I need to use another attribute?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
umutesencommented, Feb 26, 2018

I am aware that the document size will increase, however, I will be submitting the XML to an external web service, which requires the enum values to match their schema…

Anyway, the project had reference to the AspCore package, changing that to the full package on MyGet solved the issue ☺️

Thank you for your help, it is much appreciated.

1reaction
Mike-E-angelocommented, Feb 26, 2018

Ahh the conflict. You are actually increasing document size by utilizing this, but on the other hand we do strive to be as compatible with the classic serializer where possible – for better or for worse. 😄 This was an easy fix and you can try it out here:

https://www.myget.org/F/wojtpl2/api/v3/index.json

Please let us know if you find any additional issues. The easier to fix, the better. 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

XmlEnumAttribute Class (System.Xml.Serialization)
The XmlEnumAttribute belongs to a family of attributes that controls how the XmlSerializer serializes or deserializes an object. For a complete list of...
Read more >
XmlEnumAttribute Constructor (System.Xml.Serialization)
Initializes a new instance of the XmlEnumAttribute class, and specifies the XML value that the XmlSerializer generates or recognizes (when it serializes or ......
Read more >
c# - Get XmlEnumAttribute from enum
How do I retrieve the string value of XmlEnum "Name"? Hot Network Questions · I wish to kill a service with a "sytemctl...
Read more >
Type: System.Xml.Serialization.XmlEnumAttribute
Remarks. The XmlEnumAttribute belongs to a family of attributes that controls how the XmlSerializer serializes, or deserializes, an object.
Read more >
Support for EnumMemberAttribute in JsonConverterEnum
DCS and Json.NET use EnumMemberAttribute, XML uses XmlEnumAttribute. ... Supports nullable enum types and adds EnumMemberAttribute support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found