MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetAttributes

Method GetAttributes

Source/Editor/Scripting/ScriptType.cs:569–597  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 4

SubstringMethod · 0.80
StartsWithMethod · 0.45
GetPropertyMethod · 0.45
GetAttributesMethod · 0.45

Tested by

no test coverage detected