From 7627844e0176b91587f73eae1bc6e6408d66a270 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 4 Feb 2014 00:38:09 +0100 Subject: [PATCH] add special support for null values in ExpressionEvaluationVisitor --- .../NRefactory/ExpressionEvaluationVisitor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs index 6fbe0df9bf..40db94eda9 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs @@ -104,6 +104,8 @@ namespace Debugger.AddIn if (result.IsError) throw new GetValueException("Unknown error"); + if (result.ConstantValue == null && result.Type.Equals(SpecialType.NullType)) + return Eval.CreateValue(evalThread, null); throw new GetValueException("Unsupported language construct: " + result.GetType().Name); } @@ -144,7 +146,7 @@ namespace Debugger.AddIn switch (result.OperatorType) { case ExpressionType.Assign: if (!allowSetValue) - throw new InvalidOperationException("Setting values is not allowed in the current context!"); + throw new GetValueException("Setting values is not allowed in the current context!"); Debug.Assert(result.Operands.Count == 2); return VisitAssignment((dynamic)result.Operands[0], (dynamic)result.Operands[1]); case ExpressionType.Add: @@ -353,6 +355,8 @@ namespace Debugger.AddIn return InvokeMethod(null, result.Conversion.Method, val); if (result.Conversion.IsReferenceConversion && result.Conversion.IsImplicit) return val; + if (result.Conversion.IsNullLiteralConversion) + return val; throw new NotImplementedException(string.Format("conversion '{0}' not implemented!", result.Conversion)); }