Skip to content

Commit f443755

Browse files
author
David Karlaš
committed
Bug 52333 - Debugger applies rounding when casting float values to int
Since System.Convert.To, can have different behavior then casting, I removed use of this and always use DynamicCast which does proper casting. In theory performance might suffer but this should be minimal and not noticable by user at all.
1 parent 621df7c commit f443755

File tree

1 file changed

+1
-40
lines changed

1 file changed

+1
-40
lines changed

Mono.Debugging.Soft/SoftDebuggerAdaptor.cs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -391,46 +391,7 @@ public override object TryCast (EvaluationContext ctx, object val, object type)
391391
if (val == null)
392392
return null;
393393

394-
object res;
395-
396-
try {
397-
if (tt == typeof (bool))
398-
res = System.Convert.ToBoolean (val);
399-
else if (tt == typeof (byte))
400-
res = System.Convert.ToByte (val);
401-
else if (tt == typeof (sbyte))
402-
res = System.Convert.ToSByte (val);
403-
else if (tt == typeof (char))
404-
res = System.Convert.ToChar (val);
405-
else if (tt == typeof (short))
406-
res = System.Convert.ToInt16 (val);
407-
else if (tt == typeof (ushort))
408-
res = System.Convert.ToUInt16 (val);
409-
else if (tt == typeof (int))
410-
res = System.Convert.ToInt32 (val);
411-
else if (tt == typeof (uint))
412-
res = System.Convert.ToUInt32 (val);
413-
else if (tt == typeof (long))
414-
res = System.Convert.ToInt64 (val);
415-
else if (tt == typeof (ulong))
416-
res = System.Convert.ToUInt64 (val);
417-
else if (tt == typeof (float))
418-
res = System.Convert.ToSingle (val);
419-
else if (tt == typeof (double))
420-
res = System.Convert.ToDouble (val);
421-
else if (tt == typeof (decimal))
422-
res = System.Convert.ToDecimal (val);
423-
else if (tt == typeof (string))
424-
res = System.Convert.ToString (val);
425-
else if (tt == typeof (DateTime))
426-
res = System.Convert.ToDateTime (val);
427-
else
428-
res = val;
429-
} catch {
430-
res = DynamicCast (val, tt);
431-
}
432-
433-
return CreateValue (ctx, res);
394+
return CreateValue (ctx, DynamicCast (val, tt));
434395
}
435396

436397
fromType = (TypeMirror) ForceLoadType (ctx, ((Type) valueType).FullName);

0 commit comments

Comments
 (0)