Skip to content

Instantly share code, notes, and snippets.

@abrari
Created November 10, 2017 09:14
Show Gist options
  • Save abrari/c79991431a342dc7f2b967cc3459a3e9 to your computer and use it in GitHub Desktop.
Save abrari/c79991431a342dc7f2b967cc3459a3e9 to your computer and use it in GitHub Desktop.
LINQPad Object Dumper
using System.Diagnostics;
using System.IO;
namespace MyApp
{
public static class Dumper
{
public const string DumpFile = "dump.html";
public static void Dump<T>(this T o) {
var localUrl = DumpFile;
using (var writer = LINQPad.Util.CreateXhtmlWriter(true, 1))
{
writer.Write(o);
File.AppendAllText(localUrl, writer.ToString());
}
}
public static void Clear()
{
File.WriteAllText(DumpFile, string.Empty);
}
public static void Show()
{
Process.Start(DumpFile);
}
}
}
@abrari
Copy link
Author

abrari commented Nov 10, 2017

Usage example:

    internal class Program
    {
        public static void Main(string[] args)
        {
            var list = new List<string>();
            list.Add("one");
            list.Add("two");
            list.Add("three");

            Dumper.Clear();

            list.Dump();
            list.Add("four");
            list.Dump();

            Dumper.Show();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment