diff options
Diffstat (limited to 'Test/Mono.Cecil.Tests')
-rw-r--r-- | Test/Mono.Cecil.Tests/ILProcessorTests.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Test/Mono.Cecil.Tests/ILProcessorTests.cs b/Test/Mono.Cecil.Tests/ILProcessorTests.cs index 8836615..4eecfe3 100644 --- a/Test/Mono.Cecil.Tests/ILProcessorTests.cs +++ b/Test/Mono.Cecil.Tests/ILProcessorTests.cs @@ -5,6 +5,7 @@ using System.Linq; using Mono.Cecil; using Mono.Cecil.Cil; +using Mono.Cecil.Mdb; using Mono.Cecil.Pdb; using NUnit.Framework; @@ -41,6 +42,28 @@ namespace Mono.Cecil.Tests { } [Test] + public void InsertBeforeIssue697 () + { + var parameters = new ReaderParameters { SymbolReaderProvider = new MdbReaderProvider () }; + using (var module = GetResourceModule ("Issue697.dll", parameters)) + { + var pathGetterDef = module.GetTypes () + .SelectMany (t => t.Methods) + .First (m => m.Name.Equals ("get_Defer")); + + var body = pathGetterDef.Body; + var worker = body.GetILProcessor (); + var initialBody = body.Instructions.ToList (); + var head = initialBody.First (); + var opcode = worker.Create (OpCodes.Ldc_I4_1); + worker.InsertBefore (head, opcode); + worker.InsertBefore (head, worker.Create (OpCodes.Ret)); + initialBody.ForEach (worker.Remove); + AssertOpCodeSequence (new [] { OpCodes.Ldc_I4_1, OpCodes.Ret }, pathGetterDef.body); + } + } + + [Test] public void InsertAfter () { var method = CreateTestMethod (OpCodes.Ldloc_0, OpCodes.Ldloc_2, OpCodes.Ldloc_3); |