PostSharp6.4/API Reference/Post­Sharp.​Extensibility Namespace/Multicast­Attributes Enumeration

MulticastAttributes Enumeration

Attributes of elements to which multicast custom attributes (MulticastAttribute) apply.

Namespace:  PostSharp.Extensibility
Assembly:  PostSharp (in PostSharp.dll) Version: (
public enum MulticastAttributes
  Member nameValueDescription
Default0 Specifies that the set of target attributes is inherited from the parent custom attribute.
Private2 Private (visible inside the current type).
Protected4 Protected (visible inside derived types).
Internal8 Internal (visible inside the current assembly).
InternalAndProtected16 Internal and protected (visible inside derived types that are defined in the current assembly).
InternalOrProtected32 Internal or protected (visible inside all derived types and in the current assembly).
Public64 Public (visible everywhere).
AnyVisibility126 Any visibility.
Static128 Static scope.
Instance256 Instance scope.
AnyScope384 Any scope (Static | Instance).
Abstract512 Abstract methods.
NonAbstract1024 Concrete (non-abstract) methods.
AnyAbstraction1536 Any abstraction (Abstract | NonAbstract).
Virtual2048 Virtual methods.
NonVirtual4096 Non-virtual methods.
AnyVirtuality6144 Any virtuality (Virtual | NonVirtual).
Managed8192 Managed code implementation.
NonManaged16384 Non-managed code implementation (external or system).
AnyImplementation24576 Any implementation (Managed | NonManaged).
Literal32768 Literal fields.
NonLiteral65536 Non-literal fields.
AnyLiterality98304 Any field literality (Literal | NonLiteral).
InParameter131072 Input parameters.
CompilerGenerated262144 Compiler-generated code.
UserGenerated524288 User-generated code (anything expected CompilerGenerated).
AnyGeneration786432 Any code generation (CompilerGenerated | UserGenerated)l
OutParameter1048576 Output (out in C#) parameters.
RefParameter2097152 Input/Output (ref in C#) parameters.
AnyParameter3276800 Any kind of parameter passing (InParameter | OutParameter | RefParameter).
All4194302 All members.

If you specify this in a MulticastAttributeUsageAttribute, then the annotated attribute can only be multicast to elements that have these attributes. For example, if you create an aspect and annotate it with [MulticastAttributeUsage(TargetMemberAttributes=MulticastAttributes.Protected)], then multicasting will never apply the aspect to any type member that isn't protected.

If you specify this in a property of MulticastAttribute, then that specific multicast will be even more narrowed just to elements that have these attributes. For example, if you annotate a class with the aspect from the previous paragraph with [MyAspect(TargetMemberAttributes=MulticastAttributes.Virtual)], then it will only apply to that class's members that are both protected and, for methods, virtual.

There are 8 categories of flags. If you specify at least one flag for a category, you narrow the multicast just to elements that have one of the flags you specified in the category. For example, if you specify Public | Protected, you multicast to elements that are public or protected, but not private. Their other attributes (such as whether they are instance or static) do not matter.

The categories are visibility (public, private, ...); scope (static or instance); abstraction (abstract or non-abstract); virtuality (virtual or non-virtual); implementation (managed or unmanaged); literality (literal or nonliteral); generation (compiler-generated or user-created); and parameter (in, ref, or out).

If a category doesn't make sense for an element, then specifying its flags will have no effect for that element. For example, if you narrow your multicast down to virtual elements, it will still apply to fields or types (which can't be virtual).

See Also