I have an enum which describes options available for a user to select as part of settings. This is serialized to XML. One of the names is not ideal, and I'd like to rename it, but still support deserialization of older settings files.
For example:
public enum Options
{
Odd,
NonOdd // rename to 'Even'
}
I know I can rename it but specify the previous serialized name like this:
public enum Options
{
Odd,
[XmlEnum(Name = "NonOdd")]
Even
}
While this works, it continues to use NonOdd
in the XML file, which I would prefer not to do.
Is there a way to support deserialization of current and deprecated enum names, but serialize to the current name?