Skip to content

Commit d9973eb

Browse files
committed
Added form with test output.
1 parent 3c3da18 commit d9973eb

File tree

5 files changed

+369
-4
lines changed

5 files changed

+369
-4
lines changed

DotNetInspectorPlugin.csproj

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<Reference Include="System" />
5757
<Reference Include="System.Core" />
5858
<Reference Include="System.Drawing" />
59+
<Reference Include="System.Windows.Forms" />
5960
<Reference Include="System.Xml.Linq" />
6061
<Reference Include="System.Data.DataSetExtensions" />
6162
<Reference Include="Microsoft.CSharp" />
@@ -64,7 +65,52 @@
6465
<Reference Include="System.Xml" />
6566
</ItemGroup>
6667
<ItemGroup>
68+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\Comparers.cs" />
69+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\Delegates.cs" />
70+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\Enums.cs">
71+
<SubType>Component</SubType>
72+
</Compile>
73+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\Events.cs">
74+
<SubType>Component</SubType>
75+
</Compile>
76+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\Munger.cs" />
77+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\NativeMethods.cs" />
78+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\OLVListItem.cs" />
79+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\OLVListSubItem.cs" />
80+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\OlvListViewHitTestInfo.cs" />
81+
<Compile Include="BrightIdeasSoftware.ObjectListView\Implementation\VirtualListDataSource.cs" />
82+
<Compile Include="BrightIdeasSoftware.ObjectListView\ObjectListView.cs">
83+
<SubType>Component</SubType>
84+
</Compile>
85+
<Compile Include="BrightIdeasSoftware.ObjectListView\OLVColumn.cs">
86+
<SubType>Component</SubType>
87+
</Compile>
88+
<Compile Include="BrightIdeasSoftware.ObjectListView\Rendering\Renderers.cs">
89+
<SubType>Component</SubType>
90+
</Compile>
91+
<Compile Include="BrightIdeasSoftware.ObjectListView\Rendering\Styles.cs">
92+
<SubType>Component</SubType>
93+
</Compile>
94+
<Compile Include="BrightIdeasSoftware.ObjectListView\Rendering\TreeRenderer.cs">
95+
<SubType>Component</SubType>
96+
</Compile>
97+
<Compile Include="BrightIdeasSoftware.ObjectListView\SubControls\HeaderControl.cs" />
98+
<Compile Include="BrightIdeasSoftware.ObjectListView\SubControls\ToolTipControl.cs" />
99+
<Compile Include="BrightIdeasSoftware.ObjectListView\TreeListView.cs">
100+
<SubType>Component</SubType>
101+
</Compile>
102+
<Compile Include="BrightIdeasSoftware.ObjectListView\VirtualObjectListView.cs">
103+
<SubType>Component</SubType>
104+
</Compile>
67105
<Compile Include="DotNetInspectorPluginExt.cs" />
106+
<Compile Include="DotNetObject.cs" />
107+
<Compile Include="DotNetObjectCollector.cs" />
108+
<Compile Include="InspectorForm.cs">
109+
<SubType>Form</SubType>
110+
</Compile>
111+
<Compile Include="InspectorForm.Designer.cs">
112+
<DependentUpon>InspectorForm.cs</DependentUpon>
113+
</Compile>
68114
<Compile Include="Microsoft.Diagnostics.Runtime\ClrAppDomain.cs" />
69115
<Compile Include="Microsoft.Diagnostics.Runtime\ClrException.cs" />
70116
<Compile Include="Microsoft.Diagnostics.Runtime\ClrHeap.cs" />
@@ -115,6 +161,9 @@
115161
</ProjectReference>
116162
</ItemGroup>
117163
<ItemGroup>
164+
<EmbeddedResource Include="InspectorForm.resx">
165+
<DependentUpon>InspectorForm.cs</DependentUpon>
166+
</EmbeddedResource>
118167
<EmbeddedResource Include="Properties\Resources.resx">
119168
<Generator>ResXFileCodeGenerator</Generator>
120169
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -123,9 +172,7 @@
123172
<ItemGroup>
124173
<None Include="Resources\logo.png" />
125174
</ItemGroup>
126-
<ItemGroup>
127-
<Folder Include="ObjectListView\" />
128-
</ItemGroup>
175+
<ItemGroup />
129176
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
130177
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
131178
Other similar extension points exist, see Microsoft.Common.targets.

DotNetInspectorPluginExt.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
22
using System.Drawing;
3+
using System.Linq;
4+
using System.Windows.Forms;
5+
using Microsoft.Diagnostics.Runtime;
36
using ReClassNET;
47
using ReClassNET.Plugins;
58

@@ -13,7 +16,7 @@ public class DotNetInspectorPluginExt : Plugin
1316

1417
public override bool Initialize(IPluginHost pluginHost)
1518
{
16-
//System.Diagnostics.Debugger.Launch();
19+
System.Diagnostics.Debugger.Launch();
1720

1821
if (host != null)
1922
{
@@ -27,6 +30,18 @@ public override bool Initialize(IPluginHost pluginHost)
2730

2831
host = pluginHost;
2932

33+
var menuItem = host.MainWindow.MainMenu.Items.OfType<ToolStripMenuItem>().FirstOrDefault(i => i.Text == "Process");
34+
if (menuItem != null)
35+
{
36+
var showInspectorItem = new ToolStripMenuItem
37+
{
38+
Text = ".NET Inspector"
39+
};
40+
showInspectorItem.Click += (s, e) => new InspectorForm(host.Process).Show();
41+
42+
menuItem.DropDownItems.Add(showInspectorItem);
43+
}
44+
3045
return true;
3146
}
3247

InspectorForm.Designer.cs

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

InspectorForm.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Windows.Forms;
10+
using BrightIdeasSoftware;
11+
using Microsoft.Diagnostics.Runtime;
12+
using ReClassNET.Memory;
13+
14+
namespace DotNetInspectorPlugin
15+
{
16+
public partial class InspectorForm : Form
17+
{
18+
public InspectorForm(RemoteProcess process)
19+
{
20+
InitializeComponent();
21+
22+
var renderer = treeListView.TreeColumnRenderer;
23+
renderer.IsShowLines = false;
24+
renderer.UseTriangles = true;
25+
treeListView.CellEditUseWholeCell = true;
26+
27+
treeListView.CanExpandGetter = obj => ((DotNetObject)obj).Children.Any();
28+
treeListView.ChildrenGetter = obj => ((DotNetObject)obj).Children;
29+
treeListView.CellEditStarting += delegate (object sender, CellEditEventArgs e)
30+
{
31+
e.Cancel = ((DotNetObject)e.RowObject).IsValueType == false;
32+
};
33+
34+
olvColumnValue.AspectGetter = obj =>
35+
{
36+
return ((DotNetObject)obj).GetFormattedValue(false);
37+
};
38+
39+
olvColumnValue.AspectPutter = (obj, value) =>
40+
{
41+
((DotNetObject)obj).SetValue(value);
42+
};
43+
44+
var dataTarget = DataTarget.CreateFromReader(new ReClassNetDataReader(process));
45+
var info = dataTarget.ClrVersions.FirstOrDefault();
46+
if (info == null)
47+
{
48+
return;
49+
}
50+
51+
var runtime = info.CreateRuntime();
52+
if (runtime == null)
53+
{
54+
return;
55+
}
56+
57+
var heap = runtime.GetHeap();
58+
if (heap == null)
59+
{
60+
return;
61+
}
62+
63+
var collector = new DotNetObjectCollector(heap);
64+
var objects = collector.EnumerateObjects();
65+
66+
treeListView.Roots = objects;
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)