ExtendedXmlSerializer / home

A configurable and eXtensible Xml serializer for .NET.

Home Page:https://extendedxmlserializer.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sprache.ParseException?

fellsoft opened this issue · comments

I'm trying to use ExtendedXmlSerializer for a current .Net 6 project, but I just can't get it to work.

I have a reasonably complicated object to serialize, which contains classes from multiple assemblies (all of them loaded). Everything in the object is well defined, i.e. no "object" or "dynamic" types.

When I try to use ExtendedXmlSerializer in the suggested most basic way,

IExtendedXmlSerializer exSerializer = new ConfigurationContainer(),Create();
using MemoryStream ms = new MemoryStream();
using (XmlWriter xw = XmlWriter.Create(ms))
{
exSerializer.Serialize(xw, myObject);
xw.Flush();
}

I get an exception like this on the call to .Serialize:

Sprache.ParseException: Parsing failure: unexpected '�'; expected letter (Line 1, Column 1); recently consumed: `
``
The same object can be succcesfully serialized to JSON with both Newtonsoft & System.Text.JSON

I have been able to get some subsidiary parts of the object serialized with ExtendedXmlSerializer, but I can't see any consistent pattern as to why it works on some parts but not on others.

I can't find any references to this exception.

Can anyone suggest what's going wrong here?

Hi @fellsoft thank you for writing in. Unfortunately, I cannot surmise the problem you are encountering. There must be something special about your graph that we have not encountered up to this point. If you are able to provide a class with a minimal reproduction I can look into it for you and see if we can fix it.

I will say that if you are able to get this working w/ the new JSON or even Netwonsoft serializer I would recommend going that path. This repo started in 2018 and while I have been able to support it for a few years now it is becoming increasingly likely I will archive it in the future, as I have not found anyone to take over its maintenance. Adding to your comments, everything has gone to JSON these days, and it is far more supported than this product (or at least, the time that I can find to do so).

That stated, if you are able to find a reproduction I can further look into it for you and see what can be done. 👍

Thanks Mike, appreciate the response & your position.

I need the data in XML because I'm transforming it with XSLT... Ironically the only way I can get this to work is to roundtrip the object out to JSON and then back to XML with Newtonsoft!

I'll see if I can come up with a minimal reproduction.

Closing older issues here. If you are able to provide a sample I can take a look into it further for you. Closing this issue for now.

No problem - I didn't get the time to create a minimal repro, but I suspect it was do with some generic interfaces I had in deeper in the object I was trying to serialize. In the end I found another way to achieve what I wanted. Thanks for the followup.