I suggest you ...

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...

135 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    anunayanunay shared this idea  ·   ·  Admin →

    18 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  · 

        hii... all i would like to compile .cs file with out mail function can any one provide solution for it.......thanq advance

      • AlexAlex commented  · 

        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 LutzMarc Lutz commented  · 

        @o.chantosa
        CreateXhtmlWriter has an parameter maxDepth

      • Bent RasmussenBent 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 NadyMichael 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.

      • TormodTormod commented  · 

        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.

      • Pat KujawaPat Kujawa commented  · 

        Well, here's one way to use it:
        using System.Diagnostics;
        using System.IO;

        public static class Extensions
        {
        /// <summary>
        /// Dumps to a temporary html file and opens in the browser.
        /// </summary>
        /// <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))
        {
        writer.Write(o);
        File.WriteAllText(localUrl, writer.ToString());
        }
        Process.Start(localUrl);
        }
        }

      • Pat KujawaPat Kujawa commented  · 

        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).

      • o.chantosao.chantosa commented  · 

        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.

      • Joe AlbahariAdminJoe Albahari (Admin, LINQPad) commented  · 

        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.

      • Pat KujawaPat Kujawa commented  · 

        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."

      • Pat KujawaPat Kujawa commented  · 

        Using Joe and anunay's suggestions has worked well for me, but I notice that the resulting html doesn't include the javascript to allow expansion/shrinkage of different containers (a la LINQPad). I consider that ability very important, since it allows you to quickly focus on what you are interested in within the object. Is there a way to get this functionality into the Writer and for general use?

        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!

      • anunayanunay commented  · 

        Hi Joe

        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();
        writer.Write(o);
        return writer.ToString();
        }
        }

        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
        Anunay

      • Joe AlbahariAdminJoe Albahari (Admin, LINQPad) commented  · 

        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.

      • anunayanunay commented  · 

        This works if your project is simple library or a console app. In my case the VS project I'm working on is huge with over 15+ references.The variables I want to dump exist in deep nested classes which can only be instantiated after multiple UI interaction setps. I just can't call my project from Linqpad without making some serious changes to it.

      • Martin KirkMartin Kirk commented  · 

        how about creating public variables in your class in VS

        then run that program from LinqPad ??

        i know it all depends on the project type... but most programs could be called from LinqPad i think...

      Feedback and Knowledge Base