From b157f908ecdf37fb536454117824958a1e3276c1 Mon Sep 17 00:00:00 2001 From: AdunFang <30402408+AdunFang@users.noreply.github.com> Date: Wed, 28 Apr 2021 15:19:38 +0800 Subject: [PATCH] [EXaml] Fix SVACE issue (#2964) --- src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs | 1 - .../EXaml/Operation/GetObjectByProperty.cs | 17 ++++++++++++++- .../src/internal/EXaml/Operation/SetProperty.cs | 24 +++++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs b/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs index 2afc688..9ff8fe8 100755 --- a/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs +++ b/src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs @@ -45,7 +45,6 @@ namespace Tizen.NUI.EXaml foreach (char c in xaml) { - //Console.Write(c); if (null == currentOp) { switch (c) diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs index e337d9e..3dffd8c 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs @@ -38,9 +38,24 @@ namespace Tizen.NUI.EXaml public void Do() { var instance = globalDataList.GatheredInstances[instanceIndex]; + if (null == instance) + { + throw new Exception(String.Format("Can't get instance by index {0}", instanceIndex)); + } + var property = instance.GetType().GetProperty(propertyName); - var @object = property.GetMethod.Invoke(instance, Array.Empty()); + if (null == property) + { + throw new Exception(String.Format("Can't find property {0} in type {1}", propertyName, instance.GetType().FullName)); + } + + var @object = property.GetMethod?.Invoke(instance, Array.Empty()); + if (null == @object) + { + throw new Exception(String.Format("Can't get object of property {0} in type {1}", propertyName, instance.GetType().FullName)); + } + globalDataList.ObjectsFromProperty.Add(@object); } diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs index 1e3e92e..2cb35bc 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs @@ -39,12 +39,34 @@ namespace Tizen.NUI.EXaml public void Do() { object instance = globalDataList.GatheredInstances[instanceIndex]; + if (null == instance) + { + throw new Exception(String.Format("Can't get instance by index {0}", instanceIndex)); + } + var property = globalDataList.GatheredProperties[propertyIndex]; + if (null == property) + { + throw new Exception(String.Format("Can't find property {0} in type {1}", property.Name, instance.GetType().FullName)); + } + + if (null == property.SetMethod) + { + throw new Exception(String.Format("Property {0} hasn't set method", property.Name)); + } + if (value is Instance) { int valueIndex = (value as Instance).Index; - property.SetMethod.Invoke(instance, new object[] { globalDataList.GatheredInstances[valueIndex] }); + object realValue = globalDataList.GatheredInstances[valueIndex]; + + if (null == realValue) + { + throw new Exception(String.Format("Can't get instance of value by index {0}", valueIndex)); + } + + property.SetMethod.Invoke(instance, new object[] { realValue }); } else { -- 2.7.4