[EXaml] Fix build erro of Array/Extents in EXaml
authorFang Xiaohui <xiaohui.fang@samsung.com>
Fri, 4 Nov 2022 05:44:11 +0000 (13:44 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 10 Nov 2022 01:25:11 +0000 (10:25 +0900)
pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.dll
src/Tizen.NUI.XamlBuild/src/public/EXamlBuild/EXamlSetPropertiesVisitor.cs
src/Tizen.NUI.XamlBuild/src/public/XamlBuild/NUIXamlCTask.cs
src/Tizen.NUI/src/internal/EXaml/Action/RootAction.cs
src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/EXaml/Operation/CreateResourceDictionary.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/EXaml/Utility/EXamlOperationType.cs

index c1232d4..b855cff 100644 (file)
Binary files a/pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.dll and b/pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.dll differ
index 81088c4..be707b6 100755 (executable)
@@ -1059,6 +1059,11 @@ namespace Tizen.NUI.EXaml.Build.Tasks
 
         static bool CanAddToDictionary(EXamlCreateObject parent, TypeReference collectionType, IElementNode node, IXmlLineInfo lineInfo, EXamlContext context)
         {
+            if ("Tizen.NUI.Xaml.Build.Tasks.ArrayExtension" == collectionType.FullName)
+            {
+                return false;
+            }
+
             var typeOfDictionary = collectionType.GetRealTypeOfDictionary();
 
             if (null != typeOfDictionary)
@@ -1187,6 +1192,11 @@ namespace Tizen.NUI.EXaml.Build.Tasks
             var typeref = parentContext.Module.ImportReference(rootnode.XmlType.GetTypeReference(XmlTypeExtensions.ModeOfGetType.Both, parentContext.Module, rootnode));
             var visitorContext = new EXamlContext(typeref.ResolveCached(), typeref.Module, parentContext.EmbeddedResourceNameSpace);
 
+            foreach (var pair in parentContext.resourceDictionary)
+            {
+                visitorContext.resourceDictionary.Add(pair.Key, pair.Value);
+            }
+
             rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null);
             rootnode.Accept(new EXamlExpandMarkupsVisitor(visitorContext), null);
             rootnode.Accept(new PruneIgnoredNodesVisitor(), null);
index 3f06f0e..4a100f0 100755 (executable)
@@ -217,6 +217,13 @@ namespace Tizen.NUI.Xaml.Build.Tasks
                 ReadSymbols = NeedDebug,
             };
 
+            if (UseInjection)
+            {
+                XamlOptimization = 1;
+            }
+
+            LoggingHelper.LogWarning($"XamlOptimization is {XamlOptimization}.");
+
             using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(System.IO.Path.GetFullPath(Assembly), readerParameters))
             {
                 if (null != XamlFilePath)
@@ -294,13 +301,6 @@ namespace Tizen.NUI.Xaml.Build.Tasks
                         bool currentRetOfType = false;
                         IList<Exception> currentExceptionsOfType = null;
 
-                        if (UseInjection)
-                        {
-                            XamlOptimization = 1;
-                        }
-
-                        LoggingHelper.LogWarning($"XamlOptimization is {XamlOptimization}.");
-
                         if (0 == XamlOptimization)
                         {
                             currentRetOfType = true;
index 30051cf..f209abe 100755 (executable)
@@ -238,6 +238,18 @@ namespace Tizen.NUI.EXaml
                 var operation = new CreateDPObject(globalDataList, opInfo);
                 globalDataList.Operations.Add(operation);
             };
+
+            createOperations[(int)EXamlOperationType.AddToDictionary] = (GlobalDataList globalDataList, List<object> opInfo) =>
+            {
+                var operation = new AddToDictionary(globalDataList, opInfo);
+                globalDataList.Operations.Add(operation);
+            };
+
+            createOperations[(int)EXamlOperationType.CreateResourceDictionary] = (GlobalDataList globalDataList, List<object> opInfo) =>
+            {
+                var operation = new CreateResourceDictionary(globalDataList, opInfo);
+                globalDataList.Operations.Add(operation);
+            };
         }
     }
 }
diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/AddToDictionary.cs
new file mode 100755 (executable)
index 0000000..ddd7eee
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Binding.Internals;
+
+namespace Tizen.NUI.EXaml
+{
+    internal class AddToDictionary : Operation
+    {
+        public AddToDictionary(GlobalDataList globalDataList, List<object> operationInfo)
+        {
+            parentIndex = (int)operationInfo[0];
+            key = operationInfo[1];
+            value = operationInfo[2];
+            this.globalDataList = globalDataList;
+        }
+
+        private GlobalDataList globalDataList;
+
+        public void Do()
+        {
+            object dict = globalDataList.GatheredInstances[parentIndex];
+
+            var type = dict.GetType();
+            var method = type.GetMethods().FirstOrDefault(m => m.Name == "Add");
+
+            method.Invoke(dict, new object[] { key, value });
+        }
+
+        private int parentIndex;
+        private object key;
+        private object value;
+    }
+}
diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/CreateResourceDictionary.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/CreateResourceDictionary.cs
new file mode 100755 (executable)
index 0000000..19df2f9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.NUI.Binding;
+
+namespace Tizen.NUI.EXaml
+{
+    class CreateResourceDictionary : Operation
+    {
+        public CreateResourceDictionary(GlobalDataList globalDataList, List<object> operationInfo)
+        {
+            typeIndex = (int)operationInfo[0];
+            indexRangeOfContent = ((int)operationInfo[1], (int)operationInfo[2]);
+            this.globalDataList = globalDataList;
+        }
+
+        private GlobalDataList globalDataList;
+        private int typeIndex;
+        private (int, int) indexRangeOfContent;
+
+        public void Do()
+        {
+            var content = globalDataList.LongStrings.Substring(indexRangeOfContent.Item1, indexRangeOfContent.Item2 - indexRangeOfContent.Item1 + 1);
+            var resourceDictionary = EXamlExtensions.CreateObjectFromEXaml(content) as ResourceDictionary;
+
+            globalDataList.GatheredInstances.Add(resourceDictionary);
+
+            if (null == globalDataList.Root)
+            {
+                globalDataList.Root = resourceDictionary;
+            }
+        }
+    }
+}
index 4e5c598..e561022 100755 (executable)
@@ -48,6 +48,8 @@ namespace Tizen.NUI.EXaml
         RegisterXName,
         GetLongString,
         CreateDPObject,
+        AddToDictionary,
+        CreateResourceDictionary,
         MAX
     }
 }