When I use Util.Table and I set the propertyNames explicitly I expect the order of the columns to respect the order given with the propertyNames.
I ran into this when using Util.Table with a sequence of anonymous records. The way I think it works is that typeof<'A>.GetProperties() that is used gives the properties in declared order when used on a normal type and in alphabetical order when used on an anonymous type. Since I didn't like the alphabetical ordering I searched for a way to set the ordering. When I ran into the propertyNames property I expected this to pin the order.
Repro steps
Util.Table(
[ {|A = 5; B = 3; C = 9|} ],
["C"; "A"])
Looks good to me, preserving the given order in those cases seems nice to have and any performance impact shouldn't be an issue. Please do make a pull request when convenient.
Description
When I use
Util.Table
and I set the propertyNames explicitly I expect the order of the columns to respect the order given with the propertyNames. I ran into this when usingUtil.Table
with a sequence of anonymous records. The way I think it works is thattypeof<'A>.GetProperties()
that is used gives the properties in declared order when used on anormal
type and in alphabetical order when used on an anonymous type. Since I didn't like the alphabetical ordering I searched for a way to set the ordering. When I ran into thepropertyNames
property I expected this to pin the order.Repro steps
Expected behavior
Actual behavior
Known workarounds
Dont't use anonymous types?!
Related information
I reworked the
Util.Table
function to do what I expected it to do. https://github.com/arnodenuijl/IfSharp/commit/18fa8a1924504cf8753675fd9a919f8afe4a0b3eIf you want it as a pull request i can do that. Any questions or remarks are welcome