-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistency in Attribute assertions #731
Comments
@dennisdoomen in The only other API methods that have The current API methods are: bool HasAttribute<TAttribute>(this MemberInfo method);
bool HasMatchingAttribute<TAttribute>(this MemberInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate);
bool HasMatchingAttribute<TAttribute>(this Type type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate, bool inherit = false);
bool IsDecoratedWith<TAttribute>(this MemberInfo type);
bool IsDecoratedWith<TAttribute>(this Type type, bool inherit = false); HasMatchingAttribute<TAttribute>(this MemberInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
--> `GetCustomAttributes<TAttribute>(MemberInfo type)`
--> type.GetCustomAttributes(false).OfType<TAttribute>() but public static bool HasAttribute<TAttribute>(this MemberInfo method)
--> method.GetCustomAttributes(typeof(TAttribute), true) If it's not too late to change, I propose the following API: IsDecoratedWith(this Type type)
IsDecoratedWith(this TypeInfo type)
IsDecoratedWith(this MemberInfo type)
IsDecoratedWithOrInherits(this Type type)
IsDecoratedWithOrInherits(this TypeInfo type)
IsDecoratedWithOrInherits(this MemberInfo type)
IsDecoratedWith(this Type type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
IsDecoratedWith(this TypeInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
IsDecoratedWith(this MemberInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
IsDecoratedWithOrInherits(this Type type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
IsDecoratedWithOrInherits(this TypeInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate)
IsDecoratedWithOrInherits(this MemberInfo type, Expression<Func<TAttribute, bool>> isMatchingAttributePredicate) This should make the API consistent and remove the optional booleans from the API. |
@dennisdoomen, @jnyrup, are you expecting some help (see |
To implement it ;-) |
Unify API methods to check for attribute (GH-731)
If #727 gets merged, we should also revise other calls to
GetCustomAttributes(bool inherit)
andGetCustomAttributes(Type attributeType, bool inherit)
E.g
TypeSelector,ThatAreDecoratedWith
currently callsGetCustomAttributes(typeof(TAttribute), true)
which would be inconsistent with the difference betweenBeDecoratedWith
andBeDecoratedWithOrInherit
.The text was updated successfully, but these errors were encountered: