Skip to content

Commit

Permalink
It was actually fixed in e1986a4
Browse files Browse the repository at this point in the history
So just add a test for it
  • Loading branch information
airbreather committed Feb 9, 2024
1 parent 19d7875 commit 83beaba
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions YamlDotNet.Test/Serialization/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,16 @@ public void NamingConventionAppliedToEnumWhenDeserializing()
Assert.Equal(expected, actual);
}

[Fact]
[Trait("motive", "issue #656")]
public void NestedDictionaryTypes_ShouldRoundtrip()
{
var serializer = new SerializerBuilder().EnsureRoundtrip().Build();
var yaml = serializer.Serialize(new HasNestedDictionary(), typeof(HasNestedDictionary));
var dct = new DeserializerBuilder().Build().Deserialize<HasNestedDictionary>(yaml);
Assert.Contains(new KeyValuePair<int, HasNestedDictionary.Payload>(1, new HasNestedDictionary.Payload { I = 1 }), dct.Lookups);
}

public class TestState
{
public int OnSerializedCallCount { get; set; }
Expand Down Expand Up @@ -2546,5 +2556,15 @@ public void WriteYaml(IEmitter emitter, object value, Type type)
emitter.Emit(new Scalar(((NonSerializable)value).Text));
}
}

public sealed class HasNestedDictionary
{
public Dictionary<int, Payload> Lookups { get; set; } = new Dictionary<int, Payload> { [1] = new Payload { I = 1 } };

public struct Payload
{
public int I { get; set; }
}
}
}
}

0 comments on commit 83beaba

Please sign in to comment.