Add XmlEnumAttribute Support
See original GitHub issueSuppose 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:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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. 😉