94b2861243
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
61 lines
1.0 KiB
C#
61 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
|
|
using Mono.Cecil.Mdb;
|
|
|
|
namespace Mono.Cecil.Debug {
|
|
|
|
interface IFoo { }
|
|
interface IBar : IFoo { }
|
|
|
|
abstract class Bar : IBar { }
|
|
|
|
delegate void Action ();
|
|
|
|
class Program {
|
|
|
|
static int Answer ()
|
|
{
|
|
return 42;
|
|
}
|
|
|
|
static void Main (string [] args)
|
|
{
|
|
Time (() => {
|
|
var module = GetCurrentModule ();
|
|
|
|
module.Write ("dbg.rt.exe");
|
|
});
|
|
}
|
|
|
|
static void Time (Action action)
|
|
{
|
|
var watch = new Stopwatch ();
|
|
watch.Start ();
|
|
action ();
|
|
watch.Stop ();
|
|
|
|
Console.WriteLine ("Elapsed: {0}", watch.Elapsed);
|
|
}
|
|
|
|
//static TypeDefinition GetCurrentType ()
|
|
//{
|
|
// return GetCurrentModule ().Types [typeof (Program).FullName];
|
|
//}
|
|
|
|
static ModuleDefinition GetModule (string module)
|
|
{
|
|
return ModuleDefinition.ReadModule (module, new ReaderParameters {
|
|
ReadingMode = ReadingMode.Deferred,
|
|
});
|
|
}
|
|
|
|
static ModuleDefinition GetCurrentModule ()
|
|
{
|
|
return GetModule (typeof (object).Module.FullyQualifiedName);
|
|
}
|
|
}
|
|
}
|