[NUI] Fix CA1044
authorDongsug Song <dongsug.song@samsung.com>
Wed, 9 Dec 2020 11:56:39 +0000 (20:56 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 21 Dec 2020 12:05:23 +0000 (21:05 +0900)
- https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1044
- Get accessors provide read access to a property and set accessors provide write access. Although it is acceptable and often necessary to have a read-only property, the design guidelines prohibit the use of write-only properties. This is because letting a user set a value and then preventing the user from viewing the value does not provide any security. Also, without read access, the state of shared objects cannot be viewed, which limits their usefulness.

src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/KeyValue.cs
src/Tizen.NUI/src/public/XamlBinding/Transition.cs

index 935b826..ade387f 100755 (executable)
@@ -51,6 +51,7 @@ namespace Tizen.NUI.BaseComponents
         private ViewStyle viewStyle;
         private bool themeChangeSensitive = false;
         private bool excludeLayouting = false;
+        private LayoutTransition layoutTransition;
 
         private ControlState controlStates = ControlState.Normal;
 
@@ -521,6 +522,18 @@ namespace Tizen.NUI.BaseComponents
         /// <since_tizen> 3 </since_tizen>
         public string TooltipText
         {
+            get
+            {
+                using (var propertyValue = GetProperty(Property.TOOLTIP))
+                {
+                    if (propertyValue != null && propertyValue.Get(out string retrivedValue))
+                    {
+                        return retrivedValue;
+                    }
+                    NUILog.Error($"[ERROR] Fail to get TooltipText! Return error MSG (error to get TooltipText)!");
+                    return "error to get TooltipText";
+                }
+            }
             set
             {
                 SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
@@ -2069,6 +2082,10 @@ namespace Tizen.NUI.BaseComponents
         /// <since_tizen> 6 </since_tizen>
         public LayoutTransition LayoutTransition
         {
+            get
+            {
+                return layoutTransition;
+            }
             set
             {
                 if (value == null)
@@ -2083,6 +2100,8 @@ namespace Tizen.NUI.BaseComponents
                 LayoutTransitionsHelper.AddTransitionForCondition(layoutTransitions, value.Condition, value, true);
 
                 AttachTransitionsToChildren(value);
+
+                layoutTransition = value;
             }
         }
 
index 87c5445..ade27e2 100755 (executable)
@@ -124,6 +124,15 @@ namespace Tizen.NUI
         /// </summary>
         public int IntergerValue
         {
+            get
+            {
+                if (TrueValue.Get(out int retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get IntergerValue from PropertyValue! Return ErrorValue(-1)!");
+                return -1;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -135,6 +144,15 @@ namespace Tizen.NUI
         /// </summary>
         public bool BooleanValue
         {
+            get
+            {
+                if (TrueValue.Get(out bool retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get BooleanValue from PropertyValue! Return false!");
+                return false;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -146,6 +164,15 @@ namespace Tizen.NUI
         /// </summary>
         public float SingleValue
         {
+            get
+            {
+                if (TrueValue.Get(out float retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SingleValue from PropertyValue! Return ErrorValue(-1)!");
+                return -1;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -157,6 +184,15 @@ namespace Tizen.NUI
         /// </summary>
         public string StringValue
         {
+            get
+            {
+                if (TrueValue.Get(out string retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SingleValue from PropertyValue! Return ErrorString(error to get StringValue)!");
+                return "error to get StringValue";
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -168,6 +204,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector2 Vector2Value
         {
+            get
+            {
+                Vector2 retrivedValue = new Vector2(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector2Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -179,6 +225,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector3 Vector3Value
         {
+            get
+            {
+                Vector3 retrivedValue = new Vector3(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector3Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -190,6 +246,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector4 Vector4Value
         {
+            get
+            {
+                Vector4 retrivedValue = new Vector4(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector4Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -201,6 +267,16 @@ namespace Tizen.NUI
         /// </summary>
         public Position PositionValue
         {
+            get
+            {
+                Position retrivedValue = new Position(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PositionValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -212,6 +288,16 @@ namespace Tizen.NUI
         /// </summary>
         public Position2D Position2DValue
         {
+            get
+            {
+                Position2D retrivedValue = new Position2D(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Position2DValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -223,6 +309,16 @@ namespace Tizen.NUI
         /// </summary>
         public Size SizeValue
         {
+            get
+            {
+                Size retrivedValue = new Size(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SizeValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -234,6 +330,16 @@ namespace Tizen.NUI
         /// </summary>
         public Size2D Size2DValue
         {
+            get
+            {
+                Size2D retrivedValue = new Size2D(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Size2DValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -245,6 +351,16 @@ namespace Tizen.NUI
         /// </summary>
         public Color ColorValue
         {
+            get
+            {
+                Color retrivedValue = new Color(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get ColorValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -256,6 +372,16 @@ namespace Tizen.NUI
         /// </summary>
         public Rectangle RectangleValue
         {
+            get
+            {
+                Rectangle retrivedValue = new Rectangle(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RectangleValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -267,6 +393,16 @@ namespace Tizen.NUI
         /// </summary>
         public Rotation RotationValue
         {
+            get
+            {
+                Rotation retrivedValue = new Rotation();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RotationValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -278,6 +414,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector2 RelativeVector2Value
         {
+            get
+            {
+                RelativeVector2 retrivedValue = new RelativeVector2(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector2Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -289,6 +435,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector3 RelativeVector3Value
         {
+            get
+            {
+                RelativeVector3 retrivedValue = new RelativeVector3(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector3Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -300,6 +456,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector4 RelativeVector4Value
         {
+            get
+            {
+                RelativeVector4 retrivedValue = new RelativeVector4(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector4Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -311,6 +477,16 @@ namespace Tizen.NUI
         /// </summary>
         public Extents ExtentsValue
         {
+            get
+            {
+                Extents retrivedValue = new Extents(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get ExtentsValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -322,6 +498,16 @@ namespace Tizen.NUI
         /// </summary>
         public PropertyArray PropertyArrayValue
         {
+            get
+            {
+                PropertyArray retrivedValue = new PropertyArray();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PropertyArrayValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -333,6 +519,16 @@ namespace Tizen.NUI
         /// </summary>
         public PropertyMap PropertyMapValue
         {
+            get
+            {
+                PropertyMap retrivedValue = new PropertyMap();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PropertyMapValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
index d983cf9..b4e7d72 100755 (executable)
@@ -124,19 +124,19 @@ namespace Tizen.NUI
 
         private Dictionary<string, AnimationBehavior> behaviors = new Dictionary<string, AnimationBehavior>();
 
-        /// <since_tizen> 5 </since_tizen>
-        /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        /// <summary>
+        /// Hidden-API (Inhouse-API).
+        /// Convert previous "public AnimationBehavior[] Behaviors" property to method.
+        /// </summary>
+        /// <param name="Behaviors">Array of AnimationBehavior type</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public AnimationBehavior[] Behaviors
+        public void SetBehaviors(AnimationBehavior[] Behaviors)
         {
-            set
+            if (null != Behaviors)
             {
-                if (null != value)
+                foreach (AnimationBehavior behavior in Behaviors)
                 {
-                    foreach (AnimationBehavior behavior in value)
-                    {
-                        behaviors.Add(behavior.Key, behavior);
-                    }
+                    behaviors.Add(behavior.Key, behavior);
                 }
             }
         }