[EXaml] Fix SVACE issue (#2964)
authorAdunFang <30402408+AdunFang@users.noreply.github.com>
Wed, 28 Apr 2021 07:19:38 +0000 (15:19 +0800)
committerGitHub <noreply@github.com>
Wed, 28 Apr 2021 07:19:38 +0000 (16:19 +0900)
src/Tizen.NUI/src/internal/EXaml/LoadEXaml.cs
src/Tizen.NUI/src/internal/EXaml/Operation/GetObjectByProperty.cs
src/Tizen.NUI/src/internal/EXaml/Operation/SetProperty.cs

index 2afc688..9ff8fe8 100755 (executable)
@@ -45,7 +45,6 @@ namespace Tizen.NUI.EXaml
 
             foreach (char c in xaml)
             {
-                //Console.Write(c);
                 if (null == currentOp)
                 {
                     switch (c)
index e337d9e..3dffd8c 100755 (executable)
@@ -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<object>());
+            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<object>());
+            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);
         }
 
index 1e3e92e..2cb35bc 100755 (executable)
@@ -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
             {