You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MethodInfomethodInfo= ...
Type type = ...
var x = info.IsDefined(typeof(FooAttribute));// this should warn because FooAttribute cannot be applied to a method.vary= type.IsDefined(typeof(FooAttribute));// this is fine because FooAttribute can be applied to one or more of the type targets (Class, Delegate, Enum, Interface, GenericParameter, Struct).
Should also apply to GetCustomAttributes(Type, Boolean) as well as the GetCustomAttribute<>() and GetCustomAttributes<>() extension methods.
The text was updated successfully, but these errors were encountered:
Another idea for an analyzer, warn when looking for an attribute on something where the AttributeUsage says it can't be.
eg.
given
Should also apply to
GetCustomAttributes(Type, Boolean)
as well as theGetCustomAttribute<>()
andGetCustomAttributes<>()
extension methods.The text was updated successfully, but these errors were encountered: