| 1 |
using Mono.Cecil.Mdb; |
| 2 |
|
| 3 |
using NUnit.Framework; |
| 4 |
|
| 5 |
namespace Mono.Cecil.Tests { |
| 6 |
|
| 7 |
[TestFixture] |
| 8 |
public class MdbTests : BaseTestFixture { |
| 9 |
|
| 10 |
[Test] |
| 11 |
public void MdbWithJustLineInfo () |
| 12 |
{ |
| 13 |
TestModule ("simplemdb.exe", module => { |
| 14 |
var type = module.GetType ("Program"); |
| 15 |
var main = type.GetMethod ("Main"); |
| 16 |
|
| 17 |
AssertCode (@" |
| 18 |
.locals init (System.Int32 i) |
| 19 |
.line 6,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' |
| 20 |
IL_0000: ldc.i4.0 |
| 21 |
IL_0001: stloc.0 |
| 22 |
.line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' |
| 23 |
IL_0002: br IL_0013 |
| 24 |
.line 8,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' |
| 25 |
IL_0007: ldarg.0 |
| 26 |
IL_0008: ldloc.0 |
| 27 |
IL_0009: ldelem.ref |
| 28 |
IL_000a: call System.Void Program::Print(System.String) |
| 29 |
.line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' |
| 30 |
IL_000f: ldloc.0 |
| 31 |
IL_0010: ldc.i4.1 |
| 32 |
IL_0011: add |
| 33 |
IL_0012: stloc.0 |
| 34 |
IL_0013: ldloc.0 |
| 35 |
IL_0014: ldarg.0 |
| 36 |
IL_0015: ldlen |
| 37 |
IL_0016: conv.i4 |
| 38 |
IL_0017: blt IL_0007 |
| 39 |
.line 10,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' |
| 40 |
IL_001c: ldc.i4.0 |
| 41 |
IL_001d: ret |
| 42 |
", main); |
| 43 |
}, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); |
| 44 |
} |
| 45 |
|
| 46 |
[Test] |
| 47 |
public void RoundTripCoreLib () |
| 48 |
{ |
| 49 |
TestModule ("mscorlib.dll", module => { |
| 50 |
var type = module.GetType ("System.IO.__Error"); |
| 51 |
var method = type.GetMethod ("WinIOError"); |
| 52 |
|
| 53 |
Assert.IsNotNull (method.Body); |
| 54 |
}, verify: !Platform.OnMono, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); |
| 55 |
} |
| 56 |
|
| 57 |
[Test] |
| 58 |
public void PartialClass () |
| 59 |
{ |
| 60 |
TestModule ("BreakpointTest.Portable.dll", module => { |
| 61 |
var type = module.GetType ("BreakpointTest.Portable.TestService/<MyAsyncAction1>c__async3"); |
| 62 |
var method = type.GetMethod ("MoveNext"); |
| 63 |
|
| 64 |
Assert.IsNotNull (method); |
| 65 |
|
| 66 |
var info = method.DebugInformation; |
| 67 |
Assert.AreEqual (5, info.SequencePoints.Count); |
| 68 |
foreach (var sp in info.SequencePoints) |
| 69 |
Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.Actions.cs", sp.Document.Url); |
| 70 |
|
| 71 |
type = module.GetType("BreakpointTest.Portable.TestService/<MyAsyncAction2>c__async2"); |
| 72 |
method = type.GetMethod("MoveNext"); |
| 73 |
|
| 74 |
Assert.IsNotNull(method); |
| 75 |
|
| 76 |
info = method.DebugInformation; |
| 77 |
Assert.AreEqual(5, info.SequencePoints.Count); |
| 78 |
foreach (var sp in info.SequencePoints) |
| 79 |
Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.cs", sp.Document.Url); |
| 80 |
|
| 81 |
}, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); |
| 82 |
} |
| 83 |
} |
| 84 |
} |