I have a list of about 25 types found in the Microsoft.NET assembly mscorlib.dll, where I need to extract the IL signatures of the class and its members. I want one file for each type, with each signature on one line. So, for example, take the type
System.Collections.Generic.Comparer<T>
I want to extract the following from the assembly for this type (there are some private members that I do not need, but I can handle this manually if necessary).
.class public abstract auto ansi serializable beforefieldinit System.Collections.Generic.Comparer`1<T> extends System.Object implements System.Collections.IComparer, class System.Collections.Generic.IComparer`1<!T> .method family hidebysig specialname rtspecialname instance void .ctor() cil managed .method public hidebysig newslot abstract virtual instance int32 Compare(!T x, !T y) cil managed .method private hidebysig newslot virtual final instance int32 System.Collections.IComparer.Compare(object x, object y) cil managed .property class System.Collections.Generic.Comparer`1<!T> Default() { .get class System.Collections.Generic.Comparer`1<!T> System.Collections.Generic.Comparer`1::get_Default() }
So, I thought of four ways to achieve this:
Manually cut and paste each signature from each type manually into text files from ildasm (either directly or through a dump of mscorlib.dll). Some of the types are quite long, so this can become tedious. And this is definitely not a good long-term solution if I need to do more.
Write a tool that uses Reflection to try to get all the signatures. At a high level, I thought about using something like psuedo-code [1] below.
Write a tool that uses string parsing on an IL ildasm dump to find types and get signatures
Use an existing tool to complete the task.
Does anyone know of an existing tool or mechanism that can help me accomplish my task? If not, any suggestions on which direction to go to get such an instrument? And if you have any ideas on how to do this, I would be happy to hear them.
[1]
System.Reflection.GetType(string) Type.GetMethods() For each item in MethodInfo, GetMethodBody() GetILAsByteArray().ToString() Determine a way to get just the signature from the IL
source share