Browse Source

String is not primitive type.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5167 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 16 years ago
parent
commit
84422d0715
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs
  2. 6
      src/AddIns/Misc/Debugger/Debugger.Core/MetaData/DebugType.cs
  3. 4
      src/AddIns/Misc/Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs
  4. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Value.cs
  5. 6
      src/AddIns/Misc/Debugger/Debugger.Tests/Tests/DebugType_Tests.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs

@ -210,7 +210,7 @@ namespace Debugger.AddIn.TreeModel @@ -210,7 +210,7 @@ namespace Debugger.AddIn.TreeModel
return true;
} catch (NotSupportedException) {
string format = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CannotSetValue.BadFormat");
string msg = String.Format(format, newText, val.Type.PrimitiveType.ToString());
string msg = string.Format(format, newText, val.Type.PrimitiveType);
MessageService.ShowMessage(msg ,"${res:MainWindow.Windows.Debug.LocalVariables.CannotSetValue.Title}");
} catch (COMException) {
// COMException (0x80131330): Cannot perfrom SetValue on non-leaf frames.

6
src/AddIns/Misc/Debugger/Debugger.Core/MetaData/DebugType.cs

@ -127,7 +127,9 @@ namespace Debugger.MetaData @@ -127,7 +127,9 @@ namespace Debugger.MetaData
public static bool IsDefined(IDebugMemberInfo member, bool inherit, params Type[] attributeTypes)
{
// TODO: Support inherit
if (inherit)
throw new NotSupportedException("inherit");
MetaDataImport metaData = member.DebugModule.MetaData;
uint token = (uint)member.MetadataToken;
foreach(CustomAttributeProps ca in metaData.EnumCustomAttributeProps(token, 0)) {
@ -1192,8 +1194,6 @@ namespace Debugger.MetaData @@ -1192,8 +1194,6 @@ namespace Debugger.MetaData
case "System.UInt64": return typeof(System.UInt64);
case "System.Single": return typeof(System.Single);
case "System.Double": return typeof(System.Double);
// TODO: Remove, not a primitve type
case "System.String": return typeof(System.String);
default: return null;
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs

@ -656,8 +656,8 @@ namespace ICSharpCode.NRefactory.Visitors @@ -656,8 +656,8 @@ namespace ICSharpCode.NRefactory.Visitors
object VisitBinaryOperatorExpressionInternal(TypedValue leftValue, TypedValue rightValue, BinaryOperatorType op)
{
object left = leftValue.Type.IsPrimitive ? leftValue.PrimitiveValue : null;
object right = rightValue.Type.IsPrimitive ? rightValue.PrimitiveValue : null;
object left = leftValue.Type.IsPrimitive || leftValue.Type.FullName == typeof(string).FullName ? leftValue.PrimitiveValue : null;
object right = rightValue.Type.IsPrimitive || rightValue.Type.FullName == typeof(string).FullName ? rightValue.PrimitiveValue : null;
// Both are classes - do reference comparison
if (left == null && right == null) {

10
src/AddIns/Misc/Debugger/Debugger.Core/Value.cs

@ -153,6 +153,7 @@ namespace Debugger @@ -153,6 +153,7 @@ namespace Debugger
get {
if (this.IsNull) return "null";
if (this.Type.IsPrimitive) return PrimitiveValue.ToString();
if (this.Type.FullName == typeof(string).FullName) return PrimitiveValue.ToString();
return "{" + this.Type.FullName + "}";
}
}
@ -248,20 +249,23 @@ namespace Debugger @@ -248,20 +249,23 @@ namespace Debugger
/// </summary>
public object PrimitiveValue {
get {
if (this.Type.PrimitiveType == null) throw new DebuggerException("Value is not a primitive type");
if (this.Type.FullName == typeof(string).FullName) {
if (this.IsNull) return null;
return ((ICorDebugStringValue)this.CorReferenceValue.Dereference()).GetString();
} else {
if (this.Type.PrimitiveType == null)
throw new DebuggerException("Value is not a primitive type");
return CorGenericValue.GetValue(this.Type.PrimitiveType);
}
}
set {
if (this.Type.PrimitiveType == null) throw new DebuggerException("Value is not a primitive type");
if (this.Type.FullName == typeof(string).FullName) {
this.SetValue(Eval.NewString(this.AppDomain, value.ToString()));
} else {
if (value == null) throw new DebuggerException("Can not set primitive value to null");
if (this.Type.PrimitiveType == null)
throw new DebuggerException("Value is not a primitive type");
if (value == null)
throw new DebuggerException("Can not set primitive value to null");
object newValue;
try {
newValue = Convert.ChangeType(value, this.Type.PrimitiveType);

6
src/AddIns/Misc/Debugger/Debugger.Tests/Tests/DebugType_Tests.cs

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save