Skip to content

Commit

Permalink
Fixed AutoFormatting types that do not have converters (#551)
Browse files Browse the repository at this point in the history
* Fixed AutoFormatting types that do not have converters

* Addressed warning
  • Loading branch information
Mike-E-angelo authored Sep 7, 2021
1 parent 16d24df commit 5d76590
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public IConverter Get(TypeInfo parameter)
{
var underlying = Nullable.GetUnderlyingType(parameter);
var decorate = underlying != null;
var converter = _previous.Get(underlying ?? parameter);
var result = decorate ? new Converter(converter) : converter;
var converter = (decorate ? _previous.Get(underlying) : null) ?? _previous.Get(parameter);
var result = decorate && converter != null ? new Converter(converter) : converter;
return result;
}
}
Expand Down
36 changes: 36 additions & 0 deletions test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue550Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using ExtendedXmlSerializer.Configuration;
using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
using FluentAssertions;
using JetBrains.Annotations;
using Xunit;

namespace ExtendedXmlSerializer.Tests.ReportedIssues
{
public sealed class Issue550Tests
{
[Fact]
public void Verify()
{
var configuration = new ConfigurationContainer();
configuration.UseAutoFormatting();
var instance = new Subject
{
Struct = new ItemStruct()
};

var serializer = configuration.Create();
serializer.Cycle(instance).Should().BeEquivalentTo(instance);

}

class Subject
{

[UsedImplicitly] public ItemStruct? Struct;

}
struct ItemStruct
{}

}
}

0 comments on commit 5d76590

Please sign in to comment.