I am trying to use Mono.Cecil to cross reference all methods with their
source file. Unfortunately many of the method names in the MonoSymbolFile
file are blank. i.e. MonoSymbolFile.Methods[0].GetRealName() returns
null. See code example below. I am only getting 116 methods with names out
of 7000+ in the project (All 7000 are in the Methods list, they just have
no name!!). Some are frustratingly populated.
I also tried using the AssemblyDefinition, to get some value to cross
reference with the Symbol information. The AssemblyDefinition has each
method name available. I cannot see any way to do this.
There is very little info on Cecil.
Any help would be greatly appreciated. My late nights and lack of sleep
working on this problem is becoming an issue :-)
[CODE]
// Loads the assembly from the start arguments
AssemblyDefinition asm =
AssemblyDefinition.ReadAssembly(assembly);
// Iterates through the assembly's modules, aspects of the
program
foreach (ModuleDefinition mod in asm.Modules)
{
MonoSymbolFile symFile = MonoSymbolFile.ReadSymbolFile(mod);
// Iterates through the Methods
foreach (var m in symFile.Methods)
{
if (!string.IsNullOrEmpty(m.GetRealName()))
{
file.WriteLine(m.GetRealName() + " > " +
m.CompileUnit.SourceFile.FileName);
Debug.Log(m.GetRealName() + " > " +
m.CompileUnit.SourceFile.FileName);
}
}
}
[/CODE]
[CODE]
public static void Main(string monoAssembly)
{
var readerParameters = new ReaderParameters { ReadSymbols =
true };
// var assemblyDefinition =
AssemblyDefinition.ReadAssembly(args, readerParameters);
// Loads the assembly from the start arguments
AssemblyDefinition asm =
AssemblyDefinition.ReadAssembly(monoAssembly, readerParameters);
//symFile.FileName = monoAssembly + "mdb";
// Iterates through the assembly's modules, aspects of the
program
foreach (ModuleDefinition mod in asm.Modules)
{
_mod = mod;
Log(mod.Name);
// Iterates through the classes of the assembly
foreach (TypeDefinition td in mod.Types)
{
// Writes the types name,
DoType(td);
}
_mod = null;
}
Console.ReadLine();
}
static void DoType(TypeDefinition td)
{
foundModule = false;
if (td.Name.Length > 5)
if (td.Name.Substring(0, 6).ToUpper() == "LEVELM")
{
foundModule = true;
foreach (TypeDefinition ntd in td.NestedTypes)
{
// Repeat if the class has nested classes.
DoType(ntd);
}
foreach (MethodDefinition md in td.Methods)
{
// Log the content to the console
Log(td.Name + " > " + md.Name);
//MethodBody mbody = new MethodBody(md);
//if (mbody != null)
//{
//}
}
}
}
[/CODE]
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.