Open sandboxFocus

Class EditorExperienceAttribute

Configures how an aspect is presented in the IDE's code refactoring menu, including options for applying the aspect as a live template or as a custom attribute. This attribute is applied to aspect classes to control their editor experience.

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

Use this attribute on aspect classes (types implementing IAspect) to customize how the IDE suggests and displays the aspect to users. You can control whether the aspect appears in code refactoring menus and customize the menu item titles.

Two modes of aspect application are supported:

  • Live Template: The aspect is applied directly to the source code, transforming the code itself. Enable this with SuggestAsLiveTemplate.
  • Custom Attribute: The aspect is applied by adding a custom attribute to the target declaration. Enable this with SuggestAsAddAttribute.

For both modes, the aspect class must have a default constructor, and the aspect's eligibility (see BuildEligibility(IEligibilityBuilder<T>)) determines which code elements can have the aspect applied.

Examples

[EditorExperience(SuggestAsLiveTemplate = true, LiveTemplateSuggestionTitle = "Logging|Add Method Logging")]
public class LogAttribute : OverrideMethodAspect
{
// Aspect implementation
}

Constructors

Name Description
EditorExperienceAttribute()

Properties

Name Description
AddAttributeSuggestionTitle

Gets or sets the title of the code refactoring menu item that applies the aspect as a custom attribute. By default, the title is Add [Foo] if the aspect class is named FooAttribute. To organize several aspects into sub-menus, use the vertical pipe (|) to separate the different menu levels.

LiveTemplateSuggestionTitle

Gets or sets the title of the code refactoring menu item that applies the aspect as a live template. By default, the title is Apply Foo if the aspect class is named FooAttribute. To organize several aspects into sub-menus, use the vertical pipe (|) to separate the different menu levels.

SuggestAsAddAttribute

Gets or sets a value indicating whether the code refactoring menu should offer the possibility to apply this aspect as a custom attribute. This property is false by default. The property is ignored if the aspect class does not have a default constructor. The eligibility of the aspect for the Default or Inheritance scenario is taken into account. See BuildEligibility(IEligibilityBuilder<T>) for details.

SuggestAsLiveTemplate

Gets or sets a value indicating whether the code refactoring menu should offer the possibility to apply this aspect as a live template, i.e., as an action that causes the aspect to applied to the source code itself. This property is false by default. The property is ignored if the aspect class does not have a default constructor. The eligibility of the aspect for the LiveTemplate scenario is taken into account. See BuildEligibility(IEligibilityBuilder<T>) for details.

Extension Methods

See Also