Search code examples
c#postsharpaop

PostSharp attribute not inherited


I've created a type-level aspect in PostSharp, it adds some method preprocessing. I've applied it to the class, it works as advertised. However, in the classes derived from that one, it does not - method entry code is not hit.

How do I make my aspect inheritable, please?

I've tried adding [AttributeUsage(AttributeTargets.Class, Inherited=true)] to the aspect class - no effect.


Solution

  • You need to set AttributeInheritance = MulticastInheritance.Multicast

    Read more about it in the documentation

    Mulicast Attribute (Aspect) inheritance