diff --git a/src/ExtendedXmlSerializer/ExtensionModel/References/RootReferences.cs b/src/ExtendedXmlSerializer/ExtensionModel/References/RootReferences.cs index 353db3e7c..08eb3d206 100644 --- a/src/ExtendedXmlSerializer/ExtensionModel/References/RootReferences.cs +++ b/src/ExtendedXmlSerializer/ExtensionModel/References/RootReferences.cs @@ -1,5 +1,5 @@ -using System.Collections.Immutable; using ExtendedXmlSerializer.ContentModel.Format; +using System.Collections.Immutable; namespace ExtendedXmlSerializer.ExtensionModel.References { @@ -14,6 +14,11 @@ public RootReferences(IReferences references, IRootInstances root) _root = root; } - public ImmutableArray Get(IFormatWriter parameter) => _references.Get(_root.Get(parameter.Get())); + public ImmutableArray Get(IFormatWriter parameter) + { + var root = _root.Get(parameter.Get()); + var result = root != null ? _references.Get(root) : ImmutableArray.Empty; + return result; + } } } \ No newline at end of file diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue355Tests.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue355Tests.cs index 44760fb1c..84f81750e 100644 --- a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue355Tests.cs +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue355Tests.cs @@ -1,5 +1,6 @@ using ExtendedXmlSerializer.Configuration; using ExtendedXmlSerializer.Tests.ReportedIssues.Support; +using JetBrains.Annotations; using Xunit; namespace ExtendedXmlSerializer.Tests.ReportedIssues @@ -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) {} diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue358Tests.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue358Tests.cs new file mode 100644 index 000000000..12bbf0b3c --- /dev/null +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue358Tests.cs @@ -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; } + } + } +} \ No newline at end of file