Open sandboxFocus

Interface IAttribute

Represents a custom attribute applied to a declaration.

Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
public interface IAttribute : IDeclaration, IDisplayable, IDiagnosticLocation, ICompilationElement, IMeasurable, IEquatable<IDeclaration>, IAttributeData, IAspectPredecessor
Remarks

This interface combines IDeclaration (making attributes full code model citizens with their own identity), IAttributeData (providing access to constructor arguments and named arguments), and IAspectPredecessor (enabling attributes to serve as aspect predecessors when they represent aspect custom attributes).

To query attributes on a declaration, use the Attributes property, which returns an IAttributeCollection. To add new attributes to existing declarations, use IntroduceAttribute(IAdviser<IDeclaration>, IAttributeData, OverrideStrategy). To add attributes to introduced declarations, use AddAttribute(AttributeConstruction). To remove attributes, use AdviserExtensions.RemoveAttributes. Note that attributes cannot be edited; to modify an attribute, remove it and add a new one.

Properties

Name Description
ContainingDeclaration

Gets the declaration that owns the custom attribute.

Methods

Name Description
ToRef()

Gets a reference that can be used to identify the current declaration across different compilation versions.

Extension Methods

See Also