Class with property interface of List
See original GitHub issueIf you have class:
class ClassWithPropertyInterfaceOfList
{
public IList<string> List { get; set; }
public IDictionary<string, string> Dictionary { get; set; }
public ISet<string> Set { get; set; }
}
and create object:
var expected = new ClassWithPropertyInterfaceOfList
{
List = new List<string> { "Item1" },
Set = new HashSet<string> { "Item1" },
Dictionary = new Dictionary<string, string> { { "Key", "Value" } }
};
I’ve got exception:
ExtendedXmlSerializer.ExtensionModel.References.CircularReferencesDetectedException was unhandled by user code HResult=-2146233088 Message=The provided instance of type ‘ExtendedXmlSerializer.Tests.ExtensionModel.Xml.ExtendedXmlSerializerTests+ClassWithPropertyInterfaceOfList’ contains circular references within its graph. Serializing this instance would result in a recursive, endless loop. To properly serialize this instance, please create a serializer that has referential support enabled by extending it with the ReferencesExtension. Source=ExtendedXmlSerializer StackTrace: at ExtendedXmlSerializer.ExtensionModel.References.ReferenceAwareSerializers.Serializer.Write(IFormatWriter writer, Object instance) in C:\Work\ExtendedXmlSerializer\src\ExtendedXmlSerializer\ExtensionModel\References\ReferenceAwareSerializers.cs:line 77 at ExtendedXmlSerializer.ExtensionModel.Xml.ExtendedXmlSerializer.Serialize(XmlWriter writer, Object instance) in C:\Work\ExtendedXmlSerializer\src\ExtendedXmlSerializer\ExtensionModel\Xml\ExtendedXmlSerializer.cs:line 55 at ExtendedXmlSerializer.ExtensionModel.Xml.InstanceFormatter.Get(Object parameter) in C:\Work\ExtendedXmlSerializer\src\ExtendedXmlSerializer\ExtensionModel\Xml\InstanceFormatter.cs:line 50 at ExtendedXmlSerializer.ExtensionModel.Xml.Extensions.Serialize(IExtendedXmlSerializer this, IXmlWriterFactory factory, Func`1 stream, Object instance) in C:\Work\ExtendedXmlSerializer\src\ExtendedXmlSerializer\ExtensionModel\Xml\Extensions.cs:line 132 at ExtendedXmlSerializer.ExtensionModel.Xml.Extensions.Serialize(IExtendedXmlSerializer this, Object instance) in C:\Work\ExtendedXmlSerializer\src\ExtendedXmlSerializer\ExtensionModel\Xml\Extensions.cs:line 118 at ExtendedXmlSerializer.Tests.Support.SerializationSupport.Assert[T](T instance, String expected) in C:\Work\ExtendedXmlSerializer\test\ExtendedXmlSerializer.Tests\Support\SerializationSupport.cs:line 46 at ExtendedXmlSerializer.Tests.ExtensionModel.Xml.ExtendedXmlSerializerTests.PropertyInterfaceOfList() in C:\Work\ExtendedXmlSerializer\test\ExtendedXmlSerializer.Tests\ExtensionModel\Xml\ExtendedXmlSerializerTests.cs:line 205 InnerException:
I’ll add test to repo.
Issue Analytics
- State:
- Created 6 years ago
- Comments:39 (28 by maintainers)
Top GitHub Comments
v3 it’s an unofficial project at the moment, and I probably shouldn’t have mentioned it. Trying to pump myself into it. 😆
For some context, the plan is to create a new serializer as a separate project that supports numerous formats and then have ExtendedXmlSerializer be the XML version (along with classical support).
I emphasize plan as every developer has a plan until their code punches them in their face. 🤣 That’s how it is for me, anyway.
In any case, I have captured our discussion here: https://github.com/SuperDotNet/Super.NET/issues/27
ok, the code stops because I configured VS to stop at this exception. I see the code works and generates XML and deserialized objects include the references again.
I see you catch the exception and ignore it by still writing the content in
ReferenceAwareSerializers.cs
I configured VS to stop because I saw this CircularReferencesDetectedException before app closes and debugging stops 🤔 🤷♂️