Microsoft.CodeAnalysis.Editing Namespace

Classes

DocumentEditor

An editor for making changes to a document's syntax tree.

ImportAdder
SolutionEditor

An editor for making changes to multiple documents in a solution.

SymbolEditor

An editor for making changes to symbol source declarations.

SymbolEditorExtensions
SyntaxEditor

An editor for making changes to a syntax tree. The editor works by giving a list of changes to perform to a particular tree in order. Changes are given a SyntaxNode they will apply to in the original tree the editor is created for. The semantics of application are as follows:

  1. The original root provided is used as the 'current' root for all operations. This 'current' root will continually be updated, becoming the new 'current' root. The original root is never changed.
  2. Each change has its given SyntaxNode tracked, using a SyntaxAnnotation, producing a 'current' root that tracks all of them. This allows that same node to be found after prior changes are applied which mutate the tree.
  3. Each change is then applied in order it was added to the editor.
  4. A change first attempts to find its SyntaxNode in the 'current' root. If that node cannot be found, the operation will fail with an ArgumentException.
  5. The particular change will run on that node, removing, replacing, or inserting around it according to the change. If the change is passed a delegate as its 'compute' argument, it will be given the SyntaxNode found in the current root. The 'current' root will then be updated by replacing the current node with the new computed node.
  6. The 'current' root is then returned.
SyntaxEditorExtensions
SyntaxGenerator

A language agnostic factory for creating syntax nodes.

This API can be used to create language specific syntax nodes that are semantically similar between languages.

The trees generated by this API will try to respect user preferences when possible. For example, generating MemberAccessExpression(SyntaxNode, String) will be done in a way such that "this." or "Me." will be simplified according to user preference if Simplifier is used.

Structs

DeclarationModifiers

Enums

DeclarationKind
OperatorKind
SpecialTypeConstraintKind

Delegates

SymbolEditor.AsyncDeclarationEditAction

An action that make changes to a declaration node within a SyntaxTree.

SymbolEditor.DeclarationEditAction

An action that make changes to a declaration node within a SyntaxTree.