Open
Description
The existing code which simply called GetCustomAttributes doesn't take into consideration those attributes added via a TypeDescriptor. As such, you should use the TypeDescriptor.AddAttributes which gets both those defined on the class at compile time, plus those added at runtime.
Note: In a semi-related issue, here, the CategoryOrderAttribute needs to add the following override to work correctly.
public override object TypeId => CategoryValue;
I don't have the ability to create PRs or I'd submit this myself, but here's the needed function.
private int GetCategoryOrder(object categoryValue) {
Debug.Assert(SelectedObject != null);
if (categoryValue == null)
return int.MaxValue;
object selectedObject = SelectedObject;
var orderAttribute = TypeDescriptor.GetAttributes(selectedObject)
.OfType<CategoryOrderAttribute>()
.FirstOrDefault(a => Equals(a.CategoryValue, categoryValue));
return orderAttribute?.Order ?? int.MaxValue;
}
HTH!
Mark
Metadata
Metadata
Assignees
Labels
No labels