/
Program.cs
60 lines (46 loc) · 1.04 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 (ModuleDefinition).Module.FullyQualifiedName);
}
}
}