AttributeHelper
Provides a platform-independent methods for getting attributes
for use by AttributeConstraint and AttributeExistsConstraint.
using System;
using System.Reflection;
namespace NUnit.Compatibility
{
public static class AttributeHelper
{
public static Attribute[] GetCustomAttributes(object actual, Type attributeType, bool inherit)
{
ICustomAttributeProvider obj = actual as ICustomAttributeProvider;
if (obj == null)
throw new ArgumentException($"""{actual}""", "actual");
return (Attribute[])obj.GetCustomAttributes(attributeType, inherit);
}
}
}