Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
Fixes HashCode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Kotalik committed Jun 15, 2016
1 parent b4d8918 commit 25fbe6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.AspNetCore.Http.Abstractions/PathString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public bool Equals(PathString other)
/// <returns>True if both PathString values are equal</returns>
public bool Equals(PathString other, StringComparison comparisonType)
{
if (!this.HasValue && !other.HasValue)
if (!HasValue && !other.HasValue)
{
return true;
}
Expand All @@ -251,7 +251,7 @@ public override bool Equals(object obj)
/// <returns>The hash code</returns>
public override int GetHashCode()
{
return (_value != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(_value) : 0);
return (HasValue ? StringComparer.OrdinalIgnoreCase.GetHashCode(_value) : 0);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public void NotEquals_EmptyPathStringAndNonNullPathString()
Assert.NotEqual(pathString, PathString.Empty);
}

[Fact]
public void HashCode_CheckNullAndEmptyHaveSameHashcodes()
{
Assert.Equal(PathString.Empty.GetHashCode(), default(PathString).GetHashCode());
}

[Theory]
[InlineData(null, null)]
[InlineData("", null)]
Expand Down

0 comments on commit 25fbe6f

Please sign in to comment.