[NUI] fix CA2000 Warning for proterty
authorzhouleonlei <zhouleon.lei@samsung.com>
Fri, 8 Jan 2021 06:58:16 +0000 (14:58 +0800)
committerJiyun Yang <ji.yang@samsung.com>
Tue, 26 Jan 2021 08:27:40 +0000 (17:27 +0900)
src/Tizen.NUI/src/public/CustomViewRegistry.cs
src/Tizen.NUI/src/public/InputMethod.cs
src/Tizen.NUI/src/public/KeyFrames.cs
src/Tizen.NUI/src/public/Layer.cs
src/Tizen.NUI/src/public/Layouting/FlexLayout.cs
src/Tizen.NUI/src/public/PanGestureDetector.cs
src/Tizen.NUI/src/public/Path.cs
src/Tizen.NUI/src/public/Shader.cs
src/Tizen.NUI/src/public/Utility/TextPageUtil.cs

index b2b87a5..59937cd 100755 (executable)
@@ -359,8 +359,10 @@ namespace Tizen.NUI
                 System.Object val = view.GetType().GetProperty(propertyName).GetAccessors()[0].Invoke(view, null);
 
                 PropertyValue value = PropertyValue.CreateFromObject(val);
+                IntPtr ptr = (IntPtr)PropertyValue.getCPtr(value);
+                value.Dispose();
 
-                return (IntPtr)PropertyValue.getCPtr(value);
+                return ptr;
             }
             else
             {
@@ -431,6 +433,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, value);
                     }
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(Vector3)))
                 {
@@ -440,6 +443,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, value);
                     }
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(Vector4)))
                 {
@@ -450,6 +454,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, value);
                     }
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(Position)))
                 {
@@ -459,6 +464,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, value);
                     }
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(Size)))
                 {
@@ -466,8 +472,11 @@ namespace Tizen.NUI
                     ok = propValue.Get(value);
                     if (ok)
                     {
-                        propertyInfo.SetValue(view, new Size(value.Width, value.Height, value.Depth));
+                        Size sz = new Size(value.Width, value.Height, value.Depth);
+                        propertyInfo.SetValue(view, sz);
+                        sz.Dispose();
                     };
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(Color)))
                 {
@@ -478,6 +487,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, (Color)value);
                     };
+                    value.Dispose();
                 }
                 else if (type.Equals(typeof(PropertyMap)))
                 {
@@ -487,6 +497,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, map);
                     }
+                    map.Dispose();
                 }
                 else if (type.Equals(typeof(PropertyArray)))
                 {
@@ -496,6 +507,7 @@ namespace Tizen.NUI
                     {
                         propertyInfo.SetValue(view, array);
                     }
+                    array.Dispose();
                 }
                 else
                 {
@@ -510,6 +522,7 @@ namespace Tizen.NUI
             {
                 throw new global::System.InvalidOperationException("failed to find the control to write a property to: cptr = " + refObjectPtr);
             }
+            propValue.Dispose();
         }
     }
 }
index c9d68e0..f196885 100755 (executable)
@@ -390,7 +390,13 @@ namespace Tizen.NUI
         private PropertyMap ComposingInputMethodMap()
         {
             PropertyMap _outputMap = new PropertyMap();
-            if (_panelLayout != null) { _outputMap.Add("PANEL_LAYOUT", new PropertyValue((int)_panelLayout)); }
+            PropertyValue temp;
+            if (_panelLayout != null)
+            {
+                temp = new PropertyValue((int)_panelLayout);
+                _outputMap.Add("PANEL_LAYOUT", temp);
+                temp.Dispose();
+            }
             if (_actionButton != null)
             {
                 // Temporarily specify the values to match the types of ecore_imf.
@@ -398,10 +404,22 @@ namespace Tizen.NUI
                 else if (_actionButton == InputMethod.ActionButtonTitleType.Send) _actionButton = (InputMethod.ActionButtonTitleType.Send - 1); // 7
                 else if (_actionButton == InputMethod.ActionButtonTitleType.SignIn) _actionButton = (InputMethod.ActionButtonTitleType.SignIn - 1); // 8
                 else if (_actionButton == InputMethod.ActionButtonTitleType.Unspecified || _actionButton == InputMethod.ActionButtonTitleType.None) _actionButton = InputMethod.ActionButtonTitleType.Default;
-                _outputMap.Add("BUTTON_ACTION", new PropertyValue((int)_actionButton));
+                temp = new PropertyValue((int)_actionButton);
+                _outputMap.Add("BUTTON_ACTION", temp);
+                temp.Dispose();
+            }
+            if (_autoCapital != null)
+            {
+                temp = new PropertyValue((int)_autoCapital);
+                _outputMap.Add("AUTO_CAPITALIZE", temp);
+                temp.Dispose();
+            }
+            if (_variation != null)
+            {
+                temp = new PropertyValue((int)_variation);
+                _outputMap.Add("VARIATION", temp);
+                temp.Dispose();
             }
-            if (_autoCapital != null) { _outputMap.Add("AUTO_CAPITALIZE", new PropertyValue((int)_autoCapital)); }
-            if (_variation != null) { _outputMap.Add("VARIATION", new PropertyValue((int)_variation)); }
             return _outputMap;
         }
     }
index d3fd2de..905e532 100755 (executable)
@@ -53,6 +53,7 @@ namespace Tizen.NUI
         {
             PropertyValue val = PropertyValue.CreateFromObject(value);
             Add(progress, val);
+            val.Dispose();
         }
 
         /// <summary>
@@ -66,6 +67,7 @@ namespace Tizen.NUI
         {
             PropertyValue val = PropertyValue.CreateFromObject(value);
             Add(progress, val, alpha);
+            val.Dispose();
         }
 
         /// <summary>
index ba6c532..c7d4e58 100755 (executable)
@@ -155,12 +155,16 @@ namespace Tizen.NUI
             get
             {
                 float temp = 0.0f;
-                GetProperty(View.Property.OPACITY).Get(out temp);
+                var pValue = GetProperty(View.Property.OPACITY);
+                pValue.Get(out temp);
+                pValue.Dispose();
                 return temp;
             }
             set
             {
-                SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
+                var temp = new Tizen.NUI.PropertyValue(value);
+                SetProperty(View.Property.OPACITY, temp);
+                temp.Dispose();
             }
         }
 
@@ -173,12 +177,16 @@ namespace Tizen.NUI
             get
             {
                 bool temp = false;
-                GetProperty(View.Property.VISIBLE).Get(out temp);
+                var pValue = GetProperty(View.Property.VISIBLE);
+                pValue.Get(out temp);
+                pValue.Dispose();
                 return temp;
             }
             set
             {
-                SetProperty(View.Property.VISIBLE, new Tizen.NUI.PropertyValue(value));
+                var temp = new Tizen.NUI.PropertyValue(value);
+                SetProperty(View.Property.VISIBLE, temp);
+                temp.Dispose();
             }
         }
 
index a11d719..941b3da 100755 (executable)
@@ -811,6 +811,7 @@ namespace Tizen.NUI
                     // Get the frame for the child, start, top, end, bottom.
                     Vector4 frame = new Vector4(Interop.FlexLayout.GetNodeFrame(swigCPtr, childIndex), true);
                     childLayout.Layout(new LayoutLength(frame.X), new LayoutLength(frame.Y), new LayoutLength(frame.Z), new LayoutLength(frame.W));
+                    frame.Dispose();
                 }
             }
         }
index 05bbf89..8304f50 100755 (executable)
@@ -225,7 +225,9 @@ namespace Tizen.NUI
             get
             {
                 Vector2 temp = new Vector2(0.0f, 0.0f);
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenDisplacement).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenDisplacement);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
         }
@@ -240,7 +242,9 @@ namespace Tizen.NUI
             get
             {
                 Vector2 temp = new Vector2(0.0f, 0.0f);
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenVelocity).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.ScreenVelocity);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
         }
@@ -255,7 +259,9 @@ namespace Tizen.NUI
             get
             {
                 Vector2 temp = new Vector2(0.0f, 0.0f);
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalPosition).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalPosition);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
         }
@@ -270,7 +276,9 @@ namespace Tizen.NUI
             get
             {
                 Vector2 temp = new Vector2(0.0f, 0.0f);
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalDisplacement).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalDisplacement);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
         }
@@ -285,7 +293,9 @@ namespace Tizen.NUI
             get
             {
                 Vector2 temp = new Vector2(0.0f, 0.0f);
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalVelocity).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.LocalVelocity);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
         }
@@ -300,7 +310,9 @@ namespace Tizen.NUI
             get
             {
                 bool temp = false;
-                Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.PANNING).Get(out temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, PanGestureDetector.Property.PANNING);
+                pValue.Get(out temp);
+                pValue.Dispose();
                 return temp;
             }
         }
index 73846db..2d1416c 100755 (executable)
@@ -51,12 +51,16 @@ namespace Tizen.NUI
             get
             {
                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
-                Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.POINTS).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.POINTS);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
             set
             {
-                Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.POINTS, new Tizen.NUI.PropertyValue(value));
+                var temp = new Tizen.NUI.PropertyValue(value);
+                Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.POINTS, temp);
+                temp.Dispose();
             }
         }
 
@@ -69,12 +73,16 @@ namespace Tizen.NUI
             get
             {
                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
-                Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.ControlPoints).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, Path.Property.ControlPoints);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
             set
             {
-                Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.ControlPoints, new Tizen.NUI.PropertyValue(value));
+                var temp = new Tizen.NUI.PropertyValue(value);
+                Tizen.NUI.Object.SetProperty(SwigCPtr, Path.Property.ControlPoints, temp);
+                temp.Dispose();
             }
         }
 
index 424f0f5..e970b57 100755 (executable)
@@ -59,12 +59,16 @@ namespace Tizen.NUI
             get
             {
                 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
-                Tizen.NUI.Object.GetProperty(SwigCPtr, Shader.Property.PROGRAM).Get(temp);
+                var pValue = Tizen.NUI.Object.GetProperty(SwigCPtr, Shader.Property.PROGRAM);
+                pValue.Get(temp);
+                pValue.Dispose();
                 return temp;
             }
             set
             {
-                Tizen.NUI.Object.SetProperty(SwigCPtr, Shader.Property.PROGRAM, new Tizen.NUI.PropertyValue(value));
+                var temp = new Tizen.NUI.PropertyValue(value);
+                Tizen.NUI.Object.SetProperty(SwigCPtr, Shader.Property.PROGRAM, temp);
+                temp.Dispose();
             }
         }
 
index 7aa78b2..eaf0e0a 100755 (executable)
@@ -131,7 +131,9 @@ namespace Tizen.NUI.Utility
             uint count = cutOffIndexArray.Count();
             for (uint i = 0; i < count; i++)
             {
-                cutOffIndexArray.GetElementAt(i).Get(out cutOffIndex); // Gets the last index of text shown on the actual screen.
+                var temp = cutOffIndexArray.GetElementAt(i);
+                temp.Get(out cutOffIndex); // Gets the last index of text shown on the actual screen.
+                temp.Dispose();
 
                 // If markup is enabled, It should parse markup
                 if (label.EnableMarkup)