Skip to content

Commit

Permalink
Fix deserialization for Nullable types.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Oct 24, 2020
1 parent 2e4e5bb commit 816c3a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions YamlDotNet.Test/Serialization/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ public void DeserializeScalarOctalNumber()
result.Should().Be(29418);
}

[Fact]
public void DeserializeNullableScalarOctalNumber()
{
var result = Deserializer.Deserialize<int?>(UsingReaderFor("+071_352"));

result.Should().Be(29418);
}

[Fact]
public void DeserializeScalarHexNumber()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func<IPars
}
else
{
var typeCode = expectedType.GetTypeCode();
var underlyingType = Nullable.GetUnderlyingType(expectedType);
var typeCode = underlyingType != null ? underlyingType.GetTypeCode() : expectedType.GetTypeCode();
switch (typeCode)
{
case TypeCode.Boolean:
Expand Down

0 comments on commit 816c3a2

Please sign in to comment.