diff --git a/YamlDotNet.Test/Serialization/SerializationTestHelper.cs b/YamlDotNet.Test/Serialization/SerializationTestHelper.cs index f016e34d9..7b908e15d 100644 --- a/YamlDotNet.Test/Serialization/SerializationTestHelper.cs +++ b/YamlDotNet.Test/Serialization/SerializationTestHelper.cs @@ -530,4 +530,14 @@ public class NameConvention [YamlIgnore] public string fourthTest { get; set; } } + + public struct SimpleStruct + { + public int Value { get; set; } + } + + public class ClassWithNullableStruct + { + public SimpleStruct? Struct { get; set; } + } } \ No newline at end of file diff --git a/YamlDotNet.Test/Serialization/SerializationTests.cs b/YamlDotNet.Test/Serialization/SerializationTests.cs index 55a6ed9d1..2a9110822 100644 --- a/YamlDotNet.Test/Serialization/SerializationTests.cs +++ b/YamlDotNet.Test/Serialization/SerializationTests.cs @@ -244,6 +244,17 @@ public void DeserializationOfObjectsHandlesForwardReferences() new { Nothing = "ForwardReference", MyString = "ForwardReference" }, o => o.ExcludingMissingMembers()); } + [Fact] + public void SerializeAndDesierializeClassWithNullableStruct() + { + var yaml = Serializer.Serialize(new ClassWithNullableStruct + { + Struct = new SimpleStruct { Value = 42 } + }); + + var i = Deserializer.Deserialize(yaml); + } + [Fact] public void DeserializationFailsForUndefinedForwardReferences() {