Skip to content

Commit

Permalink
fix: prevent conflation of Symbol and Reflection TypeViewModel instances
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Nov 2, 2023
1 parent ac0f560 commit 55bb555
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void UsageOfEntityWithInternalDbSet_IsTreatedLikeExternalType(ClassViewMo
}

[Theory]
[ClassViewModelData(typeof(ComplexModel))]
[ReflectionClassViewModelData(typeof(ComplexModel))]
public void IncludeChildren_IncludesNonSuppressedMembers(ClassViewModelData data)
{
ClassViewModel vm = data;
Expand All @@ -95,8 +95,8 @@ public void IncludeChildren_IncludesNonSuppressedMembers(ClassViewModelData data
}

[Theory]
[ClassViewModelData(typeof(ComplexModel), nameof(ComplexModel.NoAutoIncludeReferenceNavigation))]
[ClassViewModelData(typeof(ComplexModel), nameof(ComplexModel.NoAutoIncludeByClassReferenceNavigation))]
[ReflectionClassViewModelData(typeof(ComplexModel), nameof(ComplexModel.NoAutoIncludeReferenceNavigation))]
[ReflectionClassViewModelData(typeof(ComplexModel), nameof(ComplexModel.NoAutoIncludeByClassReferenceNavigation))]
public void IncludeChildren_DoesNotIncludedOptedOutMember(ClassViewModelData data, string propName)
{
ClassViewModel vm = data;
Expand Down
5 changes: 4 additions & 1 deletion src/IntelliTect.Coalesce/TypeDefinition/TypeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ public override bool Equals(object? obj)
{
if (!(obj is TypeViewModel that)) return false;

return this.VerboseFullyQualifiedName == that.VerboseFullyQualifiedName;
return
this.VerboseFullyQualifiedName == that.VerboseFullyQualifiedName &&
// Ensure we don't conflate reflection and symbol types together:
this.GetType() == that.GetType();
}

public override int GetHashCode() => VerboseFullyQualifiedName.GetHashCode();
Expand Down

0 comments on commit 55bb555

Please sign in to comment.