Author: atsushi
Date: 2006-11-14 09:02:51 -0500 (Tue, 14 Nov 2006)
New Revision: 67845

Modified:
   trunk/mcs/tools/sgen/ChangeLog
   trunk/mcs/tools/sgen/sgen.cs
Log:
2006-11-14  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * sgen.cs : some fixes.
          - catch Assembly.LoadFrom() errors.
          - command line options were working only with /, not with --.
          - --type (/t) are to limit target types, so skip non-target types.



Modified: trunk/mcs/tools/sgen/ChangeLog
===================================================================
--- trunk/mcs/tools/sgen/ChangeLog      2006-11-14 13:57:58 UTC (rev 67844)
+++ trunk/mcs/tools/sgen/ChangeLog      2006-11-14 14:02:51 UTC (rev 67845)
@@ -1,3 +1,10 @@
+2006-11-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * sgen.cs : some fixes.
+         - catch Assembly.LoadFrom() errors.
+         - command line options were working only with /, not with --.
+         - --type (/t) are to limit target types, so skip non-target types.
+
 2004-07-10  Lluis Sanchez Gual  <[EMAIL PROTECTED]>
 
        * sgen.cs, Makefile, sgen.exe.sources: New files

Modified: trunk/mcs/tools/sgen/sgen.cs
===================================================================
--- trunk/mcs/tools/sgen/sgen.cs        2006-11-14 13:57:58 UTC (rev 67844)
+++ trunk/mcs/tools/sgen/sgen.cs        2006-11-14 14:02:51 UTC (rev 67845)
@@ -1,10 +1,12 @@
 // 
-// genxs.cs
+// sgen.cs
 //
-// Author:
+// Authors:
 //   Lluis Sanchez Gual ([EMAIL PROTECTED])
+//   Atsushi Enomoto ([EMAIL PROTECTED])
 //
 // Copyright (C) 2003 Ximian, Inc.
+// Copyright (C) 2006 Novell, Inc.
 //
 
 using System;
@@ -78,10 +80,15 @@
                }
                catch {}
                
-               if (asm == null)
-                       asm = Assembly.LoadFrom (assembly);
-                       
-                       
+               if (asm == null) {
+                       try {
+                               asm = Assembly.LoadFrom (assembly);
+                       } catch {
+                               Console.WriteLine ("Specified assembly cannot 
be loaded.");
+                               Console.WriteLine ();
+                               return 1;
+                       }
+               }
                ArrayList userTypes = new ArrayList ();
                ArrayList maps = new ArrayList ();
                XmlReflectionImporter imp = new XmlReflectionImporter ();
@@ -92,13 +99,14 @@
                foreach (Type t in asm.GetTypes())
                {
                        try {
+                               if (types != null && !types.Contains 
(t.ToString()))
+                                       continue;
+
                                maps.Add (imp.ImportTypeMapping (t));
-                               if (types == null || types.Contains 
(t.ToString())) {
-                                       userTypes.Add (t);
-                                       if (verbose) Console.WriteLine (" - " + 
t);
-                               }
+                               userTypes.Add (t);
+                               if (verbose) Console.WriteLine (" - " + t);
                        }
-                       catch (Exception ex)
+                       catch (NotImplementedException ex)
                        {
                                if (verbose) {
                                        Console.WriteLine (" - Warning: 
ignoring '" + t + "'");
@@ -142,7 +150,7 @@
 #else
        public int Run (string[] args)
        {
-               Console.WriteLine ("This tool is only supported in Mono 2.0");
+               Console.WriteLine ("This tool is only supported in 2.0 
profile.");
                return 1;
        }
 
@@ -152,18 +160,18 @@
        {
                foreach (string arg in args)
                {
-                       
-                       if (!arg.StartsWith ("--") && !arg.StartsWith ("/"))
+                       int index = arg.Length > 2 && arg [0] == '-' && arg [1] 
== '-' ? 2 : -1;
+                       index = index >= 0 ? index : arg.Length > 0 && arg [0] 
== '/' ? 1 : -1;
+                       if (index < 0)
                        {
                                assembly = arg;
                                continue;
                        }
                        
-                       int i = arg.IndexOf (":");
+                       int i = arg.IndexOf (':', index);
                        if (i == -1) i = arg.Length;
-                       string op = arg.Substring (1,i-1);
-                       string param = (i<arg.Length-1) ? arg.Substring (i+1) : 
"";
-                       
+                       string op = arg.Substring (index, i - index);
+                       string param = (i < arg.Length - index) ? arg.Substring 
(i + 1) : "";
                        if (op == "assembly" || op == "a") {
                                assembly = param;
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to