[NUI] remove build warning messages
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 14 Dec 2021 08:10:35 +0000 (17:10 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 21 Dec 2021 09:32:16 +0000 (18:32 +0900)
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs
test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextMapHelper.cs

index 557029d..9277145 100755 (executable)
@@ -1734,7 +1734,7 @@ namespace Tizen.NUI.BaseComponents
                     map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
                 
                 if (TextMapHelper.IsValue(map, 2))
-                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2, Color.Black));
+                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2));
                 
                 if (TextMapHelper.IsValue(map, 3))
                     map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
index 7db8aff..664100c 100755 (executable)
@@ -1892,7 +1892,7 @@ namespace Tizen.NUI.BaseComponents
                     map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
                 
                 if (TextMapHelper.IsValue(map, 2))
-                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2, Color.Black));
+                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2));
                 
                 if (TextMapHelper.IsValue(map, 3))
                     map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
index c0e9890..0773f2a 100644 (file)
@@ -177,12 +177,14 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static FontStyle GetFontStyleStruct(PropertyMap map)
         {
-            var defaultValue = "none";
-
             var fontStyle = new FontStyle();
-            fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
-            fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
-            fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
+            if (null != map)
+            {
+                var defaultValue = "none";
+                fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
+                fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
+                fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
+            }
 
             return fontStyle;
         }
@@ -216,11 +218,13 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static InputFilter GetInputFilterStruct(PropertyMap map)
         {
-            var defaultValue = "";
-
             var inputFilter = new InputFilter();
-            inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
-            inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
+            if (null != map)
+            {
+                var defaultValue = "";
+                inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
+                inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
+            }
 
             return inputFilter;
         }
@@ -257,9 +261,12 @@ namespace Tizen.NUI.BaseComponents
         public static Underline GetUnderlineStruct(PropertyMap map)
         {
             var underline = new Underline();
-            underline.Enable = GetBoolFromMap(map, "enable", false);
-            underline.Color = GetColorFromMap(map, "color", Color.Black);
-            underline.Height = GetFloatFromMap(map, "height", 0.0f);
+            if (null != map)
+            {
+                underline.Enable = GetBoolFromMap(map, "enable", false);
+                underline.Color = GetColorFromMap(map, "color");
+                underline.Height = GetFloatFromMap(map, "height", 0.0f);
+            }
 
             return underline;
         }
@@ -296,13 +303,13 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map)
         {
-            var defaultValue = new Vector2(0, 0);
-
             var shadow = new Tizen.NUI.Text.Shadow();
-            shadow.Offset = GetVector2FromMap(map, "offset", defaultValue);
-            defaultValue.Dispose();
-            shadow.Color = GetColorFromMap(map, "color", Color.Black);
-            shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
+            if (null != map)
+            {
+                shadow.Offset = GetVector2FromMap(map, "offset");
+                shadow.Color = GetColorFromMap(map, "color");
+                shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
+            }
 
             return shadow;
         }
@@ -337,8 +344,11 @@ namespace Tizen.NUI.BaseComponents
         public static Outline GetOutlineStruct(PropertyMap map)
         {
             var outline = new Outline();
-            outline.Color = GetColorFromMap(map, "color", Color.Black);
-            outline.Width = GetFloatFromMap(map, "width", 0.0f);
+            if (null != map)
+            {
+                outline.Color = GetColorFromMap(map, "color");
+                outline.Width = GetFloatFromMap(map, "width", 0.0f);
+            }
 
             return outline;
         }
@@ -377,15 +387,17 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static TextFit GetTextFitStruct(PropertyMap map)
         {
-            var defaultValue = "PointSize";
-
             var textFit = new TextFit();
-            textFit.Enable = GetBoolFromMap(map, "enable", false);
-            textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
-            textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
-            textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
-            textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
-            textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
+            if (null != map)
+            {
+                var defaultValue = "PointSize";
+                textFit.Enable = GetBoolFromMap(map, "enable", false);
+                textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
+                textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
+                textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
+                textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
+                textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
+            }
 
             return textFit;
         }
@@ -415,9 +427,11 @@ namespace Tizen.NUI.BaseComponents
 
             if (placeholder.FontStyle != null)
             {
-                var fontStyleValue = new PropertyValue(GetFontStyleMap((FontStyle)placeholder.FontStyle));
-                map.Add("fontStyle", fontStyleValue);
-                fontStyleValue.Dispose();
+                using (var fontStyleMap = GetFontStyleMap((FontStyle)placeholder.FontStyle))
+                using (var fontStyleValue = new PropertyValue(fontStyleMap))
+                {
+                    map.Add("fontStyle", fontStyleValue);
+                }
             }
 
             if (placeholder.PointSize != null && placeholder.PixelSize != null)
@@ -443,19 +457,22 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static Placeholder GetPlaceholderStruct(PropertyMap map)
         {
-            var defaultText = "";
-            var defaultFontStyle = new PropertyMap();
-
             var placeholder = new Placeholder();
-            placeholder.Text = GetStringFromMap(map, 0, defaultText);
-            placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
-            placeholder.Color = GetColorFromMap(map, 2, Color.Black);
-            placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
-            placeholder.FontStyle = GetFontStyleStruct(GetMapFromMap(map, 4, defaultFontStyle));
-            defaultFontStyle.Dispose();
-            placeholder.PointSize = GetNullableFloatFromMap(map, 5);
-            placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
-            placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
+            if (null != map)
+            {
+                var defaultText = "";
+                placeholder.Text = GetStringFromMap(map, 0, defaultText);
+                placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
+                placeholder.Color = GetColorFromMap(map, 2);
+                placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
+                using (var fontStyleMap = GetMapFromMap(map, 4))
+                {
+                    placeholder.FontStyle = GetFontStyleStruct(fontStyleMap);
+                }
+                placeholder.PointSize = GetNullableFloatFromMap(map, 5);
+                placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
+                placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
+            }
 
             return placeholder;
         }
@@ -494,17 +511,19 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static HiddenInput GetHiddenInputStruct(PropertyMap map)
         {
-            int defaultVlaue = 0;
-
             var hiddenInput = new HiddenInput();
-            hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
+            if (null != map)
+            {
+                int defaultVlaue = 0;
+                hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
 
-            int? substituteCharacter = GetNullableIntFromMap(map, 1);
-            if (substituteCharacter != null)
-                hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
+                int? substituteCharacter = GetNullableIntFromMap(map, 1);
+                if (substituteCharacter != null)
+                    hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
 
-            hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
-            hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
+                hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
+                hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
+            }
 
             return hiddenInput;
         }
@@ -534,8 +553,11 @@ namespace Tizen.NUI.BaseComponents
             var defaultValue = "";
 
             var selectionHandleImage = new SelectionHandleImage();
-            selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
-            selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
+            if (null != leftImageMap)
+                selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
+            
+            if (null != rightImageMap)
+                selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
 
             return selectionHandleImage;
         }
@@ -555,100 +577,136 @@ namespace Tizen.NUI.BaseComponents
         internal static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
         {
             string value = defaultValue;
-            map.Find(0, key)?.Get(out value);
+            using (var propertyValue = map.Find(0, key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
         internal static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
         {
             string value = defaultValue;
-            map.Find(key)?.Get(out value);
+            using (var propertyValue = map.Find(key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
         internal static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
         {
             bool value = defaultValue;
-            map.Find(0, key)?.Get(out value);
+            using (var propertyValue = map.Find(0, key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
         internal static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
         {
             bool value = defaultValue;
-            map.Find(key)?.Get(out value);
+            using (var propertyValue = map.Find(key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
         internal static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
         {
             int value = defaultValue;
-            map.Find(key)?.Get(out value);
+            using (var propertyValue = map.Find(key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
         internal static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
         {
             float value = defaultValue;
-            map.Find(0, key)?.Get(out value);
+            using (var propertyValue = map.Find(0, key))
+            {
+                if (null != propertyValue) propertyValue.Get(out value);
+            }
             return value;
         }
 
-        internal static Color GetColorFromMap(PropertyMap map, string key, Color defaultValue)
+        internal static Color GetColorFromMap(PropertyMap map, string key)
         {
-            Color value = new Color(defaultValue);
-            map.Find(0, key)?.Get(value);
+            Color value = new Color();
+            using (var propertyValue = map.Find(0, key))
+            {
+                if (null != propertyValue) propertyValue.Get(value);
+            }
             return value;
         }
 
-        internal static Color GetColorFromMap(PropertyMap map, int key, Color defaultValue)
+        internal static Color GetColorFromMap(PropertyMap map, int key)
         {
-            Color value = new Color(defaultValue);
-            map.Find(key)?.Get(value);
+            Color value = new Color();
+            using (var propertyValue = map.Find(key))
+            {
+                if (null != propertyValue) propertyValue.Get(value);
+            }
             return value;
         }
 
-        internal static Vector2 GetVector2FromMap(PropertyMap map, string key, Vector2 defaultValue)
+        internal static Vector2 GetVector2FromMap(PropertyMap map, string key)
         {
-            Vector2 value = new Vector2(defaultValue);
-            map.Find(0, key)?.Get(value);
+            Vector2 value = new Vector2();
+            using (var propertyValue = map.Find(0, key))
+            {
+                if (null != propertyValue) propertyValue.Get(value);
+            }
             return value;
         }
 
-        internal static PropertyMap GetMapFromMap(PropertyMap map, int key, PropertyMap defaultValue)
+        internal static PropertyMap GetMapFromMap(PropertyMap map, int key)
         {
-            PropertyMap value = new PropertyMap(defaultValue);
-            map.Find(key)?.Get(value);
+            PropertyMap value = new PropertyMap();
+            using (var propertyValue = map.Find(key))
+            {
+                if (null != propertyValue) propertyValue.Get(value);
+            }
             return value;
         }
 
         internal static int? GetNullableIntFromMap(PropertyMap map, int key)
         {
-            PropertyValue propertyValue = map.Find(key);
-            if (propertyValue == null)
-                return null;
+            using (var propertyValue = map.Find(key))
+            {
+                if (propertyValue == null)
+                    return null;
 
-            propertyValue.Get(out int value);
-            return value;
+                propertyValue.Get(out int value);
+                return value;
+            }
         }
 
         internal static float? GetNullableFloatFromMap(PropertyMap map, int key)
         {
-            PropertyValue propertyValue = map.Find(key);
-            if (propertyValue == null)
-                return null;
+            using (var propertyValue = map.Find(key))
+            {
+                if (propertyValue == null)
+                    return null;
 
-            propertyValue.Get(out float value);
-            return value;
+                propertyValue.Get(out float value);
+                return value;
+            }
         }
 
         internal static bool IsValue(PropertyMap map, int key)
         {
-            PropertyValue propertyValue = map.Find(key);
-            if (propertyValue == null)
-                return false;
+            using (var propertyValue = map.Find(key))
+            {
+                if (propertyValue == null)
+                    return false;
 
-            return true;
+                return true;
+            }
         }
     }
 }
\ No newline at end of file
index 8f41207..3e910b8 100644 (file)
@@ -954,38 +954,24 @@ namespace Tizen.NUI.Devel.Tests
             var stringKey = "color";
             var stringInvalidKey = "invalidKey";
             var intKey = 1;
-            var intInvalidKey = 10;
             var value = new Color(1.0f, 0.2f, 0.5f, 1.0f);
-            var defaultValue = Color.Black;
 
             var map = new PropertyMap();
             map.Add(stringKey, new PropertyValue(value));
             map.Add(intKey, new PropertyValue(value));
 
-            var result = TextMapHelper.GetColorFromMap(map, stringKey, defaultValue);
+            var result = TextMapHelper.GetColorFromMap(map, stringKey);
             Assert.AreEqual(value.R, result.R, "Should be equal!");
             Assert.AreEqual(value.G, result.G, "Should be equal!");
             Assert.AreEqual(value.B, result.B, "Should be equal!");
             Assert.AreEqual(value.A, result.A, "Should be equal!");
 
-            result = TextMapHelper.GetColorFromMap(map, stringInvalidKey, defaultValue);
-            Assert.AreEqual(defaultValue.R, result.R, "Should be equal!");
-            Assert.AreEqual(defaultValue.G, result.G, "Should be equal!");
-            Assert.AreEqual(defaultValue.B, result.B, "Should be equal!");
-            Assert.AreEqual(defaultValue.A, result.A, "Should be equal!");
-
-            result = TextMapHelper.GetColorFromMap(map, intKey, defaultValue);
+            result = TextMapHelper.GetColorFromMap(map, intKey);
             Assert.AreEqual(value.R, result.R, "Should be equal!");
             Assert.AreEqual(value.G, result.G, "Should be equal!");
             Assert.AreEqual(value.B, result.B, "Should be equal!");
             Assert.AreEqual(value.A, result.A, "Should be equal!");
 
-            result = TextMapHelper.GetColorFromMap(map, intInvalidKey, defaultValue);
-            Assert.AreEqual(defaultValue.R, result.R, "Should be equal!");
-            Assert.AreEqual(defaultValue.G, result.G, "Should be equal!");
-            Assert.AreEqual(defaultValue.B, result.B, "Should be equal!");
-            Assert.AreEqual(defaultValue.A, result.A, "Should be equal!");
-
             tlog.Debug(tag, $"TextMapHelperGetColorFromMap END (OK)");
         }
 
@@ -1003,19 +989,14 @@ namespace Tizen.NUI.Devel.Tests
             var stringKey = "position";
             var stringInvalidKey = "invalidKey";
             var value = new Vector2(3, 10);
-            var defaultValue = new Vector2(0, 0);
 
             var map = new PropertyMap();
             map.Add(stringKey, new PropertyValue(value));
 
-            var result = TextMapHelper.GetVector2FromMap(map, stringKey, defaultValue);
+            var result = TextMapHelper.GetVector2FromMap(map, stringKey);
             Assert.AreEqual(value.X, result.X, "Should be equal!");
             Assert.AreEqual(value.Y, result.Y, "Should be equal!");
 
-            result = TextMapHelper.GetVector2FromMap(map, stringInvalidKey, defaultValue);
-            Assert.AreEqual(defaultValue.X, result.X, "Should be equal!");
-            Assert.AreEqual(defaultValue.Y, result.Y, "Should be equal!");
-
             tlog.Debug(tag, $"TextMapHelperGetVector2FromMap END (OK)");
         }
 
@@ -1031,29 +1012,19 @@ namespace Tizen.NUI.Devel.Tests
             tlog.Debug(tag, $"TextMapHelperGetMapFromMap START");
 
             var intKey = 1;
-            var intInvalidKey = 10;
             var value = new PropertyMap();
             value.Add("width", new PropertyValue(10));
             value.Add("height", new PropertyValue(20));
-            var defaultValue = new PropertyMap();
-            defaultValue.Add("width", new PropertyValue(0));
-            defaultValue.Add("height", new PropertyValue(0));
 
             var map = new PropertyMap();
             map.Add(intKey, new PropertyValue(value));
 
-            var result = TextMapHelper.GetMapFromMap(map, intKey, defaultValue);
+            var result = TextMapHelper.GetMapFromMap(map, intKey);
             result.Find(0, "width").Get(out int width);
             result.Find(0, "height").Get(out int height);
             Assert.AreEqual(10, width, "Should be equal!");
             Assert.AreEqual(20, height, "Should be equal!");
 
-            result = TextMapHelper.GetMapFromMap(map, intInvalidKey, defaultValue);
-            result.Find(0, "width").Get(out int defaultWidth);
-            result.Find(0, "height").Get(out int defaultHeight);
-            Assert.AreEqual(0, defaultWidth, "Should be equal!");
-            Assert.AreEqual(0, defaultHeight, "Should be equal!");
-
             tlog.Debug(tag, $"TextMapHelperGetMapFromMap END (OK)");
         }