-
Notifications
You must be signed in to change notification settings - Fork 889
CategoryOrderAttribute not working as intended #842
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
Comments
BoucherS[CodePlex] For attributes with AttributeUsageAttribute.AllowMultiple set to true, the attribute collection removes duplicate instances. This means that using TypeDescriptor.GetAttributes instead of Type.GetCustomAttributes() will remove dupplicates of attributes. In the following example, only the first attribute will be considered, while they should all be considered. |
Boucher, As per your comment, the reason duplicates are removed is because I added a new PR that both adds in the missing With this change, using your above example data, all three attributes are now properly returned even when using For more information, see the 'Remarks' section on MSDN here... https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.typedescriptor.getattributes Here's the PR with the correct fixes... #1523 |
Thank you for bringing this to our attention. |
arobincaron[CodePlex]
The property grid ObjectContainerHelper class uses Type.GetCustomAttributes() to get the CategoryOrderAttribute instead of using TypeDescriptor.GetAttributes(). This is inconsistent with the way these types of attributes are retreived for the rest of property
grid and prevents adding this metadata attribute for classes that lack it.
In Xceed.Wpf.Toolkit\PropertyGrid\Implementation\ObjectContainerHelper.cs around line 109 I changed the following code:
CategoryOrderAttribute[] orderAttributes = ( selectedObject != null )
? ( CategoryOrderAttribute[] )selectedObject.GetType().GetCustomAttributes( typeof( CategoryOrderAttribute ), true )
: new CategoryOrderAttribute[ 0 ];
to
CategoryOrderAttribute[] orderAttributes = (selectedObject != null)
? TypeDescriptor.GetAttributes(selectedObject.GetType()).OfTypeltCategoryOrderAttributegt().ToArray()
: new CategoryOrderAttribute[0];
The text was updated successfully, but these errors were encountered: