ConsoleDump icon indicating copy to clipboard operation
ConsoleDump copied to clipboard

Array properties don't get printed

Open georgiosd opened this issue 10 years ago • 2 comments

Any chance to change this:

ConsoleDump.Extensions.Dump(new {
    Array = new[] { "foo", "bar" }
});

From:

ø
{ Array = System.String[] }
 Array System.String[]

To a column view that would work with multiple properties? Like a table? I understand that it would get complex really quickly if you have objects in there and not primitive types so that would be an reasonable limitation.

georgiosd avatar Apr 23 '15 17:04 georgiosd

ConsoleDump does produce tables in 2 cases (currently):

  1. Dumping a single object directly; it's field / property names are the left column and their values are the right column

    ConsoleDump.Extensions.Dump(new { foo = 1, bar = "two" })
    

    produces a table similar to:

    Name Value
    foo 1
    bar two
  2. Dumping a collection of (strongly typed) objects. The field / property names are the column headings and each item is a row in the resulting table.

    ConsoleDump.Extensions.Dump(new[] { 
        new { foo = 1, bar = "two" },
        new { foo = 3, bar = "four" },
    })
    

    produces a table similar to:

    foo bar
    1 two
    3 four

Collections of "primitives" are handled with #2. Something close to your example:

ConsoleDump.Extensions.Dump(new[] { "foo", "bar" });
System.String[]
foo
bar

I think nicely dumping objects containing collections would be challenging but perhaps something close could be supported.

Suggestion

I could add support for dumping collections of collections of primitives.

Hypothetical example:

ConsoleDump.Extensions.Dump(new[] {
    new[] { 1, 2, 3, },
    new[] { 4, 5, },
    new[] { 6, 7, 8, 9, },
});
[0] [1] [2] [3]
1 2 3
4 5
6 7 8 9

This would .ToString() anything (the same as the currently supported table styles) so this would really be adding a special case for IEnumerable<IEnumerable<T>>

@georgiosd, would dumping a collection directly or this hypothetical collection of collection support satisfy your use case?

cameronism avatar May 17 '15 15:05 cameronism

Uhm, what if, when a property is a collection, instead of displaying it in a table as above, you create an indented table table:

Foo Bar
1 2

I => TABLE FOR COLLECTION HERE

Best of both worlds?

georgiosd avatar May 18 '15 19:05 georgiosd