<PackageReference Include="NUnit" Version="4.3.0" />

AttributeHelper

public static class AttributeHelper
Provides a platform-independent methods for getting attributes for use by AttributeConstraint and AttributeExistsConstraint.
using System; using System.Reflection; using System.Runtime.CompilerServices; namespace NUnit.Compatibility { public static class AttributeHelper { [NullableContext(1)] public static Attribute[] GetCustomAttributes(object actual, Type attributeType, bool inherit) { ICustomAttributeProvider customAttributeProvider = actual as ICustomAttributeProvider; if (customAttributeProvider != null) return (Attribute[])customAttributeProvider.GetCustomAttributes(attributeType, inherit); DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(58, 1); defaultInterpolatedStringHandler.AppendLiteral("Actual value "); defaultInterpolatedStringHandler.AppendFormatted<object>(actual); defaultInterpolatedStringHandler.AppendLiteral(" does not implement ICustomAttributeProvider."); throw new ArgumentException(defaultInterpolatedStringHandler.ToStringAndClear(), "actual"); } } }