[NUI] Fix build warning CA1062 (#2234)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Size.cs
index 05d5b84..f65e33c 100755 (executable)
@@ -26,13 +26,8 @@ namespace Tizen.NUI
     /// </summary>
     /// <since_tizen> 5 </since_tizen>
     [Tizen.NUI.Binding.TypeConverter(typeof(SizeTypeConverter))]
-    public class Size : Disposable
+    public class Size : Disposable, ICloneable
     {
-        /// <summary>swigCMemOwn.</summary>
-        /// <since_tizen> 5 </since_tizen>
-        protected bool swigCMemOwn;
-
-        private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
         /// <summary>
         /// The constructor.
@@ -100,14 +95,17 @@ namespace Tizen.NUI
         /// The Width property for the width component of size
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
+        [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
         public float Width
         {
             set
             {
+                Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
+
                 Interop.Vector3.Vector3_Width_set(swigCPtr, value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-                callback?.Invoke(Width, Height, Depth);
+                callback?.Invoke(value, null, null);
             }
             get
             {
@@ -121,14 +119,17 @@ namespace Tizen.NUI
         /// The Height property for the height component of size.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
+        [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
         public float Height
         {
             set
             {
+                Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
+
                 Interop.Vector3.Vector3_Height_set(swigCPtr, value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-                callback?.Invoke(Width, Height, Depth);
+                callback?.Invoke(null, value, null);
             }
             get
             {
@@ -142,14 +143,17 @@ namespace Tizen.NUI
         /// The Depth property for the depth component of size.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
+        [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor")]
         public float Depth
         {
             set
             {
+                Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Size(...) constructor");
+
                 Interop.Vector3.Vector3_Depth_set(swigCPtr, value);
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
-                callback?.Invoke(Width, Height, Depth);
+                callback?.Invoke(null, null, value);
             }
             get
             {
@@ -168,7 +172,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator +(Size arg1, Size arg2)
         {
-            return arg1.Add(arg2);
+            return arg1?.Add(arg2);
         }
 
         /// <summary>
@@ -180,7 +184,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator -(Size arg1, Size arg2)
         {
-            return arg1.Subtract(arg2);
+            return arg1?.Subtract(arg2);
         }
 
         /// <summary>
@@ -191,7 +195,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator -(Size arg1)
         {
-            return arg1.Subtract();
+            return arg1?.Subtract();
         }
 
         /// <summary>
@@ -203,7 +207,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator *(Size arg1, Size arg2)
         {
-            return arg1.Multiply(arg2);
+            return arg1?.Multiply(arg2);
         }
 
         /// <summary>
@@ -215,7 +219,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator *(Size arg1, float arg2)
         {
-            return arg1.Multiply(arg2);
+            return arg1?.Multiply(arg2);
         }
 
         /// <summary>
@@ -227,7 +231,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator /(Size arg1, Size arg2)
         {
-            return arg1.Divide(arg2);
+            return arg1?.Divide(arg2);
         }
 
         /// <summary>
@@ -239,7 +243,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static Size operator /(Size arg1, float arg2)
         {
-            return arg1.Divide(arg2);
+            return arg1?.Divide(arg2);
         }
 
         /// <summary>
@@ -310,6 +314,10 @@ namespace Tizen.NUI
             return ret;
         }
 
+        /// <inheritdoc/>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public object Clone() => new Size(Width, Height, Depth);
+
         /// <summary>
         /// The type cast operator, Size to Vector3.
         /// </summary>
@@ -317,7 +325,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static implicit operator Vector3(Size size)
         {
-            return new Vector3(size.Width, size.Height, size.Depth);
+            return new Vector3((float)size?.Width, (float)size.Height, (float)size.Depth);
         }
 
         /// <summary>
@@ -327,7 +335,7 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static implicit operator Size(Vector3 vec)
         {
-            return new Size(vec.Width, vec.Height, vec.Depth);
+            return new Size((int)vec?.Width, (int)vec.Height, (int)vec.Depth);
         }
 
         /// <summary>
@@ -339,9 +347,9 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static implicit operator Size(Size2D size2d)
         {
-            return new Size(size2d.Width, size2d.Height, 0);
+            return new Size((int)size2d?.Width, (int)size2d.Height, 0);
         }
-        
+
 
         internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
         {
@@ -355,38 +363,15 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
+        internal Size(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
-            swigCMemOwn = cMemoryOwn;
-            swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
         }
 
-        /// <summary>
-        /// Dispose.
-        /// </summary>
-        /// <since_tizen> 5 </since_tizen>
-        protected override void Dispose(DisposeTypes type)
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            if (disposed)
-            {
-                return;
-            }
-
-            //Release your own unmanaged resources here.
-            //You should not access any managed member here except static instance.
-            //because the execution order of Finalizes is non-deterministic.
-
-            if (swigCPtr.Handle != global::System.IntPtr.Zero)
-            {
-                if (swigCMemOwn)
-                {
-                    swigCMemOwn = false;
-                    Interop.Vector3.delete_Vector3(swigCPtr);
-                }
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-            }
-
-            base.Dispose(type);
+            Interop.Vector3.delete_Vector3(swigCPtr);
         }
 
         private Size Add(Size rhs)
@@ -445,7 +430,7 @@ namespace Tizen.NUI
             return ret;
         }
 
-        internal delegate void SizeChangedCallback(float width, float height, float depth);
+        internal delegate void SizeChangedCallback(float? width, float? height, float? depth);
 
         internal Size(SizeChangedCallback cb, float w, float h, float d) : this(Interop.Vector3.new_Vector3__SWIG_1(w, h, d), true)
         {
@@ -453,6 +438,10 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        internal Size(SizeChangedCallback cb, Size other) : this(cb, other.Width, other.Height, other.Depth)
+        {
+        }
+
         private SizeChangedCallback callback = null;
     }
 }