Debug XmlSerializer

var serializer = new XmlSerializer(typeof(<x>));

serializer.UnknownAttribute += (sender, args) =>
    System.Diagnostics.Debug.Fail($"Unknown attribute { args.Attr.Name }=\'{ args.Attr.Value }\'");
serializer.UnknownNode += (sender, args) =>
    System.Diagnostics.Debug.Fail($"Unknown Node: {args.Name}\t{args.Text}");
serializer.UnknownElement += (sender, args) =>
    System.Diagnostics.Debug.Fail($"Unknown Element: { args.Element.Name }\t{ args.Element.InnerXml}");
serializer.UnreferencedObject += (sender, args) =>
    System.Diagnostics.Debug.Fail($"Unreferenced Object: { args.UnreferencedId }\t{ args.UnreferencedObject.ToString() }");

Post navigation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.