-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved reference tracking for multiple instances (#594)
- Loading branch information
1 parent
534a00e
commit 3d5c9fd
Showing
13 changed files
with
125 additions
and
83 deletions.
There are no files selected for viewing
13 changes: 7 additions & 6 deletions
13
src/ExtendedXmlSerializer/ContentModel/Reflection/VariableTypeWalker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/ExtendedXmlSerializer/ExtensionModel/References/ProcessReferenceInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace ExtendedXmlSerializer.ExtensionModel.References; | ||
|
||
readonly record struct ProcessReferenceInput(ReferenceSet Results, object Current); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/ExtendedXmlSerializer/ExtensionModel/References/ReferenceCompleted.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue584Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using System; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue584Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var items = new[] { "Some" }; | ||
var same = new InnerObject { Items = items }; | ||
var instance = new RootObject | ||
{ | ||
Item1 = same, | ||
Item2 = new InnerObject2 { Items = items }, | ||
}; | ||
|
||
var action = () => | ||
{ | ||
var serializer = new ConfigurationContainer() | ||
.Create() | ||
.ForTesting(); | ||
serializer.Cycle(instance).Should().BeEquivalentTo(instance); | ||
}; | ||
action.Should().Throw<Exception>().Where(x => x.GetType().Name == "MultipleReferencesDetectedException"); | ||
} | ||
|
||
[Fact] | ||
public void VerifyConfiguration() | ||
{ | ||
var items = new[] { "Some" }; | ||
var same = new InnerObject { Items = items }; | ||
var instance = new RootObject | ||
{ | ||
Item1 = same, | ||
Item2 = new InnerObject2 { Items = items }, | ||
}; | ||
|
||
var serializer = new ConfigurationContainer().AllowMultipleReferences() | ||
.Create() | ||
.ForTesting(); | ||
serializer.Cycle(instance).Should().BeEquivalentTo(instance); | ||
} | ||
|
||
public class RootObject | ||
{ | ||
public InnerObject Item1 { get; set; } | ||
public InnerObject2 Item2 { get; set; } | ||
} | ||
|
||
public class InnerObject | ||
{ | ||
public string[] Items { get; set; } | ||
} | ||
|
||
public class InnerObject2 | ||
{ | ||
public string[] Items { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters