|Adding Aspects Declaratively Using Attributes|
In .NET, you normally need to write one line of code for any application of a target attribute. If a custom attribute applies to all types of a namespace, you have to manually add the custom attribute to every single type.
By contrast, multicast custom attributes allow you to apply a custom attribute on multiple declarations from a single line of code by using wildcards or regular expressions, or by filtering on some attributes. It makes it easy to apply an aspect to, say, all public static methods of a namespace, with a single line of code.
Multicast attributes can be inherited: you can put it on an interface and ask it to apply to all classes implementing this interface. Attribute inheritance also works for classes, virtual or interface methods, and parameters of virtual or interface methods.
Custom attributes supporting multicasting needs to be derived from MulticastAttribute. All PostSharp aspects and constraints are derived from this class.
Multicasting of custom attribute is a feature of PostSharp. If you do not transform your assembly using PostSharp, multicast attributes will behave as plain old custom attributes.
This documentation often refers to this
Attribute multicasting supports the following scenarios:
For a conceptual overview of this feature, see:.