From: YeongJong Lee Date: Thu, 21 Jan 2021 06:04:44 +0000 (+0900) Subject: [NUI] add type check validation in ApplyPropertiesVisitor (#2489) X-Git-Tag: accepted/tizen/unified/20210219.040944~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=697416a806a69fbe3dff748e612ba82e8a108dbe;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] add type check validation in ApplyPropertiesVisitor (#2489) Co-authored-by: Jiyun Yang --- diff --git a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs index 714925d..bc8201c 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs @@ -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;