Dumping in different panel

Is there a way to use dump() in a new panel?


  • There's nothing obvious in the Dump API suggesting you can redirect it to another panel, but this query may give you alternate ideas:
    Util.SqlOutputWriter.WriteLine("Just testing...")
    Dim out2 = (New TextBox).Dump
    out2.Text = PanelManager.GetOutputPanels().Dump()(0).Heading
  • You could write an extension method in the 'My Extensions' query like this:
    public static T DumpX<T> (this T toDump, string panelName)
        System.Windows.Forms.WebBrowser browser;
        TextWriter formatter;
        var panel = PanelManager.GetOutputPanel (panelName);
        bool first = panel == null;
        if (first)
            panel = PanelManager.DisplayControl (browser = new System.Windows.Forms.WebBrowser(), panelName);
            formatter = Util.CreateXhtmlWriter (true);
            browser.Tag = formatter;
            bool init = true;
            browser.DocumentCompleted += (sender, args) =>
                if (init) browser.DocumentText = formatter.ToString();
                init = false;
            browser = (System.Windows.Forms.WebBrowser)(panel.GetControl());
            formatter = (TextWriter)browser.Tag;
        formatter.WriteLine (toDump);
        if (first || browser.ReadyState == System.Windows.Forms.WebBrowserReadyState.Complete)
            browser.DocumentText = formatter.ToString();
        return toDump;
    This will give basic Dump functionality, although without some features such as headings, DumpContainers, observables, etc.
  • Thanks to both of you!
  • Would you please add an example for dumping an observable? I can't get it without flicker...
  • I also wrote this, which works fine in a simple example but when using it with some async code, the new panel doesn't even appear :(

    [NLog.Targets.Target("LinqPadPanelTarget")] class LinqPadPanelTarget : NLog.Targets.TargetWithLayout { public string PanelName { get; set; } = "Logging"; protected override void Write(NLog.LogEventInfo log) { string line = Layout.Render(log); line.DumpToPanel(PanelName); } }

    static void RedirectNLogToLoggingPanel(NLog.LogLevel minLevel = null, string panelName = null) { var config = NLog.LogManager.Configuration; if (config == null) config = NLog.LogManager.Configuration = new NLog.Config.LoggingConfiguration(); var target = new LinqPadPanelTarget(); if(panelName != null) target.PanelName = panelName; NLog.LogManager.Configuration.AddTarget("linqpad", target); NLog.LogManager.Configuration.AddRule(minLevel ?? NLog.LogLevel.Trace, NLog.LogLevel.Fatal, "linqpad"); NLog.LogManager.ReconfigExistingLoggers(); }
  • Repro:

    RedirectNLogToLoggingPanel(); Task.WaitAll(Task.Delay(100000000));
  • Use await Task.Delay instead of Task.WaitAll (the latter is blocking).
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!