-
-
Notifications
You must be signed in to change notification settings - Fork 961
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
Custom order of parameters when using complex types #2301
Comments
It's a great idea, thanks for the suggestion!
PR is welcome! |
Great! Will work on a PR soon. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I originally had the following
int
parameter: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 overrideToString()
(just a simple class with anint
and astring
, and then using aParamsSource
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:
BenchmarkDotNet/src/BenchmarkDotNet/Parameters/ParameterComparer.cs
Line 31 in 56c66d0
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'reIComparable
, 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.
The text was updated successfully, but these errors were encountered: