[NUI] add type check validation in ApplyPropertiesVisitor (#2489)
authorYeongJong Lee <cleanlyj@naver.com>
Thu, 21 Jan 2021 06:04:44 +0000 (15:04 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Tue, 26 Jan 2021 08:27:40 +0000 (17:27 +0900)
Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs

index 714925d..bc8201c 100755 (executable)
@@ -375,7 +375,7 @@ namespace Tizen.NUI.Xaml
 
             //Call TrySetProperty first and then TrySetValue to keep the code logic consistent whether it is through xaml or code.
             //If we can assign that value to a normal property, let's do it
-            if (xpe == null && TrySetProperty(xamlelement, localName, value, serviceProvider, context, out xpe))
+            if (xpe == null && TrySetProperty(xamlelement, property, localName, value, serviceProvider, context, out xpe))
                 return;
 
             //If it's a BindableProberty, SetValue
@@ -560,7 +560,7 @@ namespace Tizen.NUI.Xaml
             return true;
         }
 
-        static bool TrySetProperty(object element, string localName, object value, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
+        static bool TrySetProperty(object element, BindableProperty property, string localName, object value, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
         {
             exception = null;
 
@@ -573,6 +573,9 @@ namespace Tizen.NUI.Xaml
             if (!IsVisibleFrom(setter, context.RootElement))
                 return false;
 
+            if (propertyInfo.PropertyType != property.ReturnType)
+                return false;
+
             if (serviceProvider != null && serviceProvider.IProvideValueTarget != null)
                 ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = propertyInfo;