Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of arrays (and nested arrays) as examples #263

Open
matt-jenner opened this issue Jan 15, 2018 · 0 comments
Open

Improve handling of arrays (and nested arrays) as examples #263

matt-jenner opened this issue Jan 15, 2018 · 0 comments

Comments

@matt-jenner
Copy link

matt-jenner commented Jan 15, 2018

Improve handling of arrays (and nested arrays) as examples

While looking at my other issue I noticed that handling of nested arrays is not supported very well (understandably an edge-case but I thought I'd take a further look). For example consider arrays like this:

new []{ new []{"bob",jim"}, new []{"fred","whoozit"} }

This when displayed on the report as an example will both come out as follows currently:

System.String[] , System.String[]

You just get whatever the result of the ToString method on whatever object type the object is. This effectively hides the example values from the user in the report.

My first thought was to check cach item in the array to see if it is itself an array, and if so recursively flatten it, however this would lead to misleading results however, consider these two examples:

new []{ new []{"bob",jim"}, new []{"fred","whoozit"} }
new []{ "bob", "jim", "fred", "whoozit" }

These will render identically:

bob, jim, fred, whoozit
bob, jim, fred, whoozit

This is also misleading, so I also propose wrapping arrays in an identifier (so-far I've used []'s) this way you can tell the structure of the array passed in. This is obviously not quite as clean but it is functional in showing the examples used are unique, if I used this approach the examples I've used would display as:

[[bob, jim], [fred, whoozit]]
[bob, jim, fred, whoozit]

This approach can also manage to display an object array with different arrays and non-array entries in an understandable way:

new object[]{ new []{"bob",jim"}, new []{1,2}, "thingy", 3 }

would render as:

[[bob, jim], [1, 2], thingy, 3]

I've completed an initial implementation of this locally but I thought I'd check to see whether you think this is useful to include in the product and if you have any suggestions for modifications before raising a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant