-
Notifications
You must be signed in to change notification settings - Fork 10
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
added support for ordered hashtables #17
added support for ordered hashtables #17
Conversation
I've always had an issue with this part. I find your fix surprizingly easy and small :) but I would like to run my use cases with you to better understand. I always did something like this adjusted to your example to achieve the same effect $columns=[ordered]@{
Name =$null
AnotherProperty =$null
Scheme=$null
LastProperty =$null
} There is an example about this in the main readme file #region Tables
$markdown+=New-MDHeader "Tables"
$markdown+=New-MDParagraph -Lines "Without aligned columns"
$markdown+=Get-Command -Module MarkdownPS |Select-Object Name,CommandType,Version | New-MDTable
$markdown+=New-MDParagraph -Lines "With aligned columns"
$markdown+=Get-Command -Module MarkdownPS | New-MDTable -Columns ([ordered]@{Name="left";CommandType="center";Version="right"})
#endregion The drivers for the
Notice that the So my question is which part of the problem does your solution address. My understanding is that this is about rendering object produced by the Can we add this pattern also in the tests |
To be honest, i've overlooked your example in the main readme file. My solution is just a easy fix to not use the parameter |
I've now added new tests to verify if New-MDTable does not distord the order of the properties. Additionally i've found a bug in the test |
Looks ok. But it is very busy so I'll take some time before publishing. Sorry. Btw, if you have some ideas, please do share or create issues. |
So I modified a bit the testing because it wasn't actually checking for the sequence. I added two randomized tests one for following the objects propery sequence and one to overwrite with specified columns. (In essence you can also render less column but a Sorry for the delay I was away,. |
This fix allows the cmdlet
New-MDTable
to support ordered hashtables.I've found out, that the cmdlet New-MDTable does not support ordered hashtables or
[pscustomobject]
.If i declare a
[pscustomobject][ordered]
with a defined order of properties, this order is ignored by the cmdlet and the column order of the table is randomly:The expected result of the cmdlet should be: