Make Dump() extension method available in Visual Studio
Dump() extension method is #1 reason I love and use LinqPad.
It would be great if I could add LinqPad.exe as reference to my Visual Studio project and call Dump() extension method on any of my objects.
As Visual Studio does not have any window to display HTML we could have two variants to Dump() extension method
DumpHTML() which return output as HTMLtext and
DumpText() which returns the output as space formatted text in a ASCII Table
User may choose to print the output to the Console, Output Window or write to the disk.
I you think generating ASCII table is lot of work, I'm fine with HTML output as well.
Please please I need this feature added right now...
I'm using ObjectDumper.NET from Visual Studio. It works perfectly.
Peter - great recommendation. ServiceStack.Text is awesome!
Why not nuget ServiceStack.Text and use that Dump method in VS
Amit Hegde commented
I wrote a simple visualizer which uses LinqPad Dump method to generate the output: https://github.com/amithegde/LpDump
hii... all i would like to compile .cs file with out mail function can any one provide solution for it.......thanq advance
Lukas Bühler commented
Created a little project that tries to emulate the LinqPad Dump method:
We created LinqPad nuget package for our dev group and tried to use Xhtml for the purpose of dumping entities during auditing and it works great, except there is a very big dependency from the whole LinqPad and Telerik has big performance issues in MVC project due to > ~500 types missing, so we have to switch to ObjectDumper class, so it would be beneficial if we could have render as Xhtml extracted into separate assembly or nuget package, happy to pay for that
Marc Lutz commented
CreateXhtmlWriter has an parameter maxDepth
Bent Rasmussen commented
If this is your number one reason to use LINQPad, then it doesn't sound like a good reason for Joe to open-source it ;-)
Michael Nady commented
I need it for another scenario, I am using a generic list of a runtime object that maps exactly to a database table. and i need to look for a specific value inside it.
if you add linqPad as extension to visual studio, i can query this collection using linq (which is not permitted in the debugger!!), or i can dump its contents.
Yes, a dump method that returns formatted text resembling the output of LinqPad would be generally useful. If your problem is to get the code to compile within visual studio, just create your own stub.
Well, here's one way to use it:
public static class Extensions
/// Dumps to a temporary html file and opens in the browser.
/// <param name="o">The object to display.</param>
public static void Dump<T>(this T o)
string localUrl = Path.GetTempFileName() + ".html";
using (var writer = LINQPad.Util.CreateXhtmlWriter(true))
Has anyone figured out how to get it to work when running unit tests? I am using Resharper's built-in testrunner, which has an HTML output window, but using CreateXhtmlWriter just dumps the HTML code (rather than rendering it).
So, I've went ahead and created a simple Visual Studio Debugger Visualizer which uses Linqpad Dump. You can find it at http://code.google.com/p/linqpadvisualizer/
I'll try to improve the serialization in the future, this is just a simple first try. :)
how do you change the "maxDepth" when using the writer object created with CreateXhtmlWriter()? I am getting an "limit of graph" error in my output.
The latest RC lets you call CreateXhtmlWriter enabling dynamic expansion of results. Use of this feature ties you into IE, though - it doesn't seem to work properly with Firefox.
Another reason for creating a LINQPad DLL (preferably without all the extra resources) is so that ClickOnce deployments can work correctly. In my case, referencing LINQPad.exe worked for development (and, I assume, installations), but I would get the following error when trying to use it with a ClickOnce deployment:
"Reference in the manifest does not match the identity of the downloaded assembly LINQPad.exe."
Also, I was wondering if there could be a way to isolate the Dump functionality without having to reference all of LINQPad - doing so increased my MSI from 600K to about 3200K :-(
Other than these issues, I am absolutely thrilled that I now have a quick, thorough tool for debugging/tracing!
Thanks for exposing this functionally in the new Beta. Since I can't use Dump directly, I have created a new extension method Print as follows
static class Extension
public static string Print<T>(this T o)
var writer = LINQPad.Util.CreateXhtmlWriter();
To view contents of any variable during debugging, I simply add myVariable.Print() to the watch window and use Visual Studios build in HTML visualizer to see formatted XHTML.
Thanks a ton
You can use LINQPad's XHTML Dump engine from within Visual Studio by adding a reference to LINQPad.exe and then doing this:
var writer = LINQPad.Util.CreateXhtmlWriter();
To call Dump(), simply call Write or WriteLine on the writer object.
When you want to view the output. call ToString() on the writer - if you write the output to a file, you can then view it in a web browser.