-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently serialization using System.Xml.Serialization does not work as I expected.
The following works:
using System.Xml.Serialization;
using newtype;
var xml = new XmlSerializer(typeof(Order));
var order = new Order { Contract = "CTR-002" };
using var sw = new StringWriter();
xml.Serialize(sw, order);
Console.WriteLine($"XML: {sw}");
public class Order { public string Contract { get; set; } }but using newtype it did not:
using System.Xml.Serialization;
using newtype;
var xml = new XmlSerializer(typeof(Order));
var order = new Order { Contract = new ContractId("CTR-002") };
using var sw = new StringWriter();
xml.Serialize(sw, order);
Console.WriteLine($"XML: {sw}");
// <Id /> — empty, value not serialized
public class Order { public ContractId Contract { get; set; } }
[newtype<string>]
public readonly partial struct ContractId;I suspect similar problems exist for other serializers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels