diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-22 15:44:01 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2011-11-22 15:44:01 +0400 |
commit | f9ae579a747632978643f5b248e3e663489a4c0a (patch) | |
tree | e4e8c638f046de576058e319b097a3fabffe184e /main/src | |
parent | a536fd54ad59e58ad37c06ae8632676a328c30e6 (diff) |
[Core] Properly implement Equals/GetHashCode on ProjectReference
Fixes the bug where we could add duplicate references to the project
when adding new webreferences as the duplicate check failed.
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectReference.cs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectReference.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectReference.cs index 12c15aa760..4ca6a5bab1 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectReference.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectReference.cs @@ -436,12 +436,27 @@ namespace MonoDevelop.Projects return MemberwiseClone(); } + public override bool Equals (object obj) + { + return Equals (obj as ProjectReference); + } + public bool Equals (ProjectReference other) { - ProjectReference oref = other as ProjectReference; - if (oref == null) return false; - - return StoredReference == oref.StoredReference && referenceType == oref.referenceType && package == oref.package; + return other != null + && StoredReference == other.StoredReference + && referenceType == other.referenceType + && package == other.package; + } + + public override int GetHashCode () + { + int result = 0; + if (StoredReference != null) + result ^= StoredReference.GetHashCode (); + if (package != null) + result ^= package.GetHashCode (); + return result; } internal void NotifyStatusChanged () |