[NUI][XamlBuild] Fix Xaml issues reported by VD
authorFang Xiaohui <xiaohui.fang@samsung.com>
Fri, 18 Mar 2022 08:35:09 +0000 (16:35 +0800)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 20 Apr 2022 08:38:08 +0000 (17:38 +0900)
pkg/Tizen.NET.API9/xamlbuild/Tizen.NUI.XamlBuild.dll [new file with mode: 0644]
src/Tizen.NUI.XamlBuild/src/public/EXamlBuild/EXamlContext.cs
src/Tizen.NUI.XamlBuild/src/public/EXamlBuild/EXamlCreateObjectVisitor.cs
src/Tizen.NUI.XamlBuild/src/public/EXamlBuild/EXamlSetPropertiesVisitor.cs
src/Tizen.NUI.XamlBuild/src/public/XamlBuild/NodeILExtensions.cs
src/Tizen.NUI.XamlBuild/src/public/XamlBuild/TypeReferenceExtensions.cs
src/Tizen.NUI.XamlBuild/src/public/XamlBuild/XamlTask.cs
src/Tizen.NUI/src/internal/EXaml/Action/GetValueAction.cs
src/Tizen.NUI/src/internal/EXaml/Operation/CreateObject.cs

diff --git a/pkg/Tizen.NET.API9/xamlbuild/Tizen.NUI.XamlBuild.dll b/pkg/Tizen.NET.API9/xamlbuild/Tizen.NUI.XamlBuild.dll
new file mode 100644 (file)
index 0000000..cd0054a
Binary files /dev/null and b/pkg/Tizen.NET.API9/xamlbuild/Tizen.NUI.XamlBuild.dll differ
index 2c4de0c9257de4280f20a7c34425eaefb67ca807..7426f3b2956cac9247876694726eab50b49d3e36 100755 (executable)
@@ -622,7 +622,11 @@ namespace Tizen.NUI.EXaml.Build.Tasks
             //Fang: How to deal the Enum
             string ret = "";
 
-            if (null == valueObject)
+            if (System.Type.Missing == valueObject)
+            {
+                ret += "yy ";
+            }
+            else if (null == valueObject)
             {
                 ret += "zz ";
             }
index 9d76d017917bc01b5441b6d0964afb1b4c0f2ef8..e50364f67363d71fe5583f8f39ca5dc885399370 100755 (executable)
@@ -128,7 +128,7 @@ namespace Tizen.NUI.EXaml.Build.Tasks
                     VariableDefinition vardef = new VariableDefinition(typeref);
                     Context.Variables[node] = vardef;
 
-                    var argumentList = GetCtorXArguments(node, factoryCtorInfo.Parameters.Count);
+                    var argumentList = GetCtorXArguments(node, factoryCtorInfo.Parameters.Count, true);
                     Context.Values[node] = new EXamlCreateObject(Context, null, typedef, argumentList.ToArray());
                     return;
                 }
@@ -164,7 +164,7 @@ namespace Tizen.NUI.EXaml.Build.Tasks
                 VariableDefinition vardef = new VariableDefinition(typeref);
                 Context.Variables[node] = vardef;
 
-                var argumentList = GetCtorXArguments(node, factoryMethodInfo.Parameters.Count);
+                var argumentList = GetCtorXArguments(node, factoryMethodInfo.Parameters.Count, false);
                 Context.Values[node] = new EXamlCreateObject(Context, null, typedef, factoryMethodInfo, argumentList?.ToArray());
                 return;
             }
@@ -454,7 +454,7 @@ namespace Tizen.NUI.EXaml.Build.Tasks
             return true;
         }
 
-        List<object> GetCtorXArguments(ElementNode enode, int paramsCount)
+        List<object> GetCtorXArguments(ElementNode enode, int paramsCount, bool isConstructor)
         {
             if (!enode.Properties.ContainsKey(XmlName.xArguments))
             {
@@ -483,9 +483,12 @@ namespace Tizen.NUI.EXaml.Build.Tasks
                 argumentList.Add(Context.Values[arguments[i]]);
             }
 
-            for (int i = arguments.Count; i < paramsCount; i++)
+            if (!isConstructor)
             {
-                argumentList.Add(null);
+                for (int i = arguments.Count; i < paramsCount; i++)
+                {
+                    argumentList.Add(Type.Missing);
+                }
             }
 
             return argumentList;
index 737cb848cc562569b885e6b2a29b936f9507892a..5a990acd1621fb80368288730475be93aa415fe0 100755 (executable)
@@ -804,7 +804,15 @@ namespace Tizen.NUI.EXaml.Build.Tasks
             var realValue = context.Values[elementNode] as EXamlCreateObject;
             if (null != realValue)
             {
-                if (realValue.GetType().InheritsFromOrImplements(propertyType))
+                var valueTypeRef = realValue.GetType();
+                if (valueTypeRef.InheritsFromOrImplements(propertyType))
+                {
+                    return true;
+                }
+
+                var realTypeFromMarkupExtension = valueTypeRef.GetRealTypeIfIsMarkupExtension();
+
+                if (true == realTypeFromMarkupExtension?.InheritsFromOrImplements(propertyType))
                 {
                     return true;
                 }
index 7e46b32caff35855158a2804c56c536c2186f2f9..0345b9e8ab998e6301709842aaa8c3464f59ec13 100755 (executable)
@@ -434,12 +434,12 @@ namespace Tizen.NUI.Xaml.Build.Tasks
             else if (targetTypeRef.FullName == "System.UInt16")
                 yield return Instruction.Create(OpCodes.Ldc_I4, unchecked((int)UInt16.Parse(str, CultureInfo.InvariantCulture)));
             else if (targetTypeRef.FullName == "System.UInt32")
-                yield return Instruction.Create(OpCodes.Ldc_I8, unchecked((uint)UInt32.Parse(str, CultureInfo.InvariantCulture)));
+                yield return Instruction.Create(OpCodes.Ldc_I4, unchecked((int)UInt32.Parse(str, CultureInfo.InvariantCulture)));
             else if (targetTypeRef.FullName == "System.UInt64")
                 yield return Instruction.Create(OpCodes.Ldc_I8, unchecked((long)UInt64.Parse(str, CultureInfo.InvariantCulture)));
             else if (targetTypeRef.FullName == "System.Single")
             {
-                if (str.EndsWith("dp") || str.EndsWith("px"))
+                if (null != GetDPValueSubFix(str))
                 {
                     var insOfDPValue = GetDPValue(module, node, targetTypeRef, str);
 
index 4ff87b25ff2d591e48f558d6f94fbdcd57085b86..914afc4dcf1d47f168036623f97bb9172a68c718 100755 (executable)
@@ -290,6 +290,34 @@ namespace Tizen.NUI.Xaml.Build.Tasks
             return typeRef.InheritsFromOrImplements(baseClass);
         }
 
+        public static TypeReference GetRealTypeIfIsMarkupExtension(this TypeReference typeRef)
+        {
+            TypeReference ret = null;
+
+            var typeDef = typeRef.ResolveCached();
+
+            foreach (var @interface in typeDef.Interfaces)
+            {
+                if (@interface.InterfaceType is GenericInstanceType instanceType)
+                {
+                    if ("Tizen.NUI.Xaml.IMarkupExtension`1" == instanceType.ElementType.FullName
+                        &&
+                        1 == instanceType.GenericArguments.Count)
+                    {
+                        ret = instanceType.GenericArguments[0];
+                        break;
+                    }
+                }
+            }
+
+            if (null == ret)
+            {
+                ret = typeDef.BaseType?.GetRealTypeIfIsMarkupExtension();
+            }
+
+            return ret;
+        }
+
         static CustomAttribute GetCustomAttribute(this TypeReference typeRef, TypeReference attribute)
         {
             var typeDef = typeRef.ResolveCached();
index dcb2dc52fa2c548e1068962891dc0e2d60e1325b..7c9498b3af6a2b133aacb95c5e93842a7d359638 100755 (executable)
@@ -25,11 +25,6 @@ using Microsoft.Build.Utilities;
 
 using Mono.Cecil;
 
-using Tizen.NUI.Xaml;
-using Mono.Cecil.Cil;
-using Mono.Cecil.Pdb;
-using Mono.Cecil.Mdb;
-
 namespace Tizen.NUI.Xaml.Build.Tasks
 {
     [LoadInSeparateAppDomain]
index b7866004112b9f450456a30f2d000e87e0289a09..f22cd94b274bd21b60f1cec88dbc65a5b764a714 100755 (executable)
@@ -167,6 +167,10 @@ namespace Tizen.NUI.EXaml
                         Value = valueString[0];
                         break;
 
+                    case 'y':
+                        Value = Type.Missing;
+                        break;
+
                     case 'z':
                         Value = null;
                         break;
index ff0e890e4744d2c4618616b6ee88ae6636459a76..a5477eb8cb9691d7a968a93b19214d41513f9bc0 100755 (executable)
@@ -16,6 +16,7 @@
  */
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Reflection;
 using System.Text;
 using Tizen.NUI.BaseComponents;
@@ -83,7 +84,7 @@ namespace Tizen.NUI.EXaml
 
                     if (null == xFactoryMethod)
                     {
-                        obj = Activator.CreateInstance(type, paramList.ToArray());
+                        obj = Activator.CreateInstance(type, BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance | BindingFlags.OptionalParamBinding, null, paramList.ToArray(), CultureInfo.CurrentCulture);
                     }
                     else
                     {