-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated DefaultPropertyResolver.IsIgnored to return true for a proper…
…ty value that references the owning instance
- Loading branch information
1 parent
76ff9eb
commit 83663a1
Showing
6 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
internal class SelfReferenceInstance | ||
{ | ||
private SelfReferenceInstance? _value; | ||
|
||
public SelfReferenceInstance Instance { get => _value ?? this; set => _value = value; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
ModelBuilder.UnitTests/Models/StructConstructorException.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,12 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
using System; | ||
|
||
internal struct StructConstructorException | ||
{ | ||
public StructConstructorException() | ||
{ | ||
throw new InvalidOperationException("This is an exception from the constructor."); | ||
} | ||
} | ||
} |
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,28 @@ | ||
namespace ModelBuilder.UnitTests.Scenarios | ||
{ | ||
using FluentAssertions; | ||
using ModelBuilder.UnitTests.Models; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class RegressionTests | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public RegressionTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public void CreateShouldSkipSelfReferencingPropertiesOnPopulateException() | ||
{ | ||
// Fixes https://github.com/roryprimrose/ModelBuilder/issues/347 | ||
var action = () => Model.WriteLog<SelfReferenceInstance>(_output.WriteLine).Create(); | ||
|
||
var actual = action.Should().NotThrow().Subject; | ||
|
||
actual.Instance.Should().BeSameAs(actual); | ||
} | ||
} | ||
} |
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