XElement nodes are not serialized correctly
filippobottega opened this issue · 9 comments
Hello,
I have an object with a property of type XElement. When I inspect the object I can see all properties in LinqPAD but the only one of type XElement is always Null.
Regards,
Filippo.
Hi Filippo,
Which kind of serialization option are you using? Default is Binary but I guess for Xml export JSON could be more suited. I'd need an example to recreate the test case locally, so if you could provide me with one I'll give it a go.
Cheers
Hi Codingadventures,
I'm using Binary but I don't know how to change the serialization option in Visual Studio.
I don't have an example ready but if you help me to change the serialization option I can try again and send you a feedback.
Regards,
Filippo.
sure thing. please refer to this section of the readme here
just select the last drop down and choose JSON. let me know how it goes and if it works for you.
Done
but now I have an error:
Logs.txt
2018-09-03T17:39:03.4456702+02:00 BroadCastData to LINQBridgeVsTruck
2018-09-03T17:39:03.5081303+02:00 Loading Cargo
2018-09-03T17:39:05.8370810+02:00 Error during LINQPad execution -
VisualizerObjectSourceException: Timeout della valutazione
in Microsoft.VisualStudio.Debugger.VisualizerObjectProvider.GetVisualizerObjectData()
in Microsoft.VisualStudio.Debugger.VisualizerObjectProvider.Microsoft.VisualStudio.DebuggerVisualizers.IVisualizerObjectProvider.GetData()
in BridgeVs.DynamicVisualizers.DynamicDebuggerVisualizer.Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
Hmmm does that mean "Function Evaluation Timeout" ? If that's the case then the issue is serialization is taking a long time. I wonder if the object is big
Could be...
I'll try with a sample to understand if the XML loaded in the XElement is too big.
Tested with JSON serialization without luck: the XElement doesn't work.
In Visual Studio
Public Class Test
Public Property Element As XElement
End Class
Dim myX = New Test With {.Element = New XElement("elementName", "This is a test")}
In LinqPad:
void Main()
{
Truck truck = new Truck("LINQBridgeVsTruck", SerializationOption.JSON);
truck.WaitDelivery("Test").Wait();
var @object = truck.UnLoadCargo<MiiTransaction.Test>();
@object.Dump("MiiTransaction.Test", 2);
}
I think it's a specific case with XElement and serialization, I'll run a few tests then. Thanks for reporting the issue
Binary formatter and Json.net don't do a good job with xml.
XmlSerialization will be available since the next release. Despite it will solve the issue, it's known to be slow and thus it might not be suitable in every situation