GetCustomAttributes behavior is different when used as extension method #30219
Labels
area-System.Reflection
question
Answer questions and provide assistance, not an issue with source code or documentation.
Milestone
Hi folks,
When doing a PR for fluentassertions/fluentassertions#1095 I have noticed a really strange behavior with
GetCustomAttributes
when using theinherits
option.Indeed this call
CustomAttributeExtensions.GetCustomAttributes(property, true).OfType<TAttribute>().Any()
returnstrue
whereasproperty.GetCustomAttributes(true).OfType<TAttribute>().Any()
returnsfalse
.I have made a couple of tests and it seems that the bug happens only for
PropertyInfo
passed to theMemberInfo
overload.Given the following classes:
This code doesn't work properly:
Please let me know if this is not the good place to report this problem.
BTW I found this issue which seems more or less related #17180
The text was updated successfully, but these errors were encountered: