You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow for benchmark categories composition using inheritance #2306
The problem is that the category defined on the derived class is not assigned to the methods declared on the base class, because BenchmarkConverteronly looks at the method declaring type. Moreover, the attribute on the derived class replaces the one defined on the base class, because the current resolution strategy ignores inherited attributes.
Is there a reason why method.ReflectedType is not used in this case and inherited attributes are explicitly ignored (both at the class and method level)?
So far, the only option is to replicate the categories on both the derived class and overridden method.
Would it be possible to add an extension point to the BenchmarkConverter (e.g., an ICategoryResolver or a CategoryResolver delegate) to plug-in a different categories discovery logic?
@BladeWise Thanks for the feedback. In #2307, I have implemented the following:
Now categories are inherited by default. Since it's a breaking change, the old behavior can be restored using [CategoryDiscoverer(false)].
Now it's possible to override the category discovering strategy with any custom logic (see IntroCategoryDiscoverer and CategoriesTests in Introduce CategoryDiscoverer, fix #2306 #2307 for usage examples)
Does it solve your problem? Do you have any comments on the implementation?
The PR solves the above issue perfectly, and the implementation is flexible enough to account for custom discovery strategies.
I am not sure if it would be worth to add an explicit configuration extension method to revert to the old behavior (or eventually opt-in to the new one), something like
The CategoryDiscovererAttribute serves the same purpose, but an explicit extension method can be sometimes easier to discover.
Thanks a lot for the quick response and support.
Activity
Enabled category inheritance, fix #2306
Introduce CategoryDiscoverer, fix #2306
AndreyAkinshin commentedon May 14, 2023
@BladeWise Thanks for the feedback. In #2307, I have implemented the following:
[CategoryDiscoverer(false)].IntroCategoryDiscovererandCategoriesTestsin Introduce CategoryDiscoverer, fix #2306 #2307 for usage examples)Does it solve your problem? Do you have any comments on the implementation?
BladeWise commentedon May 14, 2023
The PR solves the above issue perfectly, and the implementation is flexible enough to account for custom discovery strategies.
I am not sure if it would be worth to add an explicit configuration extension method to revert to the old behavior (or eventually opt-in to the new one), something like
The
CategoryDiscovererAttributeserves the same purpose, but an explicit extension method can be sometimes easier to discover.Thanks a lot for the quick response and support.
AndreyAkinshin commentedon May 14, 2023
Well, with the current state of the PR, it's possible to do
I believe there is no need for an additional shortcut method.
Great, glad to hear that. Then I merge the PR.
You're welcome!
Introduce CategoryDiscoverer, fix #2306
Enabled category inheritance, fix dotnet#2306