X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftools%2Fsgen%2Fsgen.cs;h=eb4e83acb594e007f08a037b9b633693b077b192;hb=4956113701fa44b33acd0ee5d31eb1e74af5fe30;hp=c4f0d7386d3e5e191cfd1723d2a044799628e6ca;hpb=07ec1253c277856bdbb74213e2defc8ed23cf8e3;p=mono.git diff --git a/mcs/tools/sgen/sgen.cs b/mcs/tools/sgen/sgen.cs index c4f0d7386d3..eb4e83acb59 100644 --- a/mcs/tools/sgen/sgen.cs +++ b/mcs/tools/sgen/sgen.cs @@ -1,10 +1,12 @@ // -// genxs.cs +// sgen.cs // -// Author: +// Authors: // Lluis Sanchez Gual (lluis@ximian.com) +// Atsushi Enomoto (atsushi@ximian.com) // // Copyright (C) 2003 Ximian, Inc. +// Copyright (C) 2006 Novell, Inc. // using System; @@ -78,35 +80,59 @@ public class Driver } 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 (); if (verbose) Console.WriteLine ("Generating serializer for the following types:"); - - foreach (Type t in asm.GetTypes()) - { - try { - maps.Add (imp.ImportTypeMapping (t)); - if (types == null || types.Contains (t.ToString())) { + + if (types == null) { + foreach (Type t in asm.GetTypes ()) { + try { + maps.Add (imp.ImportTypeMapping (t)); userTypes.Add (t); - if (verbose) Console.WriteLine (" - " + t); + if (verbose) + Console.WriteLine( " - " + t ); + } catch (InvalidOperationException ex) { + if (verbose) + Console.WriteLine (" - Warning: " + ex.Message); + } catch (NotImplementedException ex) { + if (verbose) { + Console.WriteLine (" - Warning: ignoring '" + t + "'"); + Console.WriteLine (" " + ex.Message); + } } } - catch (Exception ex) - { - if (verbose) { - Console.WriteLine (" - Warning: ignoring '" + t + "'"); - Console.WriteLine (" " + ex.Message); + } else { + foreach (string type in types) { + try { + Type t = asm.GetType (type); + maps.Add (imp.ImportTypeMapping (t)); + userTypes.Add (t); + if (verbose) + Console.WriteLine (" - " + t); + } catch (InvalidOperationException ex) { + if (verbose) + Console.WriteLine (" - Warning: " + ex.Message); + } catch (NotImplementedException ex) { + if (verbose) { + Console.WriteLine (" - Warning: ignoring '" + type + "'"); + Console.WriteLine (" " + ex.Message); + } } } } - + if (verbose) Console.WriteLine (); @@ -142,7 +168,7 @@ public class Driver #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 +178,18 @@ public class Driver { 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