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

Use columns for properties when dumping collections? #30

Open
wilka opened this issue May 13, 2024 · 5 comments
Open

Use columns for properties when dumping collections? #30

wilka opened this issue May 13, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request Rendering Rendering feature

Comments

@wilka
Copy link

wilka commented May 13, 2024

One of the handy things with LinqPad .Dump() is when you use it on a collection, you get a table with columns for each property. e.g. in LinqPad the code:

void Main()
{
	var people = new[] 
	{
		new Person("Marie", "Curie"),   
		new Person("Albert", "Einstein"),
		new Person("Ada", "Lovelace"),
		new Person("Cleopatra", "Philopator"),
		new Person("Nikola", "Tesla")
	};

	people.Dump();
}

record Person(string FirstName, string LastName);

gives:
image

but with Dumpify, it shows:
image

So I'd like to be able to have the more concise column-for-property format with collections.

@MoaidHathot
Copy link
Owner

MoaidHathot commented May 13, 2024

Hi @wilka, a similar feature is already supported but it is turned-off by default. It can be turned-on either globally for all dumps or per-dump:

Globally:
DumpConfig.Default.TableConfig.ShowRowSeparators = true;

Per dump:
people.Dump(tableConfig: new TableConfig { ShowRowSeparators = true });

Turning this option on results in the following output:
image

@MoaidHathot MoaidHathot self-assigned this May 13, 2024
@MoaidHathot
Copy link
Owner

MoaidHathot commented May 13, 2024

I know this isn't exactly like what you get from LinqPad, but I'm wondering how we can generalize this. LinqPad basically transposes the table.
I will think about it and how it can fit in Dumpify while taking terminal width limitations into account.
Thanks for the suggestion!

@MoaidHathot MoaidHathot added enhancement New feature or request Rendering Rendering feature labels May 13, 2024
@wilka
Copy link
Author

wilka commented May 14, 2024

If it makes any difference, I'm not hugely concerned about the terminal width limits. I tend to run my Windows Terminal at full screen, and I have a large display. But I realise that won't be the case for everyone.

I've been using Dumpify as a stepping stone from taking some LinqPad prototype code, and then turning it into a console app.

@MoaidHathot
Copy link
Owner

@wilka, is this similar to what you were looking for? (Ignore the circular reference bug)

Image

Instead of

Image

@wilka
Copy link
Author

wilka commented Jan 20, 2025

Yup, that is what I had in mind. The difference is more useful when you have more) records, so you only have a single header row shared for multiple items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Rendering Rendering feature
Projects
None yet
Development

No branches or pull requests

2 participants