-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
I originally had the following int parameter:
[Params(1_000, 10_000, 100_000, 1_000_000, 10_000_000)]
public int N;This sorted properly using the natural order of the int.
I then wanted to customize the value names (1K, 1M, etc instead), so I had to wrap the int in a complex type to override ToString() (just a simple class with an int and a string, and then using a ParamsSource of a list).
I now had correct names, but since the parameter is now a complex type, it appears that the display name is used to do an alphabetical sort instead. This causes the order to be something like "100K, 10K, 10M, 1K, etc" , which I definitely don't want.
I can see the current implementation of this here:
| return string.CompareOrdinal(x.DisplayInfo, y.DisplayInfo); |
As far as I can tell, there doesn't seem to be a way to get both a customized display but also ordering according to the integer (or some other custom ordering), without doing something extreme like having to provide an implementation of IOrderer for example (which doesn't seem at all feasible to me).
I see a mention of a proposed ParamsOrderPolicy here, but I think that doesn't provide enough flexibility.
I'm proposing a change in ParameterComparer, where complex params are tested if they're IComparable, and then simply use that interface to provide the order behavior.
I'm willing to work on this, as I feel it's a must have feature.