Skip to content

Commit

Permalink
Merge ebd3e95 into 1317d44
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-EEE authored Jan 23, 2020
2 parents 1317d44 + ebd3e95 commit 84513a8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Immutable;
using ExtendedXmlSerializer.ContentModel.Format;
using System.Collections.Immutable;

namespace ExtendedXmlSerializer.ExtensionModel.References
{
Expand All @@ -14,6 +14,11 @@ public RootReferences(IReferences references, IRootInstances root)
_root = root;
}

public ImmutableArray<object> Get(IFormatWriter parameter) => _references.Get(_root.Get(parameter.Get()));
public ImmutableArray<object> Get(IFormatWriter parameter)
{
var root = _root.Get(parameter.Get());
var result = root != null ? _references.Get(root) : ImmutableArray<object>.Empty;
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ExtendedXmlSerializer.Configuration;
using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
using JetBrains.Annotations;
using Xunit;

namespace ExtendedXmlSerializer.Tests.ReportedIssues
Expand Down Expand Up @@ -39,6 +40,7 @@ public Outer(string a, string b, string c)

sealed class CombinedProfile : CompositeConfigurationProfile
{
[UsedImplicitly]
public static CombinedProfile Default { get; } = new CombinedProfile();

CombinedProfile() : base(OuterProfile.Default) {}
Expand Down
48 changes: 48 additions & 0 deletions test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue358Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using ExtendedXmlSerializer.Configuration;
using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
using FluentAssertions;
using Xunit;

namespace ExtendedXmlSerializer.Tests.ReportedIssues
{
public sealed class Issue358Tests
{
[Fact]
void Verify()
{
var serializer = new ConfigurationContainer()
.EnableParameterizedContentWithPropertyAssignments()
.EnableReferences()
.Create()
.ForTesting();

var instance = new vector(new length(11), new length(13));

var cycled = serializer.Cycle(instance);
cycled.L1.Value.Should().Be(instance.L1.Value);
cycled.L2.Value.Should().Be(instance.L2.Value);
}

class length
{
public length(int value)
{
Value = value;
}

public int Value { get; }
}

private struct vector
{
public vector(length l1, length l2)
{
L1 = l1;
L2 = l2;
}

public length L1 { get; }
public length L2 { get; }
}
}
}

0 comments on commit 84513a8

Please sign in to comment.