Skip to content

Commit 06aae03

Browse files
committed
SAVEPOINT
1 parent b088f1e commit 06aae03

39 files changed

+363
-144
lines changed

FluentAssertions.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
146146

147147
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Style/@EntryValue">OUTLINE</s:String>
148+
<s:String x:Key="/Default/Environment/Hierarchy/Build/SolutionBuilderNext/FileVerbosityLevel/@EntryValue">Minimal</s:String>
148149
<s:String x:Key="/Default/Environment/Hierarchy/PsiConfigurationSettingsKey/LocationType/@EntryValue">SOLUTION_FOLDER</s:String>
149150
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002EDaemon_002ESettings_002EMigration_002ESwaWarningsModeSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
150151
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>

Src/FluentAssertions/Common/MemberPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class MemberPath
2020
private static readonly MemberPathSegmentEqualityComparer MemberPathSegmentEqualityComparer = new();
2121

2222
public MemberPath(IMember member, string parentPath)
23-
: this(member.ReflectedType, member.DeclaringType, parentPath.Combine(member.Name))
23+
: this(member.ReflectedType, member.DeclaringType, parentPath.Combine(member.Expectation.Name ?? member.Subject.Name))
2424
{
2525
}
2626

Src/FluentAssertions/Common/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static bool IsEquivalentTo(this IMember property, IMember otherProperty)
138138
{
139139
return (property.DeclaringType.IsSameOrInherits(otherProperty.DeclaringType) ||
140140
otherProperty.DeclaringType.IsSameOrInherits(property.DeclaringType)) &&
141-
property.Name == otherProperty.Name;
141+
property.Subject.Name == otherProperty.Subject.Name;
142142
}
143143

144144
/// <summary>

Src/FluentAssertions/Equivalency/AssertionChainExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static class AssertionChainExtensions
1010
/// </summary>
1111
public static AssertionChain For(this AssertionChain chain, IEquivalencyValidationContext context)
1212
{
13-
chain.OverrideCallerIdentifier(() => context.CurrentNode.Description);
13+
chain.OverrideCallerIdentifier(() => context.CurrentNode.Subject.Description);
1414

1515
return chain
1616
.WithReportable("configuration", () => context.Options.ToString())

Src/FluentAssertions/Equivalency/EquivalencyValidationContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public bool IsCyclicReference(object expectation)
7474
bool compareByMembers = expectation is not null && Options.GetEqualityStrategy(expectation.GetType())
7575
is EqualityStrategy.Members or EqualityStrategy.ForceMembers;
7676

77-
var reference = new ObjectReference(expectation, CurrentNode.PathAndName, compareByMembers);
77+
var reference = new ObjectReference(expectation, CurrentNode.Subject.PathAndName, compareByMembers);
7878
return CyclicReferenceDetector.IsCyclicReference(reference);
7979
}
8080

8181
public ITraceWriter TraceWriter { get; set; }
8282

8383
public override string ToString()
8484
{
85-
return Invariant($"{{Path=\"{CurrentNode.Description}\"}}");
85+
return Invariant($"{{Path=\"{CurrentNode.Subject.PathAndName}\"}}");
8686
}
8787
}

Src/FluentAssertions/Equivalency/EquivalencyValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private static void AssertEquivalencyForCyclicReference(Comparands comparands, A
9090

9191
private void TryToProveNodesAreEquivalent(Comparands comparands, IEquivalencyValidationContext context)
9292
{
93-
using var _ = context.Tracer.WriteBlock(node => node.Description);
93+
using var _ = context.Tracer.WriteBlock(node => node.Subject.Description);
9494

9595
foreach (IEquivalencyStep step in AssertionOptions.EquivalencyPlan)
9696
{

Src/FluentAssertions/Equivalency/Execution/ObjectInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public ObjectInfo(Comparands comparands, INode currentNode)
88
{
99
Type = currentNode.Type;
1010
ParentType = currentNode.ParentType;
11-
Path = currentNode.PathAndName;
11+
Path = currentNode.Expectation.PathAndName;
1212
CompileTimeType = comparands.CompileTimeType;
1313
RuntimeType = comparands.RuntimeType;
1414
}

Src/FluentAssertions/Equivalency/Field.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,21 @@
66
namespace FluentAssertions.Equivalency;
77

88
/// <summary>
9-
/// A specialized type of <see cref="INode "/> that represents a field of an object in a structural equivalency assertion.
9+
/// A specialized type of <see cref="INode"/> that represents a field of an object in a structural equivalency assertion.
1010
/// </summary>
1111
internal class Field : Node, IMember
1212
{
1313
private readonly FieldInfo fieldInfo;
1414
private bool? isBrowsable;
1515

1616
public Field(FieldInfo fieldInfo, INode parent)
17-
: this(fieldInfo.ReflectedType, fieldInfo, parent)
18-
{
19-
}
20-
21-
public Field(Type reflectedType, FieldInfo fieldInfo, INode parent)
2217
{
2318
this.fieldInfo = fieldInfo;
2419
DeclaringType = fieldInfo.DeclaringType;
25-
ReflectedType = reflectedType;
26-
Path = parent.PathAndName;
20+
ReflectedType = fieldInfo.ReflectedType;
21+
Subject = new Pathway(parent.Subject.PathAndName, fieldInfo.Name, pathAndName => $"field {parent.GetSubjectId().Combine(pathAndName)}");
22+
Expectation = new Pathway(parent.Expectation.PathAndName, fieldInfo.Name, pathAndName => $"field {pathAndName}");
2723
GetSubjectId = parent.GetSubjectId;
28-
Name = fieldInfo.Name;
2924
Type = fieldInfo.FieldType;
3025
ParentType = fieldInfo.DeclaringType;
3126
RootIsCollection = parent.RootIsCollection;
@@ -40,8 +35,6 @@ public object GetValue(object obj)
4035

4136
public Type DeclaringType { get; set; }
4237

43-
public override string Description => $"field {GetSubjectId().Combine(PathAndName)}";
44-
4538
public CSharpAccessModifier GetterAccessibility => fieldInfo.GetCSharpAccessModifier();
4639

4740
public CSharpAccessModifier SetterAccessibility => fieldInfo.GetCSharpAccessModifier();

Src/FluentAssertions/Equivalency/INode.cs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using JetBrains.Annotations;
32

43
namespace FluentAssertions.Equivalency;
54

@@ -15,14 +14,6 @@ public interface INode
1514
/// </summary>
1615
GetSubjectId GetSubjectId { get; }
1716

18-
/// <summary>
19-
/// Gets the name of this node.
20-
/// </summary>
21-
/// <example>
22-
/// "Property2"
23-
/// </example>
24-
string Name { get; set; }
25-
2617
/// <summary>
2718
/// Gets the type of this node, e.g. the type of the field or property, or the type of the collection item.
2819
/// </summary>
@@ -34,24 +25,17 @@ public interface INode
3425
/// <value>
3526
/// Is <see langword="null"/> for the root object.
3627
/// </value>
37-
[CanBeNull]
3828
Type ParentType { get; }
3929

4030
/// <summary>
41-
/// Gets the path from the root object UNTIL the current node, separated by dots or index/key brackets.
31+
/// Gets the path from the root of the subject upto and including to the current node.
4232
/// </summary>
43-
/// <example>
44-
/// "Parent[0].Property2"
45-
/// </example>
46-
string Path { get; }
33+
Pathway Subject { get; set; }
4734

4835
/// <summary>
49-
/// Gets the full path from the root object up to and including the name of the node.
36+
/// Gets the path from the root of the expectation upto and including to the current node.
5037
/// </summary>
51-
/// <example>
52-
/// "Parent[0]"
53-
/// </example>
54-
string PathAndName { get; }
38+
Pathway Expectation { get; }
5539

5640
/// <summary>
5741
/// Gets a zero-based number representing the depth within the object graph
@@ -62,14 +46,6 @@ public interface INode
6246
/// </remarks>
6347
int Depth { get; }
6448

65-
/// <summary>
66-
/// Gets the path including the description of the subject.
67-
/// </summary>
68-
/// <example>
69-
/// "property subject.Parent[0].Property2"
70-
/// </example>
71-
string Description { get; }
72-
7349
/// <summary>
7450
/// Gets a value indicating whether the current node is the root.
7551
/// </summary>

Src/FluentAssertions/Equivalency/Matching/MappedMemberMatchingRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public MappedMemberMatchingRule(string expectationMemberName, string subjectMemb
3333
public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyOptions options, AssertionChain assertionChain)
3434
{
3535
if (parent.Type.IsSameOrInherits(typeof(TExpectation)) && subject is TSubject &&
36-
expectedMember.Name == expectationMemberName)
36+
expectedMember.Subject.Name == expectationMemberName)
3737
{
3838
var member = MemberFactory.Find(subject, subjectMemberName, parent);
3939

0 commit comments

Comments
 (0)