diff --git a/src/AddIns/Debugger/Debugger.Core/Eval.cs b/src/AddIns/Debugger/Debugger.Core/Eval.cs index 2d91ed09b3..2a391b8c3b 100644 --- a/src/AddIns/Debugger/Debugger.Core/Eval.cs +++ b/src/AddIns/Debugger/Debugger.Core/Eval.cs @@ -224,20 +224,17 @@ namespace Debugger throw new GetValueException("'this' is null"); if (thisValue.IsNull) throw new GetValueException("Null reference"); - // if (!(thisValue.IsObject)) // eg Can evaluate on array - if (!thisValue.Type.GetDefinition().IsDerivedFrom(method.DeclaringType.GetDefinition())) { - throw new GetValueException( - "Can not evaluate because the object is not of proper type. " + - "Expected: " + method.DeclaringType.FullName + " Seen: " + thisValue.Type.FullName - ); - } corArgs.Add(thisValue.CorValue); } for(int i = 0; i < args.Length; i++) { Value arg = args[i]; IType paramType = method.Parameters[i].Type; - if (!arg.IsNull && !arg.Type.GetDefinition().IsDerivedFrom(paramType.GetDefinition().GetDefinition())) + if (!arg.IsNull && + arg.Type.GetDefinition() != null && + paramType.GetDefinition() != null && + !arg.Type.GetDefinition().IsDerivedFrom(paramType.GetDefinition())) { throw new GetValueException("Inncorrect parameter type. Expected " + paramType.ToString()); + } // It is importatnt to pass the parameter in the correct form (boxed/unboxed) if (paramType.IsReferenceType == true) { if (!arg.IsReference) diff --git a/src/AddIns/Debugger/Debugger.Core/Value.cs b/src/AddIns/Debugger/Debugger.Core/Value.cs index ae1aab3c52..4bb8c7742c 100644 --- a/src/AddIns/Debugger/Debugger.Core/Value.cs +++ b/src/AddIns/Debugger/Debugger.Core/Value.cs @@ -402,7 +402,7 @@ namespace Debugger if (objectInstance.IsNull) throw new GetValueException("Null reference"); // Array.Length can be called - if (objectInstance.Type.IsKnownType(KnownTypeCode.Array)) + if (objectInstance.Type.Kind == TypeKind.Array) return; if (objectInstance.Type.GetDefinition() == null || !objectInstance.Type.GetDefinition().IsDerivedFrom(memberInfo.DeclaringType.GetDefinition())) throw new GetValueException("Object is not of type " + memberInfo.DeclaringType.FullName); diff --git a/src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs b/src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs index 2fed6edbe9..11810db674 100644 --- a/src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs +++ b/src/AddIns/Debugger/Debugger.Tests/DebuggerTestsBase.cs @@ -7,11 +7,12 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using System.Security.Cryptography; using System.Text; using System.Xml; - +using ICSharpCode.NRefactory.TypeSystem; using Microsoft.CSharp; using NUnit.Framework; @@ -271,7 +272,7 @@ namespace Debugger.Tests class LocalVariable { public string Name { get; set; } - public Type Type { get; set; } + public IType Type { get; set; } public Value Value { get; set; } } @@ -281,12 +282,11 @@ namespace Debugger.Tests } public void DumpLocalVariables(string msg) - {/* + { ObjectDump( msg, - this.CurrentStackFrame.MethodInfo.GetLocalVariables(this.CurrentStackFrame.IP).Select(v => new LocalVariable() { Name = v.Name, Type = v.LocalType, Value = v.GetValue(this.CurrentStackFrame)}) + this.CurrentStackFrame.GetLocalVariables(this.CurrentStackFrame.IP).Select(v => new LocalVariable() { Name = v.Name, Type = v.Type, Value = v.GetValue(this.CurrentStackFrame)}) ); - */ } List expandProperties; diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs index 68d88ab56f..d91424f53e 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/DynamicCode.cs @@ -51,7 +51,7 @@ namespace Debugger.Tests { public partial class DebuggerTests { - [NUnit.Framework.Test] + [NUnit.Framework.Test, NUnit.Framework.Ignore("We can not load in-memory assemblies with Cecil (yet)")] public void DynamicCode() { StartTest(); diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs index 79a8fcdfa4..48a6d91047 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluatorVisitor_Tests.cs @@ -297,7 +297,7 @@ namespace Debugger.Tests AssertEval("DBBool.Null || DBBool.False", "DBBool.Null"); AssertEval("DBBool.False || DBBool.False", "DBBool.False"); AssertEval("array", "Char[] {'H', 'e', 'l', 'l', 'o'}"); - AssertEval("array.ToList()", "List {'H', 'e', 'l', 'l', 'o'}"); + AssertEval("array.ToList()", "List {'H', 'e', 'l', 'l', 'o'}"); EndTest(false); }