A visualizer creates an interface to display a variable or object in a meaningful way.
I am demonstrating an approach for integrating the PowerShell scripting engine into a C# WinForms application and making it available during visual studio debug sessions.
Quick Start
The quickest way to get working is to add these two attributes to your class you want to visualize.
[DebuggerVisualizer(typeof(PoSHVisualizer.PoSHVisualizer))]
[Serializable]
Stepping through your code, any variable defined of this type can be inspected in the visualizer by clicking on the magnifying glass.
The PowerShell visualizer is launched and you have access to the full suite of PowerShell cmdlets, the environment and your object has been injected.
A simple command line editor is presented where you can type PowerShell commands, press F5 and see the results (and errors).
Most importantly your live object is ready to work with in the PowerShell environment and you can act on it directly. Change it, inspect it or Export-Csv it.
Download
I’ve posted the PowerShell Debug Visualizer on CodePlex.
{ 3 comments… read them below or add one }
Doug,
I love the concept, but I’m having a bit of trouble getting it to work. I’m using VS2008 C# Express and I’ve added the references and decorated the class with the attributes, but it does not seem to like the DebuggerVisualizer attribute.
Any tips would be appreciated.
Thanks!
Steve
Steve, I will get back to you.
The DLLs were built with 2005.
I have 2008, I’ll test and let you know.
I’ve uploaded a 2008 version
http://www.codeplex.com/PoSHDebugVisualizer/Release/ProjectReleases.aspx?ReleaseId=8815