[corlib] ParseNumber.StringToInt now check for overflows.
[mono.git] / mcs / tools / cil-strip / cilstrip.cs
1 //
2 // mono-cil-strip
3 //
4 // Author(s):
5 //   Jb Evain (jbevain@novell.com)
6 //
7 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
8 //
9
10 using System;
11 using System.IO;
12 using System.Reflection;
13
14 using Mono.Cecil;
15
16 namespace Mono.CilStripper {
17
18         class Program {
19
20                 static void Main (string [] args)
21                 {
22                         Header ();
23
24                         if (args.Length == 0)
25                                 Usage ();
26
27                         string file = args [0];
28                         string output = args.Length > 1 ? args [1] : file;
29
30                         try {
31                                 AssemblyDefinition assembly = AssemblyFactory.GetAssembly (file);
32                                 StripAssembly (assembly, output);
33
34                                 if (file != output)
35                                         Console.WriteLine ("Assembly {0} stripped out into {1}", file, output);
36                                 else
37                                         Console.WriteLine ("Assembly {0} stripped", file);
38                         } catch (TargetInvocationException tie) {
39                                 Console.WriteLine ("Error: {0}", tie.InnerException);
40                         } catch (Exception e) {
41                                 Console.WriteLine ("Error: {0}", e);
42                         }
43                 }
44
45                 static void StripAssembly (AssemblyDefinition assembly, string output)
46                 {
47                         AssemblyStripper.StripAssembly (assembly, output);
48                 }
49
50                 static void Header ()
51                 {
52                         Console.WriteLine ("Mono CIL Stripper");
53                         Console.WriteLine ();
54                 }
55
56                 static void Usage ()
57                 {
58                         Console.WriteLine ("Usage: mono-cil-strip file [output]");
59                         Environment.Exit (1);
60                 }
61         }
62 }