You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below serializes an OuterClass that contains a list of two InnerClasses. Both InnerClasses have a reference to the same array. In the serialization, the first InnerClass's Arrayhas no anchor, but the second InnerClass's Array nevertheless uses an alias (which is presumably supposed to refer to the first Array).
using NUnit.Framework;
using SharpYaml.Serialization;
using System.Collections.Generic;
namespace Yaml {
[TestFixture]
public class Test {
[Test]
public void Anchor()
{
var array = new int[] { 1, 2 };
var expected = new OuterClass() {
InnerObjects = new List<InnerClass>()
};
for (int i = 0; i < 2; i++) {
var inner = new InnerClass {
Array = array
};
expected.InnerObjects.Add(inner);
}
var settings = new SerializerSettings() { EmitDefaultValues = true, EmitAlias = true };
settings.RegisterAssembly(typeof(OuterClass).Assembly);
var serializer = new Serializer(settings);
string serialString = serializer.Serialize(expected);
// This line throws an exception
var actual = serializer.Deserialize(serialString);
}
}
public class OuterClass {
public List<InnerClass> InnerObjects { get; set; }
}
public class InnerClass {
public int[] Array { get; set; }
}
}
The text was updated successfully, but these errors were encountered:
The code below serializes an
OuterClass
that contains a list of twoInnerClass
es. BothInnerClass
es have a reference to the same array. In the serialization, the firstInnerClass
'sArray
has no anchor, but the secondInnerClass
'sArray
nevertheless uses an alias (which is presumably supposed to refer to the firstArray
).I tested this with SharpYaml 1.9.0.
Serialization:
Code:
The text was updated successfully, but these errors were encountered: