Home

Is there any way to highlight certain rows in dump results

Just wondering if there is any way to highlight particular rows when dumping results.

Currently I add an dummy column and Util.RawHtml to colour something conditionally , eg to highlight negative values, I use something like

(from r in query
select new
{
    _ = r.Value < 0
    ? Util.RawHtml(new XElement("div", new XAttribute("style", $"color: red;"), ">>>>"))
    : Util.RawHtml(""),
   r.Name,
   r.Value,
   ...
 }).Dump();

Was wondering if there was something better that highlights the whole row. (other than repeating the same trick for every column) ?

Comments

  • edited June 2020

    In the next build, you'll be able to do this:

    from file in new DirectoryInfo (Util.LINQPadFolder).GetFiles()
    select Util.HighlightIf (
        file.Extension == ".exe",
        new
        {
            file.Name,
            file.Length,
            file.LastWriteTime
        })
    

    and this:

    from file in new DirectoryInfo (Util.LINQPadFolder).GetFiles()
    select new
    {
        Name = Util.Highlight (file.Name,
            file.Extension == ".exe" ? "yellow" :
            file.Extension == ".dll" ? "lightgreen" :
            null),  // null = no highlight
        file.Length,
        file.LastWriteTime
    };
    
  • Just got the latest build and this works great.

    Thank you very much.

Sign In or Register to comment.