/// /// DumpAssembly - dump the contents of a .Net assembly for perusal /// /// Copyright (C) 2005 Michael Davies /// All Rights Reserved. /// /// Why? Because people don't provide documentation to their assemblies /// even though the invite you to use them. Hmmph. This just makes /// it easy to verify class and method signatures - it still doesn't help /// you where the method is poorly named and you need to guess what it /// does. /// /// This program is free software; you can redistribute it and/or /// modify it under the terms of the GNU General Public License as /// published by the Free Software Foundation; either version 2 of the /// License, or (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, but /// WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with this program; if not, write to the Free Software /// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA /// 02111-1307, USA. /// /// 2005-03-06 Michael Davies /// * Version 0.0.1 - Initial Version. /// 2005-03-07 Michael Davies /// * Version 0.0.2 - Fixed tyop in multi-assembly handling. /// using System; using System.Reflection; namespace DumpAssembly { class DumpAssembly { // The Software version number static string Version = "0.0.2"; static int Main(string[] args) { if (args.Length == 0) { Console.Error.WriteLine("Usage: DumpAssembly [-h] ..."); Console.Error.WriteLine("Exiting..."); return -1; } if ((args[0] == "-h") || (args[0] == "--help")) { Console.Error.WriteLine("DumpAssembly: Dump the contents of the supplied .Net assemblies"); Console.Error.WriteLine("Usage: DumpAssembly [-h] ..."); Console.Error.WriteLine("Copyright (C) 2005 Michael Davies "); Console.Error.WriteLine("All Rights Reserved. Version {0}", Version); Console.Error.WriteLine(); Console.Error.WriteLine("This program is free software; you can redistribute it and/or"); Console.Error.WriteLine("modify it under the terms of the GNU General Public License"); Console.Error.WriteLine("as published by the Free Software Foundation; either version 2"); Console.Error.WriteLine("of the License, or (at your option) any later version."); Console.Error.WriteLine(); Console.Error.WriteLine("This program is distributed in the hope that it will be useful,"); Console.Error.WriteLine("but WITHOUT ANY WARRANTY; without even the implied warranty of"); Console.Error.WriteLine("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"); Console.Error.WriteLine("GNU General Public License for more details."); Console.Error.WriteLine(); Console.Error.WriteLine("You should have received a copy of the GNU General Public License"); Console.Error.WriteLine("along with this program; if not, write to the Free Software"); Console.Error.WriteLine("Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."); Console.Error.WriteLine(); Console.Error.WriteLine("Exiting..."); return -2; } foreach (string Filename in args) { Console.WriteLine("\nAssembly: {0}", Filename); Assembly assembly = Assembly.LoadFrom(Filename); foreach (Type type in assembly.GetTypes ()) { // There be dragons amongst the classes // TODO: Expand the list of types handled to print out // more assembly information. if (type.IsClass) { Console.WriteLine (" Class: {0}", type.FullName); // Now iterate through the properties of the object foreach(PropertyInfo prop in type.GetProperties()) { // Dump type and name of the property Console.WriteLine(" Prop:" + prop.PropertyType.FullName.ToString() + " " + prop.Name.ToString()); } // Now iterate through the fields of the object foreach(FieldInfo f in type.GetFields()) { // Dump type and name of the field Console.WriteLine(" Field:" + f.FieldType.FullName.ToString() + " " + f.Name.ToString()); } // Now iterate through the methods of the object foreach(MethodInfo m in type.GetMethods()) { // Dump type and name of the method Console.Write(" Method:" + m.Name.ToString() + " ("); // Formatting only 1 parameter specially ParameterInfo[] pma = m.GetParameters(); int i = 1; foreach (ParameterInfo pm in pma) { Console.Write(pm.ParameterType + " " + pm.Name); if (i < pma.Length) { Console.Write(", "); } i++; } // Special non-formatting of void return types string retType = m.ReturnType.ToString(); if (retType != "System.Void") { Console.WriteLine(") returns " + retType); } else { Console.WriteLine(")"); } } } } } return 0; } } } // This file has been zigned! See http://michaeldavies.org/zign-tools // zign-version: 0.9.4 // zign-hashes: MD5, SHA-1 // -----BEGIN PGP SIGNED MESSAGE----- // Hash: SHA1 // // 71b5b8cb9bad0487ddc1fa1d93b98b60b9f8f97962b47d5a57cef48fb3bf9e084fdba3f4 // -----BEGIN PGP SIGNATURE----- // Version: GnuPG v1.4.7 (Darwin) // // iD8DBQFHmzkM7kkvCQqp1vwRApoVAJ97Opct+M0nnjBkWBiyFFjYBfTv6QCfZxPM // PMiKNXjIykNPhEi5DO+2oqU= // =+Pyb // -----END PGP SIGNATURE----- // zign: Protecting you since 2007 :-) //