Schema.NET icon indicating copy to clipboard operation
Schema.NET copied to clipboard

XML Serialisation

Open SmithPlatts opened this issue 2 years ago • 4 comments

Describe the feature

Hi;

Has anyone had any success serialising any of the POCO classes to XML? I've tried both XmlSerializer and DataContractSerializer, but they both freak out for different reasons.

Is there something simple I'm missing?

Schema objects

No response

SmithPlatts avatar Sep 25 '23 08:09 SmithPlatts

Hey @SmithPlatts - haven't actually tried XML serialization before. I imagine it may have some trouble with our OneOrMany and Values types without some dedicated serializer for the,. If there are just some attributes we need to set on properties, that could be something easy enough for us to apply to the library though.

Turnerj avatar Dec 23 '23 04:12 Turnerj

Hi @Turnerj, cheers for opening the conversation.

I was actually thinking of giving that a go in my branch, and if it works without impacting the perf of the library, was going to open a PR for your review and comment.

SmithPlatts avatar Dec 23 '23 04:12 SmithPlatts

I don't imagine the existing performance of the library would be impacted - like if we just need extra attributes, that's effectively a no-op in terms of performance. If we need a new XML-based serializer, that's a bit more work and more tests to do it thoroughly. Really hoping we can get away with just some attributes etc to decorate properties!

Turnerj avatar Dec 23 '23 04:12 Turnerj

I've encountered circumstances where even attributes can change the compiler behaviour, and introduce a regression; not common, but I'm an overly defensive developer 😂

Happy to investigate the matter, and start with attributes. If a serialiser is also required, will be adding it test-first.

I'll let you know how things go.

SmithPlatts avatar Dec 23 '23 08:12 SmithPlatts