Browse Source

"Index was outside the bounds of the array." for expressions like "abc"[-1]

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5307 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
David Srbecký 16 years ago
parent
commit
d1cf2a993b
  1. 5
      src/AddIns/Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs

5
src/AddIns/Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs

@ -433,7 +433,10 @@ namespace ICSharpCode.NRefactory.Visitors @@ -433,7 +433,10 @@ namespace ICSharpCode.NRefactory.Visitors
throw new GetValueException("Single index expected");
int index = EvaluateAsInt(indexerExpression.Indexes[0]);
return CreateValue(((string)target.PrimitiveValue)[index]);
string str = (string)target.PrimitiveValue;
if (index < 0 || index >= str.Length)
throw new GetValueException("Index was outside the bounds of the array.");
return CreateValue(str[index]);
} else {
List<TypedValue> indexes = EvaluateAll(indexerExpression.Indexes);
DebugPropertyInfo pi = (DebugPropertyInfo)target.Type.GetProperty("Item", GetTypes(indexes));

Loading…
Cancel
Save