Attributes of elements to which multicast custom attributes (MulticastAttribute) apply.
Namespace: PostSharp.Extensibility
Assembly: PostSharp.dll
Syntax
[Flags]
public enum MulticastAttributes
Remarks
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).
Fields
Name | Description |
---|---|
Abstract | Abstract methods. |
All | All members. |
AnyAbstraction | Any abstraction (Abstract | NonAbstract). |
AnyGeneration | Any code generation (CompilerGenerated | UserGenerated)l |
AnyImplementation | Any implementation (Managed | NonManaged). |
AnyLiterality | Any field literality (Literal | NonLiteral). |
AnyParameter | Any kind of parameter passing (InParameter | OutParameter | RefParameter). |
AnyScope | |
AnyVirtuality | Any virtuality (Virtual | NonVirtual). |
AnyVisibility | Any visibility. |
CompilerGenerated | Compiler-generated code. |
Default | Specifies that the set of target attributes is inherited from the parent custom attribute. |
InParameter | Input parameters. |
Instance | Instance scope. |
Internal | Internal (visible inside the current assembly). |
InternalAndProtected | Internal and protected (visible inside derived types that are defined in the current assembly). |
InternalOrProtected | Internal or protected (visible inside all derived types and in the current assembly). |
Literal | Literal fields. |
Managed | Managed code implementation. |
NonAbstract | Concrete (non-abstract) methods. |
NonLiteral | Non-literal fields. |
NonManaged | Non-managed code implementation (external or system). |
NonVirtual | Non-virtual methods. |
OutParameter | Output (out in C#) parameters. |
Private | Private (visible inside the current type). |
Protected | Protected (visible inside derived types). |
Public | Public (visible everywhere). |
RefParameter | Input/Output (ref in C#) parameters. |
Static | Static scope. |
UserGenerated | User-generated code (anything expected CompilerGenerated). |
Virtual | Virtual methods. |