Skip to content

Commit

Permalink
Merge pull request #539 from brendandburns/master
Browse files Browse the repository at this point in the history
Fix deserialization for Nullable types.
  • Loading branch information
aaubry committed Oct 26, 2020
2 parents 2e4e5bb + 816c3a2 commit 7714d0d
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
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
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 7714d0d

Please sign in to comment.