From c11db2117947e3b3ac35a2cc64d557338a6394be Mon Sep 17 00:00:00 2001 From: "huiyu,eun" Date: Fri, 15 Sep 2017 10:30:44 +0900 Subject: [PATCH] [NUI] Fix Build warnings: override Equals and GetHashCode warings: CS0660, CS0661 CS0660: defines operator == or operator != but does not override Object.Equals(object o) CS0661: defines operator == or operator != but does not override Object.GetHashCode() please refer https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0660 https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0661 Change-Id: I2fc153fbf5490de9002ce0155e5c65e35f7e9d6e Signed-off-by: huiyu,eun --- src/Tizen.NUI/src/public/BaseHandle.cs | 35 +++++++++++++++++++++++++++++++++ src/Tizen.NUI/src/public/PaddingType.cs | 24 ++++++++++++++++++++++ src/Tizen.NUI/src/public/Rectangle.cs | 32 +++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI/src/public/BaseHandle.cs b/src/Tizen.NUI/src/public/BaseHandle.cs index 40ed2a1..8857779 100755 --- a/src/Tizen.NUI/src/public/BaseHandle.cs +++ b/src/Tizen.NUI/src/public/BaseHandle.cs @@ -256,6 +256,41 @@ namespace Tizen.NUI return true; } + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is BaseHandle)) + { + return false; + } + BaseHandle b = (BaseHandle)o; + if (!BaseHandle.ReferenceEquals(this, null) && !BaseHandle.ReferenceEquals(b, null)) + { + // drop into native code to see if both handles point to the same body + return this.IsEqual(b); + } + + if (BaseHandle.ReferenceEquals(this, null) && !BaseHandle.ReferenceEquals(b, null)) + { + if (b.HasBody()) return false; + else return true; + } + if (!BaseHandle.ReferenceEquals(this, null) && BaseHandle.ReferenceEquals(b, null)) + { + if (this.HasBody()) return false; + else return true; + } + + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } public BaseHandle() : this(NDalicPINVOKE.new_BaseHandle__SWIG_1()) { diff --git a/src/Tizen.NUI/src/public/PaddingType.cs b/src/Tizen.NUI/src/public/PaddingType.cs index b0e3019..f5b11af 100755 --- a/src/Tizen.NUI/src/public/PaddingType.cs +++ b/src/Tizen.NUI/src/public/PaddingType.cs @@ -125,6 +125,30 @@ namespace Tizen.NUI return !(a == b); } + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is PaddingType)) + { + return false; + } + PaddingType p = (PaddingType)o; + + // Return true if the fields match: + return (System.Math.Abs(Left - p.Left) < NDalic.GetRangedEpsilon(Left, p.Left)) && + (System.Math.Abs(Right - p.Right) < NDalic.GetRangedEpsilon(Right, p.Right)) && + (System.Math.Abs(Bottom - p.Bottom) < NDalic.GetRangedEpsilon(Bottom, p.Bottom)) && + (System.Math.Abs(Top - p.Top) < NDalic.GetRangedEpsilon(Top, p.Top)); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + ///< The Left value public float Left { diff --git a/src/Tizen.NUI/src/public/Rectangle.cs b/src/Tizen.NUI/src/public/Rectangle.cs index 0452847..e408d55 100755 --- a/src/Tizen.NUI/src/public/Rectangle.cs +++ b/src/Tizen.NUI/src/public/Rectangle.cs @@ -124,7 +124,37 @@ namespace Tizen.NUI } /// - /// The Inequality operator. + /// Equality operator. + /// + /// The object to compare with the current object. + /// True if boxes are exactly same. + public override bool Equals(object o) + { + if(o == null) + { + return false; + } + if(!(o is Rectangle)) + { + return false; + } + Rectangle r = (Rectangle)o; + + // Return true if the fields match: + return X == r.X && Y == r.Y && Width == r.Width && Height == r.Height; + } + + /// + /// Serves as the default hash function. + /// + /// A hash code for the current object. + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Inequality operator. /// /// The first rectangle. /// The second rectangle. -- 2.7.4