Method SafeGetCustomAttribute
SafeGetCustomAttribute<T>(MemberInfo, bool)
Safely gets a custom attribute of type T without triggering type resolution exceptions.
public static T? SafeGetCustomAttribute<T>(this MemberInfo memberInfo, bool inherit = true)
Parameters
memberInfoMemberInfoThe member to inspect for the attribute.
inheritboolTrue to include attributes inherited from base types.
Returns
- T
The attribute instance if found; otherwise null.
Type Parameters
TThe attribute type to resolve.