Open sandboxFocus

Class RequireAspectWeaverAttribute

Binds an aspect class to a low-level weaver implementation built with Metalama.Framework.Sdk. When this attribute is applied to an aspect class, the BuildAspect(IAspectBuilder<T>) method is bypassed and the specified weaver handles all transformations instead.

Inheritance
RequireAspectWeaverAttribute
Namespace: Metalama.Framework.Aspects
Assembly: Metalama.Framework.dll
Syntax
[AttributeUsage(AttributeTargets.Class)]
[CompileTime]
public sealed class RequireAspectWeaverAttribute : Attribute
Remarks

Use this attribute when you need to perform C# code transformations that are not possible with the standard IAspectBuilder advice API and require direct access to the Roslyn API.

The weaver type must:

  • Implement IAspectWeaver from the Metalama.Framework.Engine.AspectWeavers namespace.
  • Be annotated with [MetalamaPlugIn].
  • Have a public parameterless constructor.

Although BuildAspect(IAspectBuilder<T>) is not called, BuildEligibility(IEligibilityBuilder<T>) is still invoked, allowing you to define eligibility rules as usual.

Warning: Weaver-based aspects are significantly more complex to implement, have worse IDE integration, and have a significant performance impact. Prefer the standard aspect approach when possible.

Constructors

Name Description
RequireAspectWeaverAttribute(string)

Initializes a new instance of the RequireAspectWeaverAttribute class.

RequireAspectWeaverAttribute(Type)

Initializes a new instance of the RequireAspectWeaverAttribute class.

Properties

Name Description
Type

Gets the namespace-qualified name of the type implementing the aspect.

Extension Methods

See Also