Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ArchUnitNET/Domain/Slice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Slice(SliceIdentifier identifier, IEnumerable<IType> types)

protected bool Equals(Slice other)
{
return Equals(Identifier, other.Identifier) && Equals(Types, other.Types);
return Equals(Identifier, other.Identifier);
}

public override bool Equals(object obj)
Expand All @@ -58,11 +58,7 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
unchecked
{
return ((Identifier != null ? Identifier.GetHashCode() : 0) * 397)
^ (Types != null ? Types.GetHashCode() : 0);
}
return Identifier != null ? Identifier.GetHashCode() : 0;
}

public override string ToString()
Expand Down
12 changes: 6 additions & 6 deletions ArchUnitNETTests/Fluent/Slices/SliceDomainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ public void Slice_ToString_ReturnsDescription()
}

/// <remarks>
/// Slice.Equals compares its Types collection by reference, not by content, so
/// <c>differentTypesInstance</c> below is unequal despite also being empty. That
/// relies on the two <c>new IType[0]</c> expressions yielding distinct references --
/// true today, but it would silently stop testing anything if empty arrays were ever
/// interned, so the two instances are kept deliberately separate and named for it.
/// Slice.Equals looks at the identifier alone, so <c>differentTypesInstance</c> below is
/// equal despite holding a distinct Types instance. The two <c>new IType[0]</c>
/// expressions are kept deliberately separate and named for it: they are what would make
/// this fail again if Types were ever compared by reference.
/// </remarks>
[Fact]
public void Slice_Equals_Branches()
Expand All @@ -92,7 +91,8 @@ public void Slice_Equals_Branches()
Assert.True(slice.Equals(slice));
Assert.False(slice.Equals("not a slice"));
Assert.True(slice.Equals(sameIdentifierAndTypes));
Assert.False(slice.Equals(differentTypesInstance));
Assert.True(slice.Equals(differentTypesInstance));
Assert.Equal(slice.GetHashCode(), differentTypesInstance.GetHashCode());
Assert.False(slice.Equals(differentIdentifier));
}

Expand Down
Loading