get list of routines

get a list of all subroutines in a module (whatever a "module" is in the given language)

Download reflection.zip

Synopsis:

reflection.cs


reflection.cs

Synopsis
//WARNING UNTESTED
using System;
using System.Reflection;

class reflectionSnippet
{
  public static int Main()
  {
    dumpMethods(@"\projects\debug\snippets\cssnippets.dll");
    return 0;
  }
  public static void dumpMethods(string assemblyPath)
  {
    Assembly a = Assembly.LoadFrom(assemblyPath);
    foreach (Type type in a.GetTypes())
    {
      MethodInfo[] methods = type.GetMethods();
      foreach (MethodInfo mi in methods)
      {
        //verify 'void fn()' signature
        if (!mi.ReturnType.ToString().Equals("System.Void")) continue;
        ParameterInfo[] pi = mi.GetParameters();
        if (pi.Length != 0) continue;
        Console.WriteLine("method: {0}", mi.Name);
         
        //object y = a.createinstance("x.y.z");
        //mi.Invoke(theTest, null);
      }
    }
  }
}






Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001,2002,2003,2004,2005,2006,2007