Is it possible to reduce the size of collapsed empty lists?
I would prefer it to take up the same horizontal space as ordinary entries, empty IEnumerables and also non-empty lists.
For example
var range = Enumerable.Range(1, 30).ToArray(); var EmptyIEnumerable = range.Where(r=>false); var x1 = (from a in range select new { a, EmptyIEnumerable}) ; var x2 = (from a in range select new { a, EmptyList = EmptyIEnumerable.ToList() }) ; Util.HorizontalRun(true, x1, x2).Dump(1);
displays as
I tried changing the font on the td.typeheader style, but it would have to be unreadably small to fit.
Best Answer
-
Hi,
what about this ? (https://www.linqpad.net/CustomizingDump.aspx)
static object ToDump(object input) => input is IList { Count: 0 } ? "<Empty List>" : input;
Answers
-
Thank you.
-
You could also change the styles for what's dumped, either on a per-script basis with
Util.HtmlHead.AddStyles()
:Util.HtmlHead.AddStyles(""" table[id] { margin: 0.1em 0.1em 0.0em 0.1em; } td.typeheader { padding: 0 0.3em 0.05em 0.2em; line-height: 13px; } td:has(>table) { padding: 0.0em 0.3em 0.1em 0.3em; } """);
You also can to some extent widen columns for specific types (if there is structure to the output):
th[title*=Enumerable], th[title*=List] { min-width: 140px; }
Or update the styles globally in: Settings > Results > CSS styles for text (HTML) results
-
@JeffMercado said:
You could also change the styles for what's dumped, either on a per-script basis withUtil.HtmlHead.AddStyles()
:Util.HtmlHead.AddStyles(""" table[id] { margin: 0.1em 0.1em 0.0em 0.1em; } td.typeheader { padding: 0 0.3em 0.05em 0.2em; line-height: 13px; } td:has(>table) { padding: 0.0em 0.3em 0.1em 0.3em; } """);
Thanks, this works as well.
Would love to understand it. Is this documented somewhere, i.e.table[id]
(as opposed totable
) andtd:has(>table)
? -
I don't know if it's documented, but you can inspect the results panel source to see the HTML that renders it. With focus on the results panel, press F12. Alternatively, right click on any element in the results and inspect (like you would in a browser).
Unfortunately there aren't any classes applied to make styling easier, but there is a pattern at least from what I could gather.
Tables with an id (
table[id]
) corresponds to the "value" being dumped. Every value has a non-zero margin and we wanted to reduce it.Columns with a typeheader class (
td.typeheader
) correspond to the property of a collection of values being dumped. It's displayed a little too big so removed most of the padding and made the line height shorter.Nested values (
td:has(>table)
) were also taking up a lot of extra space so needed to remove some of the padding.