Skip to content

Commit e075315

Browse files
dahlbyknulltoken
authored andcommitted
Implement FilePath.Equals() and GetHashCode()
1 parent 1f12511 commit e075315

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

LibGit2Sharp/Core/FilePath.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23

34
namespace LibGit2Sharp.Core
45
{
5-
internal class FilePath
6+
internal class FilePath : IEquatable<FilePath>
67
{
78
internal static FilePath Empty = new FilePath(string.Empty);
89

@@ -56,5 +57,20 @@ private static string Replace(string path, char oldChar, char newChar)
5657

5758
return path == null ? null : path.Replace(oldChar, newChar);
5859
}
60+
61+
public bool Equals(FilePath other)
62+
{
63+
return other == null ? posix == null : string.Equals(posix, other.posix, StringComparison.Ordinal);
64+
}
65+
66+
public override bool Equals(object obj)
67+
{
68+
return Equals(obj as FilePath);
69+
}
70+
71+
public override int GetHashCode()
72+
{
73+
return posix == null ? 0 : posix.GetHashCode();
74+
}
5975
}
6076
}

0 commit comments

Comments
 (0)