Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorSteve Gilham <SteveGilham@users.noreply.github.com>2020-10-15 20:01:25 +0300
committerGitHub <noreply@github.com>2020-10-15 20:01:25 +0300
commit77f7bd1266371728b6bf4c2f0474231d4a2e93f0 (patch)
treebb4be7a94d0273c38a27b7f9641cc9f07a76add0 /Test
parent24c6ce49fa4eeb237ebb2ecea0e23c0f74ec7c2c (diff)
A minimum tactical fix for issue #697 (#698)
* Provoke the issue * Minimum fix (cherry picked from commit 0f23047c62027e10206a5d0dbb81cba6f2dc260f) * Revert "Provoke the issue" This reverts commit 1a2275b7f6704298fa386fa416c91bb09f0368bf. * Add unit test (cherry picked from commit 185ba884111e30cfb84aeb64f00324d995cfdd35) * Use existing infrastructure * Quick fix Co-authored-by: Jb Evain <jb@evain.net>
Diffstat (limited to 'Test')
-rw-r--r--Test/Mono.Cecil.Tests/ILProcessorTests.cs23
-rw-r--r--Test/Resources/assemblies/Issue697.dllbin0 -> 6656 bytes
-rw-r--r--Test/Resources/assemblies/Issue697.dll.mdbbin0 -> 1233 bytes
3 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);
diff --git a/Test/Resources/assemblies/Issue697.dll b/Test/Resources/assemblies/Issue697.dll
new file mode 100644
index 0000000..6310d6c
--- /dev/null
+++ b/Test/Resources/assemblies/Issue697.dll
Binary files differ
diff --git a/Test/Resources/assemblies/Issue697.dll.mdb b/Test/Resources/assemblies/Issue697.dll.mdb
new file mode 100644
index 0000000..862bd59
--- /dev/null
+++ b/Test/Resources/assemblies/Issue697.dll.mdb
Binary files differ