When overridden in a derived class, returns an array of all custom attributes applied to this member. true to search this member's inheritance chain to find the attributes; otherwise, false . An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.</
(bool inherit = false)
| 567 | /// <param name="inherit"><c>true</c> to search this member's inheritance chain to find the attributes; otherwise, <c>false</c>.</param> |
| 568 | /// <returns>An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.</returns> |
| 569 | public object[] GetAttributes(bool inherit = false) |
| 570 | { |
| 571 | if (_managed != null) |
| 572 | { |
| 573 | if (_managed is MethodInfo method) |
| 574 | { |
| 575 | try |
| 576 | { |
| 577 | // Special case for properties getter/setter methods to use the property attributes instead own |
| 578 | var name = _managed.Name; |
| 579 | if (name.StartsWith("get_") || name.StartsWith("set_")) |
| 580 | { |
| 581 | var flags = method.IsStatic ? BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly : BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; |
| 582 | var property = method.DeclaringType.GetProperty(name.Substring(4), flags); |
| 583 | if (property != null) |
| 584 | return property.GetCustomAttributes(inherit); |
| 585 | } |
| 586 | } |
| 587 | catch |
| 588 | { |
| 589 | // Silence exceptions |
| 590 | } |
| 591 | } |
| 592 | return _managed.GetCustomAttributes(inherit); |
| 593 | } |
| 594 | if (_custom != null) |
| 595 | return _custom.GetAttributes(inherit); |
| 596 | return Utils.GetEmptyArray<object>(); |
| 597 | } |
| 598 | |
| 599 | /// <summary> |
| 600 | /// Retrieves a custom attribute of a specified type that is applied to a specified member. |
nothing calls this directly
no test coverage detected