return req;
}
+ [Test]
+ public void ClassLocalReflection () {
+ MethodMirror m = entry_point.DeclaringType.Assembly.GetType ("LocalReflectClass").GetMethod ("RunMe");
+
+ Assert.IsNotNull (m);
+ //Console.WriteLine ("X: " + name + " " + m.ILOffsets.Count + " " + m.Locations.Count);
+ var offset = -1;
+ int method_base_linum = m.Locations [0].LineNumber;
+ foreach (var location in m.Locations)
+ if (location.LineNumber == method_base_linum + 2) {
+ offset = location.ILOffset;
+ break;
+ }
+
+ var req = vm.SetBreakpoint (m, offset);
+
+ Event e = null;
+
+ while (true) {
+ vm.Resume ();
+ e = GetNextEvent ();
+ if (e is BreakpointEvent)
+ break;
+ }
+
+ req.Disable ();
+
+ Assert.IsInstanceOfType (typeof (BreakpointEvent), e);
+ Assert.AreEqual (m.Name, (e as BreakpointEvent).Method.Name);
+
+ e = single_step (e.Thread);
+
+ var frame = e.Thread.GetFrames ()[0];
+ Value variable = frame.GetValue (frame.Method.GetLocal ("reflectMe"));
+
+ ObjectMirror thisObj = (ObjectMirror)variable;
+ TypeMirror thisType = thisObj.Type;
+ FieldInfoMirror thisFi = null;
+ foreach (var fi in thisType.GetFields ())
+ if (fi.Name == "someField")
+ thisFi = fi;
+
+ var gotVal = thisObj.GetValue (thisFi);
+ // If we got this far, we're good.
+ }
+
[Test]
public void SingleStepping () {
Event e = run_until ("single_stepping");
e = step_over ();
assert_location (e, "ss_nested");
e = step_into ();
- assert_location (e, "ss_nested_3");
+ assert_location (e, "ss_nested_1");
+ e = step_into ();
+ assert_location (e, "ss_nested_1");
+ e = step_into ();
+ assert_location (e, "ss_nested");
req.Disable ();
// Check DebuggerStepThrough support
AssertValue ("AB", vals [i]);
if (locals [i].Name == "t")
AssertValue ("ABC", vals [i]);
- if (locals [i].Name == "alist")
- ;
+ if (locals [i].Name == "alist") {
+ }
}
// Argument checking
v = s.InvokeMethod (e.Thread, m, null);
AssertValue (42, v);
+ // Pass boxed struct as this
+ var boxed_this = t.NewInstance () as ObjectMirror;
+ m = t.GetMethod ("invoke_return_int");
+ v = boxed_this.InvokeMethod (e.Thread, m, null);
+ AssertValue (0, v);
+
// Pass struct as this, receive intptr
m = t.GetMethod ("invoke_return_intptr");
v = s.InvokeMethod (e.Thread, m, null);
v = s.InvokeMethod (e.Thread, m, null);
AssertValue (42, v);
+ // .ctor
+ s = frame.GetArgument (1) as StructMirror;
+ t = s.Type;
+ m = t.GetMethods ().First (method => method.Name == ".ctor" && method.GetParameters ().Length == 1);
+ v = t.InvokeMethod (e.Thread, m, new Value [] { vm.CreateValue (1) });
+ AssertValue (1, (v as StructMirror)["i"]);
+
#if NET_4_5
// Invoke a method which changes state
s = frame.GetArgument (1) as StructMirror;
task = s.InvokeMethodAsyncWithResult (e.Thread, m, null);
out_this = task.Result.OutThis as StructMirror;
Assert.AreEqual (null, out_this);
+
+ // interface method
+ var cl1 = frame.Method.DeclaringType.Assembly.GetType ("ITest2");
+ m = cl1.GetMethod ("invoke_iface");
+ v = s.InvokeMethod (e.Thread, m, null);
+ AssertValue (42, v);
+
+ // virtual method
+ m = vm.RootDomain.Corlib.GetType ("System.Object").GetMethod ("ToString");
+ v = s.InvokeMethod (e.Thread, m, null, InvokeOptions.Virtual);
+ AssertValue ("42", v);
#endif
}
Assert.AreEqual ("System.Exception", types [0].FullName);
}
+ [Test]
+ public void String_GetValue () {
+ // Embedded nulls
+ object val;
+
+ // Reuse this test
+ var e = run_until ("arg2");
+
+ var frame = e.Thread.GetFrames () [0];
+
+ val = frame.GetArgument (6);
+ Assert.AreEqual ('\0'.ToString () + "A", (val as StringMirror).Value);
+ }
+
[Test]
public void String_GetChars () {
object val;