Reputation: 1747
Is there a way to tell attribute to work only when used with static methods?
AttributeUsage
class does not seem to allow such specyfic usage.
[AttributeUsage(AttributeTargets.Method,
Inherited = false, AllowMultiple = false)]
Upvotes: 10
Views: 3308
Reputation: 19646
No, there is no way to restrict this. However - you could use reflection at run-time to enforce this.
Upvotes: 5
Reputation: 26737
There is no such feature available in C# that allows you to restrict attribute usage based on a member's accessibility.
Upvotes: 1