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:
authorJb Evain <jbevain@gmail.com>2014-12-02 12:34:42 +0300
committerJb Evain <jbevain@gmail.com>2014-12-02 12:35:50 +0300
commit4290e9f449901181e0b405e26ba2e32386e4a754 (patch)
treee7ad4070b2b1483d760fa4de51b27a920835046a /Test
parent83adf058f662a50f1e88ee61c974a544eeb3ea80 (diff)
Protect access of modules of unattached definitions
Diffstat (limited to 'Test')
-rw-r--r--Test/Mono.Cecil.Tests/EventTests.cs9
-rw-r--r--Test/Mono.Cecil.Tests/FieldTests.cs9
-rw-r--r--Test/Mono.Cecil.Tests/MethodBodyTests.cs13
-rw-r--r--Test/Mono.Cecil.Tests/PropertyTests.cs8
4 files changed, 39 insertions, 0 deletions
diff --git a/Test/Mono.Cecil.Tests/EventTests.cs b/Test/Mono.Cecil.Tests/EventTests.cs
index 9762601..cb9064b 100644
--- a/Test/Mono.Cecil.Tests/EventTests.cs
+++ b/Test/Mono.Cecil.Tests/EventTests.cs
@@ -66,5 +66,14 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual ("fang_Handler", other.Name);
});
}
+
+ [Test]
+ public void UnattachedEvent ()
+ {
+ var int32 = typeof (int).ToDefinition ();
+ var evt = new EventDefinition ("Event", EventAttributes.None, int32);
+
+ Assert.AreEqual (null, evt.AddMethod);
+ }
}
}
diff --git a/Test/Mono.Cecil.Tests/FieldTests.cs b/Test/Mono.Cecil.Tests/FieldTests.cs
index aa8eea1..05165d6 100644
--- a/Test/Mono.Cecil.Tests/FieldTests.cs
+++ b/Test/Mono.Cecil.Tests/FieldTests.cs
@@ -343,6 +343,15 @@ namespace Mono.Cecil.Tests {
});
}
+ [Test]
+ public void UnattachedField ()
+ {
+ var field = new FieldDefinition ("Field", FieldAttributes.Public, typeof (int).ToDefinition ());
+
+ Assert.IsFalse (field.HasConstant);
+ Assert.IsNull (field.Constant);
+ }
+
static TypeDefinition GetPrivateImplementationType (ModuleDefinition module)
{
foreach (var type in module.Types)
diff --git a/Test/Mono.Cecil.Tests/MethodBodyTests.cs b/Test/Mono.Cecil.Tests/MethodBodyTests.cs
index a606df4..96f9e7a 100644
--- a/Test/Mono.Cecil.Tests/MethodBodyTests.cs
+++ b/Test/Mono.Cecil.Tests/MethodBodyTests.cs
@@ -303,6 +303,19 @@ namespace Mono.Cecil.Tests {
});
}
+ [Test]
+ public void UnattachedMethodBody ()
+ {
+ var system_void = typeof (void).ToDefinition ();
+ var method = new MethodDefinition ("NewMethod", MethodAttributes.Assembly | MethodAttributes.Static, system_void);
+ var body = new MethodBody (method);
+ var il = body.GetILProcessor ();
+ il.Emit (OpCodes.Ret);
+ method.Body = body;
+
+ Assert.AreEqual (body, method.Body);
+ }
+
static void AssertCode (string expected, MethodDefinition method)
{
Assert.IsTrue (method.HasBody);
diff --git a/Test/Mono.Cecil.Tests/PropertyTests.cs b/Test/Mono.Cecil.Tests/PropertyTests.cs
index 32ffa50..587868f 100644
--- a/Test/Mono.Cecil.Tests/PropertyTests.cs
+++ b/Test/Mono.Cecil.Tests/PropertyTests.cs
@@ -116,5 +116,13 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual (type.GetMethod ("get_Bingo"), property.GetMethod);
});
}
+
+ [Test]
+ public void UnattachedProperty ()
+ {
+ var property = new PropertyDefinition ("Property", PropertyAttributes.None, typeof (int).ToDefinition ());
+
+ Assert.IsNull (property.GetMethod);
+ }
}
}