Metalama 1.0 / / Metalama Documentation / Aspect API Documentation / Metalama.​Framework.​Aspects / IAspect­Receiver<TDeclaration> / Require­Aspect

Method RequireAspect

RequireAspect<TAspect>()

Requires an instance of a specified aspect type to be present on a specified declaration. If the aspect is not present, this method adds a new instance of the aspect by using the default aspect constructor.

Declaration
void RequireAspect<TAspect>()
where TAspect : IAspect<TDeclaration>, new()
Type Parameters
Name Description
TAspect

Type of the aspect. The type must be ordered after the aspect type calling this method.

Remarks

Calling this method causes the current aspect to be present in the Predecessors list even if the required aspect was already present on the target declaration.