Share via


CodeAction Class

Definition

An action produced by a CodeFixProvider or a CodeRefactoringProvider.

public ref class CodeAction abstract
public abstract class CodeAction
type CodeAction = class
Public MustInherit Class CodeAction
Inheritance
CodeAction
Derived

Constructors

CodeAction()

Properties

EquivalenceKey

Two code actions are treated as equivalent if they have equal non-null EquivalenceKey values and were generated by the same CodeFixProvider or CodeRefactoringProvider.

IsInlinable

If this code action contains NestedActions, this property provides a hint to hosts as to whether or not it's ok to elide this code action and just present the nested actions instead. When a host already has a lot of top-level actions to show, it should consider not inlining this action, to keep the number of options presented to the user low. However, if there are few options to show to the user, inlining this action could be beneficial as it would allow the user to see and choose one of the nested options with less steps. To create a CodeAction with nested actions, use Create(String, ImmutableArray<CodeAction>, Boolean).

NestedActions

Child actions contained within this CodeAction. Can be presented in a host to provide more potential solution actions to a particular problem. To create a CodeAction with nested actions, use Create(String, ImmutableArray<CodeAction>, Boolean).

Priority

Priority of this particular action within a group of other actions. Less relevant actions should override this and specify a lower priority so that more important actions are easily accessible to the user. Returns Default if not overridden.

Tags

Descriptive tags from WellKnownTags. These tags may influence how the item is displayed.

Title

A short title describing the action that may appear in a menu.

Methods

ComputeOperationsAsync(CancellationToken)

Override this method if you want to implement a CodeAction subclass that includes custom CodeActionOperation's.

ComputeOperationsAsync(IProgress<CodeAnalysisProgress>, CancellationToken)

Override this method if you want to implement a CodeAction subclass that includes custom CodeActionOperation's. Prefer overriding this method over ComputeOperationsAsync(CancellationToken) when computation is long running and progress should be shown to the user.

ComputePreviewOperationsAsync(CancellationToken)

Override this method if you want to implement a CodeAction that has a set of preview operations that are different than the operations produced by ComputeOperationsAsync(IProgress<CodeAnalysisProgress>, CancellationToken).

ComputePriority()

Computes the CodeActionPriority group this code action should be presented in. Legal values this can be must be between Lowest and High.

Create(String, Func<CancellationToken,Task<Document>>, String, CodeActionPriority)

Creates a CodeAction for a change to a single Document. Use this factory when the change is expensive to compute and should be deferred until requested.

Create(String, Func<CancellationToken,Task<Document>>, String)

Creates a CodeAction for a change to a single Document. Use this factory when the change is expensive to compute and should be deferred until requested.

Create(String, Func<CancellationToken,Task<Solution>>, String, CodeActionPriority)

Creates a CodeAction for a change to more than one Document within a Solution. Use this factory when the change is expensive to compute and should be deferred until requested.

Create(String, Func<CancellationToken,Task<Solution>>, String)

Creates a CodeAction for a change to more than one Document within a Solution. Use this factory when the change is expensive to compute and should be deferred until requested.

Create(String, Func<IProgress<CodeAnalysisProgress>,CancellationToken,Task<Document>>, String, CodeActionPriority)
Create(String, Func<IProgress<CodeAnalysisProgress>,CancellationToken,Task<Solution>>, String, CodeActionPriority)

Creates a CodeAction for a change to more than one Document within a Solution. Use this factory when the change is expensive to compute and should be deferred until requested.

Create(String, ImmutableArray<CodeAction>, Boolean, CodeActionPriority)

Creates a CodeAction representing a group of code actions.

Create(String, ImmutableArray<CodeAction>, Boolean)

Creates a CodeAction representing a group of code actions.

GetChangedDocumentAsync(CancellationToken)

Computes changes for a single document. Override this method if you want to implement a CodeAction subclass that changes a single document. Override GetChangedDocumentAsync(IProgress<CodeAnalysisProgress>, CancellationToken) to report progress progress while computing the operations.

GetChangedDocumentAsync(IProgress<CodeAnalysisProgress>, CancellationToken)

Computes changes for a single document. Override this method if you want to implement a CodeAction subclass that changes a single document. Prefer overriding this method over GetChangedDocumentAsync(CancellationToken) when computation is long running and progress should be shown to the user.

GetChangedSolutionAsync(CancellationToken)

Computes all changes for an entire solution. Override this method if you want to implement a CodeAction subclass that changes more than one document. Override GetChangedSolutionAsync(IProgress<CodeAnalysisProgress>, CancellationToken) to report progress progress while computing the operations.

GetChangedSolutionAsync(IProgress<CodeAnalysisProgress>, CancellationToken)

Computes all changes for an entire solution. Override this method if you want to implement a CodeAction subclass that changes more than one document. Prefer overriding this method over GetChangedSolutionAsync(CancellationToken) when computation is long running and progress should be shown to the user.

GetOperationsAsync(CancellationToken)

The sequence of operations that define the code action.

GetOperationsAsync(Solution, IProgress<CodeAnalysisProgress>, CancellationToken)

The sequence of operations that define the code action.

GetPreviewOperationsAsync(CancellationToken)

The sequence of operations used to construct a preview.

PostProcessAsync(IEnumerable<CodeActionOperation>, CancellationToken)

Apply post processing steps to any ApplyChangesOperation's.

PostProcessChangesAsync(Document, CancellationToken)

Apply post processing steps to a single document: Reducing nodes annotated with Annotation Formatting nodes annotated with Annotation

PostProcessChangesAsync(Solution, CancellationToken)

Apply post processing steps to solution changes, like formatting and simplification.

Applies to