Show the warning log when preload skip (#230)
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Tue, 26 May 2020 21:34:47 +0000 (06:34 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Tue, 26 May 2020 21:34:47 +0000 (06:34 +0900)
Change-Id: Ifd9a28c26cecbb996c9452db3bb57930e0311224

Managed/Tizen.Runtime/Preloader.cs

index f523fc1..f0ed99e 100644 (file)
@@ -41,6 +41,7 @@ namespace Tizen.Runtime
 
                 try
                 {
+                    Console.WriteLine("Start preload : " + fileName);
                     BindingFlags bindingFlag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
                     foreach (string line in File.ReadLines(path))
                     {
@@ -63,40 +64,35 @@ namespace Tizen.Runtime
                             typenameStr = typenameStr.Replace("." + methodStr + parenthesis, "");
                         }
 
-                        try
+                        if (assemblyStr == "" || typenameStr == "" || typenameStr.Contains(parenthesis))
                         {
-                            if (assemblyStr == "")
-                                continue;
+                            Console.WriteLine("[Warning] Skip the '" + line + "' in " + fileName);
+                            continue;
+                        }
 
+                        try
+                        {
                             Assembly asm = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(assemblyStr));
-                            if (asm == null || typenameStr == "")
-                                continue;
-
                             Type type = asm.GetType(typenameStr);
-                            if (type == null || methodStr == "")
-                                continue;
-
-                            MethodInfo method = type.GetMethod(methodStr, bindingFlag);
-                            if (method == null)
-                                continue;
+                            if (type == null)
+                                Console.WriteLine("[Warning] Check the '" + line + "' in " + fileName);
 
-                            method.Invoke(null, null);
+                            if (methodStr != "")
+                            {
+                                MethodInfo method = type.GetMethod(methodStr, bindingFlag);
+                                method.Invoke(null, null);
+                            }
                         }
-                        catch (Exception e)
+                        catch
                         {
-                            Console.WriteLine(e.ToString());
-                            Console.WriteLine("[ERROR] Failed to '" + line + "' preload");
+                            Console.WriteLine("[Error] Fail the '" + line + "' in " + fileName);
                         }
                     }
                 }
                 catch (IOException e)
                 {
                     Console.WriteLine(e.ToString());
-                    Console.WriteLine("[ERROR] Failed to " + path + " file open");
-                }
-                finally
-                {
-                    Console.WriteLine("Success to preload : " + fileName);
+                    Console.WriteLine("[Error] Failed to open file : " + fileName);
                 }
             }