Browse Source

Debugger visualizers - progress (Grid visualizer remaining).

newNRvisualizers
Martin Konicek 13 years ago
parent
commit
6ae27d89a4
  1. 3
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/GridVisualizerCommand.cs
  2. 2
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraph/ObjectGraphBuilder.cs
  3. 2
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraph/PropertiesFirstComparer.cs
  4. 5
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs
  5. 18
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs
  6. 6
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/TypeResolver.cs

3
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/GridVisualizerCommand.cs

@ -19,7 +19,8 @@ namespace Debugger.AddIn.Visualizers @@ -19,7 +19,8 @@ namespace Debugger.AddIn.Visualizers
public bool IsVisualizerAvailable(IType type)
{
if (type.IsAtomic()) return false;
IType collectionType, itemType;
ParameterizedType collectionType;
IType itemType;
// Visualizer available for IEnumerable<T> (that is, also IList<T>)
return type.ResolveIEnumerableImplementation(out collectionType, out itemType);
}

2
src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraph/ObjectGraphBuilder.cs

@ -190,7 +190,7 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -190,7 +190,7 @@ namespace Debugger.AddIn.Visualizers.Graph
LoadNodeObjectContent(baseClassNode, expression, baseType);
}
var members = type.GetFieldsAndNonIndexedProperties(GetMemberOptions.IgnoreInheritedMembers).ToList();
var members = type.GetFieldsAndNonIndexedProperties(GetMemberOptions.IgnoreInheritedMembers).Where(m => !m.IsStatic).ToList();
// non-public members
var nonPublicProperties = createProperties(expression, members.Where(m => !m.IsPublic));
if (nonPublicProperties.Count > 0) {

2
src/AddIns/Debugger/Debugger.AddIn/Visualizers/GraphVisualizer/ObjectGraph/PropertiesFirstComparer.cs

@ -10,7 +10,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -10,7 +10,7 @@ using ICSharpCode.NRefactory.TypeSystem;
namespace Debugger.AddIn.Visualizers.Graph
{
/// <summary>
/// Compares members - .NET properties come before .NET fields.
/// Compares members - properties come before fields.
/// </summary>
public sealed class PropertiesFirstComparer : IComparer<IMember>
{

5
src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs

@ -42,7 +42,8 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer @@ -42,7 +42,8 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer
Value shownValue = getValue();
IType iListType, iEnumerableType, itemType;
ParameterizedType iListType, iEnumerableType;
IType itemType;
// Value is IList
if (shownValue.Type.ResolveIListImplementation(out iListType, out itemType)) {
// Ok
@ -58,7 +59,7 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer @@ -58,7 +59,7 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer
}
shownValue = shownValue.GetPermanentReference(WindowsDebugger.EvalThread);
MemberInfo[] members = itemType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Instance);
var members = itemType.GetFieldsAndNonIndexedProperties().Where(m => m.IsPublic && !m.IsStatic);
IProperty indexerProperty = iListType.GetProperties(p => p.Name == "Item").Single();
int rowCount = (int)shownValue.GetPropertyValue(WindowsDebugger.EvalThread, iListType.GetProperties(p => p.Name == "Count").Single()).PrimitiveValue;
int columnCount = members.Length + 1;

18
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System.Linq;
using Debugger.AddIn.TreeModel;
using Debugger.AddIn.Visualizers.Graph;
using Debugger.Interop.CorDebug;
using System;
@ -42,17 +43,11 @@ namespace Debugger.AddIn.Visualizers.Utils @@ -42,17 +43,11 @@ namespace Debugger.AddIn.Visualizers.Utils
/// </summary>
public static Value CreateListFromIEnumerable(Value iEnumerableValue)
{
IType iEnumerableType, itemType;
ParameterizedType iEnumerableType;
IType itemType;
if (!iEnumerableValue.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
throw new GetValueException("Value is not IEnumerable");
// FIXME
IType listType = DebugType.CreateFromType(iEnumerableValue.AppDomain, typeof(System.Collections.Generic.List<>), itemType);
DebugConstructorInfo ctor = listType.GetConstructor(BindingFlags.Default, null, CallingConventions.Any, new System.Type[] { iEnumerableType }, null);
if (ctor == null)
throw new DebuggerException("List<T> constructor not found");
// Keep reference since we do not want to keep reenumerating it
return Value.InvokeMethod(WindowsDebugger.EvalThread, null, ctor.MethodInfo, new Value[] { iEnumerableValue }).GetPermanentReferenceOfHeapValue();
return ValueNode.CreateListFromIEnumerable(iEnumerableType, iEnumerableValue).GetPermanentReferenceOfHeapValue();
}
/// <summary>
@ -94,7 +89,10 @@ namespace Debugger.AddIn.Visualizers.Utils @@ -94,7 +89,10 @@ namespace Debugger.AddIn.Visualizers.Utils
{
// TODO reimplement check for Process.HasExited (debuggee restarted)
if (hashCodeMethod == null /*|| hashCodeMethod.Process.HasExited*/) {
IType runtimeHelpers = DebugType.CreateFromType(value.AppDomain, typeof(System.Runtime.CompilerServices.RuntimeHelpers));
IType runtimeHelpers =
value.Type.GetDefinition().Compilation.FindType(
typeof(System.Runtime.CompilerServices.RuntimeHelpers)
).GetDefinition();
hashCodeMethod = runtimeHelpers.GetMethods(m => m.FullName == "GetHashCode").FirstOrDefault();
if (hashCodeMethod == null) {
throw new DebuggerException(

6
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/TypeResolver.cs

@ -21,7 +21,7 @@ namespace Debugger.AddIn.Visualizers.Utils @@ -21,7 +21,7 @@ namespace Debugger.AddIn.Visualizers.Utils
/// <param name="iListType">Result found implementation of System.Collections.Generic.IList.</param>
/// <param name="itemType">The only generic argument of <paramref name="implementation"/></param>
/// <returns>True if found, false otherwise.</returns>
public static bool ResolveIListImplementation(this IType type, out IType iListType, out IType itemType)
public static bool ResolveIListImplementation(this IType type, out ParameterizedType iListType, out IType itemType)
{
return type.ResolveKnownBaseType(KnownTypeCode.IListOfT, out iListType, out itemType);
}
@ -32,7 +32,7 @@ namespace Debugger.AddIn.Visualizers.Utils @@ -32,7 +32,7 @@ namespace Debugger.AddIn.Visualizers.Utils
/// <param name="iEnumerableType">Result found implementation of System.Collections.Generic.IEnumerable.</param>
/// <param name="itemType">The only generic argument of <paramref name="implementation"/></param>
/// <returns>True if found, false otherwise.</returns>
public static bool ResolveIEnumerableImplementation(this IType type, out IType iEnumerableType, out IType itemType)
public static bool ResolveIEnumerableImplementation(this IType type, out ParameterizedType iEnumerableType, out IType itemType)
{
return type.ResolveKnownBaseType(KnownTypeCode.IEnumerableOfT, out iEnumerableType, out itemType);
}
@ -44,7 +44,7 @@ namespace Debugger.AddIn.Visualizers.Utils @@ -44,7 +44,7 @@ namespace Debugger.AddIn.Visualizers.Utils
/// <param name="implementation">Found implementation.</param>
/// <param name="itemType">The only generic argument of <paramref name="implementation"/></param>
/// <returns>True if found, false otherwise.</returns>
private static bool ResolveKnownBaseType(this IType type, KnownTypeCode knownTypeCode, out IType implementation, out IType itemType)
private static bool ResolveKnownBaseType(this IType type, KnownTypeCode knownTypeCode, out ParameterizedType implementation, out IType itemType)
{
if (type == null) throw new ArgumentNullException("type");
implementation = null;

Loading…
Cancel
Save